diff --git a/CMake/macros.cmake b/CMake/macros.cmake index 44fc2903875..9ba33dfb158 100644 --- a/CMake/macros.cmake +++ b/CMake/macros.cmake @@ -42,14 +42,37 @@ MACRO(SETUP_LIBDIRS) if(COMMAND cmake_policy) CMAKE_POLICY(SET CMP0003 NEW) endif(COMMAND cmake_policy) - LINK_DIRECTORIES(${PYTHON_LIBPATH} ${SDL_LIBPATH} ${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${ICONV_LIBPATH} ${OPENEXR_LIBPATH} ${QUICKTIME_LIBPATH} ${FFMPEG_LIBPATH}) - LINK_DIRECTORIES(${FREETYPE_LIBPATH}) + + LINK_DIRECTORIES(${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${FREETYPE_LIBPATH} ${LIBSAMPLERATE_LIBPATH}) + + IF(WITH_PYTHON) + LINK_DIRECTORIES(${PYTHON_LIBPATH}) + ENDIF(WITH_PYTHON) IF(WITH_INTERNATIONAL) + LINK_DIRECTORIES(${ICONV_LIBPATH}) LINK_DIRECTORIES(${GETTEXT_LIBPATH}) ENDIF(WITH_INTERNATIONAL) + IF(WITH_SDL) + LINK_DIRECTORIES(${SDL_LIBPATH}) + ENDIF(WITH_SDL) + IF(WITH_FFMPEG) + LINK_DIRECTORIES(${FFMPEG_LIBPATH}) + ENDIF(WITH_FFMPEG) + IF(WITH_OPENEXR) + LINK_DIRECTORIES(${OPENEXR_LIBPATH}) + ENDIF(WITH_OPENEXR) + IF(WITH_QUICKTIME) + LINK_DIRECTORIES(${QUICKTIME_LIBPATH}) + ENDIF(WITH_QUICKTIME) IF(WITH_OPENAL) LINK_DIRECTORIES(${OPENAL_LIBPATH}) ENDIF(WITH_OPENAL) + IF(WITH_JACK) + LINK_DIRECTORIES(${JACK_LIBPATH}) + ENDIF(WITH_JACK) + IF(WITH_FFTW3) + LINK_DIRECTORIES(${FFTW3_LIBPATH}) + ENDIF(WITH_FFTW3) IF(WIN32) LINK_DIRECTORIES(${PTHREADS_LIBPATH}) @@ -59,48 +82,45 @@ ENDMACRO(SETUP_LIBDIRS) MACRO(SETUP_LIBLINKS target) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS} ") - #TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LIB} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${SDL_LIB} ${LLIBS}) + #TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LIB} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${SDL_LIBRARY} ${LLIBS}) - TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LINKFLAGS} ${JPEG_LIBRARY} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${SDL_LIB} ${LLIBS}) + TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LINKFLAGS} ${JPEG_LIBRARY} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${LLIBS}) # since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions - IF(WIN32) - - TARGET_LINK_LIBRARIES(${target} debug ${PYTHON_LIB}_d) - - TARGET_LINK_LIBRARIES(${target} optimized ${PYTHON_LIB}) - + TARGET_LINK_LIBRARIES(${target} debug ${PYTHON_LIB}_d) + TARGET_LINK_LIBRARIES(${target} optimized ${PYTHON_LIB}) ELSE(WIN32) - - TARGET_LINK_LIBRARIES(${target} ${PYTHON_LIB}) - + TARGET_LINK_LIBRARIES(${target} ${PYTHON_LIB}) ENDIF(WIN32) - - - TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${SDL_LIB} ${LLIBS}) - TARGET_LINK_LIBRARIES(${target} ${FREETYPE_LIB}) + + TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${LLIBS}) + TARGET_LINK_LIBRARIES(${target} ${FREETYPE_LIBRARY} ${LIBSAMPLERATE_LIB}) # since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions IF(WIN32) - - TARGET_LINK_LIBRARIES(${target} debug ${PYTHON_LIB}_d) - - TARGET_LINK_LIBRARIES(${target} optimized ${PYTHON_LIB}) - - ELSE(WIN32) - - TARGET_LINK_LIBRARIES(${target} ${PYTHON_LIB}) - + TARGET_LINK_LIBRARIES(${target} debug ${PYTHON_LIB}_d) + TARGET_LINK_LIBRARIES(${target} optimized ${PYTHON_LIB}) + ELSE(WIN32) + TARGET_LINK_LIBRARIES(${target} ${PYTHON_LIB}) ENDIF(WIN32) IF(WITH_INTERNATIONAL) TARGET_LINK_LIBRARIES(${target} ${GETTEXT_LIB}) ENDIF(WITH_INTERNATIONAL) IF(WITH_OPENAL) - TARGET_LINK_LIBRARIES(${target} ${OPENAL_LIB}) + TARGET_LINK_LIBRARIES(${target} ${OPENAL_LIBRARY}) ENDIF(WITH_OPENAL) + IF(WITH_FFTW3) + TARGET_LINK_LIBRARIES(${target} ${FFTW3_LIB}) + ENDIF(WITH_FFTW3) + IF(WITH_JACK) + TARGET_LINK_LIBRARIES(${target} ${JACK_LIB}) + ENDIF(WITH_JACK) + IF(WITH_SDL) + TARGET_LINK_LIBRARIES(${target} ${SDL_LIBRARY}) + ENDIF(WITH_SDL) IF(WIN32) TARGET_LINK_LIBRARIES(${target} ${ICONV_LIB}) ENDIF(WIN32) @@ -117,3 +137,4 @@ MACRO(SETUP_LIBLINKS TARGET_LINK_LIBRARIES(${target} ${PTHREADS_LIB}) ENDIF(WIN32) ENDMACRO(SETUP_LIBLINKS) + diff --git a/CMakeLists.txt b/CMakeLists.txt index d2595bd0138..2f12d342726 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,21 +53,25 @@ SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) #----------------------------------------------------------------------------- # Set default config options -OPTION(WITH_PLAYER "Build Player" OFF) -OPTION(WITH_GAMEENGINE "Enable Game Engine" ON) -OPTION(WITH_BULLET "Enable Bullet (Physics Engine)" ON) -OPTION(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON) -OPTION(WITH_ELBEEM "Enable Elbeem (Fluid Simulation)" ON) -OPTION(WITH_QUICKTIME "Enable Quicktime Support" OFF) -OPTION(WITH_OPENEXR "Enable OpenEXR Support (http://www.openexr.com)" ON) -OPTION(WITH_DDS "Enable DDS Support" ON) -OPTION(WITH_FFMPEG "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF) -OPTION(WITH_PYTHON "Enable Embedded Python API" ON) -OPTION(WITH_SDL "Enable SDL for sound and joystick support" ON) -OPTION(WITH_OPENJPEG "Enable OpenJpeg Support (http://www.openjpeg.org/)" OFF) -OPTION(WITH_OPENAL "Enable OpenAL Support (http://www.openal.org)" ON) -OPTION(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" OFF) -OPTION(WITH_WEBPLUGIN "Enable Web Plugin (Unix only)" OFF) +OPTION(WITH_PLAYER "Build Player" OFF) +OPTION(WITH_GAMEENGINE "Enable Game Engine" ON) +OPTION(WITH_BULLET "Enable Bullet (Physics Engine)" ON) +OPTION(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON) +OPTION(WITH_ELBEEM "Enable Elbeem (Fluid Simulation)" ON) +OPTION(WITH_QUICKTIME "Enable Quicktime Support" OFF) +OPTION(WITH_OPENEXR "Enable OpenEXR Support (http://www.openexr.com)" ON) +OPTION(WITH_DDS "Enable DDS Support" ON) +OPTION(WITH_FFMPEG "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF) +OPTION(WITH_PYTHON "Enable Embedded Python API" ON) +OPTION(WITH_SDL "Enable SDL for sound and joystick support" ON) +OPTION(WITH_OPENJPEG "Enable OpenJpeg Support (http://www.openjpeg.org/)" OFF) +OPTION(WITH_OPENAL "Enable OpenAL Support (http://www.openal.org)" ON) +OPTION(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" OFF) +OPTION(WITH_WEBPLUGIN "Enable Web Plugin (Unix only)" OFF) +OPTION(WITH_FFTW3 "Enable FFTW3 support" OFF) +OPTION(WITH_JACK "Enable Jack Support (http://www.jackaudio.org)" OFF) +OPTION(WITH_CXX_GUARDEDALLOC "" OFF) +OPTION(WITH_INSTALL "Install accompanying scripts and language files needed to run blender" ON) IF(NOT WITH_GAMEENGINE AND WITH_PLAYER) MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE") @@ -93,13 +97,18 @@ IF(UNIX AND NOT APPLE) FIND_PACKAGE(OpenAL) IF(OPENAL_FOUND) SET(WITH_OPENAL ON) - SET(OPENAL_LIB ${OPENAL_LIBRARY}) - SET(OPENAL_INC ${OPENAL_INCLUDE_DIR}) ELSE(OPENAL_FOUND) SET(WITH_OPENAL OFF) ENDIF(OPENAL_FOUND) ENDIF(WITH_OPENAL) + IF(WITH_JACK) + SET(JACK /usr) + SET(JACK_INC ${JACK}/include/jack) + SET(JACK_LIB jack) + SET(JACK_LIBPATH ${JACK}/lib) + ENDIF(WITH_JACK) + FIND_LIBRARY(INTL_LIBRARY NAMES intl PATHS @@ -110,34 +119,34 @@ IF(UNIX AND NOT APPLE) PATHS /sw/lib ) + IF(INTL_LIBRARY AND ICONV_LIBRARY) SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY}) ENDIF(INTL_LIBRARY AND ICONV_LIBRARY) - - FIND_PATH(FREETYPE_INC - freetype - PATHS - /usr/local/include/freetype2 - /usr/include/freetype2 - /sw/include/freetype2 - /opt/local/include/freetype2 - /opt/csw/include/freetype2 - /opt/include/freetype2 - NO_DEFAULT_PATH - ) - SET(FREETYPE_LIB freetype) - FIND_PACKAGE(PythonLibs) - SET(PYTHON_INC "${PYTHON_INCLUDE_PATH}" CACHE STRING "") - SET(PYTHON_LIB "${PYTHON_LIBRARIES}" CACHE STRING "") - FIND_PACKAGE(PythonInterp) - SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "") + FIND_PACKAGE(Freetype) + # UNSET(FREETYPE_INCLUDE_DIRS CACHE) # cant use + + # No way to set py31. remove for now. + # FIND_PACKAGE(PythonLibs) + SET(PYTHON /usr) + SET(PYTHON_VERSION 3.1) + SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "") + # SET(PYTHON_BINARY python) # not used yet + SET(PYTHON_LIB python${PYTHON_VERSION} CACHE STRING "") + SET(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "") + + # FIND_PACKAGE(PythonInterp) # not used yet + # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "") + SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic") IF(WITH_SDL) FIND_PACKAGE(SDL) - SET(SDL_INC ${SDL_INCLUDE_DIR}) - SET(SDL_LIB ${SDL_LIBRARY}) + # UNSET(SDLMAIN_LIBRARY CACHE) + IF(NOT SDL_FOUND) + SET(WITH_SDL OFF) + ENDIF(NOT SDL_FOUND) ENDIF(WITH_SDL) FIND_PATH(OPENEXR_INC @@ -156,6 +165,18 @@ IF(UNIX AND NOT APPLE) SET(FFMPEG_INC ${FFMPEG}/include) SET(FFMPEG_LIB avformat avcodec avutil avdevice swscale) SET(FFMPEG_LIBPATH ${FFMPEG}/lib) + + IF(WITH_FFTW3) + SET(FFTW3 /usr) + SET(FFTW3_INC ${FFTW3}/include) + SET(FFTW3_LIB fftw3) + SET(FFTW3_LIBPATH ${FFTW3}/lib) + ENDIF(WITH_FFTW3) + + SET(LIBSAMPLERATE /usr) + SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include) + SET(LIBSAMPLERATE_LIB samplerate) + SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib) FIND_PACKAGE(JPEG REQUIRED) @@ -163,7 +184,13 @@ IF(UNIX AND NOT APPLE) FIND_PACKAGE(ZLIB REQUIRED) - SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++ -lX11 -ldl") + # Could use ${X11_Xinput_LIB} ${X11_X11_LIB} too + SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++ -lX11") + + IF(CMAKE_SYSTEM_NAME MATCHES "Linux") + # BSD's dont use libdl.so + SET(LLIBS "${LLIBS} -ldl") + ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") IF(WITH_OPENMP) SET(LLIBS "${LLIBS} -lgomp") @@ -178,6 +205,7 @@ IF(UNIX AND NOT APPLE) # Better warnings SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wnested-externs -Wdeclaration-after-statement") + SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare") INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ) ENDIF(UNIX AND NOT APPLE) @@ -196,10 +224,10 @@ IF(WIN32) ENDIF(CMAKE_CL_64) SET(PYTHON ${LIBDIR}/python) - SET(PYTHON_VERSION 2.6) + SET(PYTHON_VERSION 3.1) SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}") - SET(PYTHON_BINARY python) - SET(PYTHON_LIB python26) + # SET(PYTHON_BINARY python) # not used yet + SET(PYTHON_LIB python31) SET(PYTHON_LIBPATH ${PYTHON}/lib) IF(CMAKE_CL_64) @@ -207,13 +235,20 @@ IF(WIN32) ELSE(CMAKE_CL_64) #SET(WITH_OPENAL ON) SET(OPENAL ${LIBDIR}/openal) - SET(OPENAL_INC ${OPENAL}/include ${OPENAL}/include/AL) - SET(OPENAL_LIB openal_static) + SET(OPENAL_INCLUDE_DIR ${OPENAL}/include) + SET(OPENAL_LIBRARY wrap_oal) SET(OPENAL_LIBPATH ${OPENAL}/lib) ENDIF(CMAKE_CL_64) + IF(WITH_JACK) + SET(JACK ${LIBDIR}/jack) + SET(JACK_INC ${JACK}/include/jack) + SET(JACK_LIB jack) + SET(JACK_LIBPATH ${JACK}/lib) + ENDIF(WITH_JACK) + IF(CMAKE_CL_64) - SET(PNG_LIBRARIES libpng) + SET(PNG_LIBRARIES libpng) ELSE(CMAKE_CL_64) SET(PNG_LIBRARIES libpng_st) ENDIF(CMAKE_CL_64) @@ -234,30 +269,37 @@ IF(WIN32) SET(ICONV_LIB iconv) SET(ICONV_LIBPATH ${ICONV}/lib) + IF(WITH_FFTW3) + SET(FFTW3 ${LIBDIR}/fftw3) + SET(FFTW3_INC ${FFTW3}/include) + SET(FFTW3_LIB libfftw) + SET(FFTW3_LIBPATH ${FFTW3}/lib) + ENDIF(WITH_FFTW3) + SET(GETTEXT ${LIBDIR}/gettext) SET(GETTEXT_INC ${GETTEXT}/include) IF(CMAKE_CL_64) - SET(GETTEXT_LIB gettextlib) + SET(GETTEXT_LIB gettextlib) ELSE(CMAKE_CL_64) - SET(GETTEXT_LIB gnu_gettext) + SET(GETTEXT_LIB gnu_gettext) ENDIF(CMAKE_CL_64) SET(GETTEXT_LIBPATH ${GETTEXT}/lib) SET(FREETYPE ${LIBDIR}/freetype) - SET(FREETYPE_INC ${FREETYPE}/include ${FREETYPE}/include/freetype2) + SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2) SET(FREETYPE_LIBPATH ${FREETYPE}/lib) - SET(FREETYPE_LIB freetype2ST) + SET(FREETYPE_LIBRARY freetype2ST) SET(OPENEXR ${LIBDIR}/openexr) SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath) SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread) IF (MSVC80) - SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005) + SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005) ELSE (MSVC80) - SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc) + SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc) ENDIF(MSVC80) IF (MSVC90) - SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008) + SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008) ENDIF(MSVC90) @@ -271,15 +313,16 @@ IF(WIN32) SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0) SET(FFMPEG_LIBPATH ${FFMPEG}/lib) + SET(LIBSAMPLERATE ${LIBDIR}/samplerate) + SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include) + SET(LIBSAMPLERATE_LIB libsamplerate) + SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib) + IF(CMAKE_CL_64) - SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 ) + SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 ) ELSE(CMAKE_CL_64) - SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm) + SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm) ENDIF(CMAKE_CL_64) - - IF(WITH_OPENAL) - SET(LLIBS ${LLIBS} dxguid) - ENDIF(WITH_OPENAL) SET(CMAKE_CXX_FLAGS_DEBUG "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE) SET(CMAKE_CXX_FLAGS_RELEASE "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE) @@ -296,8 +339,8 @@ IF(WIN32) ENDIF(WITH_OPENMP) SET(SDL ${LIBDIR}/sdl) - SET(SDL_INC ${SDL}/include) - SET(SDL_LIB SDL) + SET(SDL_INCLUDE_DIR ${SDL}/include) + SET(SDL_LIBRARY SDL) SET(SDL_LIBPATH ${SDL}/lib) SET(PNG "${LIBDIR}/png") @@ -314,10 +357,11 @@ IF(WIN32) SET(WINTAB_INC ${LIBDIR}/wintab/include) IF(CMAKE_CL_64) - SET(PLATFORM_LINKFLAGS "/MANIFEST:NO /MANIFESTUAC:NO /MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ") + SET(PLATFORM_LINKFLAGS "/MANIFEST:NO /MANIFESTUAC:NO /MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ") ELSE(CMAKE_CL_64) - SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ") + SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ") ENDIF(CMAKE_CL_64) + SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ") ENDIF(WIN32) @@ -332,13 +376,17 @@ IF(APPLE) FIND_PACKAGE(OpenAL) IF(OPENAL_FOUND) SET(WITH_OPENAL ON) - SET(OPENAL_LIB ${OPENAL_LIBRARY}) - SET(OPENAL_INC ${OPENAL_INCLUDE_DIR}) ELSE(OPENAL_FOUND) SET(WITH_OPENAL OFF) ENDIF(OPENAL_FOUND) ENDIF(WITH_OPENAL) + IF(WITH_JACK) + SET(JACK /usr) + SET(JACK_INC ${JACK}/include/jack) + SET(JACK_LIB jack) + SET(JACK_LIBPATH ${JACK}/lib) + ENDIF(WITH_JACK) SET(PYTHON_VERSION 3.1) @@ -347,7 +395,7 @@ IF(APPLE) SET(PYTHON ${LIBDIR}/python) SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "") - SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}" CACHE STRING "") + # SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}" CACHE STRING "") # not used yet SET(PYTHON_LIB python${PYTHON_VERSION}) SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}" CACHE STRING "") # SET(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled @@ -357,7 +405,7 @@ IF(APPLE) SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/) SET(PYTHON_VERSION 2.5) SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}" CACHE STRING "") - SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION} CACHE STRING "") + # SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION} CACHE STRING "") # not used yet SET(PYTHON_LIB "") SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config CACHE STRING "") SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python") @@ -367,6 +415,13 @@ IF(APPLE) SET(GETTEXT_INC "${GETTEXT}/include") SET(GETTEXT_LIB intl iconv) SET(GETTEXT_LIBPATH ${GETTEXT}/lib) + + IF(WITH_FFTW3) + SET(FFTW3 ${LIBDIR}/fftw3) + SET(FFTW3_INC ${FFTW3}/include) + SET(FFTW3_LIB libfftw) + SET(FFTW3_LIBPATH ${FFTW3}/lib) + ENDIF(WITH_FFTW3) SET(PNG_LIBRARIES png) SET(JPEG_LIBRARY jpeg) @@ -376,15 +431,25 @@ IF(APPLE) SET(ZLIB_LIBRARIES z) SET(FREETYPE ${LIBDIR}/freetype) - SET(FREETYPE_INC ${FREETYPE}/include ${FREETYPE}/include/freetype2) + SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2) SET(FREETYPE_LIBPATH ${FREETYPE}/lib) - SET(FREETYPE_LIB freetype) + SET(FREETYPE_LIBRARY freetype) SET(OPENEXR ${LIBDIR}/openexr) SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include) SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread) SET(OPENEXR_LIBPATH ${OPENEXR}/lib) + SET(FFMPEG ${LIBDIR}/ffmpeg) + SET(FFMPEG_INC ${CMAKE_SOURCE_DIR}/extern/ffmpeg) + SET(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore) + SET(FFMPEG_LIBPATH ${FFMPEG}/lib) + + SET(LIBSAMPLERATE ${LIBDIR}/samplerate) + SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include) + SET(LIBSAMPLERATE_LIB samplerate) + SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib) + SET(LLIBS stdc++ SystemStubs) SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing") @@ -397,8 +462,8 @@ IF(APPLE) ENDIF(WITH_OPENMP) SET(SDL ${LIBDIR}/sdl) - SET(SDL_INC ${SDL}/include) - SET(SDL_LIB SDL) + SET(SDL_INCLUDE_DIR ${SDL}/include) + SET(SDL_LIBRARY SDL) SET(SDL_LIBPATH ${SDL}/lib) SET(PNG "${LIBDIR}/png") @@ -442,16 +507,18 @@ ENDIF(WITH_WEBPLUGIN) # Configure OpenGL. FIND_PACKAGE(OpenGL) INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) +# UNSET(OPENGL_LIBRARIES CACHE) # not compat with older cmake +# UNSET(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake + #----------------------------------------------------------------------------- # Extra compile flags -IF(WITH_GAMEENGINE) - SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DGAMEBLENDER ") -ENDIF(WITH_GAMEENGINE) -IF(WITH_BULLET) - SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DWITH_BULLET ") -ENDIF(WITH_BULLET) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}") + +# better not define flags here but this is a debugging option thats off by default. +IF(WITH_CXX_GUARDEDALLOC) + SET(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}") +ENDIF(WITH_CXX_GUARDEDALLOC) #----------------------------------------------------------------------------- # Libraries @@ -471,3 +538,4 @@ ADD_SUBDIRECTORY(source/creator) IF(WITH_PLAYER) ADD_SUBDIRECTORY(blenderplayer) ENDIF(WITH_PLAYER) + diff --git a/SConstruct b/SConstruct index c1b4f8da174..a96cfc0567a 100644 --- a/SConstruct +++ b/SConstruct @@ -31,6 +31,7 @@ import platform as pltfrm +# Need a better way to do this. Automagical maybe is not the best thing, maybe it is. if pltfrm.architecture()[0] == '64bit': bitness = 64 else: @@ -59,7 +60,6 @@ B = tools.Blender platform = sys.platform quickie = None quickdebug = None -nsis_build = None ##### BEGIN SETUP ##### @@ -425,8 +425,6 @@ if env['OURPLATFORM']=='darwin': bundle = '%s.app' % prg[0] bundledir = os.path.dirname(bundle) for dp, dn, df in os.walk(bundle): - if 'CVS' in dn: - dn.remove('CVS') if '.svn' in dn: dn.remove('.svn') dir=env['BF_INSTALLDIR']+dp[len(bundledir):] @@ -443,8 +441,6 @@ scriptinstall = [] if env['OURPLATFORM']!='darwin': for dp, dn, df in os.walk('bin/.blender'): - if 'CVS' in dn: - dn.remove('CVS') if '.svn' in dn: dn.remove('.svn') @@ -471,8 +467,6 @@ if env['OURPLATFORM']!='darwin': scriptpaths=['release/scripts', 'release/ui', 'release/io'] for scriptpath in scriptpaths: for dp, dn, df in os.walk(scriptpath): - if 'CVS' in dn: - dn.remove('CVS') if '.svn' in dn: dn.remove('.svn') dir=env['BF_INSTALLDIR']+'/.blender/'+os.path.basename(scriptpath)+dp[len(scriptpath):] @@ -485,8 +479,6 @@ if env['OURPLATFORM']=='linux2': icontargetlist = [] for tp, tn, tf in os.walk('release/freedesktop/icons'): - if 'CVS' in tn: - tn.remove('CVS') if '.svn' in tn: tn.remove('.svn') for f in tf: @@ -509,8 +501,6 @@ if env['OURPLATFORM']=='linuxcross': pluglist = [] plugtargetlist = [] for tp, tn, tf in os.walk('release/plugins'): - if 'CVS' in tn: - tn.remove('CVS') if '.svn' in tn: tn.remove('.svn') for f in tf: @@ -541,8 +531,6 @@ for targetdir,srcfile in zip(plugtargetlist, pluglist): textlist = [] texttargetlist = [] for tp, tn, tf in os.walk('release/text'): - if 'CVS' in tn: - tn.remove('CVS') if '.svn' in tn: tn.remove('.svn') for f in tf: @@ -574,8 +562,8 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc'): if env['WITH_BF_PYTHON']: ver = env["BF_PYTHON_VERSION"].replace(".", "") - dllsources.append('#release/windows/extra/python' + ver + '.zip') - dllsources.append('#release/windows/extra/zlib.pyd') + dllsources.append('${LCGDIR}/release/python' + ver + '.zip') + dllsources.append('${LCGDIR}/release/zlib.pyd') if env['BF_DEBUG']: dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_LIB}_d.dll') else: @@ -585,6 +573,9 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc'): pass # we link statically to iconv on win64 else: dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll'] + if env['WITH_BF_OPENAL']: + dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll') + dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll') if env['WITH_BF_FFMPEG']: dllsources += ['${LCGDIR}/ffmpeg/lib/avcodec-52.dll', '${LCGDIR}/ffmpeg/lib/avformat-52.dll', @@ -596,6 +587,8 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc'): '${LCGDIR}/ffmpeg/lib/libx264-67.dll', '${LCGDIR}/ffmpeg/lib/xvidcore.dll', '${LCGDIR}/ffmpeg/lib/swscale-0.dll'] + if env['WITH_BF_JACK']: + dllsources += ['${LCGDIR}/jack/lib/libjack.dll'] windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources) allinstall += windlls diff --git a/blenderplayer/CMakeLists.txt b/blenderplayer/CMakeLists.txt index 28fe13cbf64..77bc059a6a0 100644 --- a/blenderplayer/CMakeLists.txt +++ b/blenderplayer/CMakeLists.txt @@ -87,7 +87,6 @@ IF(UNIX) bf_scenegraph bf_IK bf_moto - bf_soundsystem bf_kernel bf_nodes bf_gpu @@ -111,6 +110,10 @@ IF(UNIX) extern_glew ) + IF(WITH_CXX_GUARDEDALLOC) + SET(BLENDER_SORTED_LIBS ${BLENDER_SORTED_LIBS} bf_guardedalloc_cpp) + ENDIF(WITH_CXX_GUARDEDALLOC) + FOREACH(SORTLIB ${BLENDER_SORTED_LIBS}) SET(REMLIB ${SORTLIB}) FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS}) diff --git a/config/darwin-config.py b/config/darwin-config.py index d6fcb14b4a9..5c0fa9a5086 100644 --- a/config/darwin-config.py +++ b/config/darwin-config.py @@ -32,22 +32,28 @@ BF_PYTHON_VERSION = '3.1' if MAC_PROC== 'powerpc' and BF_PYTHON_VERSION == '2.3': MAC_MIN_VERS = '10.3' MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk' -elif MAC_CUR_VER=='10.4': +else: MAC_MIN_VERS = '10.4' MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk' -else: - MAC_MIN_VERS = '10.5' - MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' # enable ffmpeg support WITH_BF_FFMPEG = True # -DWITH_FFMPEG -BF_FFMPEG = "#extern/ffmpeg" -BF_FFMPEG_INC = '${BF_FFMPEG}' -if USE_SDK==True: - BF_FFMPEG_EXTRA = '-isysroot '+MACOSX_SDK+' -mmacosx-version-min='+MAC_MIN_VERS -#BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib' -#BF_FFMPEG_LIB = 'avformat.a avcodec.a avutil.a' +FFMPEG_PRECOMPILED = False +if FFMPEG_PRECOMPILED: + # use precompiled ffmpeg in /lib + BF_FFMPEG = LIBDIR + '/ffmpeg' + BF_FFMPEG_INC = "#extern/ffmpeg" + BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib' + BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore' +else: + # use ffmpeg in extern + BF_FFMPEG = "#extern/ffmpeg" + BF_FFMPEG_INC = '${BF_FFMPEG}' + if USE_SDK==True: + BF_FFMPEG_EXTRA = '-isysroot '+MACOSX_SDK+' -mmacosx-version-min='+MAC_MIN_VERS + BF_XVIDCORE_CONFIG = '--disable-assembly' # currently causes errors, even with yasm installed + BF_X264_CONFIG = '--disable-pthread' if BF_PYTHON_VERSION=='3.1': # python 3.1 uses precompiled libraries in bf svn /lib by default @@ -57,7 +63,7 @@ if BF_PYTHON_VERSION=='3.1': # BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}' BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}' BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}' - # BF_PYTHON_LINKFLAGS = '-u _PyMac_Error -framework System' + # BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System'] else: # python 2.5 etc. uses built-in framework @@ -73,18 +79,13 @@ else: BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}' BF_PYTHON_LIB = '' BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config' - BF_PYTHON_LINKFLAGS = '-u _PyMac_Error -framework System -framework Python' + BF_PYTHON_LINKFLAGS = ['-u','_PyMac_Error','-framework','System','-framework','Python'] if MAC_CUR_VER=='10.3' or MAC_CUR_VER=='10.4': - BF_PYTHON_LINKFLAGS ='-u __dummy '+BF_PYTHON_LINKFLAGS + BF_PYTHON_LINKFLAGS = ['-u', '__dummy']+BF_PYTHON_LINKFLAGS BF_QUIET = '1' WITH_BF_OPENMP = '0' -# Note : should be true, but openal simply dont work on intel -if MAC_PROC == 'i386': - WITH_BF_OPENAL = False -else: - WITH_BF_OPENAL = True #different lib must be used following version of gcc # for gcc 3.3 #BF_OPENAL = LIBDIR + '/openal' @@ -106,6 +107,18 @@ BF_CXX = '/usr' WITH_BF_STATICCXX = False BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a' +BF_LIBSAMPLERATE = LIBDIR + '/samplerate' +BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include' +BF_LIBSAMPLERATE_LIB = 'samplerate' +BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib' + +# TODO - set proper paths here (add precompiled to lib/ ? ) +WITH_BF_JACK = False +BF_JACK = '/usr' +BF_JACK_INC = '${BF_JACK}/include/jack' +BF_JACK_LIB = 'jack' +BF_JACK_LIBPATH = '${BF_JACK}/lib' + WITH_BF_SDL = True BF_SDL = LIBDIR + '/sdl' #$(shell sdl-config --prefix) BF_SDL_INC = '${BF_SDL}/include' #$(shell $(BF_SDL)/bin/sdl-config --cflags) @@ -158,6 +171,12 @@ BF_BULLET = '#extern/bullet2/src' BF_BULLET_INC = '${BF_BULLET}' BF_BULLET_LIB = 'extern_bullet' +WITH_BF_FFTW3 = False +BF_FFTW3 = LIBDIR + '/fftw3' +BF_FFTW3_INC = '${BF_FFTW3}/include' +BF_FFTW3_LIB = 'libfftw3' +BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib' + #WITH_BF_NSPR = True #BF_NSPR = $(LIBDIR)/nspr #BF_NSPR_INC = -I$(BF_NSPR)/include -I$(BF_NSPR)/include/nspr @@ -193,14 +212,14 @@ BF_ICONV_LIB = 'iconv' WITH_BF_STATICOPENGL = True BF_OPENGL_LIB = 'GL GLU' BF_OPENGL_LIBPATH = '/System/Library/Frameworks/OpenGL.framework/Libraries' -BF_OPENGL_LINKFLAGS = '-framework OpenGL' +BF_OPENGL_LINKFLAGS = ['-framework', 'OpenGL'] CFLAGS = ['-pipe','-fPIC','-funsigned-char'] CPPFLAGS = ['-fpascal-strings'] CCFLAGS = ['-pipe','-fPIC','-funsigned-char','-fpascal-strings'] CXXFLAGS = [ '-pipe','-fPIC','-funsigned-char', '-fpascal-strings'] -PLATFORM_LINKFLAGS = '-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime' +PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Carbon','-framework','AGL','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','QuickTime'] #note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4 LLIBS = ['stdc++', 'SystemStubs'] @@ -209,12 +228,12 @@ LLIBS = ['stdc++', 'SystemStubs'] if MAC_MIN_VERS == '10.3': CFLAGS = ['-fuse-cxa-atexit']+CFLAGS CXXFLAGS = ['-fuse-cxa-atexit']+CXXFLAGS - PLATFORM_LINKFLAGS = '-fuse-cxa-atexit '+PLATFORM_LINKFLAGS + PLATFORM_LINKFLAGS = ['-fuse-cxa-atexit']+PLATFORM_LINKFLAGS LLIBS.append('crt3.o') if USE_SDK==True: SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS] - PLATFORM_LINKFLAGS = '-mmacosx-version-min='+MAC_MIN_VERS+ ' -Wl,-syslibroot,' + MACOSX_SDK+" "+PLATFORM_LINKFLAGS + PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS, '-Wl,-syslibroot,' + MACOSX_SDK]+PLATFORM_LINKFLAGS CCFLAGS=SDK_FLAGS+CCFLAGS CXXFLAGS=SDK_FLAGS+CXXFLAGS diff --git a/config/irix6-config.py b/config/irix6-config.py index 93d6506ccc7..d38665f282a 100644 --- a/config/irix6-config.py +++ b/config/irix6-config.py @@ -24,6 +24,11 @@ BF_CXX = '/usr' WITH_BF_STATICCXX = 'false' BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a' +BF_LIBSAMPLERATE = LCGDIR+'/samplerate' +BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include' +BF_LIBSAMPLERATE_LIB = 'samplerate' +BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib' + WITH_BF_SDL = 'true' BF_SDL = LCGDIR+'/sdl' #$(shell sdl-config --prefix) BF_SDL_INC = '${BF_SDL}/include/SDL' #$(shell $(BF_SDL)/bin/sdl-config --cflags) diff --git a/config/linux2-config.py b/config/linux2-config.py index 6b6373bb001..b8e035c72fb 100644 --- a/config/linux2-config.py +++ b/config/linux2-config.py @@ -22,6 +22,17 @@ BF_CXX = '/usr' WITH_BF_STATICCXX = False BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a' +BF_LIBSAMPLERATE = '/usr' +BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include' +BF_LIBSAMPLERATE_LIB = 'samplerate' +BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib' + +WITH_BF_JACK = False +BF_JACK = '/usr' +BF_JACK_INC = '${BF_JACK}/include/jack' +BF_JACK_LIB = 'jack' +BF_JACK_LIBPATH = '${BF_JACK}/lib' + WITH_BF_SDL = True BF_SDL = '/usr' #$(shell sdl-config --prefix) BF_SDL_INC = '${BF_SDL}/include/SDL' #$(shell $(BF_SDL)/bin/sdl-config --cflags) @@ -130,6 +141,12 @@ BF_OPENJPEG_LIB = '' BF_OPENJPEG_INC = '${BF_OPENJPEG}' BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib' +WITH_BF_FFTW3 = False +BF_FFTW3 = LIBDIR + '/usr' +BF_FFTW3_INC = '${BF_FFTW3}/include' +BF_FFTW3_LIB = 'fftw3' +BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib' + WITH_BF_REDCODE = False BF_REDCODE = '#extern/libredcode' BF_REDCODE_LIB = '' diff --git a/config/linuxcross-config.py b/config/linuxcross-config.py index a683f848f6a..9f79fab2bc2 100644 --- a/config/linuxcross-config.py +++ b/config/linuxcross-config.py @@ -28,6 +28,11 @@ BF_CXX = '/usr' WITH_BF_STATICCXX = False BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a' +BF_LIBSAMPLERATE = LIBDIR + '/samplerate' +BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include' +BF_LIBSAMPLERATE_LIB = 'samplerate' +BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib' + WITH_BF_SDL = True BF_SDL = LIBDIR + '/sdl' BF_SDL_INC = '${BF_SDL}/include' diff --git a/config/openbsd3-config.py b/config/openbsd3-config.py index 92f044394d6..95649321c07 100644 --- a/config/openbsd3-config.py +++ b/config/openbsd3-config.py @@ -16,6 +16,11 @@ WITH_BF_OPENAL = False #BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib' #BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a' +BF_LIBSAMPLERATE = '/usr/local' +BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include' +BF_LIBSAMPLERATE_LIB = 'samplerate' +BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib' + WITH_BF_SDL = True BF_SDL = '/usr/local' #$(shell sdl-config --prefix) BF_SDL_INC = '${BF_SDL}/include/SDL' #$(shell $(BF_SDL)/bin/sdl-config --cflags) diff --git a/config/sunos5-config.py b/config/sunos5-config.py index 6e970b9cab2..8af30e4f4f3 100644 --- a/config/sunos5-config.py +++ b/config/sunos5-config.py @@ -22,6 +22,11 @@ BF_CXX = '/usr' WITH_BF_STATICCXX = False BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a' +BF_LIBSAMPLERATE = '/usr/local' +BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include' +BF_LIBSAMPLERATE_LIB = 'samplerate' +BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib' + WITH_BF_SDL = True BF_SDL = '/usr/local' #$(shell sdl-config --prefix) BF_SDL_INC = '${BF_SDL}/include/SDL' #$(shell $(BF_SDL)/bin/sdl-config --cflags) @@ -109,7 +114,7 @@ BF_ICONV_LIB = 'iconv' BF_ICONV_LIBPATH = '${BF_ICONV}/lib' # enable ffmpeg support -WITH_BF_FFMPEG = False # -DWITH_FFMPEG +WITH_BF_FFMPEG = True # -DWITH_FFMPEG BF_FFMPEG = '/usr/local' BF_FFMPEG_INC = '${BF_FFMPEG}/include' BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib' diff --git a/config/win32-mingw-config.py b/config/win32-mingw-config.py index 51cd120dc72..a7de3f6111e 100644 --- a/config/win32-mingw-config.py +++ b/config/win32-mingw-config.py @@ -16,19 +16,27 @@ BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib' BF_PYTHON_LIB_STATIC = '${BF_PYTHON}/lib/libpython${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}.a' WITH_BF_OPENAL = True -WITH_BF_STATICOPENAL = False BF_OPENAL = LIBDIR + '/openal' BF_OPENAL_INC = '${BF_OPENAL}/include' -BF_OPENAL_LIB = 'dxguid openal_static' +BF_OPENAL_LIB = 'wrap_oal' BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib' -# Warning, this static lib configuration is untested! users of this OS please confirm. -BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a' WITH_BF_FFMPEG = False BF_FFMPEG_LIB = 'avformat swscale avcodec avutil avdevice xvidcore x264' BF_FFMPEG_LIBPATH = LIBDIR + '/gcc/ffmpeg/lib' BF_FFMPEG_INC = LIBDIR + '/gcc/ffmpeg/include' +BF_LIBSAMPLERATE = LIBDIR + '/samplerate' +BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include' +BF_LIBSAMPLERATE_LIB = 'libsamplerate' +BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib' + +WITH_BF_JACK = False +BF_JACK = LIBDIR + '/jack' +BF_JACK_INC = '${BF_JACK}/include' +BF_JACK_LIB = 'libjack' +BF_JACK_LIBPATH = '${BF_JACK}/lib' + WITH_BF_SDL = True BF_SDL = LIBDIR + '/sdl' BF_SDL_INC = '${BF_SDL}/include' diff --git a/config/win32-vc-config.py b/config/win32-vc-config.py index 4df15c691c2..e9bbd42e915 100644 --- a/config/win32-vc-config.py +++ b/config/win32-vc-config.py @@ -16,13 +16,10 @@ BF_PYTHON_LIB = 'python31' BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib' WITH_BF_OPENAL = True -WITH_BF_STATICOPENAL = False BF_OPENAL = LIBDIR + '/openal' -BF_OPENAL_INC = '${BF_OPENAL}/include ${BF_OPENAL}/include/AL ' -BF_OPENAL_LIB = 'dxguid openal_static' +BF_OPENAL_INC = '${BF_OPENAL}/include ' +BF_OPENAL_LIB = 'wrap_oal' BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib' -# Warning, this static lib configuration is untested! users of this OS please confirm. -BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a' # TODO - are these useful on win32? # BF_CXX = '/usr' @@ -35,6 +32,17 @@ BF_ICONV_INC = '${BF_ICONV}/include' BF_ICONV_LIB = 'iconv' BF_ICONV_LIBPATH = '${BF_ICONV}/lib' +BF_LIBSAMPLERATE = LIBDIR + '/samplerate' +BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include' +BF_LIBSAMPLERATE_LIB = 'libsamplerate' +BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib' + +WITH_BF_JACK = False +BF_JACK = LIBDIR + '/jack' +BF_JACK_INC = '${BF_JACK}/include' +BF_JACK_LIB = 'libjack' +BF_JACK_LIBPATH = '${BF_JACK}/lib' + WITH_BF_SDL = True BF_SDL = LIBDIR + '/sdl' BF_SDL_INC = '${BF_SDL}/include' @@ -136,6 +144,12 @@ BF_OPENJPEG_LIB = '' BF_OPENJPEG_INC = '${BF_OPENJPEG}' BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib' +WITH_BF_FFTW3 = False +BF_FFTW3 = LIBDIR + '/fftw3' +BF_FFTW3_INC = '${BF_FFTW3}/include' +BF_FFTW3_LIB = 'libfftw' +BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib' + WITH_BF_REDCODE = False BF_REDCODE_INC = '#extern' diff --git a/config/win64-vc-config.py b/config/win64-vc-config.py index a8be162ea97..ed08e578df8 100644 --- a/config/win64-vc-config.py +++ b/config/win64-vc-config.py @@ -16,13 +16,10 @@ BF_PYTHON_LIB = 'python31' BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib' WITH_BF_OPENAL = False -WITH_BF_STATICOPENAL = False BF_OPENAL = LIBDIR + '/openal' -BF_OPENAL_INC = '${BF_OPENAL}/include ${BF_OPENAL}/include/AL ' -BF_OPENAL_LIB = 'dxguid openal_static' +BF_OPENAL_INC = '${BF_OPENAL}/include ' +BF_OPENAL_LIB = 'wrap_oal' BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib' -# Warning, this static lib configuration is untested! users of this OS please confirm. -BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a' # TODO - are these useful on win32? # BF_CXX = '/usr' @@ -35,6 +32,11 @@ BF_ICONV_INC = '${BF_ICONV}/include' BF_ICONV_LIB = 'iconv' BF_ICONV_LIBPATH = '${BF_ICONV}/lib' +BF_LIBSAMPLERATE = LIBDIR + '/samplerate' +BF_LIBSAMPLERATE_INC = '${BF_LIBSAMPLERATE}/include' +BF_LIBSAMPLERATE_LIB = 'libsamplerate' +BF_LIBSAMPLERATE_LIBPATH = '${BF_LIBSAMPLERATE}/lib' + WITH_BF_SDL = True BF_SDL = LIBDIR + '/sdl' BF_SDL_INC = '${BF_SDL}/include' @@ -139,6 +141,12 @@ BF_OPENJPEG_LIB = '' BF_OPENJPEG_INC = '${BF_OPENJPEG}' BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib' +WITH_BF_FFTW3 = True +BF_FFTW3 = LIBDIR + '/fftw3' +BF_FFTW3_INC = '${BF_FFTW3}/include' +BF_FFTW3_LIB = 'libfftw' +BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib' + WITH_BF_REDCODE = False BF_REDCODE_INC = '#extern' diff --git a/extern/glew/CMakeLists.txt b/extern/glew/CMakeLists.txt index 53ef014927c..eea34488e17 100644 --- a/extern/glew/CMakeLists.txt +++ b/extern/glew/CMakeLists.txt @@ -26,8 +26,13 @@ SET(INC include src) +IF(UNIX) + SET(INC ${INC} ${X11_X11_INCLUDE_PATH}) +ENDIF(UNIX) + SET(SRC src/glew.c ) BLENDERLIB(extern_glew "${SRC}" "${INC}") + diff --git a/extern/libopenjpeg/CMakeLists.txt b/extern/libopenjpeg/CMakeLists.txt index c179d5328b9..0a985aceb37 100644 --- a/extern/libopenjpeg/CMakeLists.txt +++ b/extern/libopenjpeg/CMakeLists.txt @@ -24,7 +24,7 @@ # # ***** END GPL LICENSE BLOCK ***** -SET(INC . src ${FREETYPE_INC}) +SET(INC . src) FILE(GLOB SRC *.c except t1_generate_luts.c) ADD_DEFINITIONS(-DWITH_OPENJPEG) diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt index 71bd00f71ee..f33ce6a893c 100644 --- a/intern/CMakeLists.txt +++ b/intern/CMakeLists.txt @@ -24,7 +24,7 @@ # # ***** END GPL LICENSE BLOCK ***** -ADD_SUBDIRECTORY(SoundSystem) +ADD_SUBDIRECTORY(audaspace) ADD_SUBDIRECTORY(string) ADD_SUBDIRECTORY(ghost) ADD_SUBDIRECTORY(guardedalloc) diff --git a/intern/Makefile b/intern/Makefile index b559ce6978a..4bf18f987a4 100644 --- a/intern/Makefile +++ b/intern/Makefile @@ -32,7 +32,7 @@ SOURCEDIR = intern # include nan_subdirs.mk ALLDIRS = string ghost guardedalloc moto container memutil -ALLDIRS += decimation iksolver bsp SoundSystem opennl elbeem boolop smoke +ALLDIRS += decimation iksolver bsp opennl elbeem boolop smoke audaspace all:: @for i in $(ALLDIRS); do \ diff --git a/intern/SConscript b/intern/SConscript index bdbdc7fd6e9..af5d0671c27 100644 --- a/intern/SConscript +++ b/intern/SConscript @@ -1,7 +1,7 @@ #!/usr/bin/python Import ('env') -SConscript(['SoundSystem/SConscript', +SConscript(['audaspace/SConscript', 'string/SConscript', 'ghost/SConscript', 'guardedalloc/SConscript', diff --git a/intern/SoundSystem/CMakeLists.txt b/intern/SoundSystem/CMakeLists.txt deleted file mode 100644 index 9a370af2268..00000000000 --- a/intern/SoundSystem/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -# $Id$ -# ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Jacques Beaurain. -# -# ***** END GPL LICENSE BLOCK ***** - -SET(INC . intern ../moto/include ../string dummy openal sdl) - -IF(WITH_OPENAL) - FILE(GLOB SRC dummy/*.cpp intern/*.cpp openal/*.cpp sdl/*.cpp) - INCLUDE_DIRECTORIES(${OPENAL_INC} ${SDL_INC}) - STRING(REGEX MATCH ".*ramework.*" FRAMEWORK ${OPENAL_INC}) - IF(FRAMEWORK) - ADD_DEFINITIONS(-DAPPLE_FRAMEWORK_FIX) - ENDIF(FRAMEWORK) -ELSE(WITH_OPENAL) - FILE(GLOB SRC dummy/*.cpp intern/*.cpp) - ADD_DEFINITIONS(-DNO_SOUND) -ENDIF(WITH_OPENAL) - -BLENDERLIB(bf_soundsystem "${SRC}" "${INC}") -#, libtype=['core','player'], priority = [20,140] ) diff --git a/intern/SoundSystem/SConscript b/intern/SoundSystem/SConscript deleted file mode 100644 index 256b7904a0f..00000000000 --- a/intern/SoundSystem/SConscript +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python - -Import ('env') - -sources = env.Glob('dummy/*.cpp') + env.Glob('intern/*.cpp') - -incs = '. intern ../moto/include ../string dummy openal sdl' -defs = '' -if env['WITH_BF_OPENAL']: - sources += env.Glob('openal/*.cpp') + env.Glob('sdl/*.cpp') - incs += ' ' + env['BF_OPENAL_INC'] - incs += ' ' + env['BF_SDL_INC'] - defs = 'USE_OPENAL' -else: - defs = 'NO_SOUND' - -if not env['WITH_BF_SDL']: - defs += ' DISABLE_SDL' - -env.BlenderLib ('bf_soundsystem', sources, Split(incs), Split(defs), libtype=['intern','player'], priority = [25,135] ) diff --git a/intern/SoundSystem/SND_C-api.h b/intern/SoundSystem/SND_C-api.h deleted file mode 100644 index f8e439a9c26..00000000000 --- a/intern/SoundSystem/SND_C-api.h +++ /dev/null @@ -1,354 +0,0 @@ -/** - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef SND_BLENDER_H -#define SND_BLENDER_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "SoundDefines.h" - -#define SND_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name - -SND_DECLARE_HANDLE(SND_AudioDeviceInterfaceHandle); -SND_DECLARE_HANDLE(SND_SceneHandle); -SND_DECLARE_HANDLE(SND_ObjectHandle); -SND_DECLARE_HANDLE(SND_ListenerHandle); - -/** - * set the specified type - */ -extern void SND_SetDeviceType(int device_type); - -/** - * get an audiodevice - */ -extern SND_AudioDeviceInterfaceHandle SND_GetAudioDevice(void); - -/** - * and let go of it - */ -extern void SND_ReleaseDevice(void); - -/** - * check if playback is desired - */ -extern int SND_IsPlaybackWanted(SND_SceneHandle scene); - -/** - * add memlocation to cache - */ -extern int SND_AddSample(SND_SceneHandle scene, - const char* filename, - void* memlocation, - int size); - -/** - * remove all samples - */ -extern void SND_RemoveAllSamples(SND_SceneHandle scene); - -/** - * forces the object to check its buffer, and fix it if it's wrong - */ -extern int SND_CheckBuffer(SND_SceneHandle scene, SND_ObjectHandle object); - -/** - * Creates a scene, initializes it and returns a handle to that scene. - * - * @param audiodevice: handle to the audiodevice. - */ -extern SND_SceneHandle SND_CreateScene(SND_AudioDeviceInterfaceHandle audiodevice); - -/** - * Stops all sounds, suspends the scene (so all resources will be freed) and deletes the scene. - * - * @param scene: handle to the soundscene. - */ -extern void SND_DeleteScene(SND_SceneHandle scene); - -/** - * Adds a soundobject to the scene, gets the buffer the sample is loaded into. - * - * @param scene: handle to the soundscene. - * @param object: handle to soundobject. - */ -extern void SND_AddSound(SND_SceneHandle scene, SND_ObjectHandle object); - -/** - * Removes a soundobject from the scene. - * - * @param scene: handle to the soundscene. - * @param object: handle to soundobject. - */ -extern void SND_RemoveSound(SND_SceneHandle scene, SND_ObjectHandle object); - -/** - * Removes all soundobjects from the scene. - * - * @param scene: handle to the soundscene. - */ -extern void SND_RemoveAllSounds(SND_SceneHandle scene); - -/** - * Stopss all soundobjects in the scene. - * - * @param scene: handle to the soundscene. - */ -extern void SND_StopAllSounds(SND_SceneHandle scene); - -/** - * Updates the listener, checks the status of all soundobjects, builds a list of all active - * objects, updates the active objects. - * - * @param audiodevice: handle to the audiodevice. - * @param scene: handle to the soundscene. - */ -extern void SND_Proceed(SND_AudioDeviceInterfaceHandle audiodevice, SND_SceneHandle scene); - -/** - * Returns a handle to the listener. - * - * @param scene: handle to the soundscene. - */ -extern SND_ListenerHandle SND_GetListener(SND_SceneHandle scene); - -/** - * Sets the gain of the listener. - * - * @param scene: handle to the soundscene. - * @param gain: factor the gain gets multiplied with. - */ -extern void SND_SetListenerGain(SND_SceneHandle scene, double gain); - -/** - * Sets a scaling to exaggerate or deemphasize the Doppler (pitch) shift resulting from the - * calculation. - * @attention $f' = dopplerfactor * f * frac{dopplervelocity - listener_velocity}{dopplervelocity + object_velocity}$ - * @attention f: frequency in sample (soundobject) - * @attention f': effective Doppler shifted frequency - * - * @param object: handle to soundobject. - * @param dopplerfactor: the dopplerfactor. - */ -extern void SND_SetDopplerFactor(SND_SceneHandle scene, double dopplerfactor); - -/** - * Sets the value of the propagation speed relative to which the source velocities are interpreted. - * @attention $f' = dopplerfactor * f * frac{dopplervelocity - listener_velocity}{dopplervelocity + object_velocity}$ - * @attention f: frequency in sample (soundobject) - * @attention f': effective Doppler shifted frequency - * - * @param object: handle to soundobject. - * @param dopplervelocity: the dopplervelocity. - */ -extern void SND_SetDopplerVelocity(SND_SceneHandle scene, double dopplervelocity); - -/** - * Creates a new soundobject and returns a handle to it. - */ -extern SND_ObjectHandle SND_CreateSound(void); - -/** - * Deletes a soundobject. - * - * @param object: handle to soundobject. - */ -extern void SND_DeleteSound(SND_ObjectHandle object); - -/** - * Sets a soundobject to SND_MUST_PLAY, so with the next proceed it will be updated and played. - * - * @param object: handle to soundobject. - */ -extern void SND_StartSound(SND_SceneHandle scene, SND_ObjectHandle object); - -/** - * Sets a soundobject to SND_MUST_STOP, so with the next proceed it will be stopped. - * - * @param object: handle to soundobject. - */ -extern void SND_StopSound(SND_SceneHandle scene, SND_ObjectHandle object); - -/** - * Sets a soundobject to SND_MUST_PAUSE, so with the next proceed it will be paused. - * - * @param object: handle to soundobject. - */ -extern void SND_PauseSound(SND_SceneHandle scene, SND_ObjectHandle object); - -/** - * Sets the name of the sample to reference the soundobject to it. - * - * @param object: handle to soundobject. - * @param samplename: the name of the sample - */ -extern void SND_SetSampleName(SND_ObjectHandle object, char* samplename); - -/** - * Sets the gain of a soundobject. - * - * @param object: handle to soundobject. - * @param gain: factor the gain gets multiplied with. - */ -extern void SND_SetGain(SND_ObjectHandle object, double gain); - -/** - * Sets the minimum gain of a soundobject. - * - * @param object: handle to soundobject. - * @param minimumgain: lower threshold for the gain. - */ -extern void SND_SetMinimumGain(SND_ObjectHandle object, double minimumgain); - -/** - * Sets the maximum gain of a soundobject. - * - * @param object: handle to soundobject. - * @param maximumgain: upper threshold for the gain. - */ -extern void SND_SetMaximumGain(SND_ObjectHandle object, double maximumgain); - -/** - * Sets the rollofffactor. The rollofffactor is a per-Source parameter the application - * can use to increase or decrease the range of a source by decreasing or increasing the - * attenuation, respectively. The default value is 1. The implementation is free to optimize - * for a rollofffactor value of 0, which indicates that the application does not wish any - * distance attenuation on the respective Source. - * - * @param object: handle to soundobject. - * @param rollofffactor: the rollofffactor. - */ -extern void SND_SetRollOffFactor(SND_ObjectHandle object, double rollofffactor); - -/** - * Sets the referencedistance at which the listener will experience gain. - * @attention G_dB = gain - 20 * log10(1 + rollofffactor * (dist - referencedistance)/referencedistance); - * - * @param object: handle to soundobject. - * @param distance: the reference distance. - */ -extern void SND_SetReferenceDistance(SND_ObjectHandle object, double referencedistance); - -/** - * Sets the pitch of a soundobject. - * - * @param object: handle to soundobject. - * @param pitch: pitchingfactor: 2.0 for doubling the frequency, 0.5 for half the frequency. - */ -extern void SND_SetPitch(SND_ObjectHandle object, double pitch); - -/** - * Sets the position a soundobject. - * - * @param object: handle to soundobject. - * @param position: position[3]. - */ -extern void SND_SetPosition(SND_ObjectHandle object, double* position); - -/** - * Sets the velocity of a soundobject. - * - * @param object: handle to soundobject. - * @param velocity: velocity[3]. - */ -extern void SND_SetVelocity(SND_ObjectHandle object, double* velocity); - -/** - * Sets the orientation of a soundobject. - * - * @param object: handle to soundobject. - * @param orientation: orientation[9]. - */ -extern void SND_SetOrientation(SND_ObjectHandle object, double* orientation); - -/** - * Sets the loopmode of a soundobject. - * - * @param object: handle to soundobject. - * @param loopmode type of the loop (SND_LOOP_OFF, SND_LOOP_NORMAL, SND_LOOP_BIDIRECTIONAL); - */ -extern void SND_SetLoopMode(SND_ObjectHandle object, int loopmode); - -/** - * Sets the looppoints of a soundobject. - * - * @param object: handle to soundobject. - * @param loopstart startpoint of the loop - * @param loopend endpoint of the loop - */ -extern void SND_SetLoopPoints(SND_ObjectHandle object, unsigned int loopstart, unsigned int loopend); - -/** - * Gets the gain of a soundobject. - * - * @param object: handle to soundobject. - */ -extern float SND_GetGain(SND_ObjectHandle object); - -/** - * Gets the pitch of a soundobject. - * - * @param object: handle to soundobject. - */ -extern float SND_GetPitch(SND_ObjectHandle object); - -/** - * Gets the looping of a soundobject. - * 0: SND_LOOP_OFF - * 1: SND_LOOP_NORMAL - * 2: SND_LOOP_BIDIRECTIONAL - * - * @param object: handle to soundobject. - */ -extern int SND_GetLoopMode(SND_ObjectHandle object); - -/** - * Gets the playstate of a soundobject. - * SND_UNKNOWN = -1 - * SND_INITIAL - * SND_MUST_PLAY - * SND_PLAYING - * SND_MUST_STOP - * SND_STOPPED - * SND_MUST_PAUSE - * SND_PAUSED - * SND_MUST_BE_DELETED - * - * @param object: handle to soundobject. - */ -extern int SND_GetPlaystate(SND_ObjectHandle object); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/intern/SoundSystem/SND_CDObject.h b/intern/SoundSystem/SND_CDObject.h deleted file mode 100644 index c79f62d9862..00000000000 --- a/intern/SoundSystem/SND_CDObject.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SND_CDObject.h - * - * Implementation for CD playback - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __SND_CDOBJECT_H -#define __SND_CDOBJECT_H - -#include "SND_Object.h" - -class SND_CDObject : public SND_Object -{ -private: - - /** - * Private to enforce singleton - */ - SND_CDObject(); - SND_CDObject(const SND_CDObject&); - - static SND_CDObject* m_instance; - MT_Scalar m_gain; /* the gain of the object */ - int m_playmode; /* the way CD is played back (all, random, track, trackloop) */ - int m_track; /* the track for 'track' and 'trackloop' */ - int m_playstate; /* flag for current state of object */ - bool m_modified; - bool m_used; /* flag for checking if we used the cd, if not don't - call the stop cd at the end */ - -public: - static bool CreateSystem(); - static bool DisposeSystem(); - static SND_CDObject* Instance(); - - ~SND_CDObject(); - - void SetGain(MT_Scalar gain); - void SetPlaymode(int playmode); - void SetTrack(int track); - void SetPlaystate(int playstate); - void SetModified(bool modified); - void SetUsed(); - bool GetUsed(); - - bool IsModified() const; - - int GetTrack() const; - MT_Scalar GetGain() const; - int GetPlaymode() const; - int GetPlaystate() const; - -}; - -#endif //__SND_CDOBJECT_H - diff --git a/intern/SoundSystem/SND_DeviceManager.h b/intern/SoundSystem/SND_DeviceManager.h deleted file mode 100644 index 708db030519..00000000000 --- a/intern/SoundSystem/SND_DeviceManager.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SND_DeviceManager.h - * - * singleton for creating, switching and deleting audiodevices - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __SND_DEVICEMANAGER_H -#define __SND_DEVICEMANAGER_H - -#include "SND_IAudioDevice.h" - -class SND_DeviceManager -{ -public : - - /** - * a subscription is needed before instances are given away - * applications must call subscribe first, get an instance, and - * when they are finished with sound, unsubscribe - */ - static void Subscribe(); - static void Unsubscribe(); - - static SND_IAudioDevice* Instance(); - static void SetDeviceType(int device_type); - -private : - - /** - * Private to enforce singleton - */ - SND_DeviceManager(); - SND_DeviceManager(const SND_DeviceManager&); - ~SND_DeviceManager(); - - static SND_IAudioDevice* m_instance; - - /** - * The type of device to be created on a call - * to Instance(). - */ - static int m_device_type; - - /** - * Remember the number of subscriptions. - * if 0, delete the device - */ - static int m_subscriptions; -}; - -#endif //__SND_DEVICEMANAGER_H - diff --git a/intern/SoundSystem/SND_IAudioDevice.h b/intern/SoundSystem/SND_IAudioDevice.h deleted file mode 100644 index d6b3936e6ef..00000000000 --- a/intern/SoundSystem/SND_IAudioDevice.h +++ /dev/null @@ -1,343 +0,0 @@ -/** - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef SND_IAUDIODEVICE -#define SND_IAUDIODEVICE - -#include "SND_SoundObject.h" -#include "SND_CDObject.h" -#include "SND_WaveCache.h" -#include "SND_WaveSlot.h" -#include "MT_Matrix3x3.h" - -class SND_IAudioDevice -{ -public: - - /** - * constructor - */ - SND_IAudioDevice() {}; - - /** - * destructor - */ - virtual ~SND_IAudioDevice() {}; - - /** - * check to see if initialization was successfull - * - * @return indication of succes - */ - virtual bool IsInitialized()=0; - - /** - * get the wavecache (which does sample (un)loading) - * - * @return pointer to the wavecache - */ - virtual SND_WaveCache* GetWaveCache() const =0; - - /** - * loads a sample into the device - * - * @param samplename the name of the sample - * @param memlocation pointer where the sample is stored - * @param size size of the sample in memory - * - * @return pointer to the slot with sample data - */ - virtual SND_WaveSlot* LoadSample(const STR_String& samplename, - void* memlocation, - int size)=0; - - /** - * remove a sample from the wavecache - * - * @param filename pointer to filename - */ -// virtual void RemoveSample(const char* filename)=0; - - /** - * remove all samples from the wavecache - */ - virtual void RemoveAllSamples()=0; - - /** - * get a new id from the device - * - * @param pObject pointer to soundobject - * - * @return indication of success - */ - virtual bool GetNewId(SND_SoundObject* pObject)=0; - - /** - * clear an id - * - * @param pObject pointer to soundobject - */ - virtual void ClearId(SND_SoundObject* pObject)=0; - - /** - * initialize the listener - */ - virtual void InitListener()=0; - - /** - * set the value of the propagation speed relative to which the - * source velocities are interpreted. - * f' = DOPPLER_FACTOR * f * (DOPPLER_VELOCITY - Vl) / (DOPPLER_VELOCITY + Vo) - * f: frequency in sample (soundobject) - * f': effective Doppler shifted frequency - * Vl: velocity listener - * Vo: velocity soundobject - * - * @param dopplervelocity scaling factor for doppler effect - */ - virtual void SetDopplerVelocity(MT_Scalar dopplervelocity) const =0; - - /** - * set a scaling to exaggerate or deemphasize the Doppler (pitch) - * shift resulting from the calculation. - * f' = DOPPLER_FACTOR * f * (DOPPLER_VELOCITY - Listener_velocity )/(DOPPLER_VELOCITY + object_velocity ) - * - * @param dopplerfactor scaling factor for doppler effect - */ - virtual void SetDopplerFactor(MT_Scalar dopplerfactor) const =0; - - /** - * set the roll-off factor - * - * @param rollofffactor a global volume scaling factor - */ - virtual void SetListenerRollOffFactor(MT_Scalar rollofffactor) const =0; - - /** - * make the context the current one - */ - virtual void MakeCurrent() const =0; - - /** - * update the device - */ - virtual void NextFrame() const =0; - - /** - * set the volume of the listener. - * - * @param gain the mastergain - */ - virtual void SetListenerGain(float gain) const =0; - - /** - * connect the buffer with the source - * - * @param id the id of the object - * @param buffer the buffer the sample is stored in - */ - virtual void SetObjectBuffer(int id, unsigned int buffer)=0; - - /** - * pause playback of the cd - * @param id the id of the object - * - * @return the state the object is in - */ - virtual int GetPlayState(int id) =0; - - /** - * play a sound belonging to an object. - * - * @param id the id of the object - */ - virtual void PlayObject(int id) =0; - - /** - * stop a sound belonging to an object. - * - * @param id the id of the object - */ - virtual void StopObject(int id) const =0; - - /** - * stop all sounds. - */ - virtual void StopAllObjects()=0; - - /** - * pause the sound belonging to an object. - * - * @param id the id of the object - */ - virtual void PauseObject(int id) const =0; - - /** - * set the sound to looping or non-looping. - * - * @param id the id of the object - * @param loopmode type of looping (no loop, normal, bidirectional) - */ - virtual void SetObjectLoop(int id, unsigned int loopmode) const =0; - - /** - * set the looppoints of a sound - * - * @param id the id of the object - * @param loopstart the startpoint of the loop (in samples) - * @param loopend the endpoint of the loop (in samples) - */ - virtual void SetObjectLoopPoints(int id, unsigned int loopstart, unsigned int loopend) const =0; - - /** - * set the pitch of the sound. - * - * @param id the id of the object - * @param pitch the pitch - */ - virtual void SetObjectPitch(int id, MT_Scalar pitch) const =0; - - /** - * set the gain of the sound. - * - * @param id the id of the object - * @param gain the gain - */ - virtual void SetObjectGain(int id, MT_Scalar gain) const =0; - - /** - * ROLLOFF_FACTOR is per-Source parameter the application can use to increase or decrease - * the range of a source by decreasing or increasing the attenuation, respectively. The - * default value is 1. The implementation is free to optimize for a ROLLOFF_FACTOR value - * of 0, which indicates that the application does not wish any distance attenuation on - * the respective Source. - * - * @param id the id of the object - * @param rolloff a per-source volume scaling factor - */ - virtual void SetObjectRollOffFactor(int id, MT_Scalar rolloff) const =0; - - /** - * min_gain indicates the minimal gain which is always guaranteed for this sound - * - * @param id the id of the object - * @param mingain the minimum gain of the object - */ - virtual void SetObjectMinGain(int id, MT_Scalar mingain) const =0; - - /** - * max_gain indicates the maximal gain which is always guaranteed for this sound - * - * @param id the id of the object - * @param maxgain the maximum gain of the object - */ - virtual void SetObjectMaxGain(int id, MT_Scalar maxgain) const =0; - /** - * set the distance at which the Listener will experience gain. - * G_dB = GAIN - 20*log10(1 + ROLLOFF_FACTOR*(dist-REFERENCE_DISTANCE)/REFERENCE_DISTANCE ); - * - * @param id the id of the object - * @param referencedistance the distance at which the listener will start hearing - */ - virtual void SetObjectReferenceDistance(int id, MT_Scalar referencedistance) const =0; - - /** - * set the position, velocity and orientation of a sound. - * - * @param id the id of the object - * @param position the position of the object - * @param velocity the velocity of the object - * @param orientation the orientation of the object - * @param lisposition the position of the listener - * @param rollofffactor the rollofffactor of the object - */ - virtual void SetObjectTransform(int id, - const MT_Vector3& position, - const MT_Vector3& velocity, - const MT_Matrix3x3& orientation, - const MT_Vector3& lisposition, - const MT_Scalar& rollofffactor) const =0; - - /** - * make a sound 2D - * - * @param id the id of the object - */ - virtual void ObjectIs2D(int id) const =0; - - /** - * tell the device we want cd suppport - */ - virtual void UseCD() const =0; - - /** - * start playback of the cd - * - * @param track the tracknumber to start playback from - */ - virtual void PlayCD(int track) const =0; - - /** - * pause playback of the cd (true == pause, false == resume) - */ - virtual void PauseCD(bool pause) const =0; - - /** - * stop playback of the cd - */ - virtual void StopCD() const =0; - - /** - * set the playbackmode of the cd - * SND_CD_ALL play all tracks - * SND_CD_TRACK play one track - * SND_CD_TRACKLOOP play one track looped - * SND_CD_RANDOM play all tracks in random order - * - * @param playmode playmode - */ - virtual void SetCDPlaymode(int playmode) const =0; - - /** - * set the volume playback of the cd - * - * @param gain the gain - */ - virtual void SetCDGain(MT_Scalar gain) const =0; - - virtual void StartUsingDSP() =0; - virtual float* GetSpectrum() =0; - virtual void StopUsingDSP() =0; - -protected: - - virtual void RevokeSoundObject(SND_SoundObject* pObject)=0; -}; - -#endif //SND_IAUDIODEVICE - diff --git a/intern/SoundSystem/SND_Object.h b/intern/SoundSystem/SND_Object.h deleted file mode 100644 index f23827974e3..00000000000 --- a/intern/SoundSystem/SND_Object.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SND_Object.h - * - * Abstract sound object - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __SND_OBJECT_H -#define __SND_OBJECT_H - -#include "GEN_List.h" -#include "MT_Matrix3x3.h" -#include "SoundDefines.h" - -/** - * SND_Object is an interface class for soundobjects, listeners and other - * kinds of sound related thingies. - */ - -class SND_Object : public GEN_Link -{ -public: - SND_Object() {}; - virtual ~SND_Object() {}; -}; - -#endif //__SND_OBJECT_H - diff --git a/intern/SoundSystem/SND_Scene.h b/intern/SoundSystem/SND_Scene.h deleted file mode 100644 index bb3ff932bce..00000000000 --- a/intern/SoundSystem/SND_Scene.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * SND_Scene.h - * - * The scene for sounds. - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifdef WIN32 -#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning -#endif //WIN32 - -#ifndef __SND_SCENE_H -#define __SND_SCENE_H - -#include "SoundDefines.h" -#include "SND_SoundObject.h" -#include "SND_CDObject.h" -#include "SND_SoundListener.h" -#include "SND_WaveSlot.h" - -#include "MT_Vector3.h" -#include "MT_Matrix3x3.h" -#include "STR_String.h" - -#include - - -class SND_Scene -{ - std::set m_soundobjects; - - GEN_List m_activeobjects; - class SND_IAudioDevice* m_audiodevice; - class SND_WaveCache* m_wavecache; - class SND_SoundListener m_listener; - bool m_audio; // to check if audio works - bool m_audioplayback; // to check if audioplayback is wanted - - void UpdateListener(); - void BuildActiveList(MT_Scalar curtime); - void UpdateActiveObects(); - void UpdateCD(); - -public: - SND_Scene(SND_IAudioDevice* adi); - ~SND_Scene(); - - bool IsPlaybackWanted(); - - void AddActiveObject(SND_SoundObject* pObject, MT_Scalar curtime); - void RemoveActiveObject(SND_SoundObject* pObject); - void DeleteObjectWhenFinished(SND_SoundObject* pObject); - - void Proceed(); - - int LoadSample(const STR_String& samplename, - void* memlocation, - int size); - void RemoveAllSamples(); - bool CheckBuffer(SND_SoundObject* pObject); - bool IsSampleLoaded(STR_String& samplename); - - void AddObject(SND_SoundObject* pObject); - bool SetCDObject(SND_CDObject* cdobject); - void DeleteObject(SND_SoundObject* pObject); - void RemoveAllObjects(); - void StopAllObjects(); - int GetObjectStatus(SND_SoundObject* pObject) const; - - void SetListenerTransform(const MT_Vector3& pos, - const MT_Vector3& vel, - const MT_Matrix3x3& mat); - - SND_SoundListener* GetListener(); -}; - -#endif //__SND_SCENE_H - diff --git a/intern/SoundSystem/SND_SoundListener.h b/intern/SoundSystem/SND_SoundListener.h deleted file mode 100644 index 2f6a6e8cddd..00000000000 --- a/intern/SoundSystem/SND_SoundListener.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SND_SoundListener.h - * - * A SoundListener is for sound what a camera is for vision. - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __SND_SOUNDLISTENER_H -#define __SND_SOUNDLISTENER_H - -#include "SND_Object.h" - -class SND_SoundListener : public SND_Object -{ -public: - SND_SoundListener(); - virtual ~SND_SoundListener(); - - void SetStateFlag(unsigned int stateflags); - void SetGain(MT_Scalar gain); - void SetPosition(const MT_Vector3& pos); - void SetVelocity(const MT_Vector3& vel); - void SetOrientation(const MT_Matrix3x3& ori); - void SetDopplerFactor(MT_Scalar dopplerfactor); - void SetDopplerVelocity(MT_Scalar dopplervelocity); - void SetScale(MT_Scalar scale); - - void SetModified(bool modified); - bool IsModified() const; - - unsigned int GetStateFlags() const; - MT_Scalar GetGain() const; - MT_Vector3 GetPosition() const; - MT_Vector3 GetVelocity() const; - MT_Matrix3x3 GetOrientation(); - - MT_Scalar GetDopplerFactor() const; - MT_Scalar GetDopplerVelocity() const; - MT_Scalar GetScale() const; - -private: - void* m_listener; - bool m_modified; - - MT_Scalar m_gain; /* overall gain */ - MT_Vector3 m_position; /* position; left/right, up/down, in/out */ - MT_Vector3 m_velocity; /* velocity of the listener */ - MT_Matrix3x3 m_orientation; /* orientation of the listener */ - - MT_Scalar m_dopplerfactor; /* scaling factor for the Doppler (pitch) shift */ - MT_Scalar m_dopplervelocity; /* factor for the reference velocity (for Dopplereffect) */ - MT_Scalar m_scale; -}; - -#endif //__SND_SOUNDLISTENER_H - diff --git a/intern/SoundSystem/SND_SoundObject.h b/intern/SoundSystem/SND_SoundObject.h deleted file mode 100644 index 7bd43fb4e66..00000000000 --- a/intern/SoundSystem/SND_SoundObject.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * SND_SoundObject.h - * - * Implementation of the abstract sound object - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __SND_SOUNDOBJECT_H -#define __SND_SOUNDOBJECT_H - -#include "SND_Object.h" -#include "STR_String.h" - -/** - * SND_SoundObject is a class for api independent sounddata storage conected to an actuator - */ - -class SND_SoundObject : public SND_Object -{ -private: - STR_String m_samplename; /* name of the sample */ - STR_String m_objectname; /* name of the object */ - unsigned int m_buffer; - - bool m_active; /* is the object active or not? */ - int m_id; - MT_Scalar m_lifespan; /* the lifespan of the sound seconds */ - MT_Scalar m_timestamp; - - MT_Scalar m_length; /* length of the sample in seconds */ - - MT_Scalar m_gain; /* the gain of the object */ - MT_Scalar m_rollofffactor; /* the scaling factor to increase or decrease the range - of a source by decreasing or increasing the - attenuation, respectively */ - MT_Scalar m_referencedistance;/* the distance at which the listener will experience - gain */ - MT_Scalar m_mingain; /* indicates the minimal gain which is always guaranteed - for this source */ - MT_Scalar m_maxgain; /* indicates the maximal gain which is always guaranteed - for this source */ - - MT_Scalar m_pitch; /* the pitch of the object */ - MT_Vector3 m_position; /* position; left/right, up/down, in/out */ - MT_Vector3 m_velocity; /* velocity of the object */ - MT_Matrix3x3 m_orientation; /* orientation of the object */ - unsigned int m_loopmode; /* loop normal or bidirectional? */ - unsigned int m_loopstart; /* start of looppoint in samples! */ - unsigned int m_loopend; /* end of looppoint in samples! */ - bool m_is3d; /* is the object 3D or 2D? */ - int m_playstate; /* flag for current state of object */ - bool m_modified; - unsigned int m_running; - bool m_highpriority; /* may the sound be ditched when we run out of voices? */ - -public: - - SND_SoundObject(); - ~SND_SoundObject(); - - void SetBuffer(unsigned int buffer); - void SetActive(bool active); - - void StartSound(); - void StopSound(); - void PauseSound(); - void DeleteWhenFinished(); - - void SetObjectName(STR_String objectname); - void SetSampleName(STR_String samplename); - void SetLength(MT_Scalar length); - - void SetPitch(MT_Scalar pitch); - void SetGain(MT_Scalar gain); - void SetMinGain(MT_Scalar mingain); - void SetMaxGain(MT_Scalar maxgain); - void SetRollOffFactor(MT_Scalar rollofffactor); - void SetReferenceDistance(MT_Scalar distance); - void SetPosition(const MT_Vector3& pos); - void SetVelocity(const MT_Vector3& vel); - void SetOrientation(const MT_Matrix3x3& orient); - void SetLoopMode(unsigned int loopmode); - void SetLoopStart(unsigned int loopstart); - void SetLoopEnd(unsigned int loopend); - void Set3D(bool threedee); - void SetPlaystate(int playstate); - void SetHighPriority(bool priority); - - void SetId(int id); - void SetLifeSpan(); - void SetTimeStamp(MT_Scalar timestamp); - - void SetModified(bool modified); - - bool IsLifeSpanOver(MT_Scalar curtime) const; - bool IsActive() const; - bool IsModified() const; - bool IsHighPriority() const; - - void InitRunning(); - bool IsRunning() const; - void AddRunning(); - - int GetId() const; - MT_Scalar GetLifeSpan() const; - MT_Scalar GetTimestamp() const; - - unsigned int GetBuffer(); - const STR_String& GetSampleName(); - const STR_String& GetObjectName(); - - MT_Scalar GetLength() const; - MT_Scalar GetGain() const; - MT_Scalar GetPitch() const; - - MT_Scalar GetMinGain() const; - MT_Scalar GetMaxGain() const; - MT_Scalar GetRollOffFactor() const; - MT_Scalar GetReferenceDistance() const; - - MT_Vector3 GetPosition() const; - MT_Vector3 GetVelocity() const; - MT_Matrix3x3 GetOrientation() const; - unsigned int GetLoopMode() const; - unsigned int GetLoopStart() const; - unsigned int GetLoopEnd() const; - bool Is3D() const; - int GetPlaystate() const; - -}; - -#endif //__SND_SOUNDOBJECT_H - diff --git a/intern/SoundSystem/SND_Utils.h b/intern/SoundSystem/SND_Utils.h deleted file mode 100644 index 82b7c69a595..00000000000 --- a/intern/SoundSystem/SND_Utils.h +++ /dev/null @@ -1,111 +0,0 @@ -/** - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef SND_UTILS_H -#define SND_UTILS_H - -#include "SND_WaveSlot.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef struct -{ - unsigned char riff[4]; - signed int size; - unsigned char type[4]; -} WavFileHeader; - -typedef struct -{ - unsigned short format; - unsigned short numberofchannels; - unsigned int samplerate; - unsigned int bytespersec; - unsigned short blockalignment; - unsigned short bitrate; -} WavFmtHeader; - -typedef struct -{ - unsigned short size; - unsigned short samplesperblock; -} WavFmtExHeader; - -typedef struct -{ - unsigned int Manufacturer; - unsigned int Product; - unsigned int SamplePeriod; - unsigned int Note; - unsigned int FineTune; - unsigned int SMPTEFormat; - unsigned int SMPTEOffest; - unsigned int loops; - unsigned int SamplerData; - struct - { - unsigned int Identifier; - unsigned int Type; - unsigned int Start; - unsigned int End; - unsigned int Fraction; - unsigned int Count; - } Loop[1]; -} WavSampleHeader; - -typedef struct -{ - unsigned char id[4]; - unsigned int size; -} WavChunkHeader; - -/** - * loads a sample and returns a pointer - */ -extern void* SND_LoadSample(char *filename); - -extern bool SND_IsSampleValid(const STR_String& name, void* memlocation); -extern unsigned int SND_GetSampleFormat(void* sample); -extern unsigned int SND_GetNumberOfChannels(void* sample); -extern unsigned int SND_GetSampleRate(void* sample); -extern unsigned int SND_GetBitRate(void* sample); -extern unsigned int SND_GetNumberOfSamples(void* sample, unsigned int sample_length); -extern unsigned int SND_GetHeaderSize(void* sample, unsigned int sample_length); -extern unsigned int SND_GetExtraChunk(void* sample); - -extern void SND_GetSampleInfo(signed char* sample, SND_WaveSlot* waveslot); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/intern/SoundSystem/SND_WaveCache.h b/intern/SoundSystem/SND_WaveCache.h deleted file mode 100644 index 2c457797768..00000000000 --- a/intern/SoundSystem/SND_WaveCache.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SND_WaveCache.h - * - * abstract wavecache, a way to organize samples - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifdef WIN32 -#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning -#endif //WIN32 - -#ifndef __SND_WAVECACHE_H -#define __SND_WAVECACHE_H - -#include "SND_WaveSlot.h" -#include "SoundDefines.h" -#include "SND_SoundObject.h" -#include - -class SND_WaveCache -{ -public: - SND_WaveCache(); - virtual ~SND_WaveCache(); - - SND_WaveSlot* GetWaveSlot(const STR_String& samplename); - - void RemoveAllSamples(); - void RemoveSample(const STR_String& samplename, int buffer); - -private: - std::map m_samplecache; - - SND_WaveSlot* m_bufferList[NUM_BUFFERS]; - - void FreeSamples(); -}; - -#endif //__SND_WAVECACHE_H - diff --git a/intern/SoundSystem/SND_WaveSlot.h b/intern/SoundSystem/SND_WaveSlot.h deleted file mode 100644 index 75cddfa36d8..00000000000 --- a/intern/SoundSystem/SND_WaveSlot.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * SND_WaveSlot.cpp - * - * class for storing sample related information - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __SND_WAVESLOT_H -#define __SND_WAVESLOT_H - -#include "STR_String.h" - -class SND_WaveSlot -{ - STR_String m_samplename; - bool m_loaded; - void* m_data; - unsigned int m_buffer; - unsigned int m_sampleformat; - unsigned int m_numberofchannels; - unsigned int m_samplerate; - unsigned int m_bitrate; - unsigned int m_numberofsamples; - unsigned int m_filesize; - -public: - - SND_WaveSlot(): m_loaded(false), - m_data(NULL), - m_buffer(0), - m_sampleformat(0), - m_numberofchannels(0), - m_samplerate(0), - m_bitrate(0), - m_numberofsamples(0), - m_filesize(0) - {}; - ~SND_WaveSlot(); - - void SetSampleName(STR_String samplename); - void SetLoaded(bool loaded); - void SetData(void* data); - void SetBuffer(unsigned int buffer); - void SetSampleFormat(unsigned int sampleformat); - void SetNumberOfChannels(unsigned int numberofchannels); - void SetSampleRate(unsigned int samplerate); - void SetBitRate(unsigned int bitrate); - void SetNumberOfSamples(unsigned int numberofsamples); - void SetFileSize(unsigned int filesize); - - - const STR_String& GetSampleName(); - bool IsLoaded() const; - void* GetData(); - unsigned int GetBuffer() const; - unsigned int GetSampleFormat() const; - unsigned int GetNumberOfChannels() const; - unsigned int GetSampleRate() const; - unsigned int GetBitRate() const; - unsigned int GetNumberOfSamples() const; - unsigned int GetFileSize() const; - -}; - -#endif //__SND_WAVESLOT_H - diff --git a/intern/SoundSystem/SND_test/Makefile b/intern/SoundSystem/SND_test/Makefile deleted file mode 100644 index 279eeace0d8..00000000000 --- a/intern/SoundSystem/SND_test/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# $Id$ -# -# ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): none yet. -# -# ***** END GPL LICENSE BLOCK ***** -# -# - -LIBNAME = soundsystem -DIR = $(OCGDIR)/intern/SoundSystem -ALLTARGETS = $(OBJS) $(DIR)/$(DEBUG_DIR)SoundSystem - -include nan_compile.mk - -CPPFLAGS += $(NAN_LEVEL_1_WARNINGS) - -CPPFLAGS += -I$(NAN_MOTO)/include -CPPFLAGS += -I.. -I../SND_BlenderWaveCache -I../SND_OpenAL - -TESTLIB = $(OCGDIR)/gameengine/OpenALSoundSystem/$(DEBUG_DIR)libOpenALSoundSystem.a -TESTLIB += $(OCGDIR)/gameengine/BlenderWaveCache/$(DEBUG_DIR)libBlenderWaveCache.a -TESTLIB += $(OCGDIR)/intern/SoundSystem/$(DEBUG_DIR)libsoundsystem.a -TESTLIB += $(NAN_OPENAL)/lib/libopenal.a - -$(DIR)/$(DEBUG_DIR)SoundSystem: $(OBJS) $(TESTLIB) - $(CC) $(LDFLAGS) -o $@ $(OBJS) $(TESTLIB) -lm -pthread -ldl -lstdc++ diff --git a/intern/SoundSystem/SND_test/SND_test.c b/intern/SoundSystem/SND_test/SND_test.c deleted file mode 100644 index 0d19dc2e131..00000000000 --- a/intern/SoundSystem/SND_test/SND_test.c +++ /dev/null @@ -1,154 +0,0 @@ -/* SND_test.c nov 2000 -* -* testfile for the SND module -* -* janco verduin -* -* $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** -*/ - -#include "SND_C-api.h" -#include "BlenderWaveCacheCApi.h" -#include "OpenALC-Api.h" -#include -#include - -#ifdef HAVE_CONFIG_H -#include -#endif - -#if defined(WIN32) -#include -#else -#include -#endif -#include - -static int buf[3]; - -float oPos[3]={3.0, 0.0,-1.0}; -float oVel[3]={0.0, 0.0, 1.0}; -float oOri[6]={0.0, 0.0, 1.0, 0.0, 1.0, 0.0}; - -void* ReadFile(char *filename) -{ - int file, filelen; - void *data = NULL; - -#if defined(WIN32) - file = open(filename, O_BINARY|O_RDONLY); -#else - file = open(filename, 0|O_RDONLY); -#endif - - if (file == -1) { - printf("can't open file.\n"); - printf("press q for quit.\n"); - - } - else { - filelen = lseek(file, 0, SEEK_END); - lseek(file, 0, SEEK_SET); - - if (filelen != 0){ - data = malloc(filelen); - if (read(file, data, filelen) != filelen) { - free(data); - data = NULL; - } - } - close(file); - - } - return (data); -} - -int main(int argc, char* argv[]) -{ - int ch; - char* samplename = NULL; - void* sampleinmemory = NULL; - SND_CacheHandle wavecache = NULL; - SND_SceneHandle scene = NULL; - SND_ObjectHandle object = NULL; - - wavecache = SND_GetWaveCache(); - scene = SND_CreateOpenALScene(wavecache); - - samplename = "2.wav"; - sampleinmemory = ReadFile(samplename); - - if (sampleinmemory) { - - object = SND_CreateObject(); - SND_AddMemoryLocation(samplename, sampleinmemory); - SND_SetSampleName(object, samplename); - SND_AddObject(scene, object); - printf("go your gang...\n"); - printf("1: play\n"); - printf("2: stop\n"); - printf("q: quit\n"); - } - do - { - ch = getchar(); - ch = toupper(ch); - switch (ch) - { - case '1': - { - SND_SetPitch(object, 1.0); - SND_SetGain(object, 1.0); - SND_StartSound(object); - break; - } - case '2': - { - SND_StopSound(object); - break; - } - default: - break; - } - - SND_Proceed(scene); - - } while (ch != 'Q'); - - if (object) { - - SND_RemoveObject(scene, object); - SND_DeleteObject(object); - } - - SND_DeleteScene(scene); - SND_DeleteCache(); - - return 0; - -} diff --git a/intern/SoundSystem/SoundDefines.h b/intern/SoundSystem/SoundDefines.h deleted file mode 100644 index 5238507c866..00000000000 --- a/intern/SoundSystem/SoundDefines.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * SoundDefines.h - * - * this is where all kinds of defines are stored - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __SOUNDDEFINES_H -#define __SOUNDDEFINES_H - -/* the types of devices */ -enum -{ - snd_e_dummydevice = 0, - snd_e_openaldevice -}; - -/* general stuff */ -#define NUM_BUFFERS 128 -#define NUM_SOURCES 24 /* 24 is the limit for openal on windows, was 16 in 2.47 and previous */ - -/* openal related stuff */ -#define AL_LOOPING 0x1007 - -/* activelist defines */ -enum -{ - SND_REMOVE_ACTIVE_OBJECT = 0, - SND_ADD_ACTIVE_OBJECT, - SND_DO_NOTHING -}; - -/* playstate flags */ -enum -{ - SND_UNKNOWN = -1, - SND_INITIAL, - SND_MUST_PLAY, - SND_PLAYING, - SND_MUST_STOP, - SND_STOPPED, - SND_MUST_PAUSE, - SND_PAUSED, - SND_MUST_RESUME, - SND_MUST_STOP_WHEN_FINISHED, - SND_MUST_BE_DELETED -}; - -/* loopmodes */ -enum -{ - SND_LOOP_OFF = 0, - SND_LOOP_NORMAL, - SND_LOOP_BIDIRECTIONAL -}; - - -/* cd playstate flags */ -enum -{ - SND_CD_ALL = 0, - SND_CD_TRACK, - SND_CD_TRACKLOOP -}; - -/* sample types */ -enum -{ - SND_WAVE_FORMAT_UNKNOWN = 0, - SND_WAVE_FORMAT_PCM, - SND_WAVE_FORMAT_ADPCM, - SND_WAVE_FORMAT_ALAW = 6, - SND_WAVE_FORMAT_MULAW, - SND_WAVE_FORMAT_DIALOGIC_OKI_ADPCM = 17, - SND_WAVE_FORMAT_CONTROL_RES_VQLPC = 34, - SND_WAVE_FORMAT_GSM_610 = 49, - SND_WAVE_FORMAT_MPEG3 = 85 -}; - -#endif //__SOUNDDEFINES_H - diff --git a/intern/SoundSystem/dummy/SND_DummyDevice.h b/intern/SoundSystem/dummy/SND_DummyDevice.h deleted file mode 100644 index 988f731d1bf..00000000000 --- a/intern/SoundSystem/dummy/SND_DummyDevice.h +++ /dev/null @@ -1,93 +0,0 @@ -/** - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef SND_DUMMYDEVICE -#define SND_DUMMYDEVICE - -#include "SND_AudioDevice.h" - -class SND_DummyDevice : public SND_AudioDevice -{ -public: - SND_DummyDevice(); - ~SND_DummyDevice(); - - bool Init() { return false; } - - SND_WaveSlot* LoadSample(const STR_String& samplename, - void* memlocation, - int size) { return NULL; } - - void InitListener() {}; - void SetListenerGain(float gain) const {}; - void SetDopplerVelocity(MT_Scalar dopplervelocity) const {}; - void SetDopplerFactor(MT_Scalar dopplerfactor) const {}; - void SetListenerRollOffFactor(MT_Scalar rollofffactor) const {}; - - void MakeCurrent() const {}; - - void NextFrame() const {}; - - void SetObjectBuffer(int id, unsigned int buffer) {}; - - int GetPlayState(int id) { return SND_UNKNOWN; } - void PlayObject(int id) {}; - void StopObject(int id) const {}; - void StopAllObjects() {}; - void PauseObject(int id) const {}; - - void SetObjectLoop(int id, unsigned int loopmode) const {}; - void SetObjectLoopPoints(int id, unsigned int loopstart, unsigned int loopend) const {}; - void SetObjectPitch(int id, MT_Scalar pitch) const {}; - void SetObjectGain(int id, MT_Scalar gain) const {}; - void SetObjectMinGain(int id, MT_Scalar mingain) const {}; - void SetObjectMaxGain(int id, MT_Scalar maxgain) const {}; - void SetObjectRollOffFactor(int id, MT_Scalar rolloff) const {}; - void SetObjectReferenceDistance(int id, MT_Scalar distance) const {}; - - void SetObjectTransform(int id, - const MT_Vector3& position, - const MT_Vector3& velocity, - const MT_Matrix3x3& orientation, - const MT_Vector3& lisposition, - const MT_Scalar& rollofffactor) const {}; - void ObjectIs2D(int id) const {}; - - void PlayCD(int track) const {}; - void PauseCD(bool pause) const {}; - void StopCD() const {}; - void SetCDPlaymode(int playmode) const {}; - void SetCDGain(MT_Scalar gain) const {}; - - void StartUsingDSP() {}; - float* GetSpectrum() { return NULL; } - void StopUsingDSP() {}; -}; - -#endif //SND_DUMMYDEVICE - diff --git a/intern/SoundSystem/intern/SND_AudioDevice.cpp b/intern/SoundSystem/intern/SND_AudioDevice.cpp deleted file mode 100644 index 4a5c0e2c498..00000000000 --- a/intern/SoundSystem/intern/SND_AudioDevice.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/** - * $Id$ - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "SND_AudioDevice.h" -#include "SND_SoundObject.h" - -#ifdef WIN32 -// This warning tells us about truncation of __long__ stl-generated names. -// It can occasionally cause DevStudio to have internal compiler warnings. -#pragma warning( disable : 4786 ) -#endif - - -SND_AudioDevice::SND_AudioDevice() -{ - m_wavecache = NULL; - m_audio = false; - - for (int i = 0; i < NUM_SOURCES; i++) - { - m_idObjectArray[i] = new SND_IdObject(); - m_idObjectArray[i]->SetId(i); - m_idObjectArray[i]->SetSoundObject(NULL); - m_idObjectList.addTail(m_idObjectArray[i]); - } -} - - - -SND_AudioDevice::~SND_AudioDevice() -{ - for (int i = 0; i < NUM_SOURCES; i++) - { - delete m_idObjectArray[i]; - m_idObjectArray[i] = NULL; - } - - if (m_wavecache) - { - delete m_wavecache; - m_wavecache = NULL; - } -} - - - -bool SND_AudioDevice::IsInitialized() -{ - return m_audio; -} - - - -SND_WaveCache* SND_AudioDevice::GetWaveCache() const -{ - return m_wavecache; -} - - - -/* seeks an unused id and returns it */ -bool SND_AudioDevice::GetNewId(SND_SoundObject* pObject) -{ -#ifdef ONTKEVER - printf("SND_AudioDevice::GetNewId\n"); -#endif - - bool result = false; - - // first, get the oldest (the first) idobject - SND_IdObject* pIdObject = (SND_IdObject*)m_idObjectList.getHead(); - - if (pIdObject->isTail()) - { - } - else - { - // find the first id object which doesn't have a high priority soundobject - bool ThisSoundMustStay = false; - bool OutOfIds = false; - - do - { - // if no soundobject present, it's seat may be taken - if (pIdObject->GetSoundObject()) - { - // and also if it ain't highprio - if (pIdObject->GetSoundObject()->IsHighPriority()) - { - ThisSoundMustStay = true; - pIdObject = (SND_IdObject*)pIdObject->getNext(); - - // if the last one is a priority sound too, then there are no id's left - // and we won't add any new sounds - if (pIdObject->isTail()) - OutOfIds = true; - } - else - { - ThisSoundMustStay = false; - } - } - else - { - ThisSoundMustStay = false; - } - - } while (ThisSoundMustStay && !OutOfIds); - - if (!OutOfIds) - { - SND_SoundObject* oldobject = pIdObject->GetSoundObject(); - - // revoke the old object if present - if (oldobject) - { -#ifdef ONTKEVER - printf("oldobject: %x\n", oldobject); -#endif - RevokeSoundObject(oldobject); - } - - // set the new soundobject into the idobject - pIdObject->SetSoundObject(pObject); - - // set the id into the soundobject - int id = pIdObject->GetId(); - pObject->SetId(id); - - // connect the new id to the buffer the sample is stored in - SetObjectBuffer(id, pObject->GetBuffer()); - - // remove the idobject from the list and add it in the back again - pIdObject->remove(); - m_idObjectList.addTail(pIdObject); - - result = true; - } - } - - return result; -} - - - -void SND_AudioDevice::ClearId(SND_SoundObject* pObject) -{ -#ifdef ONTKEVER - printf("SND_AudioDevice::ClearId\n"); -#endif - - if (pObject) - { - int id = pObject->GetId(); - - if (id != -1) - { - // lets get the idobject belonging to the soundobject - SND_IdObject* pIdObject = m_idObjectArray[id]; - SND_SoundObject* oldobject = pIdObject->GetSoundObject(); - - if (oldobject) - { - RevokeSoundObject(oldobject); - - // clear the idobject from the soundobject - pIdObject->SetSoundObject(NULL); - } - - // remove the idobject and place it in front - pIdObject->remove(); - m_idObjectList.addHead(pIdObject); - } - } -} - - - -void SND_AudioDevice::RevokeSoundObject(SND_SoundObject* pObject) -{ -#ifdef ONTKEVER - printf("SND_AudioDevice::RevokeSoundObject\n"); -#endif - - // stop the soundobject - int id = pObject->GetId(); - - if (id >= 0 && id < NUM_SOURCES) - { - StopObject(id); - - // remove the object from the 'activelist' - pObject->SetActive(false); - -#ifdef ONTKEVER - printf("pObject->remove();\n"); -#endif - } - - // make sure its id is invalid - pObject->SetId(-1); -} - -/* -void SND_AudioDevice::RemoveSample(const char* filename) -{ - if (m_wavecache) - m_wavecache->RemoveSample(filename); -} -*/ - -void SND_AudioDevice::RemoveAllSamples() -{ - if (m_wavecache) - m_wavecache->RemoveAllSamples(); -} - diff --git a/intern/SoundSystem/intern/SND_AudioDevice.h b/intern/SoundSystem/intern/SND_AudioDevice.h deleted file mode 100644 index 54e8feea90e..00000000000 --- a/intern/SoundSystem/intern/SND_AudioDevice.h +++ /dev/null @@ -1,115 +0,0 @@ -/** - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef SND_AUDIODEVICE -#define SND_AUDIODEVICE - -#include "SND_IAudioDevice.h" -#include "SoundDefines.h" -#include "SND_IdObject.h" - -class SND_AudioDevice : public SND_IAudioDevice -{ -public: - SND_AudioDevice(); - virtual ~SND_AudioDevice(); - - virtual bool IsInitialized(); - - SND_WaveCache* GetWaveCache() const; - - bool GetNewId(SND_SoundObject* pObject); - void ClearId(SND_SoundObject* pObject); - - void UseCD() const {}; - - /* to be implemented in derived class - - virtual SND_WaveSlot* LoadSample(const STR_String& samplename, - void* memlocation, - int size) =0; - */ -// void RemoveSample(const char* filename); - void RemoveAllSamples(); - - /* to be implemented in derived class - - virtual void InitListener()=0; - virtual void SetListenerGain(float gain) const =0; - virtual void SetDopplerVelocity(MT_Scalar dopplervelocity) const =0; - virtual void SetDopplerFactor(MT_Scalar dopplerfactor) const =0; - virtual void SetListenerRollOffFactor(MT_Scalar rollofffactor) const =0; - - virtual void MakeCurrent() const =0; - - virtual void UpdateDevice() const =0; - - virtual void SetObjectBuffer(int id, unsigned int buffer)=0; - virtual int GetPlayState(int id)=0; - virtual void PlayObject(int id)=0; - virtual void StopObject(int id) const =0; - virtual void StopAllObjects()=0; - virtual void PauseObject(int id) const =0; - - virtual void SetObjectLoop(int id, bool loop) const =0; - virtual void SetObjectLoopPoints(int id, unsigned int loopstart, unsigned int loopend) const =0; - virtual void SetObjectPitch(int id, MT_Scalar pitch) const =0; - virtual void SetObjectGain(int id, MT_Scalar gain) const =0; - virtual void SetObjectRollOffFactor(int id, MT_Scalar rolloff) const =0; - virtual void SetObjectMinGain(int id, MT_Scalar mingain) const =0; - virtual void SetObjectMaxGain(int id, MT_Scalar maxgain) const =0; - virtual void SetObjectReferenceDistance(int id, MT_Scalar referencedistance) const =0; - - virtual void SetObjectTransform(int id, - const MT_Vector3& position, - const MT_Vector3& velocity, - const MT_Matrix3x3& orientation, - const MT_Vector3& lisposition, - const MT_Scalar& rollofffactor) const =0; - virtual void ObjectIs2D(int id) const =0; - - virtual void PlayCD(int track) const =0; - virtual void PauseCD(bool pause) const =0; - virtual void StopCD() const =0; - virtual void SetCDPlaymode(int playmode) const =0; - virtual void SetCDGain(MT_Scalar gain) const =0; - virtual float* GetSpectrum() =0; - */ - -protected: - bool m_audio; - GEN_List m_idObjectList; - SND_IdObject* m_idObjectArray[NUM_SOURCES]; - SND_WaveCache* m_wavecache; - -private: - void RevokeSoundObject(SND_SoundObject* pObject); -}; - -#endif //SND_AUDIODEVICE - diff --git a/intern/SoundSystem/intern/SND_C-api.cpp b/intern/SoundSystem/intern/SND_C-api.cpp deleted file mode 100644 index 09846269dcc..00000000000 --- a/intern/SoundSystem/intern/SND_C-api.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* - * SND_C-Api.cpp - * - * C Api for soundmodule - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "SND_C-api.h" -#include "SND_DeviceManager.h" -#include "SND_Scene.h" - -#ifdef WIN32 -#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning -#endif //WIN32 - - - -void SND_SetDeviceType(int device_type) -{ - SND_DeviceManager::SetDeviceType(device_type); -} - - - -SND_AudioDeviceInterfaceHandle SND_GetAudioDevice() -{ - SND_IAudioDevice* audiodevice = NULL; - - SND_DeviceManager::Subscribe(); - audiodevice = SND_DeviceManager::Instance(); - - if (!audiodevice->IsInitialized()) - { - SND_DeviceManager::SetDeviceType(snd_e_dummydevice); - audiodevice = SND_DeviceManager::Instance(); - } - - return (SND_AudioDeviceInterfaceHandle)audiodevice; -} - - - -void SND_ReleaseDevice() -{ - SND_DeviceManager::Unsubscribe(); -} - - - -int SND_IsPlaybackWanted(SND_SceneHandle scene) -{ - assert(scene); - bool result = ((SND_Scene*)scene)->IsPlaybackWanted(); - - return (int)result; -} - - - -// create a scene -SND_SceneHandle SND_CreateScene(SND_AudioDeviceInterfaceHandle audiodevice) -{ - // initialize sound scene and object - SND_Scene* scene = new SND_Scene((SND_IAudioDevice*)audiodevice); - - return (SND_SceneHandle)scene; -} - - - -void SND_DeleteScene(SND_SceneHandle scene) -{ - assert(scene); - delete (SND_Scene*)scene; -} - - - -int SND_AddSample(SND_SceneHandle scene, - const char* filename, - void* memlocation, - int size) -{ - assert(scene); - assert(memlocation); - int buffer = ((SND_Scene*)scene)->LoadSample(filename, memlocation, size); - - return buffer; -} - - - -void SND_RemoveAllSamples(SND_SceneHandle scene) -{ - assert(scene); - ((SND_Scene*)scene)->RemoveAllSamples(); -} - - - -int SND_CheckBuffer(SND_SceneHandle scene, SND_ObjectHandle object) -{ - assert(scene); - assert(object); - int result = (int)((SND_Scene*)scene)->CheckBuffer((SND_SoundObject*)object); - - return result; -} - - - -void SND_AddSound(SND_SceneHandle scene, SND_ObjectHandle object) -{ - assert(scene); - assert(object); - ((SND_Scene*)scene)->AddObject((SND_SoundObject *)object); -} - - - -void SND_RemoveSound(SND_SceneHandle scene, SND_ObjectHandle object) -{ - assert(scene); - assert(object); - ((SND_Scene*)scene)->DeleteObject((SND_SoundObject *)object); -} - - - -void SND_RemoveAllSounds(SND_SceneHandle scene) -{ - assert(scene); - ((SND_Scene*)scene)->RemoveAllObjects(); -} - - - -void SND_StopAllSounds(SND_SceneHandle scene) -{ - assert(scene); - ((SND_Scene*)scene)->StopAllObjects(); -} - - - -void SND_Proceed(SND_AudioDeviceInterfaceHandle audiodevice, SND_SceneHandle scene) -{ - assert(scene); - ((SND_Scene*)scene)->Proceed(); - ((SND_IAudioDevice*)audiodevice)->NextFrame(); -} - - - -SND_ListenerHandle SND_GetListener(SND_SceneHandle scene) -{ - assert(scene); - return (SND_ListenerHandle)((SND_Scene*)scene)->GetListener(); -} - - - -void SND_SetListenerGain(SND_SceneHandle scene, double gain) -{ - assert(scene); - SND_SoundListener* listener = ((SND_Scene*)scene)->GetListener(); - listener->SetGain((MT_Scalar)gain); -} - - - -void SND_SetDopplerFactor(SND_SceneHandle scene, double dopplerfactor) -{ - assert(scene); - SND_SoundListener* listener = ((SND_Scene*)scene)->GetListener(); - listener->SetDopplerFactor(dopplerfactor); -} - - - -void SND_SetDopplerVelocity(SND_SceneHandle scene, double dopplervelocity) -{ - assert(scene); - SND_SoundListener* listener = ((SND_Scene*)scene)->GetListener(); - listener->SetDopplerVelocity(dopplervelocity); -} - - - -// Object instantiation -SND_ObjectHandle SND_CreateSound() -{ - return (SND_ObjectHandle)new SND_SoundObject(); -} - - - -void SND_DeleteSound(SND_ObjectHandle object) -{ - assert(object); - delete (SND_SoundObject*)object; -} - - - -// Object control -void SND_StartSound(SND_SceneHandle scene, SND_ObjectHandle object) -{ - assert(scene); - assert(object); - ((SND_Scene*)scene)->AddActiveObject((SND_SoundObject*)object, 0); -} - - - -void SND_StopSound(SND_SceneHandle scene, SND_ObjectHandle object) -{ - assert(scene); - assert(object); - ((SND_Scene*)scene)->RemoveActiveObject((SND_SoundObject*)object); -} - - - -void SND_PauseSound(SND_SceneHandle scene, SND_ObjectHandle object) -{ - assert(scene); - assert(object); - ((SND_Scene*)scene)->RemoveActiveObject((SND_SoundObject*)object); -} - - - -void SND_SetSampleName(SND_ObjectHandle object, char* samplename) -{ - assert(object); - STR_String name = samplename; - ((SND_SoundObject*)object)->SetSampleName(name); -} - - - -void SND_SetGain(SND_ObjectHandle object, double gain) -{ - assert(object); - ((SND_SoundObject*)object)->SetGain(gain); -} - - - -void SND_SetMinimumGain(SND_ObjectHandle object, double minimumgain) -{ - assert(object); - ((SND_SoundObject*)object)->SetMinGain(minimumgain); -} - - - -void SND_SetMaximumGain(SND_ObjectHandle object, double maximumgain) -{ - assert(object); - ((SND_SoundObject*)object)->SetMaxGain(maximumgain); -} - - - -void SND_SetRollOffFactor(SND_ObjectHandle object, double rollofffactor) -{ - assert(object); - ((SND_SoundObject*)object)->SetRollOffFactor(rollofffactor); -} - - - -void SND_SetReferenceDistance(SND_ObjectHandle object, double referencedistance) -{ - assert(object); - ((SND_SoundObject*)object)->SetReferenceDistance(referencedistance); -} - - - -void SND_SetPitch(SND_ObjectHandle object, double pitch) -{ - assert(object); - ((SND_SoundObject*)object)->SetPitch(pitch); -} - - - -void SND_SetPosition(SND_ObjectHandle object, double* position) -{ - assert(object); - ((SND_SoundObject*)object)->SetPosition(position); -} - - - -void SND_SetVelocity(SND_ObjectHandle object, double* velocity) -{ - assert(object); - ((SND_SoundObject*)object)->SetVelocity(velocity); -} - - - -void SND_SetOrientation(SND_ObjectHandle object, double* orientation) -{ - assert(object); - ((SND_SoundObject*)object)->SetOrientation(orientation); -} - - - -void SND_SetLoopMode(SND_ObjectHandle object, int loopmode) -{ - assert(object); - ((SND_SoundObject*)object)->SetLoopMode(loopmode); -} - - - -void SND_SetLoopPoints(SND_ObjectHandle object, unsigned int loopstart, unsigned int loopend) -{ - assert(object); - ((SND_SoundObject*)object)->SetLoopStart(loopstart); - ((SND_SoundObject*)object)->SetLoopEnd(loopend); -} - - - -float SND_GetGain(SND_ObjectHandle object) -{ - assert(object); - MT_Scalar gain = ((SND_SoundObject*)object)->GetGain(); - return (float) gain; -} - - - -float SND_GetPitch(SND_ObjectHandle object) -{ - assert(object); - MT_Scalar pitch = ((SND_SoundObject*)object)->GetPitch(); - return (float) pitch; -} - - - -int SND_GetLoopMode(SND_ObjectHandle object) -{ - assert(object); - return ((SND_SoundObject*)object)->GetLoopMode(); -} - - - -int SND_GetPlaystate(SND_ObjectHandle object) -{ - assert(object); - return ((SND_SoundObject*)object)->GetPlaystate(); -} diff --git a/intern/SoundSystem/intern/SND_CDObject.cpp b/intern/SoundSystem/intern/SND_CDObject.cpp deleted file mode 100644 index 089e0d554e4..00000000000 --- a/intern/SoundSystem/intern/SND_CDObject.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * SND_CDObject.cpp - * - * Implementation for CD playback - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "SND_CDObject.h" - -#ifdef HAVE_CONFIG_H -#include -#endif - -SND_CDObject* SND_CDObject::m_instance = NULL; - -bool SND_CDObject::CreateSystem() -{ - bool result = false; - - if (!m_instance) - { - m_instance = new SND_CDObject(); - result = true; - } - - return result; -} - - - -bool SND_CDObject::DisposeSystem() -{ - bool result = false; - - if (m_instance) - { - delete m_instance; - m_instance = NULL; - result = true; - } - - return result; -} - - - -SND_CDObject* SND_CDObject::Instance() -{ - return m_instance; -} - - - -SND_CDObject::SND_CDObject() -{ - m_gain = 1; - m_playmode = SND_CD_ALL; - m_track = 1; - m_playstate = SND_STOPPED; - m_used = false; - - // don't set the cd standard on modified: - // if not used, we don't wanna touch it (performance) - m_modified = false; -} - - - -SND_CDObject::~SND_CDObject() -{ -} - - - -void SND_CDObject::SetGain(MT_Scalar gain) -{ - m_gain = gain; - m_modified = true; -} - - - -void SND_CDObject::SetPlaymode(int playmode) -{ - m_playmode = playmode; -} - - - -void SND_CDObject::SetPlaystate(int playstate) -{ - m_playstate = playstate; -} - - - -void SND_CDObject::SetTrack(int track) -{ - m_track = track; -} - - - -int SND_CDObject::GetTrack() const -{ - return m_track; -} - - - -MT_Scalar SND_CDObject::GetGain() const -{ - return m_gain; -} - - -int SND_CDObject::GetPlaystate() const -{ - return m_playstate; -} - - - -bool SND_CDObject::IsModified() const -{ - return m_modified; -} - - - -void SND_CDObject::SetModified(bool modified) -{ - m_modified = modified; -} - - - -int SND_CDObject::GetPlaymode() const -{ - return m_playmode; -} - - - -void SND_CDObject::SetUsed() -{ - m_used = true; -} - - - -bool SND_CDObject::GetUsed() -{ - return m_used; -} - diff --git a/intern/SoundSystem/intern/SND_DeviceManager.cpp b/intern/SoundSystem/intern/SND_DeviceManager.cpp deleted file mode 100644 index c4bc887dffe..00000000000 --- a/intern/SoundSystem/intern/SND_DeviceManager.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * SND_DeviceManager.h - * - * singleton for creating, switching and deleting audiodevices - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "SND_DeviceManager.h" -#include "SND_DependKludge.h" -#include "SND_DummyDevice.h" -#ifdef USE_OPENAL -#include "SND_OpenALDevice.h" -#endif - -SND_IAudioDevice* SND_DeviceManager::m_instance = NULL; -int SND_DeviceManager::m_subscriptions = 0; - -#ifdef USE_OPENAL -int SND_DeviceManager::m_device_type = snd_e_openaldevice; -#else -int SND_DeviceManager::m_device_type = snd_e_dummydevice; -#endif - -void SND_DeviceManager::Subscribe() -{ - ++m_subscriptions; -} - - - -void SND_DeviceManager::Unsubscribe() -{ - --m_subscriptions; - - // only release memory if there is a m_instance but no subscriptions left - if (m_subscriptions == 0 && m_instance) - { - delete m_instance; - m_instance = NULL; - } - - if (m_subscriptions < 0) - m_subscriptions = 0; -} - - - -SND_IAudioDevice* SND_DeviceManager::Instance() -{ - // only give away an instance if there are subscriptions - if (m_subscriptions) - { - // if there's no instance yet, set and create a new one - if (m_instance == NULL) - { - SetDeviceType(m_device_type); - } - - return m_instance; - } - else - { - return NULL; - } -} - - - -void SND_DeviceManager::SetDeviceType(int device_type) -{ - // if we want to change devicetype, first delete the old one - if (m_instance) - { - delete m_instance; - m_instance = NULL; - } - - // let's create the chosen device - switch (device_type) - { -#ifdef USE_OPENAL - case snd_e_openaldevice: - { - m_instance = new SND_OpenALDevice(); - m_device_type = device_type; - break; - } -#endif - default: - { - m_instance = new SND_DummyDevice(); - m_device_type = device_type; - break; - } - } -} diff --git a/intern/SoundSystem/intern/SND_IdObject.cpp b/intern/SoundSystem/intern/SND_IdObject.cpp deleted file mode 100644 index b261442db0a..00000000000 --- a/intern/SoundSystem/intern/SND_IdObject.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SND_IdObject.cpp - * - * Object for storing runtime data, like id's, soundobjects etc - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "SND_IdObject.h" - -#ifdef HAVE_CONFIG_H -#include -#endif - -SND_IdObject::SND_IdObject() -{ -} - - - -SND_IdObject::~SND_IdObject() -{ -} - - - -SND_SoundObject* SND_IdObject::GetSoundObject() -{ - return m_soundObject; -} - - - -void SND_IdObject::SetSoundObject(SND_SoundObject* pObject) -{ - m_soundObject = pObject; -} - - - -int SND_IdObject::GetId() -{ - return m_id; -} - - - -void SND_IdObject::SetId(int id) -{ - m_id = id; -} diff --git a/intern/SoundSystem/intern/SND_IdObject.h b/intern/SoundSystem/intern/SND_IdObject.h deleted file mode 100644 index 86611b026f0..00000000000 --- a/intern/SoundSystem/intern/SND_IdObject.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SND_IdObject.h - * - * Object for storing runtime data, like id's, soundobjects etc - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __SND_IDOBJECT_H -#define __SND_IDOBJECT_H - -#include "SND_SoundObject.h" -#include "GEN_List.h" -#include "SoundDefines.h" - -class SND_IdObject : public GEN_Link -{ - SND_SoundObject* m_soundObject; - int m_id; - -public: - SND_IdObject(); - virtual ~SND_IdObject(); - - SND_SoundObject* GetSoundObject(); - void SetSoundObject(SND_SoundObject* pObject); - - int GetId(); - void SetId(int id); -}; - -#endif //__SND_OBJECT_H - diff --git a/intern/SoundSystem/intern/SND_Scene.cpp b/intern/SoundSystem/intern/SND_Scene.cpp deleted file mode 100644 index af1b43a08aa..00000000000 --- a/intern/SoundSystem/intern/SND_Scene.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/* -* SND_Scene.cpp -* -* The scene for sounds. -* -* $Id$ -* - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef WIN32 -#pragma warning (disable:4786) // Get rid of stupid stl-visual compiler debug warning -#endif //WIN32 - -#include "SND_Scene.h" -#include "SND_DependKludge.h" -#include "SND_IAudioDevice.h" - -#include -#include - -//static unsigned int tijd = 0; - -SND_Scene::SND_Scene(SND_IAudioDevice* audiodevice) - : m_audiodevice(audiodevice) -{ - if (m_audiodevice) - m_wavecache = m_audiodevice->GetWaveCache(); - - if (!m_wavecache || !audiodevice) - { - m_audio = false; - } - else - { - //if so, go ahead! - m_audio = true; -#ifdef ONTKEVER - printf("SND_Scene::SND_Scene() m_audio == true\n"); -#endif - m_audiodevice->InitListener(); - } - - IsPlaybackWanted(); -} - - - -SND_Scene::~SND_Scene() -{ - StopAllObjects(); -} - - - -// check if audioplayback is wanted -bool SND_Scene::IsPlaybackWanted() -{ - /* Removed the functionality for checking if noaudio was provided on */ - /* the commandline. */ - if (m_audiodevice && m_wavecache) - { - m_audioplayback = true; - } - else - { - StopAllObjects(); - m_audioplayback = false; - } - - return m_audioplayback; -} - - - -int SND_Scene::LoadSample(const STR_String& samplename, - void* memlocation, - int size) -{ - int result = -1; - - if (m_audiodevice) - { - SND_WaveSlot* waveslot = m_audiodevice->LoadSample(samplename, memlocation, size); - - if (waveslot) - result = waveslot->GetBuffer(); - } - - return result; -} - - - -void SND_Scene::RemoveAllSamples() -{ - if (m_audio && m_audiodevice) - m_audiodevice->RemoveAllSamples(); -} - - - -bool SND_Scene::CheckBuffer(SND_SoundObject* pObject) -{ - bool result = false; - - if (pObject && m_wavecache) - { - SND_WaveSlot* waveslot = m_wavecache->GetWaveSlot(pObject->GetSampleName()); - - if (waveslot) - { - pObject->SetBuffer(waveslot->GetBuffer()); - - result = true; - } - } - - return result; -} - - - -bool SND_Scene::IsSampleLoaded(STR_String& samplename) -{ - bool result = false; - - if (samplename && m_wavecache) - { - SND_WaveSlot* waveslot = m_wavecache->GetWaveSlot(samplename); - - if (waveslot && waveslot->IsLoaded()) - result = true; - } - - return result; -} - - - -void SND_Scene::AddObject(SND_SoundObject* pObject) -{ - if (m_audio) - { - STR_String samplename = pObject->GetSampleName(); - SND_WaveSlot* slot = NULL; - - // don't add the object if no valid sample is referenced - if (samplename != "") - { - // check if the sample is already loaded - slot = m_wavecache->GetWaveSlot(samplename); - } - - if (slot) - { - pObject->SetBuffer(slot->GetBuffer()); - - // needed for expected lifespan of the sample, but ain't necesary anymore i think - MT_Scalar samplelength = slot->GetNumberOfSamples(); - MT_Scalar samplerate = slot->GetSampleRate(); - MT_Scalar soundlength = samplelength/samplerate; - pObject->SetLength(soundlength); - - // add the object to the list - m_soundobjects.insert((SND_SoundObject*)pObject); - } - } -} - - - -void SND_Scene::SetListenerTransform(const MT_Vector3& pos, - const MT_Vector3& vel, - const MT_Matrix3x3& ori) -{ - if (m_audio) - { - GetListener()->SetPosition(pos); - GetListener()->SetVelocity(vel); - GetListener()->SetOrientation(ori); - } -} - - - -void SND_Scene::UpdateListener() -{ - // process the listener if modified - if (m_listener.IsModified()) - { - m_audiodevice->SetListenerGain(m_listener.GetGain()); - m_audiodevice->SetDopplerVelocity(m_listener.GetDopplerVelocity()); - m_audiodevice->SetDopplerFactor(m_listener.GetDopplerFactor()); - m_listener.SetModified(false); - } -} - - - -void SND_Scene::AddActiveObject(SND_SoundObject* pObject, MT_Scalar curtime) -{ - if (m_audio) - { - if (pObject) - { -#ifdef ONTKEVER - printf("SND_Scene::AddActiveObject\n"); -#endif - - // first check if the object is already on the list - if (pObject->IsActive()) - { - pObject->SetTimeStamp(curtime); - pObject->StartSound(); - } - else - { - pObject->SetTimeStamp(curtime); - - // compute the expected lifespan - pObject->SetLifeSpan(); - - // lets give the new active-to-be object an id - if (m_audiodevice->GetNewId(pObject)) - { - // and add the object - m_activeobjects.addTail(pObject); - pObject->StartSound(); - pObject->SetActive(true); - } - } - } - } -} - - - -void SND_Scene::RemoveActiveObject(SND_SoundObject* pObject) -{ - if (m_audio) - { - if (pObject) - { -#ifdef ONTKEVER - printf("SND_Scene::RemoveActiveObject\n"); -#endif - // if inactive, remove it from the list - if (pObject->IsActive()) - { - // first make sure it is stopped - m_audiodevice->ClearId(pObject); - } - } - } -} - - - -void SND_Scene::UpdateActiveObects() -{ -// ++tijd; - - SND_SoundObject* pObject; - // update only the objects that need to be updated - for (pObject = (SND_SoundObject*)m_activeobjects.getHead(); - !pObject->isTail(); - pObject = (SND_SoundObject*)pObject->getNext()) - { - int id = pObject->GetId(); - - if (id >= 0) - { - if (pObject->Is3D()) - { - // Get the global positions and velocity vectors - // of the listener and soundobject - MT_Vector3 op = pObject->GetPosition(); - MT_Vector3 lp = m_listener.GetPosition(); - MT_Vector3 position = op - lp; - - // Calculate relative velocity in global coordinates - // of the sound with respect to the listener. - MT_Vector3 ov = pObject->GetVelocity(); - MT_Vector3 lv = m_listener.GetVelocity(); - MT_Vector3 velocity = ov - lv; - - // Now map the object position and velocity into - // the local coordinates of the listener. - MT_Matrix3x3 lo = m_listener.GetOrientation(); - - MT_Vector3 local_sound_pos = position * lo; - MT_Vector3 local_sound_vel = velocity * lo; - - m_audiodevice->SetObjectTransform( - id, - local_sound_pos, - local_sound_vel, - pObject->GetOrientation(), // make relative to listener! - lp, - pObject->GetRollOffFactor()); - } - else - { - m_audiodevice->ObjectIs2D(id); - } - - // update the situation - if (pObject->IsModified()) - { - m_audiodevice->SetObjectPitch(id, pObject->GetPitch()); - m_audiodevice->SetObjectGain(id, pObject->GetGain()); - m_audiodevice->SetObjectMinGain(id, pObject->GetMinGain()); - m_audiodevice->SetObjectMaxGain(id, pObject->GetMaxGain()); - m_audiodevice->SetObjectReferenceDistance(id, pObject->GetReferenceDistance()); - m_audiodevice->SetObjectRollOffFactor(id, pObject->GetRollOffFactor()); - m_audiodevice->SetObjectLoop(id, pObject->GetLoopMode()); - m_audiodevice->SetObjectLoopPoints(id, pObject->GetLoopStart(), pObject->GetLoopEnd()); - pObject->SetModified(false); - } - - pObject->AddRunning(); - -#ifdef ONTKEVER - STR_String naam = pObject->GetObjectName(); - STR_String sample = pObject->GetSampleName(); - - int id = pObject->GetId(); - int buffer = pObject->GetBuffer(); - - float gain = pObject->GetGain(); - float pitch = pObject->GetPitch(); - float timestamp = pObject->GetTimestamp(); - - printf("naam: %s, sample: %s \n", naam.Ptr(), sample.Ptr()); - printf("id: %d, buffer: %d \n", id, buffer); - printf("gain: %f, pitch: %f, ts: %f \n\n", gain, pitch, timestamp); -#endif -#ifdef USE_OPENAL - // ok, properties Set. now see if it must play - switch (pObject->GetPlaystate()){ - case SND_MUST_PLAY: - m_audiodevice->PlayObject(id); - pObject->SetPlaystate(SND_PLAYING); - break; - case SND_MUST_STOP: - RemoveActiveObject(pObject); - break; - case SND_MUST_PAUSE: - m_audiodevice->PauseObject(id); - pObject->SetPlaystate(SND_PAUSED); - break; - } -#endif - - // check to see if the sound is still playing - // if not: release its id - int playstate = m_audiodevice->GetPlayState(id); -#ifdef ONTKEVER - if (playstate != 2) - printf("%d - ",playstate); -#endif - - if ((playstate == SND_STOPPED) && !pObject->GetLoopMode()) - { - RemoveActiveObject(pObject); - } - } - } -} - - - -void SND_Scene::UpdateCD() -{ - if (m_audiodevice) - { - SND_CDObject* pCD = SND_CDObject::Instance(); - - if (pCD) - { - int playstate = pCD->GetPlaystate(); - - switch (playstate) - { - case SND_MUST_PLAY: - { - // initialize the cd only when you need it - m_audiodevice->SetCDGain(pCD->GetGain()); - m_audiodevice->SetCDPlaymode(pCD->GetPlaymode()); - m_audiodevice->PlayCD(pCD->GetTrack()); - pCD->SetPlaystate(SND_PLAYING); - pCD->SetUsed(); - break; - } - case SND_MUST_PAUSE: - { - m_audiodevice->PauseCD(true); - pCD->SetPlaystate(SND_PAUSED); - break; - } - case SND_MUST_RESUME: - { - m_audiodevice->PauseCD(false); - pCD->SetPlaystate(SND_PLAYING); - break; - } - case SND_MUST_STOP: - { - m_audiodevice->StopCD(); - pCD->SetPlaystate(SND_STOPPED); - break; - } - default: - { - } - } - - // this one is only for realtime modifying settings - if (pCD->IsModified()) - { - m_audiodevice->SetCDGain(pCD->GetGain()); - pCD->SetModified(false); - } - } - } -} - - - -void SND_Scene::Proceed() -{ - if (m_audio && m_audioplayback) - { - m_audiodevice->MakeCurrent(); - - UpdateListener(); - UpdateActiveObects(); - UpdateCD(); - -// m_audiodevice->UpdateDevice(); - } -} - - -void SND_Scene::DeleteObject(SND_SoundObject* pObject) -{ -#ifdef ONTKEVER - printf("SND_Scene::DeleteObject\n"); -#endif - - if (pObject) - { - if (m_audiodevice) - m_audiodevice->ClearId(pObject); - - // must remove object from m_activeList - std::set::iterator set_it; - set_it = m_soundobjects.find(pObject); - - if (set_it != m_soundobjects.end()) - m_soundobjects.erase(set_it); - - // release the memory - delete pObject; - pObject = NULL; - } -} - - - -void SND_Scene::RemoveAllObjects() -{ -#ifdef ONTKEVER - printf("SND_Scene::RemoveAllObjects\n"); -#endif - - StopAllObjects(); - - std::set::iterator it = m_soundobjects.begin(); - - while (it != m_soundobjects.end()) - { - delete (*it); - it++; - } - - m_soundobjects.clear(); -} - - - -void SND_Scene::StopAllObjects() -{ - if (m_audio) - { -#ifdef ONTKEVER - printf("SND_Scene::StopAllObjects\n"); -#endif - - SND_SoundObject* pObject; - - for (pObject = (SND_SoundObject*)m_activeobjects.getHead(); - !pObject->isTail(); - pObject = (SND_SoundObject*)pObject->getNext()) - { - m_audiodevice->ClearId(pObject); - } - } -} - - - -SND_SoundListener* SND_Scene::GetListener() -{ - return &m_listener; -} diff --git a/intern/SoundSystem/intern/SND_SoundListener.cpp b/intern/SoundSystem/intern/SND_SoundListener.cpp deleted file mode 100644 index 26163e87765..00000000000 --- a/intern/SoundSystem/intern/SND_SoundListener.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * SND_SoundListener.cpp - * - * A SoundListener is for sound what a camera is for vision. - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "SND_SoundListener.h" - -#ifdef HAVE_CONFIG_H -#include -#endif - -SND_SoundListener::SND_SoundListener() -{ - m_modified = true; - m_gain = 1.0; - m_dopplerfactor = 1.0; - m_dopplervelocity = 1.0; - m_scale = 1.0; - m_position[0] = 0.0; - m_position[1] = 0.0; - m_position[2] = 0.0; - m_velocity[0] = 0.0; - m_velocity[1] = 0.0; - m_velocity[2] = 0.0; - m_orientation[0][0] = 1.0; - m_orientation[0][1] = 0.0; - m_orientation[0][2] = 0.0; - m_orientation[1][0] = 0.0; - m_orientation[1][1] = 1.0; - m_orientation[1][2] = 0.0; - m_orientation[2][0] = 0.0; - m_orientation[2][1] = 0.0; - m_orientation[2][2] = 1.0; -} - - -SND_SoundListener::~SND_SoundListener() -{ - ; /* intentionally empty */ - -} - - - -void SND_SoundListener::SetGain(MT_Scalar gain) -{ - m_gain = gain; - m_modified = true; -} - - - -void SND_SoundListener::SetPosition (const MT_Vector3& pos) -{ - m_position = pos; -} - - - -void SND_SoundListener::SetVelocity(const MT_Vector3& vel) -{ - m_velocity = vel; -} - - - -void SND_SoundListener::SetOrientation(const MT_Matrix3x3& ori) -{ - m_orientation = ori; -} - - - -void SND_SoundListener::SetDopplerFactor(MT_Scalar dopplerfactor) -{ - m_dopplerfactor = dopplerfactor; - m_modified = true; -} - - - -void SND_SoundListener::SetDopplerVelocity(MT_Scalar dopplervelocity) -{ - m_dopplervelocity = dopplervelocity; - m_modified = true; -} - - - -void SND_SoundListener::SetScale(MT_Scalar scale) -{ - m_scale = scale; - m_modified = true; -} - - - -MT_Scalar SND_SoundListener::GetGain() const -{ - return m_gain; -} - - - -MT_Vector3 SND_SoundListener::GetPosition() const -{ - return m_position; -} - - - -MT_Vector3 SND_SoundListener::GetVelocity() const -{ - return m_velocity; -} - - - -MT_Matrix3x3 SND_SoundListener::GetOrientation() -{ - return m_orientation; -} - - - -MT_Scalar SND_SoundListener::GetDopplerFactor() const -{ - return m_dopplerfactor; -} - - - -MT_Scalar SND_SoundListener::GetDopplerVelocity() const -{ - return m_dopplervelocity; -} - - - -MT_Scalar SND_SoundListener::GetScale() const -{ - return m_scale; -} - - - -bool SND_SoundListener::IsModified() const -{ - return m_modified; -} - - - -void SND_SoundListener::SetModified(bool modified) -{ - m_modified = modified; -} diff --git a/intern/SoundSystem/intern/SND_SoundObject.cpp b/intern/SoundSystem/intern/SND_SoundObject.cpp deleted file mode 100644 index 7a244b5090d..00000000000 --- a/intern/SoundSystem/intern/SND_SoundObject.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* - * SND_SoundObject.cpp - * - * Implementation of the abstract sound object - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "SND_SoundObject.h" - -#ifdef HAVE_CONFIG_H -#include -#endif - -SND_SoundObject::SND_SoundObject()// : m_modified(true) -{ - m_samplename = ""; - m_length = 0; - m_buffer = 0; - - m_gain = 0.0; - m_pitch = 1.0; - - m_mingain = 0.0; - m_maxgain = 1.0; - m_rollofffactor = 1.0; - m_referencedistance = 1.0; - - m_position[0] = 0.0; - m_position[1] = 0.0; - m_position[2] = 0.0; - m_velocity[0] = 0.0; - m_velocity[1] = 0.0; - m_velocity[2] = 0.0; - m_orientation[0][0] = 1.0; - m_orientation[0][1] = 0.0; - m_orientation[0][2] = 0.0; - m_orientation[1][0] = 0.0; - m_orientation[1][1] = 1.0; - m_orientation[1][2] = 0.0; - m_orientation[2][0] = 0.0; - m_orientation[2][1] = 0.0; - m_orientation[2][2] = 1.0; - - m_loopstart = 0; - m_loopend = 0; - m_loopmode = SND_LOOP_NORMAL; - m_is3d = true; - m_playstate = SND_INITIAL; - m_active = false; - m_id = -1; - m_lifespan = 0; - m_timestamp = 0; - m_modified = true; - m_running = 0; - m_highpriority = false; -} - - - -SND_SoundObject::~SND_SoundObject() -{ -} - - - -void SND_SoundObject::StartSound() -{ - if (m_id >= 0) - m_playstate = SND_MUST_PLAY; -} - - - -void SND_SoundObject::StopSound() -{ - if (m_id >= 0) - m_playstate = SND_MUST_STOP; -} - - - -void SND_SoundObject::PauseSound() -{ - if (m_id >= 0) - m_playstate = SND_MUST_PAUSE; -} - - - -void SND_SoundObject::DeleteWhenFinished() -{ - m_playstate = SND_MUST_BE_DELETED; -} - - - -void SND_SoundObject::SetGain(MT_Scalar gain) -{ - m_gain = gain; - m_modified = true; -} - - - -void SND_SoundObject::SetMinGain(MT_Scalar mingain) -{ - m_mingain = mingain; - m_modified = true; -} - - - -void SND_SoundObject::SetMaxGain(MT_Scalar maxgain) -{ - m_maxgain = maxgain; - m_modified = true; -} - - - -void SND_SoundObject::SetRollOffFactor(MT_Scalar rollofffactor) -{ - m_rollofffactor = rollofffactor; - m_modified = true; -} - - - -void SND_SoundObject::SetReferenceDistance(MT_Scalar referencedistance) -{ - m_referencedistance = referencedistance; - m_modified = true; -} - - - -void SND_SoundObject::SetPitch(MT_Scalar pitch) -{ - m_pitch = pitch; - m_modified = true; -} - - - -void SND_SoundObject::SetLoopMode(unsigned int loopmode) -{ - m_loopmode = loopmode; - m_modified = true; -} - - - -void SND_SoundObject::SetLoopStart(unsigned int loopstart) -{ - m_loopstart = loopstart; - m_modified = true; -} - - - -void SND_SoundObject::SetLoopEnd(unsigned int loopend) -{ - m_loopend = loopend; - m_modified = true; -} - - - -void SND_SoundObject::Set3D(bool threedee) -{ - m_is3d = threedee; -} - - - -void SND_SoundObject::SetLifeSpan() -{ - m_lifespan = m_length / m_pitch; -} - - - -bool SND_SoundObject::IsLifeSpanOver(MT_Scalar curtime) const -{ - bool result = false; - - if ((curtime - m_timestamp) > m_lifespan) - result = true; - - return result; -} - - - -void SND_SoundObject::SetActive(bool active) -{ - m_active = active; - - if (!active) - { - m_playstate = SND_STOPPED; - (this)->remove(); - } -} - - - -void SND_SoundObject::SetBuffer(unsigned int buffer) -{ - m_buffer = buffer; -} - - - -void SND_SoundObject::SetObjectName(STR_String objectname) -{ - m_objectname = objectname; -} - - - -void SND_SoundObject::SetSampleName(STR_String samplename) -{ - m_samplename = samplename; -} - - - -void SND_SoundObject::SetLength(MT_Scalar length) -{ - m_length = length; -} - - - -void SND_SoundObject::SetPosition(const MT_Vector3& pos) -{ - m_position = pos; -} - - - -void SND_SoundObject::SetVelocity(const MT_Vector3& vel) -{ - m_velocity = vel; -} - - - -void SND_SoundObject::SetOrientation(const MT_Matrix3x3& orient) -{ - m_orientation = orient; -} - - - -void SND_SoundObject::SetPlaystate(int playstate) -{ - m_playstate = playstate; -} - - - -void SND_SoundObject::SetId(int id) -{ - m_id = id; -} - - - -void SND_SoundObject::SetTimeStamp(MT_Scalar timestamp) -{ - m_timestamp = timestamp; -} - - - -void SND_SoundObject::SetHighPriority(bool priority) -{ - m_highpriority = priority; -} - - - -bool SND_SoundObject::IsHighPriority() const -{ - return m_highpriority; -} - - - -bool SND_SoundObject::IsActive()const -{ - return m_active; -} - - - -int SND_SoundObject::GetId()const -{ - return m_id; -} - - - -MT_Scalar SND_SoundObject::GetLifeSpan()const -{ - return m_lifespan; -} - - - -MT_Scalar SND_SoundObject::GetTimestamp()const -{ - return m_timestamp; -} - - - -unsigned int SND_SoundObject::GetBuffer() -{ - return m_buffer; -} - - - -const STR_String& SND_SoundObject::GetSampleName() -{ - return m_samplename; -} - - - -const STR_String& SND_SoundObject::GetObjectName() -{ - return m_objectname; -} - - - -MT_Scalar SND_SoundObject::GetLength() const -{ - return m_length; -} - - - -MT_Scalar SND_SoundObject::GetGain() const -{ - return m_gain; -} - - - -MT_Scalar SND_SoundObject::GetPitch() const -{ - return m_pitch; -} - - - -MT_Scalar SND_SoundObject::GetMinGain() const -{ - return m_mingain; -} - - - -MT_Scalar SND_SoundObject::GetMaxGain() const -{ - return m_maxgain; -} - - - -MT_Scalar SND_SoundObject::GetRollOffFactor() const -{ - return m_rollofffactor; -} - - - -MT_Scalar SND_SoundObject::GetReferenceDistance() const -{ - return m_referencedistance; -} - - - -MT_Vector3 SND_SoundObject::GetPosition() const -{ - return m_position; -} - - - -MT_Vector3 SND_SoundObject::GetVelocity() const -{ - return m_velocity; -} - - - -MT_Matrix3x3 SND_SoundObject::GetOrientation() const -{ - return m_orientation; -} - - - -unsigned int SND_SoundObject::GetLoopMode() const -{ - return m_loopmode; -} - - - -unsigned int SND_SoundObject::GetLoopStart() const -{ - return m_loopstart; -} - - - -unsigned int SND_SoundObject::GetLoopEnd() const -{ - return m_loopend; -} - - - -bool SND_SoundObject::Is3D() const -{ - return m_is3d; -} - - - -int SND_SoundObject::GetPlaystate() const -{ - return m_playstate; -} - - - -bool SND_SoundObject::IsModified() const -{ - return m_modified; -} - - - -void SND_SoundObject::SetModified(bool modified) -{ - m_modified = modified; -} - - - -void SND_SoundObject::InitRunning() -{ - m_running = 0; -} - - - -bool SND_SoundObject::IsRunning() const -{ - bool result = false; - - if (m_running > 100) - result = true; - - return result; -} - - - -void SND_SoundObject::AddRunning() -{ - ++m_running; -} diff --git a/intern/SoundSystem/intern/SND_Utils.cpp b/intern/SoundSystem/intern/SND_Utils.cpp deleted file mode 100644 index dbc3135b35c..00000000000 --- a/intern/SoundSystem/intern/SND_Utils.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/* - * SND_Utils.cpp - * - * Util functions for soundthingies - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "SND_Utils.h" -#include "SoundDefines.h" -#include "SND_DependKludge.h" -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#include -#define open _open -#define read _read -#define close _close -#define write _write -#define lseek _lseek -#else -#include -#endif - -#define BUFFERSIZE 32 - - -/***************************************************************************** - * Begin of temporary Endian stuff. - * I think there should be a central place to handle endian conversion but for - * the time being it suffices. Note that the defines come from the Blender - * source. - *****************************************************************************/ -typedef enum -{ - SND_endianBig = 0, - SND_endianLittle -} SND_TEndian; - -#if defined(__BIG_ENDIAN__) || defined(__sparc) || defined(__sparc__) -const SND_TEndian SND_fEndian = SND_endianBig; -#else -const SND_TEndian SND_fEndian = SND_endianLittle; -#endif - -/* This one swaps the bytes in a short */ -#define SWITCH_SHORT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; \ - p_i[0] = p_i[1]; \ - p_i[1] = s_i; } - -/* This one rotates the bytes in an int */ -#define SWITCH_INT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \ - s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; } -/***************************************************************************** - * End of temporary Endian stuff. - *****************************************************************************/ - - -/* loads a file */ -void* SND_LoadSample(char *filename) -{ - int file, filelen, buffersize = BUFFERSIZE; - void* data = NULL; - -#if defined(WIN32) - file = open(filename, O_BINARY|O_RDONLY); -#else - file = open(filename, 0|O_RDONLY); -#endif - - if (file == -1) - { - //printf("can't open file.\n"); - //printf("press q for quit.\n"); - } - else - { - filelen = lseek(file, 0, SEEK_END); - lseek(file, 0, SEEK_SET); - - if (filelen != 0) - { - data = malloc(buffersize); - - if (read(file, data, buffersize) != buffersize) - { - free(data); - data = NULL; - } - } - close(file); - - } - return (data); -} - - - -bool SND_IsSampleValid(const STR_String& name, void* memlocation) -{ - bool result = false; - bool loadedsample = false; - char buffer[BUFFERSIZE]; - - if (!memlocation) - { - STR_String samplename = name; - memlocation = SND_LoadSample(samplename.Ptr()); - - if (memlocation) - loadedsample = true; - } - - if (memlocation) - { - memcpy(&buffer, memlocation, BUFFERSIZE); - - if(!(memcmp(buffer, "RIFF", 4) && memcmp(&(buffer[8]), "WAVEfmt ", 8))) - { - /* This was endian unsafe. See top of the file for the define. */ - short shortbuf = *((short *) &buffer[20]); - if (SND_fEndian == SND_endianBig) SWITCH_SHORT(shortbuf); - - if (shortbuf == SND_WAVE_FORMAT_PCM) - result = true; - } - } - if (loadedsample) - { - free(memlocation); - memlocation = NULL; - } - - return result; -} - - - -/* checks if the passed pointer is a valid sample */ -static bool CheckSample(void* sample) -{ - bool valid = false; - char buffer[32]; - - memcpy(buffer, sample, 16); - - if(!(memcmp(buffer, "RIFF", 4) && memcmp(&(buffer[8]), "WAVEfmt ", 8))) - { - valid = true; - } - - return valid; -} - - - -/* gets the type of the sample (0 == unknown, 1 == PCM etc */ -unsigned int SND_GetSampleFormat(void* sample) -{ - short sampletype = 0; - - if (CheckSample(sample)) - { - memcpy(&sampletype, ((char*)sample) + 20, 2); - } - /* This was endian unsafe. See top of the file for the define. */ - if (SND_fEndian == SND_endianBig) SWITCH_SHORT(sampletype); - - return (unsigned int)sampletype; -} - - - -/* gets the number of channels in a sample */ -unsigned int SND_GetNumberOfChannels(void* sample) -{ - short numberofchannels = 0; - - if (CheckSample(sample)) - { - memcpy(&numberofchannels, ((char*)sample) + 22, 2); - } - /* This was endian unsafe. See top of the file for the define. */ - if (SND_fEndian == SND_endianBig) SWITCH_SHORT(numberofchannels); - - return (unsigned int)numberofchannels; -} - - - -/* gets the samplerate of a sample */ -unsigned int SND_GetSampleRate(void* sample) -{ - unsigned int samplerate = 0; - - if (CheckSample(sample)) - { - memcpy(&samplerate, ((char*)sample) + 24, 4); - } - /* This was endian unsafe. See top of the file for the define. */ - if (SND_fEndian == SND_endianBig) SWITCH_INT(samplerate); - - return samplerate; -} - - - -/* gets the bitrate of a sample */ -unsigned int SND_GetBitRate(void* sample) -{ - short bitrate = 0; - - if (CheckSample(sample)) - { - memcpy(&bitrate, ((char*)sample) + 34, 2); - } - /* This was endian unsafe. See top of the file for the define. */ - if (SND_fEndian == SND_endianBig) SWITCH_SHORT(bitrate); - - return (unsigned int)bitrate; -} - - - -/* gets the length of the actual sample data (without the header) */ -unsigned int SND_GetNumberOfSamples(void* sample, unsigned int sample_length) -{ - unsigned int chunklength, length = 0, offset; - unsigned short block_align; - if (CheckSample(sample)) - { - memcpy(&chunklength, ((char*)sample) + 16, 4); - memcpy(&block_align, ((char*)sample) + 32, 2); /* always 2 or 4 it seems */ - - /* This was endian unsafe. See top of the file for the define. */ - if (SND_fEndian == SND_endianBig) - { - SWITCH_INT(chunklength); - SWITCH_SHORT(block_align); - } - - offset = 16 + chunklength + 4; - - /* This seems very unsafe, what if data is never found (f.i. corrupt file)... */ - // lets find "data" - while (memcmp(((char*)sample) + offset, "data", 4)) - { - offset += block_align; - - if (offset+block_align > sample_length) /* save us from crashing */ - return 0; - } - offset += 4; - memcpy(&length, ((char*)sample) + offset, 4); - - /* This was endian unsafe. See top of the file for the define. */ - if (SND_fEndian == SND_endianBig) SWITCH_INT(length); - } - - return length; -} - - - -/* gets the size of the entire header (file - sampledata) */ -unsigned int SND_GetHeaderSize(void* sample, unsigned int sample_length) -{ - unsigned int chunklength, headersize = 0, offset = 16; - unsigned short block_align; - if (CheckSample(sample)) - { - memcpy(&chunklength, ((char*)sample) + offset, 4); - memcpy(&block_align, ((char*)sample) + 32, 2); /* always 2 or 4 it seems */ - - /* This was endian unsafe. See top of the file for the define. */ - if (SND_fEndian == SND_endianBig) - { - SWITCH_INT(chunklength); - SWITCH_SHORT(block_align); - } - offset = offset + chunklength + 4; - - // lets find "data" - while (memcmp(((char*)sample) + offset, "data", 4)) - { - offset += block_align; - - if (offset+block_align > sample_length) /* save us from crashing */ - return 0; - } - headersize = offset + 8; - } - - return headersize; -} - - -unsigned int SND_GetExtraChunk(void* sample) -{ - unsigned int extrachunk = 0, chunklength, offset = 16; - char data[4]; - - if (CheckSample(sample)) - { - memcpy(&chunklength, ((char*)sample) + offset, 4); - offset = offset + chunklength + 4; - memcpy(data, ((char*)sample) + offset, 4); - - // lets find "cue" - while (memcmp(data, "cue", 3)) - { - offset += 4; - memcpy(data, ((char*)sample) + offset, 4); - } - } - - return extrachunk; -} - - - -void SND_GetSampleInfo(signed char* sample, SND_WaveSlot* waveslot) -{ - WavFileHeader fileheader; - WavFmtHeader fmtheader; - WavFmtExHeader fmtexheader; - WavSampleHeader sampleheader; - WavChunkHeader chunkheader; - - if (CheckSample(sample)) - { - memcpy(&fileheader, sample, sizeof(WavFileHeader)); - fileheader.size = SND_GetHeaderSize(sample, waveslot->GetFileSize()); - if (fileheader.size) { /* this may fail for corrupt files */ - sample += sizeof(WavFileHeader); - fileheader.size = ((fileheader.size+1) & ~1) - 4; - - while ((fileheader.size > 0) && (memcpy(&chunkheader, sample, sizeof(WavChunkHeader)))) - { - sample += sizeof(WavChunkHeader); - if (!memcmp(chunkheader.id, "fmt ", 4)) - { - memcpy(&fmtheader, sample, sizeof(WavFmtHeader)); - waveslot->SetSampleFormat(fmtheader.format); - - if (fmtheader.format == 0x0001) - { - waveslot->SetNumberOfChannels(fmtheader.numberofchannels); - waveslot->SetBitRate(fmtheader.bitrate); - waveslot->SetSampleRate(fmtheader.samplerate); - sample += chunkheader.size; - } - else - { - memcpy(&fmtexheader, sample, sizeof(WavFmtExHeader)); - sample += chunkheader.size; - } - } - else if (!memcmp(chunkheader.id, "data", 4)) - { - if (fmtheader.format == 0x0001) - { - waveslot->SetNumberOfSamples(chunkheader.size); - sample += chunkheader.size; - } - else if (fmtheader.format == 0x0011) - { - //IMA ADPCM - } - else if (fmtheader.format == 0x0055) - { - //MP3 WAVE - } - } - else if (!memcmp(chunkheader.id, "smpl", 4)) - { - memcpy(&sampleheader, sample, sizeof(WavSampleHeader)); - //loop = sampleheader.loops; - sample += chunkheader.size; - } - else - sample += chunkheader.size; - - sample += chunkheader.size & 1; - fileheader.size -= (((chunkheader.size + 1) & ~1) + 8); - } - } - } -} diff --git a/intern/SoundSystem/intern/SND_WaveCache.cpp b/intern/SoundSystem/intern/SND_WaveCache.cpp deleted file mode 100644 index a678bd554bb..00000000000 --- a/intern/SoundSystem/intern/SND_WaveCache.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * SND_WaveCache.cpp - * - * abstract wavecache, a way to organize samples - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef WIN32 -#pragma warning (disable:4786) // Get rid of stupid stl-visual compiler debug warning -#endif //WIN32 - -#include "SND_WaveCache.h" -#include - -#ifdef __APPLE__ -# include -#else -# ifdef __FreeBSD__ -# include -# else -# include -# endif -#endif - -SND_WaveCache::SND_WaveCache() -{ - // do the buffer administration - for (int i = 0; i < NUM_BUFFERS; i++) - m_bufferList[i] = NULL; -} - - - -SND_WaveCache::~SND_WaveCache() -{ - // clean up the mess - FreeSamples(); - RemoveAllSamples(); -} - - - -SND_WaveSlot* SND_WaveCache::GetWaveSlot(const STR_String& samplename) -{ - SND_WaveSlot* waveslot = NULL; - - std::map::iterator find_result = m_samplecache.find(samplename); - - // let's see if we have already loaded this sample - if (find_result != m_samplecache.end()) - { - waveslot = (*find_result).second; - } - else - { - // so the sample wasn't loaded, so do it here - for (int bufnum = 0; bufnum < NUM_BUFFERS; bufnum++) - { - // find an empty buffer - if (m_bufferList[bufnum] == NULL) - { - waveslot = new SND_WaveSlot(); - waveslot->SetSampleName(samplename); - waveslot->SetBuffer(bufnum); - m_bufferList[bufnum] = waveslot; - break; - } - } - m_samplecache.insert(std::pair(samplename, waveslot)); - } - - return waveslot; -} - - - -void SND_WaveCache::RemoveAllSamples() -{ - // remove all samples - m_samplecache.clear(); - - // reset the list of buffers - for (int i = 0; i < NUM_BUFFERS; i++) - m_bufferList[i] = NULL; -} - - - -void SND_WaveCache::RemoveSample(const STR_String& samplename, int buffer) -{ - m_samplecache.erase(samplename); - m_bufferList[buffer] = NULL; -} - - - -void SND_WaveCache::FreeSamples() -{ - // iterate through the bufferlist and delete the waveslot if present - for (int i = 0; i < NUM_BUFFERS; i++) - { - if (m_bufferList[i]) - { - delete m_bufferList[i]; - m_bufferList[i] = NULL; - } - } -} diff --git a/intern/SoundSystem/intern/SND_WaveSlot.cpp b/intern/SoundSystem/intern/SND_WaveSlot.cpp deleted file mode 100644 index 43b2bb55892..00000000000 --- a/intern/SoundSystem/intern/SND_WaveSlot.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/** - * $Id$ - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "SND_WaveSlot.h" - -#ifdef HAVE_CONFIG_H -#include -#endif - -SND_WaveSlot::~SND_WaveSlot() -{ -#ifdef ONTKEVER - printf("neeeeeee...\n"); -#endif -} - - - -void SND_WaveSlot::SetSampleName(STR_String samplename) -{ - m_samplename = samplename; -} - - - -void SND_WaveSlot::SetLoaded(bool loaded) -{ - m_loaded = loaded; -} - - - -void SND_WaveSlot::SetData(void* data) -{ - m_data = data; -} - - - -void SND_WaveSlot::SetBuffer(unsigned int buffer) -{ - m_buffer = buffer; -} - - - -void SND_WaveSlot::SetSampleFormat(unsigned int sampleformat) -{ - m_sampleformat = sampleformat; -} - - - -void SND_WaveSlot::SetNumberOfChannels(unsigned int numberofchannels) -{ - m_numberofchannels = numberofchannels; -} - - - -void SND_WaveSlot::SetSampleRate(unsigned int samplerate) -{ - m_samplerate = samplerate; -} - - - -void SND_WaveSlot::SetBitRate(unsigned int bitrate) -{ - m_bitrate = bitrate; -} - - - -void SND_WaveSlot::SetNumberOfSamples(unsigned int numberofsamples) -{ - m_numberofsamples = numberofsamples; -} - - - -void SND_WaveSlot::SetFileSize(unsigned int filesize) -{ - m_filesize = filesize; -} - - - -const STR_String& SND_WaveSlot::GetSampleName() -{ - return m_samplename; -} - - - -bool SND_WaveSlot::IsLoaded() const -{ - return m_loaded; -} - - - -void* SND_WaveSlot::GetData() -{ - return m_data; -} - - - -unsigned int SND_WaveSlot::GetBuffer() const -{ - return m_buffer; -} - - - -unsigned int SND_WaveSlot::GetSampleFormat() const -{ - return m_sampleformat; -} - - - -unsigned int SND_WaveSlot::GetNumberOfChannels() const -{ - return m_numberofchannels; -} - - - -unsigned int SND_WaveSlot::GetSampleRate() const -{ - return m_samplerate; -} - - - -unsigned int SND_WaveSlot::GetBitRate() const -{ - return m_bitrate; -} - - - -unsigned int SND_WaveSlot::GetNumberOfSamples() const -{ - return m_numberofsamples; -} - - - -unsigned int SND_WaveSlot::GetFileSize() const -{ - return m_filesize; -} diff --git a/intern/SoundSystem/make/msvc_6_0/SoundSystem.dsp b/intern/SoundSystem/make/msvc_6_0/SoundSystem.dsp deleted file mode 100644 index 1bd973dfb6c..00000000000 --- a/intern/SoundSystem/make/msvc_6_0/SoundSystem.dsp +++ /dev/null @@ -1,206 +0,0 @@ -# Microsoft Developer Studio Project File - Name="SoundSystem" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=SoundSystem - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "SoundSystem.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "SoundSystem.mak" CFG="SoundSystem - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "SoundSystem - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "SoundSystem - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "SoundSystem - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\..\..\..\obj\windows\intern\soundsystem" -# PROP Intermediate_Dir "..\..\..\..\obj\windows\intern\soundsystem" -# PROP Target_Dir "" -LINK32=link.exe -lib -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../" /I "../../../../../lib/windows/string/include" /I "../../../../../lib/windows/moto/include" /I "../../dummy" /I "../../openal" /I "..\..\..\string" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /YX /J /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\..\..\..\obj\windows\intern\soundsystem\libSoundSystem.lib" -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Cmds=ECHO Copying header files XCOPY /Y ..\..\*.h ..\..\..\..\..\lib\windows\SoundSystem\include\*.h ECHO Copying lib XCOPY /Y ..\..\..\..\obj\windows\intern\soundsystem\*.lib ..\..\..\..\..\lib\windows\SoundSystem\lib\*.a ECHO Done -# End Special Build Tool - -!ELSEIF "$(CFG)" == "SoundSystem - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "SoundSystem___Win32_Debug" -# PROP BASE Intermediate_Dir "SoundSystem___Win32_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\..\..\..\obj\windows\intern\soundsystem\debug" -# PROP Intermediate_Dir "..\..\..\..\obj\windows\intern\soundsystem\debug" -# PROP Target_Dir "" -LINK32=link.exe -lib -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "../../" /I "../../../../../lib/windows/string/include" /I "../../../../../lib/windows/moto/include" /I "../../dummy" /I "../../openal" /I "..\..\..\string" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /YX /J /FD /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\..\..\..\obj\windows\intern\soundsystem\debug\libSoundSystem.lib" -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Cmds=ECHO Copying header files XCOPY /Y ..\..\*.h ..\..\..\..\..\lib\windows\SoundSystem\include\*.h ECHO Copying lib XCOPY /Y ..\..\..\..\obj\windows\intern\soundsystem\debug\*.lib ..\..\..\..\..\lib\windows\SoundSystem\lib\debug\*.a ECHO Done -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "SoundSystem - Win32 Release" -# Name "SoundSystem - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\intern\SND_AudioDevice.cpp -# End Source File -# Begin Source File - -SOURCE="..\..\intern\SND_C-api.cpp" -# End Source File -# Begin Source File - -SOURCE=..\..\intern\SND_CDObject.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\intern\SND_DeviceManager.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\intern\SND_IdObject.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\intern\SND_Scene.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\intern\SND_SoundListener.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\intern\SND_SoundObject.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\intern\SND_Utils.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\intern\SND_WaveCache.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\intern\SND_WaveSlot.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=..\..\intern\SND_AudioDevice.h -# End Source File -# Begin Source File - -SOURCE="..\..\SND_C-api.h" -# End Source File -# Begin Source File - -SOURCE=..\..\SND_CDObject.h -# End Source File -# Begin Source File - -SOURCE=..\..\SND_DependKludge.h -# End Source File -# Begin Source File - -SOURCE=..\..\SND_DeviceManager.h -# End Source File -# Begin Source File - -SOURCE=..\..\SND_IAudioDevice.h -# End Source File -# Begin Source File - -SOURCE=..\..\intern\SND_IdObject.h -# End Source File -# Begin Source File - -SOURCE=..\..\SND_Object.h -# End Source File -# Begin Source File - -SOURCE=..\..\SND_Scene.h -# End Source File -# Begin Source File - -SOURCE=..\..\SND_SoundListener.h -# End Source File -# Begin Source File - -SOURCE=..\..\SND_SoundObject.h -# End Source File -# Begin Source File - -SOURCE=..\..\SND_Utils.h -# End Source File -# Begin Source File - -SOURCE=..\..\SND_WaveCache.h -# End Source File -# Begin Source File - -SOURCE=..\..\SND_WaveSlot.h -# End Source File -# Begin Source File - -SOURCE=..\..\SoundDefines.h -# End Source File -# End Group -# End Target -# End Project diff --git a/intern/SoundSystem/make/msvc_6_0/dummy/DummySoundSystem.dsp b/intern/SoundSystem/make/msvc_6_0/dummy/DummySoundSystem.dsp deleted file mode 100644 index 2bf372d0382..00000000000 --- a/intern/SoundSystem/make/msvc_6_0/dummy/DummySoundSystem.dsp +++ /dev/null @@ -1,103 +0,0 @@ -# Microsoft Developer Studio Project File - Name="DummySoundSystem" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=DummySoundSystem - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "DummySoundSystem.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "DummySoundSystem.mak" CFG="DummySoundSystem - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "DummySoundSystem - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "DummySoundSystem - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "DummySoundSystem - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\..\..\..\..\obj\windows\intern\soundsystem\dummy" -# PROP Intermediate_Dir "..\..\..\..\..\obj\windows\intern\soundsystem\dummy" -# PROP Target_Dir "" -LINK32=link.exe -lib -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\intern" /I "..\..\..\..\SoundSystem" /I "..\..\..\..\moto\include" /I "..\..\..\..\string" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /J /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\..\..\..\..\obj\windows\intern\soundsystem\dummy\libDummySoundSystem.lib" - -!ELSEIF "$(CFG)" == "DummySoundSystem - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\..\..\..\..\obj\windows\intern\soundsystem\dummy\debug" -# PROP Intermediate_Dir "..\..\..\..\..\obj\windows\intern\soundsystem\dummy\debug" -# PROP Target_Dir "" -LINK32=link.exe -lib -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\intern" /I "..\..\..\..\SoundSystem" /I "..\..\..\..\moto\include" /I "..\..\..\..\string" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /J /FD /c -# SUBTRACT CPP /Fr -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\..\..\..\..\obj\windows\intern\soundsystem\dummy\debug\libDummySoundSystem.lib" - -!ENDIF - -# Begin Target - -# Name "DummySoundSystem - Win32 Release" -# Name "DummySoundSystem - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\..\dummy\SND_DummyDevice.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=..\..\..\dummy\SND_DummyDevice.h -# End Source File -# End Group -# End Target -# End Project diff --git a/intern/SoundSystem/make/msvc_6_0/openal/OpenALSoundSystem.dsp b/intern/SoundSystem/make/msvc_6_0/openal/OpenALSoundSystem.dsp deleted file mode 100644 index ef0c10e8eff..00000000000 --- a/intern/SoundSystem/make/msvc_6_0/openal/OpenALSoundSystem.dsp +++ /dev/null @@ -1,106 +0,0 @@ -# Microsoft Developer Studio Project File - Name="OpenALSoundSystem" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=OpenALSoundSystem - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "OpenALSoundSystem.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "OpenALSoundSystem.mak" CFG="OpenALSoundSystem - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "OpenALSoundSystem - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "OpenALSoundSystem - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "OpenALSoundSystem - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\..\..\..\..\obj\windows\intern\soundsystem\openal" -# PROP Intermediate_Dir "..\..\..\..\..\obj\windows\intern\soundsystem\openal" -# PROP Target_Dir "" -LINK32=link.exe -lib -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\intern" /I "..\..\..\..\SoundSystem" /I "..\..\..\..\SoundSystem\sdl" /I "..\..\..\..\moto\include" /I "..\..\..\..\string" /I "..\..\..\..\..\..\lib\windows\openal\include" /I "..\..\..\..\..\..\lib\windows\sdl\include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /YX /J /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\..\..\..\..\obj\windows\intern\soundsystem\openal\libOpenALSoundSystem.lib" - -!ELSEIF "$(CFG)" == "OpenALSoundSystem - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "OpenALSoundSystem___Win32_Debug" -# PROP BASE Intermediate_Dir "OpenALSoundSystem___Win32_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\..\..\..\..\obj\windows\intern\soundsystem\openal\debug" -# PROP Intermediate_Dir "..\..\..\..\..\obj\windows\intern\soundsystem\openal\debug" -# PROP Target_Dir "" -LINK32=link.exe -lib -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\intern" /I "..\..\..\..\SoundSystem" /I "..\..\..\..\SoundSystem\sdl" /I "..\..\..\..\moto\include" /I "..\..\..\..\string" /I "..\..\..\..\..\..\lib\windows\sdl\include" /I "..\..\..\..\..\..\lib\windows\openal\include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /YX /J /FD /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\..\..\..\..\obj\windows\intern\soundsystem\openal\debug\libOpenALSoundSystem.lib" - -!ENDIF - -# Begin Target - -# Name "OpenALSoundSystem - Win32 Release" -# Name "OpenALSoundSystem - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\..\openal\SND_OpenALDevice.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\sdl\SND_SDLCDDevice.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=..\..\..\openal\SND_OpenALDevice.h -# End Source File -# End Group -# End Target -# End Project diff --git a/intern/SoundSystem/make/msvc_7_0/SoundSystem.vcproj b/intern/SoundSystem/make/msvc_7_0/SoundSystem.vcproj deleted file mode 100644 index f0952c582b7..00000000000 --- a/intern/SoundSystem/make/msvc_7_0/SoundSystem.vcproj +++ /dev/null @@ -1,339 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/intern/SoundSystem/make/msvc_7_0/dummy/DummySoundSystem.vcproj b/intern/SoundSystem/make/msvc_7_0/dummy/DummySoundSystem.vcproj deleted file mode 100644 index 103b589e732..00000000000 --- a/intern/SoundSystem/make/msvc_7_0/dummy/DummySoundSystem.vcproj +++ /dev/null @@ -1,243 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/intern/SoundSystem/make/msvc_7_0/openal/OpenALSoundSystem.vcproj b/intern/SoundSystem/make/msvc_7_0/openal/OpenALSoundSystem.vcproj deleted file mode 100644 index 8ce971ac1aa..00000000000 --- a/intern/SoundSystem/make/msvc_7_0/openal/OpenALSoundSystem.vcproj +++ /dev/null @@ -1,249 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/intern/SoundSystem/make/msvc_9_0/SoundSystem.vcproj b/intern/SoundSystem/make/msvc_9_0/SoundSystem.vcproj deleted file mode 100644 index bd75fe88d43..00000000000 --- a/intern/SoundSystem/make/msvc_9_0/SoundSystem.vcproj +++ /dev/null @@ -1,447 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/intern/SoundSystem/make/msvc_9_0/dummy/DummySoundSystem.vcproj b/intern/SoundSystem/make/msvc_9_0/dummy/DummySoundSystem.vcproj deleted file mode 100644 index 2109d92d430..00000000000 --- a/intern/SoundSystem/make/msvc_9_0/dummy/DummySoundSystem.vcproj +++ /dev/null @@ -1,343 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/intern/SoundSystem/make/msvc_9_0/openal/OpenALSoundSystem.vcproj b/intern/SoundSystem/make/msvc_9_0/openal/OpenALSoundSystem.vcproj deleted file mode 100644 index 5593f00cb2b..00000000000 --- a/intern/SoundSystem/make/msvc_9_0/openal/OpenALSoundSystem.vcproj +++ /dev/null @@ -1,351 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/intern/SoundSystem/openal/SND_OpenALDevice.cpp b/intern/SoundSystem/openal/SND_OpenALDevice.cpp deleted file mode 100644 index 424a05246ac..00000000000 --- a/intern/SoundSystem/openal/SND_OpenALDevice.cpp +++ /dev/null @@ -1,864 +0,0 @@ -/* - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * SND_OpenALDevice derived from SND_IAudioDevice - */ - -#ifdef WIN32 -#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning -#endif //WIN32 - -#include "SND_OpenALDevice.h" -#ifndef __APPLE__ -#include "SND_SDLCDDevice.h" -#endif -#include "SoundDefines.h" - -#include "SND_Utils.h" - -#ifdef APPLE_FRAMEWORK_FIX -#include -#include -#else -#include -#include -#endif - -#include -#include -#if defined(WIN32) -#include -#else -#include -#endif -#include - -#include - -/*************************** ALUT replacement *****************************/ - -/* instead of relying on alut, we just implement our own - * WAV loading functions, hopefully more reliable */ - -#include - -typedef struct /* WAV File-header */ -{ - ALubyte Id[4]; - ALsizei Size; - ALubyte Type[4]; -} WAVFileHdr_Struct; - -typedef struct /* WAV Fmt-header */ -{ - ALushort Format; - ALushort Channels; - ALuint SamplesPerSec; - ALuint BytesPerSec; - ALushort BlockAlign; - ALushort BitsPerSample; -} WAVFmtHdr_Struct; - -typedef struct /* WAV FmtEx-header */ -{ - ALushort Size; - ALushort SamplesPerBlock; -} WAVFmtExHdr_Struct; - -typedef struct /* WAV Smpl-header */ -{ - ALuint Manufacturer; - ALuint Product; - ALuint SamplePeriod; - ALuint Note; - ALuint FineTune; - ALuint SMPTEFormat; - ALuint SMPTEOffest; - ALuint Loops; - ALuint SamplerData; - struct - { - ALuint Identifier; - ALuint Type; - ALuint Start; - ALuint End; - ALuint Fraction; - ALuint Count; - } Loop[1]; -} WAVSmplHdr_Struct; - -typedef struct /* WAV Chunk-header */ -{ - ALubyte Id[4]; - ALuint Size; -} WAVChunkHdr_Struct; - -static void *SND_loadFileIntoMemory(const char *filename, int *len_r) -{ - FILE *fp= fopen(filename, "rb"); - void *data; - - if (!fp) { - *len_r= -1; - return NULL; - } - - fseek(fp, 0L, SEEK_END); - *len_r= ftell(fp); - fseek(fp, 0L, SEEK_SET); - - data= malloc(*len_r); - if (!data) { - *len_r= -1; - return NULL; - } - - if (fread(data, *len_r, 1, fp)!=1) { - *len_r= -1; - free(data); - return NULL; - } - - return data; -} - -#define TEST_SWITCH_INT(a) if(big_endian) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \ - s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; } - -#define TEST_SWITCH_SHORT(a) if(big_endian) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; } - -static int stream_read(void *out, ALbyte **stream, ALsizei size, ALsizei *memsize) -{ - if(size <= *memsize) { - memcpy(out, *stream, size); - return 1; - } - else { - memset(out, 0, size); - return 0; - } -} - -static int stream_skip(ALbyte **stream, ALsizei size, ALsizei *memsize) -{ - if(size <= *memsize) { - *stream += size; - *memsize -= size; - return 1; - } - else - return 0; -} - -ALvoid SND_alutLoadWAVMemory(ALbyte *memory,ALsizei memsize,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq,ALboolean *loop) -{ - WAVChunkHdr_Struct ChunkHdr; - WAVFmtExHdr_Struct FmtExHdr; - WAVFileHdr_Struct FileHdr; - WAVSmplHdr_Struct SmplHdr; - WAVFmtHdr_Struct FmtHdr; - ALbyte *Stream= memory; - int test_endian= 1; - int big_endian= !((char*)&test_endian)[0]; - - *format=AL_FORMAT_MONO16; - *data=NULL; - *size=0; - *freq=22050; - *loop=AL_FALSE; - - if(!Stream) - return; - - stream_read(&FileHdr,&Stream,sizeof(WAVFileHdr_Struct),&memsize); - stream_skip(&Stream,sizeof(WAVFileHdr_Struct),&memsize); - - TEST_SWITCH_INT(FileHdr.Size); - FileHdr.Size=((FileHdr.Size+1)&~1)-4; - - while((FileHdr.Size!=0) && stream_read(&ChunkHdr,&Stream,sizeof(WAVChunkHdr_Struct),&memsize)) - { - TEST_SWITCH_INT(ChunkHdr.Size); - stream_skip(&Stream,sizeof(WAVChunkHdr_Struct),&memsize); - - if (!memcmp(ChunkHdr.Id,"fmt ",4)) - { - stream_read(&FmtHdr,&Stream,sizeof(WAVFmtHdr_Struct),&memsize); - - TEST_SWITCH_SHORT(FmtHdr.Format); - TEST_SWITCH_SHORT(FmtHdr.Channels); - TEST_SWITCH_INT(FmtHdr.SamplesPerSec); - TEST_SWITCH_INT(FmtHdr.BytesPerSec); - TEST_SWITCH_SHORT(FmtHdr.BlockAlign); - TEST_SWITCH_SHORT(FmtHdr.BitsPerSample); - - if (FmtHdr.Format==0x0001) - { - *format=(FmtHdr.Channels==1? - (FmtHdr.BitsPerSample==8?AL_FORMAT_MONO8:AL_FORMAT_MONO16): - (FmtHdr.BitsPerSample==8?AL_FORMAT_STEREO8:AL_FORMAT_STEREO16)); - *freq=FmtHdr.SamplesPerSec; - } - else - { - stream_read(&FmtExHdr,&Stream,sizeof(WAVFmtExHdr_Struct),&memsize); - TEST_SWITCH_SHORT(FmtExHdr.Size); - TEST_SWITCH_SHORT(FmtExHdr.SamplesPerBlock); - } - } - else if (!memcmp(ChunkHdr.Id,"data",4)) - { - if (FmtHdr.Format==0x0001) - { - if((ALsizei)ChunkHdr.Size <= memsize) - { - *size=ChunkHdr.Size; - *data=malloc(ChunkHdr.Size+31); - - if (*data) { - stream_read(*data,&Stream,ChunkHdr.Size,&memsize); - memset(((char *)*data)+ChunkHdr.Size,0,31); - - if(FmtHdr.BitsPerSample == 16 && big_endian) { - int a, len= *size/2; - short *samples= (short*)*data; - - for(a=0; aStopCD(); - SND_CDObject::DisposeSystem(); - } -#ifndef __APPLE__ - if (m_cdrom) - delete m_cdrom; -#endif - if (m_device) - alcCloseDevice((ALCdevice*) m_device); -} - - -SND_WaveSlot* SND_OpenALDevice::LoadSample(const STR_String& name, - void* memlocation, - int size) -{ - SND_WaveSlot* waveslot = NULL; - STR_String samplename = name; - - if (m_audio) - { - /* create the waveslot */ - waveslot = m_wavecache->GetWaveSlot(samplename); - - /* do we support this sample? */ - if (SND_IsSampleValid(name, memlocation)) - { - if (waveslot) - { - bool freemem = false; - int buffer = waveslot->GetBuffer(); - void* data = NULL; - char loop = 'a'; - int sampleformat, bitrate, numberofchannels; - ALenum al_error = alGetError(); - ALsizei samplerate, numberofsamples; // openal_2.14+ - - /* Give them some safe defaults just incase */ - bitrate = numberofchannels = 0; - - if (!(size && memlocation)) { - memlocation = SND_loadFileIntoMemory(samplename.Ptr(), &size); - freemem = true; - } - - /* load the sample from memory? */ - if (size && memlocation) - { - waveslot->SetFileSize(size); - - /* what was (our) buffer? */ - int buffer = waveslot->GetBuffer(); - - /* get some info out of the sample */ - SND_GetSampleInfo((signed char*)memlocation, waveslot); - numberofchannels = SND_GetNumberOfChannels(memlocation); - bitrate = SND_GetBitRate(memlocation); - - /* load the sample into openal */ - SND_alutLoadWAVMemory((ALbyte*)memlocation, size, &sampleformat, &data, &numberofsamples, &samplerate, &loop); - /* put it in the buffer */ - alBufferData(m_buffers[buffer], sampleformat, data, numberofsamples, samplerate); - } - - if(freemem) - free(memlocation); - - /* fill the waveslot with info */ - al_error = alGetError(); - if (al_error == AL_NO_ERROR && m_buffers[buffer]) - { - waveslot->SetData(data); - waveslot->SetSampleFormat(sampleformat); - waveslot->SetNumberOfChannels(numberofchannels); - waveslot->SetSampleRate(samplerate); - waveslot->SetBitRate(bitrate); - waveslot->SetNumberOfSamples(numberofsamples); - - /* if the loading succeeded, mark the waveslot */ - waveslot->SetLoaded(true); - } - else - { - /* or when it failed, free the waveslot */ - m_wavecache->RemoveSample(waveslot->GetSampleName(), waveslot->GetBuffer()); - waveslot = NULL; - } - - /* and free the original stuff (copy was made in openal) */ - SND_alutUnloadWAV(sampleformat, data, numberofsamples, samplerate); - } - } - else - { - /* sample not supported, remove waveslot */ - m_wavecache->RemoveSample(waveslot->GetSampleName(), waveslot->GetBuffer()); - waveslot = NULL; - } - } - return waveslot; -} - - - -// listener's and general stuff ////////////////////////////////////////////////////// - - - -/* sets the global dopplervelocity */ -void SND_OpenALDevice::SetDopplerVelocity(MT_Scalar dopplervelocity) const -{ - alDopplerVelocity ((float)dopplervelocity); -} - - - -/* sets the global dopplerfactor */ -void SND_OpenALDevice::SetDopplerFactor(MT_Scalar dopplerfactor) const -{ - alDopplerFactor ((float)dopplerfactor); -} - - - -/* sets the global rolloff factor */ -void SND_OpenALDevice::SetListenerRollOffFactor(MT_Scalar rollofffactor) const -{ - // not implemented in openal -} - - - -void SND_OpenALDevice::NextFrame() const -{ - // CD -#ifndef __APPLE__ - m_cdrom->NextFrame(); -#endif - // not needed by openal -} - - - -// set the gain for the listener -void SND_OpenALDevice::SetListenerGain(float gain) const -{ - alListenerf (AL_GAIN, gain); -} - - - -void SND_OpenALDevice::InitListener() -{ - // initialize the listener with these values that won't change - // (as long as we can have only one listener) - // now we can superimpose all listeners on each other (for they - // have the same settings) - float lispos[3] = {0,0,0}; - float lisvel[3] = {0,0,0}; -#ifdef WIN32 - float lisori[6] = {0,1,0,0,0,1}; -#else - float lisori[6] = {0,0,1,0,-1,0}; -#endif - - alListenerfv(AL_POSITION, lispos); - alListenerfv(AL_VELOCITY, lisvel); - alListenerfv(AL_ORIENTATION, lisori); -} - - - -// source playstate stuff //////////////////////////////////////////////////////////// - - - -/* sets the buffer */ -void SND_OpenALDevice::SetObjectBuffer(int id, unsigned int buffer) -{ - alSourcei (m_sources[id], AL_BUFFER, m_buffers[buffer]); -} - - - -// check if the sound's still playing -int SND_OpenALDevice::GetPlayState(int id) -{ - int alstate = 0; - int result = 0; - -#ifdef __APPLE__ - alGetSourcei(m_sources[id], AL_SOURCE_STATE, &alstate); -#else - alGetSourceiv(m_sources[id], AL_SOURCE_STATE, &alstate); -#endif - - switch(alstate) - { - case AL_INITIAL: - { - result = SND_INITIAL; - break; - } - case AL_PLAYING: - { - result = SND_PLAYING; - break; - } - case AL_PAUSED: - { - result = SND_PAUSED; - break; - } - case AL_STOPPED: - { - result = SND_STOPPED; - break; - } - default: - result = SND_UNKNOWN; - } - - return result; -} - - - -// make the source play -void SND_OpenALDevice::PlayObject(int id) -{ - alSourcePlay(m_sources[id]); -} - - - -// make the source stop -void SND_OpenALDevice::StopObject(int id) const -{ - float obpos[3] = {0,0,0}; - float obvel[3] = {0,0,0}; - - alSourcefv(m_sources[id], AL_POSITION, obpos); - alSourcefv(m_sources[id], AL_VELOCITY, obvel); - - alSourcef(m_sources[id], AL_GAIN, 1.0); - alSourcef(m_sources[id], AL_PITCH, 1.0); - alSourcei(m_sources[id], AL_LOOPING, AL_FALSE); - alSourceStop(m_sources[id]); -} - - - -// stop all sources -void SND_OpenALDevice::StopAllObjects() -{ - alSourceStopv(NUM_SOURCES, m_sources); -} - - - -// pause the source -void SND_OpenALDevice::PauseObject(int id) const -{ - alSourcePause(m_sources[id]); -} - - - -// source properties stuff //////////////////////////////////////////////////////////// - - - -// give openal the object's pitch -void SND_OpenALDevice::SetObjectPitch(int id, MT_Scalar pitch) const -{ - alSourcef (m_sources[id], AL_PITCH, (float)pitch); -} - - - -// give openal the object's gain -void SND_OpenALDevice::SetObjectGain(int id, MT_Scalar gain) const -{ - alSourcef (m_sources[id], AL_GAIN, (float)gain); -} - - - -// give openal the object's looping -void SND_OpenALDevice::SetObjectLoop(int id, unsigned int loopmode) const -{ - if (loopmode == SND_LOOP_OFF) - { - //printf("%d - ", id); - alSourcei (m_sources[id], AL_LOOPING, AL_FALSE); - } - else - alSourcei (m_sources[id], AL_LOOPING, AL_TRUE); -} - -void SND_OpenALDevice::SetObjectLoopPoints(int id, unsigned int loopstart, unsigned int loopend) const -{ - - -} - - -void SND_OpenALDevice::SetObjectMinGain(int id, MT_Scalar mingain) const -{ - alSourcef (m_sources[id], AL_MIN_GAIN, (float)mingain); -} - - - -void SND_OpenALDevice::SetObjectMaxGain(int id, MT_Scalar maxgain) const -{ - alSourcef (m_sources[id], AL_MAX_GAIN, (float)maxgain); -} - - - -void SND_OpenALDevice::SetObjectRollOffFactor(int id, MT_Scalar rollofffactor) const -{ - alSourcef (m_sources[id], AL_ROLLOFF_FACTOR, (float)rollofffactor); -} - - - -void SND_OpenALDevice::SetObjectReferenceDistance(int id, MT_Scalar referencedistance) const -{ - alSourcef (m_sources[id], AL_REFERENCE_DISTANCE, (float)referencedistance); -} - - - -// give openal the object's position -void SND_OpenALDevice::ObjectIs2D(int id) const -{ - float obpos[3] = {0,0,0}; - float obvel[3] = {0,0,0}; - - alSourcefv(m_sources[id], AL_POSITION, obpos); - alSourcefv(m_sources[id], AL_VELOCITY, obvel); -} - - - -void SND_OpenALDevice::SetObjectTransform(int id, - const MT_Vector3& position, - const MT_Vector3& velocity, - const MT_Matrix3x3& orientation, - const MT_Vector3& lisposition, - const MT_Scalar& rollofffactor) const -{ - float obpos[3]; - float obvel[3]; - - obpos[0] = (float)position[0] * (float)rollofffactor; //x (l/r) - obpos[1] = (float)position[1] * (float)rollofffactor; - obpos[2] = (float)position[2] * (float)rollofffactor; - - alSourcefv(m_sources[id], AL_POSITION, obpos); - - velocity.getValue(obvel); - alSourcefv(m_sources[id], AL_VELOCITY, obvel); -} - -void SND_OpenALDevice::PlayCD(int track) const -{ -#ifndef __APPLE__ - m_cdrom->PlayCD(track); -#endif -} - - -void SND_OpenALDevice::PauseCD(bool pause) const -{ -#ifndef __APPLE__ - m_cdrom->PauseCD(pause); -#endif -} - -void SND_OpenALDevice::StopCD() const -{ -#ifndef __APPLE__ - SND_CDObject* pCD = SND_CDObject::Instance(); - - if (pCD && pCD->GetUsed()) - { - m_cdrom->StopCD(); - } -#endif -} - -void SND_OpenALDevice::SetCDPlaymode(int playmode) const -{ -#ifndef __APPLE__ - m_cdrom->SetCDPlaymode(playmode); -#endif -} - -void SND_OpenALDevice::SetCDGain(MT_Scalar gain) const -{ -#ifndef __APPLE__ - m_cdrom->SetCDGain(gain); -#endif -} diff --git a/intern/SoundSystem/openal/SND_OpenALDevice.h b/intern/SoundSystem/openal/SND_OpenALDevice.h deleted file mode 100644 index a7b97cc314f..00000000000 --- a/intern/SoundSystem/openal/SND_OpenALDevice.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef SND_OPENALDEVICE -#define SND_OPENALDEVICE - -#include "SND_AudioDevice.h" -#include "SoundDefines.h" - -struct SDL_CD; - -class SND_OpenALDevice : public SND_AudioDevice -{ -public: - SND_OpenALDevice(); - virtual ~SND_OpenALDevice(); - - SND_WaveSlot* LoadSample(const STR_String& samplename, - void* memlocation, - int size); - - void InitListener(); - void SetListenerGain(float gain) const; - void SetDopplerVelocity(MT_Scalar dopplervelocity) const; - void SetDopplerFactor(MT_Scalar dopplerfactor) const; - void SetListenerRollOffFactor(MT_Scalar rollofffactor) const; - - void MakeCurrent() const; - - void NextFrame() const; - void UseCD() const; - - void SetObjectBuffer(int id, unsigned int buffer); - - int GetPlayState(int id); - void PlayObject(int id); - void StopObject(int id) const; - void StopAllObjects(); - void PauseObject(int id) const; - - void SetObjectLoop(int id, unsigned int loopmode) const; - void SetObjectLoopPoints(int id, unsigned int loopstart, unsigned int loopend) const; - void SetObjectPitch(int id, MT_Scalar pitch) const; - void SetObjectGain(int id, MT_Scalar gain) const; - void SetObjectMinGain(int id, MT_Scalar mingain) const; - void SetObjectMaxGain(int id, MT_Scalar maxgain) const; - void SetObjectRollOffFactor(int id, MT_Scalar rolloff) const; - void SetObjectReferenceDistance(int id, MT_Scalar distance) const; - - void SetObjectTransform(int id, - const MT_Vector3& position, - const MT_Vector3& velocity, - const MT_Matrix3x3& orientation, - const MT_Vector3& lisposition, - const MT_Scalar& rollofffactor) const; - void ObjectIs2D(int id) const; - - void PlayCD(int track) const; - void PauseCD(bool pause) const; - void StopCD() const; - void SetCDPlaymode(int playmode) const; - void SetCDGain(MT_Scalar gain) const; - - void StartUsingDSP() {}; - float* GetSpectrum() { return NULL; } - void StopUsingDSP() {}; - -private: - void* m_context; - void* m_device; - - unsigned int m_buffers[NUM_BUFFERS]; - unsigned int m_sources[NUM_SOURCES]; - bool m_buffersinitialized; - bool m_sourcesinitialized; -#ifndef __APPLE__ - class SND_SDLCDDevice* m_cdrom; -#endif -}; - -#endif //SND_OPENALDEVICE - diff --git a/intern/SoundSystem/openal/pthread_cancel.cpp b/intern/SoundSystem/openal/pthread_cancel.cpp deleted file mode 100644 index bb36d1dd136..00000000000 --- a/intern/SoundSystem/openal/pthread_cancel.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * FreeBSD 3.4 does not yet have pthread_cancel (3.5 and above do) - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef __FreeBSD__ - -#include - -#if (__FreeBSD_version < 350000) -#include - -#define FD_READ 0x1 -#define _FD_LOCK(_fd,_type,_ts) _thread_fd_lock(_fd, _type, _ts) -#define _FD_UNLOCK(_fd,_type) _thread_fd_unlock(_fd, _type) - -int pthread_cancel(pthread_t pthread) { - pthread_exit(NULL); - return 0; -} - -long fpathconf(int fd, int name) -{ - long ret; - - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - ret = _thread_sys_fpathconf(fd, name); - _FD_UNLOCK(fd, FD_READ); - } - return ret; -} - -#endif - -int pthread_atfork(void *a, void *b, void *c) { - return 0; -} - -#endif diff --git a/intern/SoundSystem/sdl/SND_SDLCDDevice.cpp b/intern/SoundSystem/sdl/SND_SDLCDDevice.cpp deleted file mode 100644 index 5054c39e8a1..00000000000 --- a/intern/SoundSystem/sdl/SND_SDLCDDevice.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * SND_SDLCDDevice - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef WIN32 -#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning -#endif //WIN32 - -#include "MT_Scalar.h" - -#include "SND_SDLCDDevice.h" -#include "SoundDefines.h" - -#ifndef DISABLE_SDL -#include -#else -#include -#endif - -SND_SDLCDDevice::SND_SDLCDDevice() : - m_cdrom(NULL), - m_cdplaying(false), - m_cdtrack(0), - m_cdplaymode(SND_CD_TRACK), - m_frame(0) -{ - init(); -} - -void SND_SDLCDDevice::init() -{ -#ifdef DISABLE_SDL - fprintf(stderr, "Blender compiled without SDL, no CDROM support\n"); - return; -#else - if (SDL_InitSubSystem(SDL_INIT_CDROM)) - { - fprintf(stderr, "Error initializing CDROM\n"); - return; - } - - /* Check for CD drives */ - if(!SDL_CDNumDrives()) - { - /* None found */ - fprintf(stderr, "No CDROM devices available\n"); - return; - } - - /* Open the default drive */ - m_cdrom = SDL_CDOpen(0); - - /* Did if open? Check if cdrom is NULL */ - if(!m_cdrom) - { - fprintf(stderr, "Couldn't open drive: %s\n", SDL_GetError()); - return; - } -#endif -} - -SND_SDLCDDevice::~SND_SDLCDDevice() -{ -#ifndef DISABLE_SDL - StopCD(); - SDL_CDClose(m_cdrom); -#endif -} - -void SND_SDLCDDevice::NextFrame() -{ -#ifndef DISABLE_SDL - m_frame++; - m_frame &= 127; - - if (!m_frame && m_cdrom && m_cdplaying && SDL_CDStatus(m_cdrom) == CD_STOPPED) - { - switch (m_cdplaymode) - { - case SND_CD_ALL: - if (m_cdtrack < m_cdrom->numtracks) - PlayCD(m_cdtrack + 1); - else - m_cdplaying = false; - break; - default: - case SND_CD_TRACK: - m_cdplaying = false; - break; - case SND_CD_TRACKLOOP: - PlayCD(m_cdtrack); - break; - } - - } -#endif -} - -void SND_SDLCDDevice::PlayCD(int track) -{ -#ifndef DISABLE_SDL - if ( m_cdrom && CD_INDRIVE(SDL_CDStatus(m_cdrom)) ) { - SDL_CDPlayTracks(m_cdrom, track-1, 0, track, 0); - m_cdplaying = true; - m_cdtrack = track; - } -#endif -} - - -void SND_SDLCDDevice::PauseCD(bool pause) -{ -#ifndef DISABLE_SDL - if (!m_cdrom) - return; - - if (pause) - SDL_CDPause(m_cdrom); - else - SDL_CDResume(m_cdrom); -#endif -} - -void SND_SDLCDDevice::StopCD() -{ -#ifndef DISABLE_SDL - if (m_cdrom) - SDL_CDStop(m_cdrom); - m_cdplaying = false; -#endif -} - -void SND_SDLCDDevice::SetCDPlaymode(int playmode) -{ - m_cdplaymode = playmode; -} - -void SND_SDLCDDevice::SetCDGain(MT_Scalar gain) -{ - -} diff --git a/intern/SoundSystem/sdl/SND_SDLCDDevice.h b/intern/SoundSystem/sdl/SND_SDLCDDevice.h deleted file mode 100644 index 96600d53630..00000000000 --- a/intern/SoundSystem/sdl/SND_SDLCDDevice.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef SND_SDLCDDEVICE -#define SND_SDLCDDEVICE - -struct SDL_CD; - -class SND_SDLCDDevice -{ -public: - SND_SDLCDDevice(); - ~SND_SDLCDDevice(); - - void NextFrame(); - - void PlayCD(int track); - void PauseCD(bool pause); - void StopCD(); - void SetCDPlaymode(int playmode); - void SetCDGain(MT_Scalar gain); - -private: - void init(); - /* CD Audio */ - SDL_CD* m_cdrom; - bool m_cdplaying; - int m_cdtrack; - unsigned char m_cdplaymode; - unsigned char m_frame; -}; - -#endif diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt new file mode 100644 index 00000000000..940a4b2bedc --- /dev/null +++ b/intern/audaspace/CMakeLists.txt @@ -0,0 +1,58 @@ +# $Id$ +# ***** BEGIN LGPL LICENSE BLOCK ***** +# +# Copyright 2009 Jörg Hermann Müller +# +# This file is part of AudaSpace. +# +# AudaSpace is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# AudaSpace 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 Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with AudaSpace. If not, see . +# +# ***** END LGPL LICENSE BLOCK ***** + +SET(INC . intern FX SRC ${PTHREADS_INC} ${LIBSAMPLERATE_INC}) + +FILE(GLOB SRC intern/*.cpp intern/*.h FX/*.cpp SRC/*.cpp) + +IF(WITH_FFMPEG) + SET(INC ${INC} ffmpeg ${FFMPEG_INC}) + FILE(GLOB FFMPEGSRC ffmpeg/*.cpp) + ADD_DEFINITIONS(-DWITH_FFMPEG) +ENDIF(WITH_FFMPEG) + +IF(WITH_SDL) + SET(INC ${INC} SDL ${SDL_INCLUDE_DIR}) + FILE(GLOB SDLSRC SDL/*.cpp) + ADD_DEFINITIONS(-DWITH_SDL) +ENDIF(WITH_SDL) + +IF(WITH_OPENAL) + SET(INC ${INC} OpenAL ${OPENAL_INCLUDE_DIR}) + FILE(GLOB OPENALSRC OpenAL/*.cpp) + ADD_DEFINITIONS(-DWITH_OPENAL) + + STRING(REGEX MATCH ".*ramework.*" FRAMEWORK ${OPENAL_INCLUDE_DIR}) + IF(FRAMEWORK) + ADD_DEFINITIONS(-DAPPLE_FRAMEWORK_FIX) + ENDIF(FRAMEWORK) +ENDIF(WITH_OPENAL) + +IF(WITH_JACK) + SET(INC ${INC} jack ${JACK_INC}) + FILE(GLOB JACKSRC jack/*.cpp) + ADD_DEFINITIONS(-DWITH_JACK) +ENDIF(WITH_JACK) + +SET(SRC ${SRC} ${FFMPEGSRC} ${SDLSRC} ${OPENALSRC} ${JACKSRC}) + +BLENDERLIB(bf_audaspace "${SRC}" "${INC}") diff --git a/intern/audaspace/COPYING b/intern/audaspace/COPYING new file mode 100644 index 00000000000..94a9ed024d3 --- /dev/null +++ b/intern/audaspace/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 3 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, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/intern/audaspace/COPYING.LESSER b/intern/audaspace/COPYING.LESSER new file mode 100644 index 00000000000..cca7fc278f5 --- /dev/null +++ b/intern/audaspace/COPYING.LESSER @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/intern/audaspace/FX/AUD_DelayFactory.cpp b/intern/audaspace/FX/AUD_DelayFactory.cpp new file mode 100644 index 00000000000..25ce4faed4c --- /dev/null +++ b/intern/audaspace/FX/AUD_DelayFactory.cpp @@ -0,0 +1,58 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_DelayFactory.h" +#include "AUD_DelayReader.h" +#include "AUD_Space.h" + +AUD_DelayFactory::AUD_DelayFactory(AUD_IFactory* factory, float delay) : + AUD_EffectFactory(factory), + m_delay(delay) {} + +AUD_DelayFactory::AUD_DelayFactory(float delay) : + AUD_EffectFactory(0), + m_delay(delay) {} + +float AUD_DelayFactory::getDelay() +{ + return m_delay; +} + +void AUD_DelayFactory::setDelay(float delay) +{ + m_delay = delay; +} + +AUD_IReader* AUD_DelayFactory::createReader() +{ + AUD_IReader* reader = getReader(); + + if(reader != 0) + { + reader = new AUD_DelayReader(reader, m_delay); AUD_NEW("reader") + } + + return reader; +} diff --git a/intern/audaspace/FX/AUD_DelayFactory.h b/intern/audaspace/FX/AUD_DelayFactory.h new file mode 100644 index 00000000000..5ad4b9ab996 --- /dev/null +++ b/intern/audaspace/FX/AUD_DelayFactory.h @@ -0,0 +1,70 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_DELAYFACTORY +#define AUD_DELAYFACTORY + +#include "AUD_EffectFactory.h" + +/** + * This factory plays another factory delayed. + */ +class AUD_DelayFactory : public AUD_EffectFactory +{ +private: + /** + * The delay in samples. + */ + float m_delay; + +public: + /** + * Creates a new delay factory. + * \param factory The input factory. + * \param delay The desired delay in seconds. + */ + AUD_DelayFactory(AUD_IFactory* factory = 0, float delay = 0); + + /** + * Creates a new delay factory. + * \param delay The desired delay in seconds. + */ + AUD_DelayFactory(float delay); + + /** + * Returns the delay in seconds. + */ + float getDelay(); + + /** + * Sets the delay. + * \param delay The new delay value in seconds. + */ + void setDelay(float delay); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_DELAYFACTORY diff --git a/intern/audaspace/FX/AUD_DelayReader.cpp b/intern/audaspace/FX/AUD_DelayReader.cpp new file mode 100644 index 00000000000..38d3b893b5c --- /dev/null +++ b/intern/audaspace/FX/AUD_DelayReader.cpp @@ -0,0 +1,111 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_DelayReader.h" +#include "AUD_Buffer.h" + +#include + +AUD_DelayReader::AUD_DelayReader(AUD_IReader* reader, float delay) : + AUD_EffectReader(reader) +{ + m_delay = (int)(delay * reader->getSpecs().rate); + m_remdelay = m_delay; + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") +} + +AUD_DelayReader::~AUD_DelayReader() +{ + delete m_buffer; AUD_DELETE("buffer") +} + +void AUD_DelayReader::seek(int position) +{ + if(position < 0) + return; + + if(position < m_delay) + { + m_remdelay = m_delay - position; + m_reader->seek(0); + } + else + { + m_remdelay = 0; + m_reader->seek(position - m_delay); + } +} + +int AUD_DelayReader::getLength() +{ + int len = m_reader->getLength(); + if(len < 0) + return len; + return len+m_delay; +} + +int AUD_DelayReader::getPosition() +{ + if(m_remdelay > 0) + return m_delay-m_remdelay; + return m_reader->getPosition() + m_delay; +} + +void AUD_DelayReader::read(int & length, sample_t* & buffer) +{ + if(m_remdelay > 0) + { + int samplesize = AUD_SAMPLE_SIZE(m_reader->getSpecs()); + + if(m_buffer->getSize() < length*samplesize) + m_buffer->resize(length*samplesize); + + if(length > m_remdelay) + { + if(getSpecs().format == AUD_FORMAT_U8) + memset(m_buffer->getBuffer(), 0x80, m_remdelay*samplesize); + else + memset(m_buffer->getBuffer(), 0, m_remdelay*samplesize); + int len = length - m_remdelay; + m_reader->read(len, buffer); + memcpy(m_buffer->getBuffer()+m_remdelay*samplesize, + buffer, len*samplesize); + if(len < length-m_remdelay) + length = m_remdelay + len; + m_remdelay = 0; + } + else + { + if(getSpecs().format == AUD_FORMAT_U8) + memset(m_buffer->getBuffer(), 0x80, length*samplesize); + else + memset(m_buffer->getBuffer(), 0, length*samplesize); + m_remdelay -= length; + } + buffer = m_buffer->getBuffer(); + } + else + m_reader->read(length, buffer); +} diff --git a/intern/audaspace/FX/AUD_DelayReader.h b/intern/audaspace/FX/AUD_DelayReader.h new file mode 100644 index 00000000000..4662b455dfc --- /dev/null +++ b/intern/audaspace/FX/AUD_DelayReader.h @@ -0,0 +1,73 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_DELAYREADER +#define AUD_DELAYREADER + +#include "AUD_EffectReader.h" +class AUD_Buffer; + +/** + * This class reads another reader and changes it's delay. + */ +class AUD_DelayReader : public AUD_EffectReader +{ +private: + /** + * The playback buffer. + */ + AUD_Buffer *m_buffer; + + /** + * The delay level. + */ + int m_delay; + + /** + * The remaining delay for playback. + */ + int m_remdelay; + +public: + /** + * Creates a new delay reader. + * \param reader The reader to read from. + * \param delay The delay in seconds. + * \exception AUD_Exception Thrown if the reader specified is NULL. + */ + AUD_DelayReader(AUD_IReader* reader, float delay); + + /** + * Destroys the reader. + */ + virtual ~AUD_DelayReader(); + + virtual void seek(int position); + virtual int getLength(); + virtual int getPosition(); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_DELAYREADER diff --git a/intern/audaspace/FX/AUD_DoubleReader.cpp b/intern/audaspace/FX/AUD_DoubleReader.cpp new file mode 100644 index 00000000000..181e394da98 --- /dev/null +++ b/intern/audaspace/FX/AUD_DoubleReader.cpp @@ -0,0 +1,158 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_DoubleReader.h" +#include "AUD_Buffer.h" + +#include + +AUD_DoubleReader::AUD_DoubleReader(AUD_IReader* reader1, + AUD_IReader* reader2) : + m_reader1(reader1), m_reader2(reader2) +{ + try + { + if(!reader1) + AUD_THROW(AUD_ERROR_READER); + + if(!reader2) + AUD_THROW(AUD_ERROR_READER); + + AUD_Specs s1, s2; + s1 = reader1->getSpecs(); + s2 = reader2->getSpecs(); + if(memcmp(&s1, &s2, sizeof(AUD_Specs)) != 0) + AUD_THROW(AUD_ERROR_READER); + } + + catch(AUD_Exception e) + { + if(reader1) + { + delete reader1; AUD_DELETE("reader") + } + if(reader2) + { + delete reader2; AUD_DELETE("reader") + } + + throw; + } + + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") + m_finished1 = false; +} + +AUD_DoubleReader::~AUD_DoubleReader() +{ + delete m_reader1; AUD_DELETE("reader") + delete m_reader2; AUD_DELETE("reader") + delete m_buffer; AUD_DELETE("buffer") +} + +bool AUD_DoubleReader::isSeekable() +{ + return false; +} + +void AUD_DoubleReader::seek(int position) +{ + int length1 = m_reader1->getLength(); + + if(position < 0) + position = 0; + + if(position < length1) + { + m_reader1->seek(position); + m_reader2->seek(0); + m_finished1 = false; + } + else + { + m_reader2->seek(position-length1); + m_finished1 = true; + } +} + +int AUD_DoubleReader::getLength() +{ + int len1 = m_reader1->getLength(); + int len2 = m_reader2->getLength(); + if(len1 < 0 || len2 < 0) + return -1; + return len1 + len2; +} + +int AUD_DoubleReader::getPosition() +{ + return m_reader1->getPosition() + m_reader2->getPosition(); +} + +AUD_Specs AUD_DoubleReader::getSpecs() +{ + return m_reader1->getSpecs(); +} + +AUD_ReaderType AUD_DoubleReader::getType() +{ + if(m_reader1->getType() == AUD_TYPE_BUFFER && + m_reader2->getType() == AUD_TYPE_BUFFER) + return AUD_TYPE_BUFFER; + return AUD_TYPE_STREAM; +} + +bool AUD_DoubleReader::notify(AUD_Message &message) +{ + return m_reader1->notify(message) | m_reader2->notify(message); +} + +void AUD_DoubleReader::read(int & length, sample_t* & buffer) +{ + if(!m_finished1) + { + int len = length; + m_reader1->read(len, buffer); + if(len < length) + { + int samplesize = AUD_SAMPLE_SIZE(m_reader1->getSpecs()); + if(m_buffer->getSize() < length * samplesize) + m_buffer->resize(length * samplesize); + memcpy(m_buffer->getBuffer(), buffer, len*samplesize); + len = length - len; + length -= len; + m_reader2->read(len, buffer); + memcpy(m_buffer->getBuffer() + length*samplesize, + buffer, len*samplesize); + length += len; + buffer = m_buffer->getBuffer(); + m_finished1 = true; + } + } + else + { + m_reader2->read(length, buffer); + } +} diff --git a/intern/audaspace/FX/AUD_DoubleReader.h b/intern/audaspace/FX/AUD_DoubleReader.h new file mode 100644 index 00000000000..d82b81ec0ba --- /dev/null +++ b/intern/audaspace/FX/AUD_DoubleReader.h @@ -0,0 +1,83 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_DOUBLEREADER +#define AUD_DOUBLEREADER + +#include "AUD_IReader.h" +class AUD_Buffer; + +/** + * This reader plays two readers with the same specs sequently. + */ +class AUD_DoubleReader : public AUD_IReader +{ +private: + /** + * The first reader. + */ + AUD_IReader* m_reader1; + + /** + * The second reader. + */ + AUD_IReader* m_reader2; + + /** + * Whether we've reached the end of the first reader. + */ + bool m_finished1; + + /** + * The playback buffer for the intersecting part. + */ + AUD_Buffer* m_buffer; + +public: + /** + * Creates a new ping pong reader. + * \param reader1 The first reader to read from. + * \param reader2 The second reader to read from. + * \exception AUD_Exception Thrown if one of the reader specified is NULL + * or the specs from the readers differ. + */ + AUD_DoubleReader(AUD_IReader* reader1, AUD_IReader* reader2); + + /** + * Destroys the reader. + */ + virtual ~AUD_DoubleReader(); + + virtual bool isSeekable(); + virtual void seek(int position); + virtual int getLength(); + virtual int getPosition(); + virtual AUD_Specs getSpecs(); + virtual AUD_ReaderType getType(); + virtual bool notify(AUD_Message &message); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_DOUBLEREADER diff --git a/intern/audaspace/FX/AUD_EffectFactory.cpp b/intern/audaspace/FX/AUD_EffectFactory.cpp new file mode 100644 index 00000000000..882499416b7 --- /dev/null +++ b/intern/audaspace/FX/AUD_EffectFactory.cpp @@ -0,0 +1,50 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_EffectFactory.h" +#include "AUD_IReader.h" + +AUD_IReader* AUD_EffectFactory::getReader() +{ + if(m_factory != 0) + return m_factory->createReader(); + + return 0; +} + +AUD_EffectFactory::AUD_EffectFactory(AUD_IFactory* factory) +{ + m_factory = factory; +} + +void AUD_EffectFactory::setFactory(AUD_IFactory* factory) +{ + m_factory = factory; +} + +AUD_IFactory* AUD_EffectFactory::getFactory() +{ + return m_factory; +} diff --git a/intern/audaspace/FX/AUD_EffectFactory.h b/intern/audaspace/FX/AUD_EffectFactory.h new file mode 100644 index 00000000000..67259b9e6c3 --- /dev/null +++ b/intern/audaspace/FX/AUD_EffectFactory.h @@ -0,0 +1,76 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_EFFECTFACTORY +#define AUD_EFFECTFACTORY + +#include "AUD_IFactory.h" + +/** + * This factory is a base class for all effect factories that take one other + * factory as input. + */ +class AUD_EffectFactory : public AUD_IFactory +{ +protected: + /** + * If there is no reader it is created out of this factory. + */ + AUD_IFactory* m_factory; + + /** + * Returns the reader created out of the factory. + * This method can be used for the createReader function of the implementing + * classes. + * \return The reader created out of the factory or NULL if there is none. + */ + AUD_IReader* getReader(); + +public: + /** + * Creates a new factory. + * \param factory The input factory. + */ + AUD_EffectFactory(AUD_IFactory* factory); + + /** + * Destroys the factory. + */ + virtual ~AUD_EffectFactory() {} + + /** + * Sets the input factory. + * \param factory The input factory. + */ + void setFactory(AUD_IFactory* factory); + + /** + * Returns the saved factory. + * \return The factory or NULL if there has no factory been saved. + */ + AUD_IFactory* getFactory(); +}; + +#endif //AUD_EFFECTFACTORY diff --git a/intern/audaspace/FX/AUD_EffectReader.cpp b/intern/audaspace/FX/AUD_EffectReader.cpp new file mode 100644 index 00000000000..47026b88440 --- /dev/null +++ b/intern/audaspace/FX/AUD_EffectReader.cpp @@ -0,0 +1,78 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_EffectReader.h" + +AUD_EffectReader::AUD_EffectReader(AUD_IReader* reader) +{ + if(!reader) + AUD_THROW(AUD_ERROR_READER); + m_reader = reader; +} + +AUD_EffectReader::~AUD_EffectReader() +{ + delete m_reader; AUD_DELETE("reader") +} + +bool AUD_EffectReader::isSeekable() +{ + return m_reader->isSeekable(); +} + +void AUD_EffectReader::seek(int position) +{ + m_reader->seek(position); +} + +int AUD_EffectReader::getLength() +{ + return m_reader->getLength(); +} + +int AUD_EffectReader::getPosition() +{ + return m_reader->getPosition(); +} + +AUD_Specs AUD_EffectReader::getSpecs() +{ + return m_reader->getSpecs(); +} + +AUD_ReaderType AUD_EffectReader::getType() +{ + return m_reader->getType(); +} + +bool AUD_EffectReader::notify(AUD_Message &message) +{ + return m_reader->notify(message); +} + +void AUD_EffectReader::read(int & length, sample_t* & buffer) +{ + m_reader->read(length, buffer); +} diff --git a/intern/audaspace/FX/AUD_EffectReader.h b/intern/audaspace/FX/AUD_EffectReader.h new file mode 100644 index 00000000000..f64bf34077d --- /dev/null +++ b/intern/audaspace/FX/AUD_EffectReader.h @@ -0,0 +1,66 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_EFFECTREADER +#define AUD_EFFECTREADER + +#include "AUD_IReader.h" + +/** + * This reader is a base class for all effect readers that take one other reader + * as input. + */ +class AUD_EffectReader : public AUD_IReader +{ +protected: + /** + * The reader to read from. + */ + AUD_IReader* m_reader; + +public: + /** + * Creates a new effect reader. + * \param reader The reader to read from. + * \exception AUD_Exception Thrown if the reader specified is NULL. + */ + AUD_EffectReader(AUD_IReader* reader); + + /** + * Destroys the reader. + */ + virtual ~AUD_EffectReader(); + + virtual bool isSeekable(); + virtual void seek(int position); + virtual int getLength(); + virtual int getPosition(); + virtual AUD_Specs getSpecs(); + virtual AUD_ReaderType getType(); + virtual bool notify(AUD_Message &message); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_EFFECTREADER diff --git a/intern/audaspace/FX/AUD_FaderFactory.cpp b/intern/audaspace/FX/AUD_FaderFactory.cpp new file mode 100644 index 00000000000..4357e11bd43 --- /dev/null +++ b/intern/audaspace/FX/AUD_FaderFactory.cpp @@ -0,0 +1,84 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_FaderFactory.h" +#include "AUD_FaderReader.h" + +AUD_FaderFactory::AUD_FaderFactory(AUD_IFactory* factory, AUD_FadeType type, + float start, float length) : + AUD_EffectFactory(factory), + m_type(type), + m_start(start), + m_length(length) {} + +AUD_FaderFactory::AUD_FaderFactory(AUD_FadeType type, + float start, float length) : + AUD_EffectFactory(0), + m_type(type), + m_start(start), + m_length(length) {} + +AUD_FadeType AUD_FaderFactory::getType() +{ + return m_type; +} + +void AUD_FaderFactory::setType(AUD_FadeType type) +{ + m_type = type; +} + +float AUD_FaderFactory::getStart() +{ + return m_start; +} + +void AUD_FaderFactory::setStart(float start) +{ + m_start = start; +} + +float AUD_FaderFactory::getLength() +{ + return m_length; +} + +void AUD_FaderFactory::setLength(float length) +{ + m_length = length; +} + +AUD_IReader* AUD_FaderFactory::createReader() +{ + AUD_IReader* reader = getReader(); + + if(reader != 0) + { + reader = new AUD_FaderReader(reader, m_type, m_start, m_length); + AUD_NEW("reader") + } + + return reader; +} diff --git a/intern/audaspace/FX/AUD_FaderFactory.h b/intern/audaspace/FX/AUD_FaderFactory.h new file mode 100644 index 00000000000..4999ccac8f1 --- /dev/null +++ b/intern/audaspace/FX/AUD_FaderFactory.h @@ -0,0 +1,111 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_FADERFACTORY +#define AUD_FADERFACTORY + +#include "AUD_EffectFactory.h" + +/** + * This factory fades another factory. + * If the fading type is AUD_FADE_IN, everything before the fading start will be + * silenced, for AUD_FADE_OUT that's true for everything after fading ends. + */ +class AUD_FaderFactory : public AUD_EffectFactory +{ +private: + /** + * The fading type. + */ + AUD_FadeType m_type; + + /** + * The fading start. + */ + float m_start; + + /** + * The fading length. + */ + float m_length; + +public: + /** + * Creates a new fader factory. + * \param factory The input factory. + * \param type The fading type. + * \param start The time where fading should start in seconds. + * \param length How long fading should last in seconds. + */ + AUD_FaderFactory(AUD_IFactory* factory = 0, + AUD_FadeType type = AUD_FADE_IN, + float start = 0.0f, float length = 1.0f); + + /** + * Creates a new fader factory. + * \param type The fading type. + * \param start The time where fading should start in seconds. + * \param length How long fading should last in seconds. + */ + AUD_FaderFactory(AUD_FadeType type = AUD_FADE_IN, + float start = 0.0f, float length = 1.0f); + + /** + * Returns the fading type. + */ + AUD_FadeType getType(); + + /** + * Sets the fading type. + * \param type The new fading type: AUD_FADE_IN or AUD_FADE_OUT. + */ + void setType(AUD_FadeType type); + + /** + * Returns the fading start. + */ + float getStart(); + + /** + * Sets the fading start. + * \param start The new fading start. + */ + void setStart(float start); + + /** + * Returns the fading length. + */ + float getLength(); + + /** + * Sets the fading length. + * \param start The new fading length. + */ + void setLength(float length); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_FADERFACTORY diff --git a/intern/audaspace/FX/AUD_FaderReader.cpp b/intern/audaspace/FX/AUD_FaderReader.cpp new file mode 100644 index 00000000000..d5096e7fae1 --- /dev/null +++ b/intern/audaspace/FX/AUD_FaderReader.cpp @@ -0,0 +1,133 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_FaderReader.h" +#include "AUD_Buffer.h" + +#include + +AUD_FaderReader::AUD_FaderReader(AUD_IReader* reader, AUD_FadeType type, + float start,float length) : + AUD_EffectReader(reader), + m_type(type), + m_start(start), + m_length(length) +{ + int bigendian = 1; + bigendian = (((char*)&bigendian)[0]) ? 0: 1; // 1 if Big Endian + + switch(m_reader->getSpecs().format) + { + case AUD_FORMAT_S16: + m_adjust = AUD_volume_adjust; + break; + case AUD_FORMAT_S32: + m_adjust = AUD_volume_adjust; + break; + case AUD_FORMAT_FLOAT32: + m_adjust = AUD_volume_adjust; + break; + case AUD_FORMAT_FLOAT64: + m_adjust = AUD_volume_adjust; + break; + case AUD_FORMAT_U8: + m_adjust = AUD_volume_adjust_u8; + break; + case AUD_FORMAT_S24: + m_adjust = bigendian ? AUD_volume_adjust_s24_be : + AUD_volume_adjust_s24_le; + break; + default: + delete m_reader; + AUD_THROW(AUD_ERROR_READER); + } + + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") +} + +AUD_FaderReader::~AUD_FaderReader() +{ + delete m_buffer; AUD_DELETE("buffer") +} + +bool AUD_FaderReader::notify(AUD_Message &message) +{ + return m_reader->notify(message); +} + +void AUD_FaderReader::read(int & length, sample_t* & buffer) +{ + int position = m_reader->getPosition(); + AUD_Specs specs = m_reader->getSpecs(); + int samplesize = AUD_SAMPLE_SIZE(specs); + + m_reader->read(length, buffer); + + if(m_buffer->getSize() < length * samplesize) + m_buffer->resize(length * samplesize); + + if((position + length) / (float)specs.rate <= m_start) + { + if(m_type != AUD_FADE_OUT) + { + buffer = m_buffer->getBuffer(); + memset(buffer, + specs.format == AUD_FORMAT_U8 ? 0x80 : 0, + length * samplesize); + } + } + else if(position / (float)specs.rate >= m_start+m_length) + { + if(m_type == AUD_FADE_OUT) + { + buffer = m_buffer->getBuffer(); + memset(buffer, + specs.format == AUD_FORMAT_U8 ? 0x80 : 0, + length * samplesize); + } + } + else + { + sample_t* buf = m_buffer->getBuffer(); + float volume; + + for(int i = 0; i < length; i++) + { + volume = (((position+i)/(float)specs.rate)-m_start) / m_length; + if(volume > 1.0f) + volume = 1.0f; + else if(volume < 0.0f) + volume = 0.0f; + + if(m_type == AUD_FADE_OUT) + volume = 1.0f - volume; + + m_adjust(buf + i * samplesize, buffer + i * samplesize, + specs.channels, volume); + } + + buffer = buf; + } +} diff --git a/intern/audaspace/FX/AUD_FaderReader.h b/intern/audaspace/FX/AUD_FaderReader.h new file mode 100644 index 00000000000..773643b2f5d --- /dev/null +++ b/intern/audaspace/FX/AUD_FaderReader.h @@ -0,0 +1,86 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_FADERREADER +#define AUD_FADERREADER + +#include "AUD_EffectReader.h" +#include "AUD_ConverterFunctions.h" +class AUD_Buffer; + +/** + * This class fades another reader. + * If the fading type is AUD_FADE_IN, everything before the fading start will be + * silenced, for AUD_FADE_OUT that's true for everything after fading ends. + */ +class AUD_FaderReader : public AUD_EffectReader +{ +private: + /** + * The playback buffer. + */ + AUD_Buffer *m_buffer; + + /** + * The fading type. + */ + AUD_FadeType m_type; + + /** + * The fading start. + */ + float m_start; + + /** + * The fading length. + */ + float m_length; + + /** + * Volume adjustment function. + */ + AUD_volume_adjust_f m_adjust; + +public: + /** + * Creates a new fader reader. + * \param type The fading type. + * \param start The time where fading should start in seconds. + * \param length How long fading should last in seconds. + * \exception AUD_Exception Thrown if the reader specified is NULL. + */ + AUD_FaderReader(AUD_IReader* reader, AUD_FadeType type, + float start,float length); + + /** + * Destroys the reader. + */ + virtual ~AUD_FaderReader(); + + virtual bool notify(AUD_Message &message); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_FADERREADER diff --git a/intern/audaspace/FX/AUD_LimiterFactory.cpp b/intern/audaspace/FX/AUD_LimiterFactory.cpp new file mode 100644 index 00000000000..6f19575240a --- /dev/null +++ b/intern/audaspace/FX/AUD_LimiterFactory.cpp @@ -0,0 +1,67 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_LimiterFactory.h" +#include "AUD_LimiterReader.h" +#include "AUD_Space.h" + +AUD_LimiterFactory::AUD_LimiterFactory(AUD_IFactory* factory, + float start, float end) : + AUD_EffectFactory(factory), + m_start(start), + m_end(end) {} + +float AUD_LimiterFactory::getStart() +{ + return m_start; +} + +void AUD_LimiterFactory::setStart(float start) +{ + m_start = start; +} + +float AUD_LimiterFactory::getEnd() +{ + return m_end; +} + +void AUD_LimiterFactory::setEnd(float end) +{ + m_end = end; +} + +AUD_IReader* AUD_LimiterFactory::createReader() +{ + AUD_IReader* reader = getReader(); + + if(reader != 0) + { + reader = new AUD_LimiterReader(reader, m_start, m_end); + AUD_NEW("reader") + } + + return reader; +} diff --git a/intern/audaspace/FX/AUD_LimiterFactory.h b/intern/audaspace/FX/AUD_LimiterFactory.h new file mode 100644 index 00000000000..588fea6eb4b --- /dev/null +++ b/intern/audaspace/FX/AUD_LimiterFactory.h @@ -0,0 +1,84 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_LIMITERFACTORY +#define AUD_LIMITERFACTORY + +#include "AUD_EffectFactory.h" + +/** + * This factory limits another factory in start and end time. + */ +class AUD_LimiterFactory : public AUD_EffectFactory +{ +private: + /** + * The start time. + */ + float m_start; + + /** + * The end time. + */ + float m_end; + +public: + /** + * Creates a new limiter factory. + * \param factory The input factory. + * \param start The desired start time. + * \param end The desired end time, a negative value signals that it should + * play to the end. + */ + AUD_LimiterFactory(AUD_IFactory* factory = 0, + float start = 0, float end = -1); + + /** + * Returns the start time. + */ + float getStart(); + + /** + * Sets the start time. + * \param start The new start time. + */ + void setStart(float start); + + /** + * Returns the end time. + */ + float getEnd(); + + /** + * Sets the end time. + * \param end The new end time, a negative value signals that it should play + * to the end. + */ + void setEnd(float end); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_LIMITERFACTORY diff --git a/intern/audaspace/FX/AUD_LimiterReader.cpp b/intern/audaspace/FX/AUD_LimiterReader.cpp new file mode 100644 index 00000000000..05882369001 --- /dev/null +++ b/intern/audaspace/FX/AUD_LimiterReader.cpp @@ -0,0 +1,95 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_LimiterReader.h" +#include "AUD_Buffer.h" + +#include + +AUD_LimiterReader::AUD_LimiterReader(AUD_IReader* reader, + float start, float end) : + AUD_EffectReader(reader) +{ + m_end = (int)(end * reader->getSpecs().rate); + + if(start <= 0) + m_start = 0; + else + { + m_start = (int)(start * reader->getSpecs().rate); + if(m_reader->isSeekable()) + m_reader->seek(m_start); + else + { + // skip first m_start samples by reading them + int length; + sample_t* buffer; + for(int i = m_start; + i >= AUD_DEFAULT_BUFFER_SIZE; + i -= AUD_DEFAULT_BUFFER_SIZE) + { + length = AUD_DEFAULT_BUFFER_SIZE; + m_reader->read(length, buffer); + length = i; + } + m_reader->read(length, buffer); + } + } +} + +void AUD_LimiterReader::seek(int position) +{ + m_reader->seek(position + m_start); +} + +int AUD_LimiterReader::getLength() +{ + int len = m_reader->getLength(); + if(m_reader->getType() != AUD_TYPE_BUFFER || len < 0 || + (len > m_end && m_end >= 0)) + len = m_end; + return len - m_start; +} + +int AUD_LimiterReader::getPosition() +{ + return m_reader->getPosition() - m_start; +} + +void AUD_LimiterReader::read(int & length, sample_t* & buffer) +{ + if(m_end >= 0) + { + int position = m_reader->getPosition(); + if(position+length > m_end) + length = m_end - position; + if(length < 0) + { + length = 0; + return; + } + } + m_reader->read(length, buffer); +} diff --git a/intern/audaspace/FX/AUD_LimiterReader.h b/intern/audaspace/FX/AUD_LimiterReader.h new file mode 100644 index 00000000000..9921f5ee1b0 --- /dev/null +++ b/intern/audaspace/FX/AUD_LimiterReader.h @@ -0,0 +1,64 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_LIMITERREADER +#define AUD_LIMITERREADER + +#include "AUD_EffectReader.h" + +/** + * This reader limits another reader in start and end sample. + */ +class AUD_LimiterReader : public AUD_EffectReader +{ +private: + /** + * The start sample: inclusive. + */ + int m_start; + + /** + * The end sample: exlusive. + */ + int m_end; + +public: + /** + * Creates a new limiter reader. + * \param reader The reader to read from. + * \param start The desired start sample (inclusive). + * \param end The desired end sample (exklusive), a negative value signals + * that it should play to the end. + * \exception AUD_Exception Thrown if the reader specified is NULL. + */ + AUD_LimiterReader(AUD_IReader* reader, float start = 0, float end = -1); + + virtual void seek(int position); + virtual int getLength(); + virtual int getPosition(); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_LIMITERREADER diff --git a/intern/audaspace/FX/AUD_LoopFactory.cpp b/intern/audaspace/FX/AUD_LoopFactory.cpp new file mode 100644 index 00000000000..90186f623ff --- /dev/null +++ b/intern/audaspace/FX/AUD_LoopFactory.cpp @@ -0,0 +1,57 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_LoopFactory.h" +#include "AUD_LoopReader.h" + +AUD_LoopFactory::AUD_LoopFactory(AUD_IFactory* factory, int loop) : + AUD_EffectFactory(factory), + m_loop(loop) {} + +AUD_LoopFactory::AUD_LoopFactory(int loop) : + AUD_EffectFactory(0), + m_loop(loop) {} + +int AUD_LoopFactory::getLoop() +{ + return m_loop; +} + +void AUD_LoopFactory::setLoop(int loop) +{ + m_loop = loop; +} + +AUD_IReader* AUD_LoopFactory::createReader() +{ + AUD_IReader* reader = getReader(); + + if(reader != 0) + { + reader = new AUD_LoopReader(reader, m_loop); AUD_NEW("reader") + } + + return reader; +} diff --git a/intern/audaspace/FX/AUD_LoopFactory.h b/intern/audaspace/FX/AUD_LoopFactory.h new file mode 100644 index 00000000000..461d8c9ab69 --- /dev/null +++ b/intern/audaspace/FX/AUD_LoopFactory.h @@ -0,0 +1,74 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_LOOPFACTORY +#define AUD_LOOPFACTORY + +#include "AUD_EffectFactory.h" + +/** + * This factory loops another factory. + * \note The reader has to be seekable. + */ +class AUD_LoopFactory : public AUD_EffectFactory +{ +private: + /** + * The loop count. + */ + float m_loop; + +public: + /** + * Creates a new loop factory. + * \param factory The input factory. + * \param loop The desired loop count, negative values result in endless + * looping. + */ + AUD_LoopFactory(AUD_IFactory* factory = 0, int loop = -1); + + /** + * Creates a new loop factory. + * \param loop The desired loop count, negative values result in endless + * looping. + */ + AUD_LoopFactory(int loop); + + /** + * Returns the loop count. + */ + int getLoop(); + + /** + * Sets the loop count. + * \param loop The desired loop count, negative values result in endless + * looping. + */ + void setLoop(int loop); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_LOOPFACTORY diff --git a/intern/audaspace/FX/AUD_LoopReader.cpp b/intern/audaspace/FX/AUD_LoopReader.cpp new file mode 100644 index 00000000000..9e270321013 --- /dev/null +++ b/intern/audaspace/FX/AUD_LoopReader.cpp @@ -0,0 +1,107 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_LoopReader.h" +#include "AUD_Buffer.h" + +#include +#include + +AUD_LoopReader::AUD_LoopReader(AUD_IReader* reader, int loop) : + AUD_EffectReader(reader), m_loop(loop) +{ + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") +} + +AUD_LoopReader::~AUD_LoopReader() +{ + delete m_buffer; AUD_DELETE("buffer") +} + +AUD_ReaderType AUD_LoopReader::getType() +{ + if(m_loop < 0) + return AUD_TYPE_STREAM; + return m_reader->getType(); +} + +bool AUD_LoopReader::notify(AUD_Message &message) +{ + if(message.type == AUD_MSG_LOOP) + { + m_loop = message.loopcount; + + m_reader->notify(message); + + return true; + } + return m_reader->notify(message); +} + +void AUD_LoopReader::read(int & length, sample_t* & buffer) +{ + int samplesize = AUD_SAMPLE_SIZE(m_reader->getSpecs()); + + int len = length; + + m_reader->read(len, buffer); + + if(len < length && m_loop != 0) + { + int pos = 0; + + if(m_buffer->getSize() < length*samplesize) + m_buffer->resize(length*samplesize); + + memcpy(m_buffer->getBuffer() + pos * samplesize, + buffer, len * samplesize); + + pos += len; + + while(pos < length && m_loop != 0) + { + if(m_loop > 0) + m_loop--; + + m_reader->seek(0); + + len = length - pos; + m_reader->read(len, buffer); + // prevent endless loop + if(!len) + break; + + memcpy(m_buffer->getBuffer() + pos * samplesize, + buffer, len * samplesize); + + pos += len; + } + + length = pos; + buffer = m_buffer->getBuffer(); + } + else + length = len; +} diff --git a/intern/audaspace/FX/AUD_LoopReader.h b/intern/audaspace/FX/AUD_LoopReader.h new file mode 100644 index 00000000000..621ee3493ab --- /dev/null +++ b/intern/audaspace/FX/AUD_LoopReader.h @@ -0,0 +1,69 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_LOOPREADER +#define AUD_LOOPREADER + +#include "AUD_EffectReader.h" +class AUD_Buffer; + +/** + * This class reads another reader and loops it. + * \note The other reader must be seekable. + */ +class AUD_LoopReader : public AUD_EffectReader +{ +private: + /** + * The playback buffer. + */ + AUD_Buffer *m_buffer; + + /** + * The left loop count. + */ + int m_loop; + +public: + /** + * Creates a new loop reader. + * \param reader The reader to read from. + * \param loop The desired loop count, negative values result in endless + * looping. + * \exception AUD_Exception Thrown if the reader specified is NULL. + */ + AUD_LoopReader(AUD_IReader* reader, int loop); + + /** + * Destroys the reader. + */ + virtual ~AUD_LoopReader(); + + virtual AUD_ReaderType getType(); + virtual bool notify(AUD_Message &message); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_LOOPREADER diff --git a/intern/audaspace/FX/AUD_PingPongFactory.cpp b/intern/audaspace/FX/AUD_PingPongFactory.cpp new file mode 100644 index 00000000000..a030d581b1a --- /dev/null +++ b/intern/audaspace/FX/AUD_PingPongFactory.cpp @@ -0,0 +1,67 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_PingPongFactory.h" +#include "AUD_DoubleReader.h" +#include "AUD_ReverseFactory.h" + +AUD_PingPongFactory::AUD_PingPongFactory(AUD_IFactory* factory) : + AUD_EffectFactory(factory) {} + +AUD_IReader* AUD_PingPongFactory::createReader() +{ + if(m_factory == 0) + return 0; + + AUD_IReader* reader = m_factory->createReader(); + + if(reader != 0) + { + AUD_IReader* reader2; + AUD_ReverseFactory factory(m_factory); + + try + { + reader2 = factory.createReader(); + } + catch(AUD_Exception e) + { + reader2 = 0; + } + + if(reader2 != 0) + { + reader = new AUD_DoubleReader(reader, reader2); + AUD_NEW("reader") + } + else + { + delete reader; AUD_DELETE("reader") + reader = 0; + } + } + + return reader; +} diff --git a/intern/audaspace/FX/AUD_PingPongFactory.h b/intern/audaspace/FX/AUD_PingPongFactory.h new file mode 100644 index 00000000000..b8854da550a --- /dev/null +++ b/intern/audaspace/FX/AUD_PingPongFactory.h @@ -0,0 +1,51 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_PINGPONGFACTORY +#define AUD_PINGPONGFACTORY + +#include "AUD_EffectFactory.h" + +/** + * This factory plays another factory first normal, then reversed. + * \note Readers from the underlying factory must be from the buffer type. + */ +class AUD_PingPongFactory : public AUD_EffectFactory +{ +public: + /** + * Creates a new ping pong factory. + * \param factory The input factory. + */ + AUD_PingPongFactory(AUD_IFactory* factory = 0); + + /** + * Destroys the factory. + */ + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_PINGPONGFACTORY diff --git a/intern/audaspace/FX/AUD_PitchFactory.cpp b/intern/audaspace/FX/AUD_PitchFactory.cpp new file mode 100644 index 00000000000..5f814283c12 --- /dev/null +++ b/intern/audaspace/FX/AUD_PitchFactory.cpp @@ -0,0 +1,48 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_PitchFactory.h" +#include "AUD_PitchReader.h" +#include "AUD_Space.h" + +AUD_PitchFactory::AUD_PitchFactory(AUD_IFactory* factory, float pitch) : + AUD_EffectFactory(factory), + m_pitch(pitch) {} + +AUD_PitchFactory::AUD_PitchFactory(float pitch) : + AUD_EffectFactory(0), + m_pitch(pitch) {} + +AUD_IReader* AUD_PitchFactory::createReader() +{ + AUD_IReader* reader = getReader(); + + if(reader != 0) + { + reader = new AUD_PitchReader(reader, m_pitch); AUD_NEW("reader") + } + + return reader; +} diff --git a/intern/audaspace/FX/AUD_PitchFactory.h b/intern/audaspace/FX/AUD_PitchFactory.h new file mode 100644 index 00000000000..3209aa46983 --- /dev/null +++ b/intern/audaspace/FX/AUD_PitchFactory.h @@ -0,0 +1,70 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_PITCHFACTORY +#define AUD_PITCHFACTORY + +#include "AUD_EffectFactory.h" + +/** + * This factory changes the pitch of another factory. + */ +class AUD_PitchFactory : public AUD_EffectFactory +{ +private: + /** + * The pitch. + */ + float m_pitch; + +public: + /** + * Creates a new pitch factory. + * \param factory The input factory. + * \param pitch The desired pitch. + */ + AUD_PitchFactory(AUD_IFactory* factory = 0, float pitch = 1.0); + + /** + * Creates a new pitch factory. + * \param pitch The desired pitch. + */ + AUD_PitchFactory(float pitch); + + /** + * Returns the pitch. + */ + float getPitch(); + + /** + * Sets the pitch. + * \param pitch The new pitch value. Should be between 0.0 and 1.0. + */ + void setPitch(float pitch); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_PITCHFACTORY diff --git a/intern/audaspace/FX/AUD_PitchReader.cpp b/intern/audaspace/FX/AUD_PitchReader.cpp new file mode 100644 index 00000000000..c53264e1350 --- /dev/null +++ b/intern/audaspace/FX/AUD_PitchReader.cpp @@ -0,0 +1,39 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_PitchReader.h" + +AUD_PitchReader::AUD_PitchReader(AUD_IReader* reader, float pitch) : + AUD_EffectReader(reader) +{ + m_pitch = pitch; +} + +AUD_Specs AUD_PitchReader::getSpecs() +{ + AUD_Specs specs = m_reader->getSpecs(); + specs.rate = (AUD_SampleRate)((int)(specs.rate * m_pitch)); + return specs; +} diff --git a/intern/audaspace/FX/AUD_PitchReader.h b/intern/audaspace/FX/AUD_PitchReader.h new file mode 100644 index 00000000000..440e9cc843c --- /dev/null +++ b/intern/audaspace/FX/AUD_PitchReader.h @@ -0,0 +1,54 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_PITCHREADER +#define AUD_PITCHREADER + +#include "AUD_EffectReader.h" + +/** + * This class reads another reader and changes it's pitch. + */ +class AUD_PitchReader : public AUD_EffectReader +{ +private: + /** + * The pitch level. + */ + float m_pitch; + +public: + /** + * Creates a new pitch reader. + * \param reader The reader to read from. + * \param pitch The size of the buffer. + * \exception AUD_Exception Thrown if the reader specified is NULL. + */ + AUD_PitchReader(AUD_IReader* reader, float pitch); + + virtual AUD_Specs getSpecs(); +}; + +#endif //AUD_PITCHREADER diff --git a/intern/audaspace/FX/AUD_ReverseFactory.cpp b/intern/audaspace/FX/AUD_ReverseFactory.cpp new file mode 100644 index 00000000000..1242641c350 --- /dev/null +++ b/intern/audaspace/FX/AUD_ReverseFactory.cpp @@ -0,0 +1,43 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_ReverseFactory.h" +#include "AUD_ReverseReader.h" +#include "AUD_Space.h" + +AUD_ReverseFactory::AUD_ReverseFactory(AUD_IFactory* factory) : + AUD_EffectFactory(factory) {} + +AUD_IReader* AUD_ReverseFactory::createReader() +{ + AUD_IReader* reader = getReader(); + + if(reader != 0) + { + reader = new AUD_ReverseReader(reader); AUD_NEW("reader") + } + + return reader; +} diff --git a/intern/audaspace/FX/AUD_ReverseFactory.h b/intern/audaspace/FX/AUD_ReverseFactory.h new file mode 100644 index 00000000000..4b664c47281 --- /dev/null +++ b/intern/audaspace/FX/AUD_ReverseFactory.h @@ -0,0 +1,50 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_REVERSEFACTORY +#define AUD_REVERSEFACTORY + +#include "AUD_EffectFactory.h" + +/** + * This factory reads another factory reverted. + * \note Readers from the underlying factory must be from the buffer type. + */ +class AUD_ReverseFactory : public AUD_EffectFactory +{ +public: + /** + * Creates a new reverse factory. + * \param factory The input factory. + */ + AUD_ReverseFactory(AUD_IFactory* factory = 0); + + /** + * Destroys the factory. + */ + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_REVERSEFACTORY diff --git a/intern/audaspace/FX/AUD_ReverseReader.cpp b/intern/audaspace/FX/AUD_ReverseReader.cpp new file mode 100644 index 00000000000..043480b91b9 --- /dev/null +++ b/intern/audaspace/FX/AUD_ReverseReader.cpp @@ -0,0 +1,111 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_ReverseReader.h" +#include "AUD_Buffer.h" + +#include + +AUD_ReverseReader::AUD_ReverseReader(AUD_IReader* reader) : + AUD_EffectReader(reader) +{ + if(reader->getType() != AUD_TYPE_BUFFER) + AUD_THROW(AUD_ERROR_READER); + + m_length = reader->getLength(); + if(m_length < 0) + AUD_THROW(AUD_ERROR_READER); + + m_position = 0; + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") +} + +AUD_ReverseReader::~AUD_ReverseReader() +{ + delete m_buffer; AUD_DELETE("buffer") +} + +void AUD_ReverseReader::seek(int position) +{ + m_position = position; +} + +int AUD_ReverseReader::getLength() +{ + return m_length; +} + +int AUD_ReverseReader::getPosition() +{ + return m_position; +} + +void AUD_ReverseReader::read(int & length, sample_t* & buffer) +{ + // first correct the length + if(m_position+length > m_length) + length = m_length-m_position; + + if(length <= 0) + { + length = 0; + return; + } + + int samplesize = AUD_SAMPLE_SIZE(getSpecs()); + + // resize buffer if needed + if(m_buffer->getSize() < length * samplesize) + m_buffer->resize(length * samplesize); + + buffer = m_buffer->getBuffer(); + + sample_t* buf; + int len = length; + + // read from reader + m_reader->seek(m_length-m_position-len); + m_reader->read(len, buf); + + // set null if reader didn't give enough data + if(len < length) + { + if(getSpecs().format == AUD_FORMAT_U8) + memset(buffer, 0x80, (length-len)*samplesize); + else + memset(buffer, 0, (length-len)*samplesize); + buffer += length-len; + } + + // copy the samples reverted + for(int i = 0; i < len; i++) + memcpy(buffer + i * samplesize, + buf + (len - 1 - i) * samplesize, + samplesize); + + m_position += length; + + buffer = m_buffer->getBuffer(); +} diff --git a/intern/audaspace/FX/AUD_ReverseReader.h b/intern/audaspace/FX/AUD_ReverseReader.h new file mode 100644 index 00000000000..045d2ac5a8e --- /dev/null +++ b/intern/audaspace/FX/AUD_ReverseReader.h @@ -0,0 +1,74 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_REVERSEREADER +#define AUD_REVERSEREADER + +#include "AUD_EffectReader.h" +class AUD_Buffer; + +/** + * This class reads another reader from back to front. + * \note The underlying reader must be a buffer. + */ +class AUD_ReverseReader : public AUD_EffectReader +{ +private: + /** + * The current position. + */ + int m_position; + + /** + * The sample count. + */ + int m_length; + + /** + * The playback buffer. + */ + AUD_Buffer* m_buffer; + +public: + /** + * Creates a new reverse reader. + * \param reader The reader to read from. + * \exception AUD_Exception Thrown if the reader specified is NULL or not + * a buffer. + */ + AUD_ReverseReader(AUD_IReader* reader); + + /** + * Destroys the reader. + */ + virtual ~AUD_ReverseReader(); + + virtual void seek(int position); + virtual int getLength(); + virtual int getPosition(); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_REVERSEREADER diff --git a/intern/audaspace/FX/AUD_VolumeFactory.cpp b/intern/audaspace/FX/AUD_VolumeFactory.cpp new file mode 100644 index 00000000000..fbde608aa12 --- /dev/null +++ b/intern/audaspace/FX/AUD_VolumeFactory.cpp @@ -0,0 +1,57 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_VolumeFactory.h" +#include "AUD_VolumeReader.h" + +AUD_VolumeFactory::AUD_VolumeFactory(AUD_IFactory* factory, float volume) : + AUD_EffectFactory(factory), + m_volume(volume) {} + +AUD_VolumeFactory::AUD_VolumeFactory(float volume) : + AUD_EffectFactory(0), + m_volume(volume) {} + +float AUD_VolumeFactory::getVolume() +{ + return m_volume; +} + +void AUD_VolumeFactory::setVolume(float volume) +{ + m_volume = volume; +} + +AUD_IReader* AUD_VolumeFactory::createReader() +{ + AUD_IReader* reader = getReader(); + + if(reader != 0) + { + reader = new AUD_VolumeReader(reader, m_volume); AUD_NEW("reader") + } + + return reader; +} diff --git a/intern/audaspace/FX/AUD_VolumeFactory.h b/intern/audaspace/FX/AUD_VolumeFactory.h new file mode 100644 index 00000000000..d2812536d83 --- /dev/null +++ b/intern/audaspace/FX/AUD_VolumeFactory.h @@ -0,0 +1,72 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_VOLUMEFACTORY +#define AUD_VOLUMEFACTORY + +#include "AUD_EffectFactory.h" + +/** + * This factory changes the volume of another factory. + * The set volume should be a value between 0.0 and 1.0, higher values at your + * own risk! + */ +class AUD_VolumeFactory : public AUD_EffectFactory +{ +private: + /** + * The volume. + */ + float m_volume; + +public: + /** + * Creates a new volume factory. + * \param factory The input factory. + * \param volume The desired volume. + */ + AUD_VolumeFactory(AUD_IFactory* factory = 0, float volume = 1.0); + + /** + * Creates a new volume factory. + * \param volume The desired volume. + */ + AUD_VolumeFactory(float volume); + + /** + * Returns the volume. + */ + float getVolume(); + + /** + * Sets the volume. + * \param volume The new volume value. Should be between 0.0 and 1.0. + */ + void setVolume(float volume); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_VOLUMEFACTORY diff --git a/intern/audaspace/FX/AUD_VolumeReader.cpp b/intern/audaspace/FX/AUD_VolumeReader.cpp new file mode 100644 index 00000000000..fc3f20152a6 --- /dev/null +++ b/intern/audaspace/FX/AUD_VolumeReader.cpp @@ -0,0 +1,97 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_VolumeReader.h" +#include "AUD_Buffer.h" + +#include + +AUD_VolumeReader::AUD_VolumeReader(AUD_IReader* reader, float volume) : + AUD_EffectReader(reader), + m_volume(volume) +{ + int bigendian = 1; + bigendian = (((char*)&bigendian)[0]) ? 0: 1; // 1 if Big Endian + + switch(m_reader->getSpecs().format) + { + case AUD_FORMAT_S16: + m_adjust = AUD_volume_adjust; + break; + case AUD_FORMAT_S32: + m_adjust = AUD_volume_adjust; + break; + case AUD_FORMAT_FLOAT32: + m_adjust = AUD_volume_adjust; + break; + case AUD_FORMAT_FLOAT64: + m_adjust = AUD_volume_adjust; + break; + case AUD_FORMAT_U8: + m_adjust = AUD_volume_adjust_u8; + break; + case AUD_FORMAT_S24: + m_adjust = bigendian ? AUD_volume_adjust_s24_be : + AUD_volume_adjust_s24_le; + break; + default: + delete m_reader; + AUD_THROW(AUD_ERROR_READER); + } + + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") +} + +AUD_VolumeReader::~AUD_VolumeReader() +{ + delete m_buffer; AUD_DELETE("buffer") +} + +bool AUD_VolumeReader::notify(AUD_Message &message) +{ + if(message.type == AUD_MSG_VOLUME) + { + m_volume = message.volume; + + m_reader->notify(message); + + return true; + } + return m_reader->notify(message); +} + +void AUD_VolumeReader::read(int & length, sample_t* & buffer) +{ + sample_t* buf; + AUD_Specs specs = m_reader->getSpecs(); + + m_reader->read(length, buf); + if(m_buffer->getSize() < length*AUD_SAMPLE_SIZE(specs)) + m_buffer->resize(length*AUD_SAMPLE_SIZE(specs)); + + buffer = m_buffer->getBuffer(); + + m_adjust(buffer, buf, length * specs.channels, m_volume); +} diff --git a/intern/audaspace/FX/AUD_VolumeReader.h b/intern/audaspace/FX/AUD_VolumeReader.h new file mode 100644 index 00000000000..f38ae4d265c --- /dev/null +++ b/intern/audaspace/FX/AUD_VolumeReader.h @@ -0,0 +1,72 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_VOLUMEREADER +#define AUD_VOLUMEREADER + +#include "AUD_EffectReader.h" +#include "AUD_ConverterFunctions.h" +class AUD_Buffer; + +/** + * This class reads another reader and changes it's volume. + */ +class AUD_VolumeReader : public AUD_EffectReader +{ +private: + /** + * The playback buffer. + */ + AUD_Buffer *m_buffer; + + /** + * The volume level. + */ + float m_volume; + + /** + * Volume adjustment function. + */ + AUD_volume_adjust_f m_adjust; + +public: + /** + * Creates a new volume reader. + * \param reader The reader to read from. + * \param volume The size of the buffer. + * \exception AUD_Exception Thrown if the reader specified is NULL. + */ + AUD_VolumeReader(AUD_IReader* reader, float volume); + + /** + * Destroys the reader. + */ + virtual ~AUD_VolumeReader(); + + virtual bool notify(AUD_Message &message); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_VOLUMEREADER diff --git a/intern/SoundSystem/openal/Makefile b/intern/audaspace/FX/Makefile similarity index 84% rename from intern/SoundSystem/openal/Makefile rename to intern/audaspace/FX/Makefile index b28ab628d4c..bda0e2bdab6 100644 --- a/intern/SoundSystem/openal/Makefile +++ b/intern/audaspace/FX/Makefile @@ -28,17 +28,16 @@ # # -LIBNAME = OpenALSoundSystem -DIR = $(OCGDIR)/intern/$(LIBNAME) +LIBNAME = aud_fx +DIR = $(OCGDIR)/intern/audaspace include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) -CPPFLAGS += -I$(NAN_OPENAL)/include -CPPFLAGS += -I$(NAN_STRING)/include -CPPFLAGS += -I$(NAN_MOTO)/include +CPPFLAGS += -I../ffmpeg CPPFLAGS += -I../intern +CPPFLAGS += -I../SDL +CPPFLAGS += -I../SRC CPPFLAGS += -I.. CPPFLAGS += -I. -CPPFLAGS += -I../sdl diff --git a/intern/SoundSystem/Makefile b/intern/audaspace/Makefile similarity index 59% rename from intern/SoundSystem/Makefile rename to intern/audaspace/Makefile index 4d346f65138..2d66dcf67fa 100644 --- a/intern/SoundSystem/Makefile +++ b/intern/audaspace/Makefile @@ -32,39 +32,31 @@ include nan_definitions.mk -LIBNAME = SoundSystem -SOURCEDIR = intern/SoundSystem +LIBNAME = audaspace +SOURCEDIR = intern/audaspace DIR = $(OCGDIR)/$(SOURCEDIR) DIRS = intern -DIRS += dummy +DIRS += FX +DIRS += SDL +DIRS += SRC -ifneq ($(NAN_NO_OPENAL),true) - ifeq ($(OS),windows) - DIRS += openal sdl - endif - ifeq ($(OS),darwin) - DIRS += openal - endif - ifeq ($(OS),$(findstring $(OS), "linux freebsd solaris")) - DIRS += openal sdl - endif - ifeq ($(OS), irix) - DIRS += sdl - endif -else - export CPPFLAGS += -DNO_SOUND +ifeq ($(WITH_FFMPEG),true) + DIRS += ffmpeg endif include nan_subdirs.mk install: $(ALL_OR_DEBUG) - @[ -d $(NAN_SOUNDSYSTEM) ] || mkdir $(NAN_SOUNDSYSTEM) - @[ -d $(NAN_SOUNDSYSTEM)/include ] || mkdir $(NAN_SOUNDSYSTEM)/include - @[ -d $(NAN_SOUNDSYSTEM)/lib/$(DEBUG_DIR) ] || mkdir $(NAN_SOUNDSYSTEM)/lib/$(DEBUG_DIR) - @../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)libSoundSystem.a $(NAN_SOUNDSYSTEM)/lib/$(DEBUG_DIR) + @[ -d $(NAN_AUDASPACE) ] || mkdir $(NAN_AUDASPACE) + @[ -d $(NAN_AUDASPACE)/include ] || mkdir $(NAN_AUDASPACE)/include + @[ -d $(NAN_AUDASPACE)/lib/$(DEBUG_DIR) ] || mkdir $(NAN_AUDASPACE)/lib/$(DEBUG_DIR) + @../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)libaudaspace.a $(DIR)/$(DEBUG_DIR)libaud_fx.a $(DIR)/$(DEBUG_DIR)libaud_src.a $(NAN_AUDASPACE)/lib/$(DEBUG_DIR) + ifeq ($(OS),darwin) - ranlib $(NAN_SOUNDSYSTEM)/lib/$(DEBUG_DIR)libSoundSystem.a + ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaudaspace.a + ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_src.a + ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_fx.a endif - @../tools/cpifdiff.sh *.h $(NAN_SOUNDSYSTEM)/include/ + @../tools/cpifdiff.sh intern/*.h $(NAN_AUDASPACE)/include/ diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp new file mode 100644 index 00000000000..f94b11a11b8 --- /dev/null +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp @@ -0,0 +1,1362 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_OpenALDevice.h" +#include "AUD_IReader.h" +#include "AUD_IMixer.h" +#include "AUD_ConverterFactory.h" +#include "AUD_SourceCaps.h" + +#include +#include + +#ifdef WIN32 +#include +#else +#include +#endif + +#define AUD_OPENAL_CYCLE_BUFFERS 3 + +/// Saves the data for playback. +struct AUD_OpenALHandle : AUD_Handle +{ + /// Whether it's a buffered or a streamed source. + bool isBuffered; + + /// The reader source. + AUD_IReader* reader; + + /// Whether to keep the source if end of it is reached. + bool keep; + + /// OpenAL sample format. + ALenum format; + + /// OpenAL source. + ALuint source; + + /// OpenAL buffers. + ALuint buffers[AUD_OPENAL_CYCLE_BUFFERS]; + + /// The first buffer to be read next. + int current; + + /// Whether the stream doesn't return any more data. + bool data_end; +}; + +struct AUD_OpenALBufferedFactory +{ + /// The factory. + AUD_IFactory* factory; + + /// The OpenAL buffer. + ALuint buffer; +}; + +typedef std::list::iterator AUD_HandleIterator; +typedef std::list::iterator AUD_BFIterator; + +/******************************************************************************/ +/**************************** Threading Code **********************************/ +/******************************************************************************/ + +void* AUD_openalRunThread(void* device) +{ + AUD_OpenALDevice* dev = (AUD_OpenALDevice*)device; + dev->updateStreams(); + return NULL; +} + +void AUD_OpenALDevice::start() +{ + lock(); + + if(!m_playing) + { + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + + pthread_create(&m_thread, &attr, AUD_openalRunThread, this); + + pthread_attr_destroy(&attr); + + m_playing = true; + } + + unlock(); +} + +void AUD_OpenALDevice::updateStreams() +{ + AUD_OpenALHandle* sound; + + int length; + sample_t* buffer; + + ALint info; + AUD_Specs specs; + + while(1) + { + lock(); + + alcSuspendContext(m_context); + + // for all sounds + AUD_HandleIterator it = m_playingSounds->begin(); + while(it != m_playingSounds->end()) + { + sound = *it; + // increment the iterator to make sure it's valid, + // in case the sound gets deleted after stopping + ++it; + + // is it a streamed sound? + if(!sound->isBuffered) + { + // check for buffer refilling + alGetSourcei(sound->source, AL_BUFFERS_PROCESSED, &info); + + if(info) + { + specs = sound->reader->getSpecs(); + + // for all empty buffers + while(info--) + { + // if there's still data to play back + if(!sound->data_end) + { + // read data + length = m_buffersize; + sound->reader->read(length, buffer); + + // read nothing? + if(length == 0) + { + sound->data_end = true; + break; + } + + // unqueue buffer + alSourceUnqueueBuffers(sound->source, 1, + &sound->buffers[sound->current]); + ALenum err; + if((err = alGetError()) != AL_NO_ERROR) + { + sound->data_end = true; + break; + } + + // fill with new data + alBufferData(sound->buffers[sound->current], + sound->format, + buffer, + length * AUD_SAMPLE_SIZE(specs), + specs.rate); + + if(alGetError() != AL_NO_ERROR) + { + sound->data_end = true; + break; + } + + // and queue again + alSourceQueueBuffers(sound->source, 1, + &sound->buffers[sound->current]); + if(alGetError() != AL_NO_ERROR) + { + sound->data_end = true; + break; + } + + sound->current = (sound->current+1) % + AUD_OPENAL_CYCLE_BUFFERS; + } + else + break; + } + } + } + + // check if the sound has been stopped + alGetSourcei(sound->source, AL_SOURCE_STATE, &info); + + if(info != AL_PLAYING) + { + // if it really stopped + if(sound->data_end) + { + // pause or + if(sound->keep) + pause(sound); + // stop + else + stop(sound); + } + // continue playing + else + alSourcePlay(sound->source); + } + } + + alcProcessContext(m_context); + + // stop thread + if(m_playingSounds->empty()) + { + unlock(); + m_playing = false; + pthread_exit(NULL); + } + + unlock(); + +#ifdef WIN32 + Sleep(20); +#else + usleep(20000); +#endif + } +} + +/******************************************************************************/ +/**************************** IDevice Code ************************************/ +/******************************************************************************/ + +bool AUD_OpenALDevice::isValid(AUD_Handle* handle) +{ + for(AUD_HandleIterator i = m_playingSounds->begin(); + i != m_playingSounds->end(); i++) + if(*i == handle) + return true; + for(AUD_HandleIterator i = m_pausedSounds->begin(); + i != m_pausedSounds->end(); i++) + if(*i == handle) + return true; + return false; +} + +AUD_OpenALDevice::AUD_OpenALDevice(AUD_Specs specs, int buffersize) +{ + // cannot determine how many channels or which format OpenAL uses, but + // it at least is able to play 16 bit stereo audio + specs.channels = AUD_CHANNELS_STEREO; + specs.format = AUD_FORMAT_S16; + + m_device = alcOpenDevice(NULL); + + if(!m_device) + AUD_THROW(AUD_ERROR_OPENAL); + + // at least try to set the frequency + ALCint attribs[] = { ALC_FREQUENCY, specs.rate, 0 }; + ALCint* attributes = attribs; + if(specs.rate == AUD_RATE_INVALID) + attributes = NULL; + + m_context = alcCreateContext(m_device, attributes); + alcMakeContextCurrent(m_context); + + alcGetIntegerv(m_device, ALC_FREQUENCY, 1, (ALCint*)&specs.rate); + + // check for specific formats and channel counts to be played back + if(alIsExtensionPresent("AL_EXT_FLOAT32") == AL_TRUE) + specs.format = AUD_FORMAT_FLOAT32; + + m_useMC = alIsExtensionPresent("AL_EXT_MCFORMATS") == AL_TRUE; + + alGetError(); + + m_converter = new AUD_ConverterFactory(specs); AUD_NEW("factory") + + m_specs = specs; + m_buffersize = buffersize; + m_playing = false; + + m_playingSounds = new std::list(); AUD_NEW("list") + m_pausedSounds = new std::list(); AUD_NEW("list") + m_bufferedFactories = new std::list(); + AUD_NEW("list") + + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + + pthread_mutex_init(&m_mutex, &attr); + + pthread_mutexattr_destroy(&attr); +} + +AUD_OpenALDevice::~AUD_OpenALDevice() +{ + AUD_OpenALHandle* sound; + + lock(); + alcSuspendContext(m_context); + + // delete all playing sounds + while(!m_playingSounds->empty()) + { + sound = *(m_playingSounds->begin()); + alDeleteSources(1, &sound->source); + if(!sound->isBuffered) + { + delete sound->reader; AUD_DELETE("reader") + alDeleteBuffers(AUD_OPENAL_CYCLE_BUFFERS, sound->buffers); + } + delete sound; AUD_DELETE("handle") + m_playingSounds->erase(m_playingSounds->begin()); + } + + // delete all paused sounds + while(!m_pausedSounds->empty()) + { + sound = *(m_pausedSounds->begin()); + alDeleteSources(1, &sound->source); + if(!sound->isBuffered) + { + delete sound->reader; AUD_DELETE("reader") + alDeleteBuffers(AUD_OPENAL_CYCLE_BUFFERS, sound->buffers); + } + delete sound; AUD_DELETE("handle") + m_pausedSounds->erase(m_pausedSounds->begin()); + } + + // delete all buffered factories + while(!m_bufferedFactories->empty()) + { + alDeleteBuffers(1, &(*(m_bufferedFactories->begin()))->buffer); + delete *m_bufferedFactories->begin(); AUD_DELETE("bufferedfactory"); + m_bufferedFactories->erase(m_bufferedFactories->begin()); + } + + alcProcessContext(m_context); + + // wait for the thread to stop + if(m_playing) + { + unlock(); + pthread_join(m_thread, NULL); + } + else + unlock(); + + delete m_playingSounds; AUD_DELETE("list") + delete m_pausedSounds; AUD_DELETE("list") + delete m_bufferedFactories; AUD_DELETE("list") + + // quit OpenAL + alcMakeContextCurrent(NULL); + alcDestroyContext(m_context); + alcCloseDevice(m_device); + + delete m_converter; AUD_DELETE("factory") + + pthread_mutex_destroy(&m_mutex); +} + +AUD_Specs AUD_OpenALDevice::getSpecs() +{ + return m_specs; +} + +bool AUD_OpenALDevice::getFormat(ALenum &format, AUD_Specs specs) +{ + bool valid = true; + format = 0; + + switch(specs.format) + { + case AUD_FORMAT_U8: + switch(specs.channels) + { + case AUD_CHANNELS_MONO: + format = AL_FORMAT_MONO8; + break; + case AUD_CHANNELS_STEREO: + format = AL_FORMAT_STEREO8; + break; + case AUD_CHANNELS_SURROUND4: + if(m_useMC) + { + format = alGetEnumValue("AL_FORMAT_QUAD8"); + break; + } + case AUD_CHANNELS_SURROUND51: + if(m_useMC) + { + format = alGetEnumValue("AL_FORMAT_51CHN8"); + break; + } + case AUD_CHANNELS_SURROUND61: + if(m_useMC) + { + format = alGetEnumValue("AL_FORMAT_61CHN8"); + break; + } + case AUD_CHANNELS_SURROUND71: + if(m_useMC) + { + format = alGetEnumValue("AL_FORMAT_71CHN8"); + break; + } + default: + valid = false; + } + break; + case AUD_FORMAT_S16: + switch(specs.channels) + { + case AUD_CHANNELS_MONO: + format = AL_FORMAT_MONO16; + break; + case AUD_CHANNELS_STEREO: + format = AL_FORMAT_STEREO16; + break; + case AUD_CHANNELS_SURROUND4: + if(m_useMC) + { + format = alGetEnumValue("AL_FORMAT_QUAD16"); + break; + } + case AUD_CHANNELS_SURROUND51: + if(m_useMC) + { + format = alGetEnumValue("AL_FORMAT_51CHN16"); + break; + } + case AUD_CHANNELS_SURROUND61: + if(m_useMC) + { + format = alGetEnumValue("AL_FORMAT_61CHN16"); + break; + } + case AUD_CHANNELS_SURROUND71: + if(m_useMC) + { + format = alGetEnumValue("AL_FORMAT_71CHN16"); + break; + } + default: + valid = false; + } + break; + case AUD_FORMAT_FLOAT32: + switch(specs.channels) + { + case AUD_CHANNELS_MONO: + format = alGetEnumValue("AL_FORMAT_MONO_FLOAT32"); + break; + case AUD_CHANNELS_STEREO: + format = alGetEnumValue("AL_FORMAT_STEREO_FLOAT32"); + break; + case AUD_CHANNELS_SURROUND4: + if(m_useMC) + { + format = alGetEnumValue("AL_FORMAT_QUAD32"); + break; + } + case AUD_CHANNELS_SURROUND51: + if(m_useMC) + { + format = alGetEnumValue("AL_FORMAT_51CHN32"); + break; + } + case AUD_CHANNELS_SURROUND61: + if(m_useMC) + { + format = alGetEnumValue("AL_FORMAT_61CHN32"); + break; + } + case AUD_CHANNELS_SURROUND71: + if(m_useMC) + { + format = alGetEnumValue("AL_FORMAT_71CHN32"); + break; + } + default: + valid = false; + } + break; + default: + valid = false; + } + + if(!format) + valid = false; + + return valid; +} + +AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep) +{ + // check if it is a buffered factory + for(AUD_BFIterator i = m_bufferedFactories->begin(); + i != m_bufferedFactories->end(); i++) + { + if((*i)->factory == factory) + { + // create the handle + AUD_OpenALHandle* sound = new AUD_OpenALHandle; AUD_NEW("handle") + sound->keep = keep; + sound->current = -1; + sound->isBuffered = true; + sound->data_end = true; + + alcSuspendContext(m_context); + + // OpenAL playback code + try + { + alGenSources(1, &sound->source); + if(alGetError() != AL_NO_ERROR) + AUD_THROW(AUD_ERROR_OPENAL); + + try + { + alSourcei(sound->source, AL_BUFFER, (*i)->buffer); + if(alGetError() != AL_NO_ERROR) + AUD_THROW(AUD_ERROR_OPENAL); + } + catch(AUD_Exception e) + { + alDeleteSources(1, &sound->source); + throw; + } + } + catch(AUD_Exception e) + { + delete sound; AUD_DELETE("handle") + alcProcessContext(m_context); + unlock(); + throw; + } + + // play sound + m_playingSounds->push_back(sound); + + alSourcei(sound->source, AL_SOURCE_RELATIVE, 1); + start(); + + alcProcessContext(m_context); + unlock(); + + return sound; + } + } + + AUD_IReader* reader = factory->createReader(); + + if(reader == NULL) + AUD_THROW(AUD_ERROR_READER); + + AUD_Specs specs; + + specs = reader->getSpecs(); + + // check format + bool valid = true; + + if(specs.format == AUD_FORMAT_INVALID) + valid = false; + else if(specs.format == AUD_FORMAT_S24 || + specs.format == AUD_FORMAT_S32 || + specs.format == AUD_FORMAT_FLOAT32 || + specs.format == AUD_FORMAT_FLOAT64) + { + m_converter->setReader(reader); + reader = m_converter->createReader(); + specs = reader->getSpecs(); + } + + // create the handle + AUD_OpenALHandle* sound = new AUD_OpenALHandle; AUD_NEW("handle") + sound->keep = keep; + sound->reader = reader; + sound->current = 0; + sound->isBuffered = false; + sound->data_end = false; + + valid &= getFormat(sound->format, specs); + + if(!valid) + { + delete sound; AUD_DELETE("handle") + delete reader; AUD_DELETE("reader") + return NULL; + } + + lock(); + alcSuspendContext(m_context); + + // OpenAL playback code + try + { + alGenBuffers(AUD_OPENAL_CYCLE_BUFFERS, sound->buffers); + if(alGetError() != AL_NO_ERROR) + AUD_THROW(AUD_ERROR_OPENAL); + + try + { + sample_t* buf; + int length; + + for(int i = 0; i < AUD_OPENAL_CYCLE_BUFFERS; i++) + { + length = m_buffersize; + reader->read(length, buf); + alBufferData(sound->buffers[i], sound->format, buf, + length * AUD_SAMPLE_SIZE(specs), specs.rate); + if(alGetError() != AL_NO_ERROR) + AUD_THROW(AUD_ERROR_OPENAL); + } + + alGenSources(1, &sound->source); + if(alGetError() != AL_NO_ERROR) + AUD_THROW(AUD_ERROR_OPENAL); + + try + { + alSourceQueueBuffers(sound->source, AUD_OPENAL_CYCLE_BUFFERS, + sound->buffers); + if(alGetError() != AL_NO_ERROR) + AUD_THROW(AUD_ERROR_OPENAL); + } + catch(AUD_Exception e) + { + alDeleteSources(1, &sound->source); + throw; + } + } + catch(AUD_Exception e) + { + alDeleteBuffers(AUD_OPENAL_CYCLE_BUFFERS, sound->buffers); + throw; + } + } + catch(AUD_Exception e) + { + delete sound; AUD_DELETE("handle") + delete reader; AUD_DELETE("reader") + alcProcessContext(m_context); + unlock(); + throw; + } + + // play sound + m_playingSounds->push_back(sound); + alSourcei(sound->source, AL_SOURCE_RELATIVE, 1); + + start(); + + alcProcessContext(m_context); + unlock(); + + return sound; +} + +bool AUD_OpenALDevice::pause(AUD_Handle* handle) +{ + // only songs that are played can be paused + lock(); + for(AUD_HandleIterator i = m_playingSounds->begin(); + i != m_playingSounds->end(); i++) + { + if(*i == handle) + { + m_pausedSounds->push_back(*i); + alSourcePause((*i)->source); + m_playingSounds->erase(i); + unlock(); + return true; + } + } + unlock(); + return false; +} + +bool AUD_OpenALDevice::resume(AUD_Handle* handle) +{ + lock(); + + // only songs that are paused can be resumed + for(AUD_HandleIterator i = m_pausedSounds->begin(); + i != m_pausedSounds->end(); i++) + { + if(*i == handle) + { + m_playingSounds->push_back(*i); + start(); + m_pausedSounds->erase(i); + unlock(); + return true; + } + } + unlock(); + return false; +} + +bool AUD_OpenALDevice::stop(AUD_Handle* handle) +{ + AUD_OpenALHandle* sound; + + lock(); + for(AUD_HandleIterator i = m_playingSounds->begin(); + i != m_playingSounds->end(); i++) + { + if(*i == handle) + { + sound = *i; + alDeleteSources(1, &sound->source); + if(!sound->isBuffered) + { + delete sound->reader; AUD_DELETE("reader") + alDeleteBuffers(AUD_OPENAL_CYCLE_BUFFERS, sound->buffers); + } + delete *i; AUD_DELETE("handle") + m_playingSounds->erase(i); + unlock(); + return true; + } + } + for(AUD_HandleIterator i = m_pausedSounds->begin(); + i != m_pausedSounds->end(); i++) + { + if(*i == handle) + { + sound = *i; + alDeleteSources(1, &sound->source); + if(!sound->isBuffered) + { + delete sound->reader; AUD_DELETE("reader") + alDeleteBuffers(AUD_OPENAL_CYCLE_BUFFERS, sound->buffers); + } + delete *i; AUD_DELETE("handle") + m_pausedSounds->erase(i); + unlock(); + return true; + } + } + unlock(); + return false; +} + +bool AUD_OpenALDevice::setKeep(AUD_Handle* handle, bool keep) +{ + lock(); + if(isValid(handle)) + { + ((AUD_OpenALHandle*)handle)->keep = keep; + unlock(); + return true; + } + unlock(); + return false; +} + +bool AUD_OpenALDevice::sendMessage(AUD_Handle* handle, AUD_Message &message) +{ + lock(); + + bool result = false; + + if(handle == 0) + { + for(AUD_HandleIterator i = m_playingSounds->begin(); + i != m_playingSounds->end(); i++) + if(!(*i)->isBuffered) + result |= (*i)->reader->notify(message); + for(AUD_HandleIterator i = m_pausedSounds->begin(); + i != m_pausedSounds->end(); i++) + if(!(*i)->isBuffered) + result |= (*i)->reader->notify(message); + } + else if(isValid(handle)) + if(!((AUD_OpenALHandle*)handle)->isBuffered) + result = ((AUD_OpenALHandle*)handle)->reader->notify(message); + unlock(); + return result; +} + +bool AUD_OpenALDevice::seek(AUD_Handle* handle, float position) +{ + lock(); + + if(isValid(handle)) + { + AUD_OpenALHandle* alhandle = (AUD_OpenALHandle*)handle; + if(alhandle->isBuffered) + alSourcef(alhandle->source, AL_SEC_OFFSET, position); + else + { + alhandle->reader->seek((int)(position * + alhandle->reader->getSpecs().rate)); + alhandle->data_end = false; + + ALint info; + + alGetSourcei(alhandle->source, AL_SOURCE_STATE, &info); + + if(info != AL_PLAYING) + { + if(info != AL_STOPPED) + alSourceStop(alhandle->source); + + alSourceUnqueueBuffers(alhandle->source, + AUD_OPENAL_CYCLE_BUFFERS, + alhandle->buffers); + if(alGetError() == AL_NO_ERROR) + { + sample_t* buf; + int length; + AUD_Specs specs = alhandle->reader->getSpecs(); + + for(int i = 0; i < AUD_OPENAL_CYCLE_BUFFERS; i++) + { + length = m_buffersize; + alhandle->reader->read(length, buf); + alBufferData(alhandle->buffers[i], alhandle->format, + buf, length * AUD_SAMPLE_SIZE(specs), + specs.rate); + + if(alGetError() != AL_NO_ERROR) + break; + } + + alSourceQueueBuffers(alhandle->source, + AUD_OPENAL_CYCLE_BUFFERS, + alhandle->buffers); + } + + alSourceRewind(alhandle->source); + } + } + unlock(); + return true; + } + + unlock(); + return false; +} + +float AUD_OpenALDevice::getPosition(AUD_Handle* handle) +{ + lock(); + + float position = 0.0; + + if(isValid(handle)) + { + AUD_OpenALHandle* h = (AUD_OpenALHandle*)handle; + if(h->isBuffered) + alGetSourcef(h->source, AL_SEC_OFFSET, &position); + else + position = h->reader->getPosition() / + (float)h->reader->getSpecs().rate; + } + + unlock(); + return position; +} + +AUD_Status AUD_OpenALDevice::getStatus(AUD_Handle* handle) +{ + lock(); + for(AUD_HandleIterator i = m_playingSounds->begin(); + i != m_playingSounds->end(); i++) + { + if(*i == handle) + { + unlock(); + return AUD_STATUS_PLAYING; + } + } + for(AUD_HandleIterator i = m_pausedSounds->begin(); + i != m_pausedSounds->end(); i++) + { + if(*i == handle) + { + unlock(); + return AUD_STATUS_PAUSED; + } + } + unlock(); + return AUD_STATUS_INVALID; +} + +void AUD_OpenALDevice::lock() +{ + pthread_mutex_lock(&m_mutex); +} + +void AUD_OpenALDevice::unlock() +{ + pthread_mutex_unlock(&m_mutex); +} + +/******************************************************************************/ +/**************************** Capabilities Code *******************************/ +/******************************************************************************/ + +bool AUD_OpenALDevice::checkCapability(int capability) +{ + return capability == AUD_CAPS_3D_DEVICE || + capability == AUD_CAPS_VOLUME || + capability == AUD_CAPS_SOURCE_VOLUME || + capability == AUD_CAPS_SOURCE_PITCH || + capability == AUD_CAPS_BUFFERED_FACTORY; +} + +bool AUD_OpenALDevice::setCapability(int capability, void *value) +{ + switch(capability) + { + case AUD_CAPS_VOLUME: + alListenerf(AL_GAIN, *((float*)value)); + return true; + case AUD_CAPS_SOURCE_VOLUME: + { + AUD_SourceCaps* caps = (AUD_SourceCaps*) value; + lock(); + if(isValid(caps->handle)) + { + alSourcef(((AUD_OpenALHandle*)caps->handle)->source, + AL_GAIN, caps->value); + unlock(); + return true; + } + unlock(); + } + break; + case AUD_CAPS_SOURCE_PITCH: + { + AUD_SourceCaps* caps = (AUD_SourceCaps*) value; + lock(); + if(isValid(caps->handle)) + { + alSourcef(((AUD_OpenALHandle*)caps->handle)->source, + AL_PITCH, caps->value); + unlock(); + return true; + } + unlock(); + } + break; + case AUD_CAPS_BUFFERED_FACTORY: + { + AUD_IFactory* factory = (AUD_IFactory*) value; + + // load the factory into an OpenAL buffer + if(factory) + { + lock(); + for(AUD_BFIterator i = m_bufferedFactories->begin(); + i != m_bufferedFactories->end(); i++) + { + if((*i)->factory == factory) + { + unlock(); + return true; + } + } + unlock(); + + AUD_IReader* reader = factory->createReader(); + + if(reader == NULL) + return false; + + AUD_Specs specs; + + specs = reader->getSpecs(); + + // determine format + bool valid = reader->getType() == AUD_TYPE_BUFFER; + + if(valid) + { + if(specs.format == AUD_FORMAT_INVALID) + valid = false; + else if(specs.format == AUD_FORMAT_S24 || + specs.format == AUD_FORMAT_S32 || + specs.format == AUD_FORMAT_FLOAT32 || + specs.format == AUD_FORMAT_FLOAT64) + { + m_converter->setReader(reader); + reader = m_converter->createReader(); + specs = reader->getSpecs(); + } + } + + ALenum format; + + if(valid) + valid = getFormat(format, specs); + + if(!valid) + { + delete reader; AUD_DELETE("reader") + return false; + } + + // load into a buffer + lock(); + alcSuspendContext(m_context); + + AUD_OpenALBufferedFactory* bf = new AUD_OpenALBufferedFactory; + AUD_NEW("bufferedfactory"); + bf->factory = factory; + + try + { + alGenBuffers(1, &bf->buffer); + if(alGetError() != AL_NO_ERROR) + AUD_THROW(AUD_ERROR_OPENAL); + + try + { + sample_t* buf; + int length = reader->getLength(); + + reader->read(length, buf); + alBufferData(bf->buffer, format, buf, + length * AUD_SAMPLE_SIZE(specs), + specs.rate); + if(alGetError() != AL_NO_ERROR) + AUD_THROW(AUD_ERROR_OPENAL); + } + catch(AUD_Exception e) + { + alDeleteBuffers(1, &bf->buffer); + throw; + } + } + catch(AUD_Exception e) + { + delete bf; AUD_DELETE("bufferedfactory") + delete reader; AUD_DELETE("reader") + alcProcessContext(m_context); + unlock(); + return false; + } + + m_bufferedFactories->push_back(bf); + + alcProcessContext(m_context); + unlock(); + } + else + { + // stop all playing and paused buffered sources + lock(); + alcSuspendContext(m_context); + + AUD_OpenALHandle* sound; + AUD_HandleIterator it = m_playingSounds->begin(); + while(it != m_playingSounds->end()) + { + sound = *it; + ++it; + + if(sound->isBuffered) + stop(sound); + } + alcProcessContext(m_context); + + while(!m_bufferedFactories->empty()) + { + alDeleteBuffers(1, + &(*(m_bufferedFactories->begin()))->buffer); + delete *m_bufferedFactories->begin(); + AUD_DELETE("bufferedfactory"); + m_bufferedFactories->erase(m_bufferedFactories->begin()); + } + unlock(); + } + + return true; + } + break; + } + return false; +} + +bool AUD_OpenALDevice::getCapability(int capability, void *value) +{ + switch(capability) + { + case AUD_CAPS_VOLUME: + alGetListenerf(AL_GAIN, (float*)value); + return true; + case AUD_CAPS_SOURCE_VOLUME: + { + AUD_SourceCaps* caps = (AUD_SourceCaps*) value; + lock(); + if(isValid(caps->handle)) + { + alGetSourcef(((AUD_OpenALHandle*)caps->handle)->source, + AL_GAIN, &caps->value); + unlock(); + return true; + } + unlock(); + } + break; + case AUD_CAPS_SOURCE_PITCH: + { + AUD_SourceCaps* caps = (AUD_SourceCaps*) value; + lock(); + if(isValid(caps->handle)) + { + alGetSourcef(((AUD_OpenALHandle*)caps->handle)->source, + AL_PITCH, &caps->value); + unlock(); + return true; + } + unlock(); + } + break; + } + return false; +} + +/******************************************************************************/ +/**************************** 3D Device Code **********************************/ +/******************************************************************************/ + +AUD_Handle* AUD_OpenALDevice::play3D(AUD_IFactory* factory, bool keep) +{ + AUD_OpenALHandle* handle = (AUD_OpenALHandle*)play(factory, keep); + if(handle) + alSourcei(handle->source, AL_SOURCE_RELATIVE, 0); + return handle; +} + +bool AUD_OpenALDevice::updateListener(AUD_3DData &data) +{ + alListenerfv(AL_POSITION, (ALfloat*)data.position); + alListenerfv(AL_VELOCITY, (ALfloat*)data.velocity); + alListenerfv(AL_ORIENTATION, (ALfloat*)&(data.orientation[3])); + + return true; +} + +bool AUD_OpenALDevice::setSetting(AUD_3DSetting setting, float value) +{ + switch(setting) + { + case AUD_3DS_DISTANCE_MODEL: + if(value == AUD_DISTANCE_MODEL_NONE) + alDistanceModel(AL_NONE); + else if(value == AUD_DISTANCE_MODEL_INVERSE) + alDistanceModel(AL_INVERSE_DISTANCE); + else if(value == AUD_DISTANCE_MODEL_INVERSE_CLAMPED) + alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); + else if(value == AUD_DISTANCE_MODEL_LINEAR) + alDistanceModel(AL_LINEAR_DISTANCE); + else if(value == AUD_DISTANCE_MODEL_LINEAR_CLAMPED) + alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED); + else if(value == AUD_DISTANCE_MODEL_EXPONENT) + alDistanceModel(AL_EXPONENT_DISTANCE); + else if(value == AUD_DISTANCE_MODEL_EXPONENT_CLAMPED) + alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED); + else + return false; + return true; + case AUD_3DS_DOPPLER_FACTOR: + alDopplerFactor(value); + return true; + case AUD_3DS_SPEED_OF_SOUND: + alSpeedOfSound(value); + return true; + default: + return false; + } +} + +float AUD_OpenALDevice::getSetting(AUD_3DSetting setting) +{ + switch(setting) + { + case AUD_3DS_DISTANCE_MODEL: + switch(alGetInteger(AL_DISTANCE_MODEL)) + { + case AL_NONE: + return AUD_DISTANCE_MODEL_NONE; + case AL_INVERSE_DISTANCE: + return AUD_DISTANCE_MODEL_INVERSE; + case AL_INVERSE_DISTANCE_CLAMPED: + return AUD_DISTANCE_MODEL_INVERSE_CLAMPED; + case AL_LINEAR_DISTANCE: + return AUD_DISTANCE_MODEL_LINEAR; + case AL_LINEAR_DISTANCE_CLAMPED: + return AUD_DISTANCE_MODEL_LINEAR_CLAMPED; + case AL_EXPONENT_DISTANCE: + return AUD_DISTANCE_MODEL_EXPONENT; + case AL_EXPONENT_DISTANCE_CLAMPED: + return AUD_DISTANCE_MODEL_EXPONENT_CLAMPED; + } + case AUD_3DS_DOPPLER_FACTOR: + return alGetFloat(AL_DOPPLER_FACTOR); + case AUD_3DS_SPEED_OF_SOUND: + return alGetFloat(AL_SPEED_OF_SOUND); + default: + return std::numeric_limits::quiet_NaN(); + } +} + +bool AUD_OpenALDevice::updateSource(AUD_Handle* handle, AUD_3DData &data) +{ + lock(); + + if(isValid(handle)) + { + int source = ((AUD_OpenALHandle*)handle)->source; + alSourcefv(source, AL_POSITION, (ALfloat*)data.position); + alSourcefv(source, AL_VELOCITY, (ALfloat*)data.velocity); + alSourcefv(source, AL_DIRECTION, (ALfloat*)&(data.orientation[3])); + unlock(); + return true; + } + + unlock(); + return false; +} + +bool AUD_OpenALDevice::setSourceSetting(AUD_Handle* handle, + AUD_3DSourceSetting setting, + float value) +{ + lock(); + + bool result = false; + + if(isValid(handle)) + { + int source = ((AUD_OpenALHandle*)handle)->source; + + switch(setting) + { + case AUD_3DSS_CONE_INNER_ANGLE: + alSourcef(source, AL_CONE_INNER_ANGLE, value); + result = true; + break; + case AUD_3DSS_CONE_OUTER_ANGLE: + alSourcef(source, AL_CONE_OUTER_ANGLE, value); + result = true; + break; + case AUD_3DSS_CONE_OUTER_GAIN: + alSourcef(source, AL_CONE_OUTER_GAIN, value); + result = true; + break; + case AUD_3DSS_IS_RELATIVE: + alSourcei(source, AL_SOURCE_RELATIVE, value > 0.0); + result = true; + break; + case AUD_3DSS_MAX_DISTANCE: + alSourcef(source, AL_MAX_DISTANCE, value); + result = true; + break; + case AUD_3DSS_MAX_GAIN: + alSourcef(source, AL_MAX_GAIN, value); + result = true; + break; + case AUD_3DSS_MIN_GAIN: + alSourcef(source, AL_MIN_GAIN, value); + result = true; + break; + case AUD_3DSS_REFERENCE_DISTANCE: + alSourcef(source, AL_REFERENCE_DISTANCE, value); + result = true; + break; + case AUD_3DSS_ROLLOFF_FACTOR: + alSourcef(source, AL_ROLLOFF_FACTOR, value); + result = true; + break; + default: + break; + } + } + + unlock(); + return result; +} + +float AUD_OpenALDevice::getSourceSetting(AUD_Handle* handle, + AUD_3DSourceSetting setting) +{ + float result = std::numeric_limits::quiet_NaN();; + + lock(); + + if(isValid(handle)) + { + int source = ((AUD_OpenALHandle*)handle)->source; + + switch(setting) + { + case AUD_3DSS_CONE_INNER_ANGLE: + alGetSourcef(source, AL_CONE_INNER_ANGLE, &result); + break; + case AUD_3DSS_CONE_OUTER_ANGLE: + alGetSourcef(source, AL_CONE_OUTER_ANGLE, &result); + break; + case AUD_3DSS_CONE_OUTER_GAIN: + alGetSourcef(source, AL_CONE_OUTER_GAIN, &result); + break; + case AUD_3DSS_IS_RELATIVE: + { + ALint i; + alGetSourcei(source, AL_SOURCE_RELATIVE, &i); + result = i ? 1.0 : 0.0; + break; + } + case AUD_3DSS_MAX_DISTANCE: + alGetSourcef(source, AL_MAX_DISTANCE, &result); + break; + case AUD_3DSS_MAX_GAIN: + alGetSourcef(source, AL_MAX_GAIN, &result); + break; + case AUD_3DSS_MIN_GAIN: + alGetSourcef(source, AL_MIN_GAIN, &result); + break; + case AUD_3DSS_REFERENCE_DISTANCE: + alGetSourcef(source, AL_REFERENCE_DISTANCE, &result); + break; + case AUD_3DSS_ROLLOFF_FACTOR: + alGetSourcef(source, AL_ROLLOFF_FACTOR, &result); + break; + default: + break; + } + } + + unlock(); + return result; +} diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.h b/intern/audaspace/OpenAL/AUD_OpenALDevice.h new file mode 100644 index 00000000000..074cd3d1924 --- /dev/null +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.h @@ -0,0 +1,171 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_OPENALDEVICE +#define AUD_OPENALDEVICE + +#include "AUD_IDevice.h" +#include "AUD_I3DDevice.h" +struct AUD_OpenALHandle; +struct AUD_OpenALBufferedFactory; +class AUD_ConverterFactory; + +#include +#include +#include +#include + +/** + * This device plays through OpenAL. + */ +class AUD_OpenALDevice : public AUD_IDevice, public AUD_I3DDevice +{ +private: + /** + * The OpenAL device handle. + */ + ALCdevice* m_device; + + /** + * The OpenAL context. + */ + ALCcontext* m_context; + + /** + * The specification of the device. + */ + AUD_Specs m_specs; + + /** + * Whether the device has the AL_EXT_MCFORMATS extension. + */ + bool m_useMC; + + /** + * The converter factory for readers with wrong input format. + */ + AUD_ConverterFactory* m_converter; + + /** + * The list of sounds that are currently playing. + */ + std::list* m_playingSounds; + + /** + * The list of sounds that are currently paused. + */ + std::list* m_pausedSounds; + + /** + * The list of buffered factories. + */ + std::list* m_bufferedFactories; + + /** + * The mutex for locking. + */ + pthread_mutex_t m_mutex; + + /** + * The streaming thread. + */ + pthread_t m_thread; + + /** + * The condition for streaming thread wakeup. + */ + bool m_playing; + + /** + * Buffer size. + */ + int m_buffersize; + + /** + * Starts the streaming thread. + */ + void start(); + + /** + * Checks if a handle is valid. + * \param handle The handle to check. + * \return Whether the handle is valid. + */ + bool isValid(AUD_Handle* handle); + + /** + * Gets the format according to the specs. + * \param format The variable to put the format into. + * \param specs The specs to read the format from. + * \return Whether the format is valid or not. + */ + bool getFormat(ALenum &format, AUD_Specs specs); + +public: + /** + * Opens the OpenAL audio device for playback. + * \param specs The wanted audio specification. + * \param buffersize The size of the internal buffer. + * \note The specification really used for opening the device may differ. + * \note The buffersize will be multiplicated by three for this device. + * \exception AUD_Exception Thrown if the audio device cannot be opened. + */ + AUD_OpenALDevice(AUD_Specs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE); + + /** + * Streaming thread main function. + */ + void updateStreams(); + + virtual ~AUD_OpenALDevice(); + + virtual AUD_Specs getSpecs(); + virtual AUD_Handle* play(AUD_IFactory* factory, bool keep = false); + virtual bool pause(AUD_Handle* handle); + virtual bool resume(AUD_Handle* handle); + virtual bool stop(AUD_Handle* handle); + virtual bool setKeep(AUD_Handle* handle, bool keep); + virtual bool sendMessage(AUD_Handle* handle, AUD_Message &message); + virtual bool seek(AUD_Handle* handle, float position); + virtual float getPosition(AUD_Handle* handle); + virtual AUD_Status getStatus(AUD_Handle* handle); + virtual void lock(); + virtual void unlock(); + virtual bool checkCapability(int capability); + virtual bool setCapability(int capability, void *value); + virtual bool getCapability(int capability, void *value); + + virtual AUD_Handle* play3D(AUD_IFactory* factory, bool keep = false); + virtual bool updateListener(AUD_3DData &data); + virtual bool setSetting(AUD_3DSetting setting, float value); + virtual float getSetting(AUD_3DSetting setting); + virtual bool updateSource(AUD_Handle* handle, AUD_3DData &data); + virtual bool setSourceSetting(AUD_Handle* handle, + AUD_3DSourceSetting setting, float value); + virtual float getSourceSetting(AUD_Handle* handle, + AUD_3DSourceSetting setting); +}; + +#endif //AUD_OPENALDEVICE diff --git a/intern/audaspace/SConscript b/intern/audaspace/SConscript new file mode 100644 index 00000000000..caae070359a --- /dev/null +++ b/intern/audaspace/SConscript @@ -0,0 +1,29 @@ +#!/usr/bin/python + +Import ('env') + +sources = env.Glob('intern/*.cpp') + env.Glob('FX/*.cpp') + env.Glob('SRC/*.cpp') +incs = '. intern FX SRC ' + env['BF_PTHREADS_INC'] + ' ' + env['BF_LIBSAMPLERATE_INC'] +defs = [] + +if env['WITH_BF_FFMPEG']: + sources += env.Glob('ffmpeg/*.cpp') + incs += ' ffmpeg ' + env['BF_FFMPEG_INC'] + defs.append('WITH_FFMPEG') + +if env['WITH_BF_SDL']: + sources += env.Glob('SDL/*.cpp') + incs += ' SDL ' + env['BF_SDL_INC'] + defs.append('WITH_SDL') + +if env['WITH_BF_OPENAL']: + sources += env.Glob('OpenAL/*.cpp') + incs += ' OpenAL ' + env['BF_OPENAL_INC'] + defs.append('WITH_OPENAL') + +if env['WITH_BF_JACK']: + sources += env.Glob('jack/*.cpp') + incs += ' jack ' + env['BF_JACK_INC'] + defs.append('WITH_JACK') + +env.BlenderLib ('bf_audaspace', sources, Split(incs), defs, libtype=['intern'], priority = [25] ) diff --git a/intern/audaspace/SDL/AUD_SDLDevice.cpp b/intern/audaspace/SDL/AUD_SDLDevice.cpp new file mode 100644 index 00000000000..dd443e7f5c7 --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLDevice.cpp @@ -0,0 +1,90 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SDLMixer.h" +#include "AUD_SDLDevice.h" +#include "AUD_IReader.h" + +void AUD_SDLDevice::SDL_mix(void *data, Uint8* buffer, int length) +{ + AUD_SDLDevice* device = (AUD_SDLDevice*)data; + + device->mix((sample_t*)buffer, length/AUD_SAMPLE_SIZE(device->m_specs)); +} + +AUD_SDLDevice::AUD_SDLDevice(AUD_Specs specs, int buffersize) +{ + if(specs.channels == AUD_CHANNELS_INVALID) + specs.channels = AUD_CHANNELS_STEREO; + if(specs.format == AUD_FORMAT_INVALID) + specs.format = AUD_FORMAT_S16; + if(specs.rate == AUD_RATE_INVALID) + specs.rate = AUD_RATE_44100; + + m_specs = specs; + + SDL_AudioSpec format, obtained; + + format.freq = m_specs.rate; + if(m_specs.format == AUD_FORMAT_U8) + format.format = AUDIO_U8; + else + format.format = AUDIO_S16SYS; + format.channels = m_specs.channels; + format.samples = buffersize; + format.callback = AUD_SDLDevice::SDL_mix; + format.userdata = this; + + if(SDL_OpenAudio(&format, &obtained) != 0) + AUD_THROW(AUD_ERROR_SDL); + + m_specs.rate = (AUD_SampleRate)obtained.freq; + m_specs.channels = (AUD_Channels)obtained.channels; + if(obtained.format == AUDIO_U8) + m_specs.format = AUD_FORMAT_U8; + else if(obtained.format == AUDIO_S16LSB || obtained.format == AUDIO_S16MSB) + m_specs.format = AUD_FORMAT_S16; + else + AUD_THROW(AUD_ERROR_SDL); + + m_mixer = new AUD_SDLMixer(); AUD_NEW("mixer") + m_mixer->setSpecs(m_specs); + + create(); +} + +AUD_SDLDevice::~AUD_SDLDevice() +{ + lock(); + SDL_CloseAudio(); + unlock(); + + destroy(); +} + +void AUD_SDLDevice::playing(bool playing) +{ + SDL_PauseAudio(playing ? 0 : 1); +} diff --git a/intern/audaspace/SDL/AUD_SDLDevice.h b/intern/audaspace/SDL/AUD_SDLDevice.h new file mode 100644 index 00000000000..e2c6f7631b7 --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLDevice.h @@ -0,0 +1,66 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SDLDEVICE +#define AUD_SDLDEVICE + +#include "AUD_SoftwareDevice.h" + +#include + +/** + * This device plays back through SDL, the simple direct media layer. + */ +class AUD_SDLDevice : public AUD_SoftwareDevice +{ +private: + /** + * Mixes the next bytes into the buffer. + * \param data The SDL device. + * \param buffer The target buffer. + * \param length The length in bytes to be filled. + */ + static void SDL_mix(void *data, Uint8* buffer, int length); + +protected: + virtual void playing(bool playing); + +public: + /** + * Opens the SDL audio device for playback. + * \param specs The wanted audio specification. + * \param buffersize The size of the internal buffer. + * \note The specification really used for opening the device may differ. + * \exception AUD_Exception Thrown if the audio device cannot be opened. + */ + AUD_SDLDevice(AUD_Specs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE); + + /** + * Closes the SDL audio device. + */ + virtual ~AUD_SDLDevice(); +}; + +#endif //AUD_SDLDEVICE diff --git a/intern/audaspace/SDL/AUD_SDLMixer.cpp b/intern/audaspace/SDL/AUD_SDLMixer.cpp new file mode 100644 index 00000000000..cacc0c7063c --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLMixer.cpp @@ -0,0 +1,83 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SDLMixer.h" +#include "AUD_SDLMixerFactory.h" + +#include + +AUD_SDLMixer::AUD_SDLMixer() +{ + m_factory = NULL; +} + +AUD_SDLMixer::~AUD_SDLMixer() +{ + if(m_factory) + { + delete m_factory; AUD_DELETE("factory") + } +} + +AUD_IReader* AUD_SDLMixer::prepare(AUD_IReader* reader) +{ + m_factory->setReader(reader); + return m_factory->createReader(); +} + +void AUD_SDLMixer::setSpecs(AUD_Specs specs) +{ + m_samplesize = AUD_SAMPLE_SIZE(specs); + if(m_factory) + { + delete m_factory; AUD_DELETE("factory") + } + m_factory = new AUD_SDLMixerFactory(specs); AUD_NEW("factory") +} + +void AUD_SDLMixer::add(sample_t* buffer, AUD_Specs specs, int length, + float volume) +{ + AUD_SDLMixerBuffer buf; + buf.buffer = buffer; + buf.length = length; + buf.volume = volume; + m_buffers.push_back(buf); +} + +void AUD_SDLMixer::superpose(sample_t* buffer, int length, float volume) +{ + AUD_SDLMixerBuffer buf; + + while(!m_buffers.empty()) + { + buf = m_buffers.front(); + m_buffers.pop_front(); + SDL_MixAudio((Uint8*)buffer, + (Uint8*)buf.buffer, + buf.length * m_samplesize, + (int)(SDL_MIX_MAXVOLUME * volume * buf.volume)); + } +} diff --git a/intern/audaspace/SDL/AUD_SDLMixer.h b/intern/audaspace/SDL/AUD_SDLMixer.h new file mode 100644 index 00000000000..2cc4e51f66d --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLMixer.h @@ -0,0 +1,76 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SDLMIXER +#define AUD_SDLMIXER + +#include "AUD_IMixer.h" +class AUD_SDLMixerFactory; +#include + +struct AUD_SDLMixerBuffer +{ + sample_t* buffer; + int length; + float volume; +}; + +/** + * This class is able to mix audiosignals with the help of SDL. + */ +class AUD_SDLMixer : public AUD_IMixer +{ +private: + /** + * The mixer factory that prepares all readers for superposition. + */ + AUD_SDLMixerFactory* m_factory; + + /** + * The list of buffers to superpose. + */ + std::list m_buffers; + + /** + * The size of an output sample. + */ + int m_samplesize; + +public: + /** + * Creates the mixer. + */ + AUD_SDLMixer(); + + virtual ~AUD_SDLMixer(); + + virtual AUD_IReader* prepare(AUD_IReader* reader); + virtual void setSpecs(AUD_Specs specs); + virtual void add(sample_t* buffer, AUD_Specs specs, int length, + float volume); + virtual void superpose(sample_t* buffer, int length, float volume); +}; + +#endif //AUD_SDLMIXER diff --git a/intern/audaspace/SDL/AUD_SDLMixerFactory.cpp b/intern/audaspace/SDL/AUD_SDLMixerFactory.cpp new file mode 100644 index 00000000000..e0b0c7d3603 --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLMixerFactory.cpp @@ -0,0 +1,65 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SDLMixerFactory.h" +#include "AUD_SDLMixerReader.h" + +#include + +AUD_SDLMixerFactory::AUD_SDLMixerFactory(AUD_IReader* reader, AUD_Specs specs) : + AUD_MixerFactory(reader, specs) {} + +AUD_SDLMixerFactory::AUD_SDLMixerFactory(AUD_IFactory* factory, AUD_Specs specs) : + AUD_MixerFactory(factory, specs) {} + +AUD_SDLMixerFactory::AUD_SDLMixerFactory(AUD_Specs specs) : + AUD_MixerFactory(specs) {} + +AUD_IReader* AUD_SDLMixerFactory::createReader() +{ + AUD_IReader* reader = getReader(); + + if(reader != 0) + { + AUD_Specs specs = reader->getSpecs(); + if(memcmp(&m_specs, &specs, sizeof(AUD_Specs)) != 0) + { + try + { + reader = new AUD_SDLMixerReader(reader, m_specs); + AUD_NEW("reader") + } + catch(AUD_Exception e) + { + // return 0 in case SDL cannot mix the source + if(e.error != AUD_ERROR_SDL) + throw; + else + reader = NULL; + } + } + } + return reader; +} diff --git a/intern/audaspace/SDL/AUD_SDLMixerFactory.h b/intern/audaspace/SDL/AUD_SDLMixerFactory.h new file mode 100644 index 00000000000..44b36d06859 --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLMixerFactory.h @@ -0,0 +1,45 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SDLMIXERFACTORY +#define AUD_SDLMIXERFACTORY + +#include "AUD_MixerFactory.h" + +/** + * This factory creates a resampling reader that uses SDL's resampling + * functionality which unfortunately is very very very limited. + */ +class AUD_SDLMixerFactory : public AUD_MixerFactory +{ +public: + AUD_SDLMixerFactory(AUD_IReader* reader, AUD_Specs specs); + AUD_SDLMixerFactory(AUD_IFactory* factory, AUD_Specs specs); + AUD_SDLMixerFactory(AUD_Specs specs); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_SDLMIXERFACTORY diff --git a/intern/audaspace/SDL/AUD_SDLMixerReader.cpp b/intern/audaspace/SDL/AUD_SDLMixerReader.cpp new file mode 100644 index 00000000000..ec61f99f02d --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLMixerReader.cpp @@ -0,0 +1,216 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SDLMixerReader.h" +#include "AUD_Buffer.h" + +#include + +inline Uint16 AUD_TO_SDL(AUD_SampleFormat format) +{ + // SDL only supports 8 and 16 bit audio + switch(format) + { + case AUD_FORMAT_U8: + return AUDIO_U8; + case AUD_FORMAT_S16: + return AUDIO_S16SYS; + default: + AUD_THROW(AUD_ERROR_SDL); + } +} + +// greatest common divisor +inline int gcd(int a, int b) +{ + int c; + + // make sure a is the bigger + if(b > a) + { + c = b; + b = a; + a = c; + } + + // greetings from Euclides + while(b != 0) + { + c = a % b; + a = b; + b = c; + } + return a; +} + +AUD_SDLMixerReader::AUD_SDLMixerReader(AUD_IReader* reader, + AUD_Specs specs) +{ + if(reader == NULL) + AUD_THROW(AUD_ERROR_READER); + + m_reader = reader; + m_tspecs = specs; + m_sspecs = reader->getSpecs(); + + try + { + // SDL only supports 8 and 16 bit sample formats + if(SDL_BuildAudioCVT(&m_cvt, + AUD_TO_SDL(m_sspecs.format), + m_sspecs.channels, + m_sspecs.rate, + AUD_TO_SDL(specs.format), + specs.channels, + specs.rate) == -1) + AUD_THROW(AUD_ERROR_SDL); + } + catch(AUD_Exception e) + { + delete m_reader; AUD_DELETE("reader") + throw; + } + + m_eor = false; + m_rsposition = 0; + m_rssize = 0; + m_ssize = m_sspecs.rate / gcd(specs.rate, m_sspecs.rate); + m_tsize = m_tspecs.rate * m_ssize / m_sspecs.rate; + + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") + m_rsbuffer = new AUD_Buffer(); AUD_NEW("buffer") +} + +AUD_SDLMixerReader::~AUD_SDLMixerReader() +{ + delete m_reader; AUD_DELETE("reader") + delete m_buffer; AUD_DELETE("buffer") + delete m_rsbuffer; AUD_DELETE("buffer") +} + +bool AUD_SDLMixerReader::isSeekable() +{ + return m_reader->isSeekable(); +} + +void AUD_SDLMixerReader::seek(int position) +{ + m_reader->seek(position * m_ssize / m_tsize); + m_eor = false; +} + +int AUD_SDLMixerReader::getLength() +{ + return m_reader->getLength() * m_tsize / m_ssize; +} + +int AUD_SDLMixerReader::getPosition() +{ + return m_reader->getPosition() * m_tsize / m_ssize; +} + +AUD_Specs AUD_SDLMixerReader::getSpecs() +{ + return m_tspecs; +} + +AUD_ReaderType AUD_SDLMixerReader::getType() +{ + return m_reader->getType(); +} + +bool AUD_SDLMixerReader::notify(AUD_Message &message) +{ + return m_reader->notify(message); +} + +void AUD_SDLMixerReader::read(int & length, sample_t* & buffer) +{ + // sample count for the target buffer without getting a shift + int tns = length + m_tsize - length % m_tsize; + // sample count for the source buffer without getting a shift + int sns = tns * m_ssize / m_tsize; + // target sample size + int tss = AUD_SAMPLE_SIZE(m_tspecs); + // source sample size + int sss = AUD_SAMPLE_SIZE(m_sspecs); + + // input is output buffer + int buf_size = AUD_MAX(tns*tss, sns*sss); + + // resize if necessary + if(m_rsbuffer->getSize() < buf_size) + m_rsbuffer->resize(buf_size, true); + + if(m_buffer->getSize() < length*tss) + m_buffer->resize(length*tss); + + buffer = m_buffer->getBuffer(); + int size; + int index = 0; + sample_t* buf; + + while(index < length) + { + if(m_rsposition == m_rssize) + { + // no more data + if(m_eor) + length = index; + // mix + else + { + // read from source + size = sns; + m_reader->read(size, buf); + + // prepare + m_cvt.buf = m_rsbuffer->getBuffer(); + m_cvt.len = size*sss; + memcpy(m_cvt.buf, buf, size*sss); + + // convert + SDL_ConvertAudio(&m_cvt); + + // end of reader + if(size < sns) + m_eor = true; + + m_rsposition = 0; + m_rssize = size * m_tsize / m_ssize; + } + } + + // size to copy + size = AUD_MIN(m_rssize-m_rsposition, length-index); + + // copy + memcpy(m_buffer->getBuffer() + index * tss, + m_rsbuffer->getBuffer() + m_rsposition * tss, + size*tss); + m_rsposition += size; + index += size; + } +} diff --git a/intern/audaspace/SDL/AUD_SDLMixerReader.h b/intern/audaspace/SDL/AUD_SDLMixerReader.h new file mode 100644 index 00000000000..56668d02171 --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLMixerReader.h @@ -0,0 +1,128 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SDLMIXERREADER +#define AUD_SDLMIXERREADER + +#include "AUD_IReader.h" +class AUD_Buffer; + +#include + +/** + * This class mixes a sound source with help of the SDL library. + * Unfortunately SDL is only capable of 8 and 16 bit audio, mono and stereo, as + * well as resampling only 2^n sample rate relationships where n is a natural + * number. + * \warning Although SDL can only resample 2^n sample rate relationships, this + * class doesn't check for compliance, so in case of other factors, + * the behaviour is undefined. + */ +class AUD_SDLMixerReader : public AUD_IReader +{ +private: + /** + * The reader that is being mixed. + */ + AUD_IReader* m_reader; + + /** + * The current reading position in the resampling buffer. + */ + int m_rsposition; + + /** + * The count of mixed samples in the resampling buffer. + */ + int m_rssize; + + /** + * The smallest count of source samples to get a fractionless resampling + * factor. + */ + int m_ssize; + + /** + * The smallest count of target samples to get a fractionless resampling + * factor. + */ + int m_tsize; + + /** + * The sound output buffer. + */ + AUD_Buffer *m_buffer; + + /** + * The resampling buffer. + */ + AUD_Buffer *m_rsbuffer; + + /** + * The target specification. + */ + AUD_Specs m_tspecs; + + /** + * The sample specification of the source. + */ + AUD_Specs m_sspecs; + + /** + * Saves whether the end of the source has been reached. + */ + bool m_eor; + + /** + * The SDL_AudioCVT structure used for resampling. + */ + SDL_AudioCVT m_cvt; + +public: + /** + * Creates a resampling reader. + * \param reader The reader to mix. + * \param specs The target specification. + * \exception AUD_Exception Thrown if the source specification cannot be + * mixed to the target specification or if the reader is + * NULL. + */ + AUD_SDLMixerReader(AUD_IReader* reader, AUD_Specs specs); + /** + * Destroys the reader. + */ + ~AUD_SDLMixerReader(); + + virtual bool isSeekable(); + virtual void seek(int position); + virtual int getLength(); + virtual int getPosition(); + virtual AUD_Specs getSpecs(); + virtual AUD_ReaderType getType(); + virtual bool notify(AUD_Message &message); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_SDLMIXERREADER diff --git a/intern/SoundSystem/sdl/Makefile b/intern/audaspace/SDL/Makefile similarity index 92% rename from intern/SoundSystem/sdl/Makefile rename to intern/audaspace/SDL/Makefile index 669d7110797..e36b2de41fe 100644 --- a/intern/SoundSystem/sdl/Makefile +++ b/intern/audaspace/SDL/Makefile @@ -28,7 +28,7 @@ # # -LIBNAME = SDLSoundSystem +LIBNAME = aud_sdl DIR = $(OCGDIR)/intern/$(LIBNAME) include nan_compile.mk @@ -36,8 +36,6 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CPPFLAGS += $(NAN_SDLCFLAGS) -CPPFLAGS += -I$(NAN_STRING)/include -CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../intern CPPFLAGS += -I.. CPPFLAGS += -I. diff --git a/intern/audaspace/SRC/AUD_SRCResampleFactory.cpp b/intern/audaspace/SRC/AUD_SRCResampleFactory.cpp new file mode 100644 index 00000000000..bcace340b24 --- /dev/null +++ b/intern/audaspace/SRC/AUD_SRCResampleFactory.cpp @@ -0,0 +1,53 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SRCResampleFactory.h" +#include "AUD_SRCResampleReader.h" + +AUD_SRCResampleFactory::AUD_SRCResampleFactory(AUD_IReader* reader, + AUD_Specs specs) : + AUD_ResampleFactory(reader, specs) {} + +AUD_SRCResampleFactory::AUD_SRCResampleFactory(AUD_IFactory* factory, + AUD_Specs specs) : + AUD_ResampleFactory(factory, specs) {} + +AUD_SRCResampleFactory::AUD_SRCResampleFactory(AUD_Specs specs) : + AUD_ResampleFactory(specs) {} + +AUD_IReader* AUD_SRCResampleFactory::createReader() +{ + AUD_IReader* reader = getReader(); + + if(reader != 0) + { + if(reader->getSpecs().rate != m_specs.rate) + { + reader = new AUD_SRCResampleReader(reader, m_specs); + AUD_NEW("reader") + } + } + return reader; +} diff --git a/intern/audaspace/SRC/AUD_SRCResampleFactory.h b/intern/audaspace/SRC/AUD_SRCResampleFactory.h new file mode 100644 index 00000000000..c23c1d2c82e --- /dev/null +++ b/intern/audaspace/SRC/AUD_SRCResampleFactory.h @@ -0,0 +1,46 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SRCRESAMPLEFACTORY +#define AUD_SRCRESAMPLEFACTORY + +#include "AUD_ResampleFactory.h" + +/** + * This factory creates a resampling reader that uses libsamplerate for + * resampling. + * \note The format of the input must be float. + */ +class AUD_SRCResampleFactory : public AUD_ResampleFactory +{ +public: + AUD_SRCResampleFactory(AUD_IReader* reader, AUD_Specs specs); + AUD_SRCResampleFactory(AUD_IFactory* factory, AUD_Specs specs); + AUD_SRCResampleFactory(AUD_Specs specs); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_SRCRESAMPLEFACTORY diff --git a/intern/audaspace/SRC/AUD_SRCResampleReader.cpp b/intern/audaspace/SRC/AUD_SRCResampleReader.cpp new file mode 100644 index 00000000000..f7564d3c010 --- /dev/null +++ b/intern/audaspace/SRC/AUD_SRCResampleReader.cpp @@ -0,0 +1,119 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SRCResampleReader.h" +#include "AUD_Buffer.h" + +#include +#include +#include + +static long src_callback(void *cb_data, float **data) +{ + return ((AUD_SRCResampleReader*)cb_data)->doCallback(data); +} + +AUD_SRCResampleReader::AUD_SRCResampleReader(AUD_IReader* reader, + AUD_Specs specs) : + AUD_EffectReader(reader) +{ + m_sspecs = reader->getSpecs(); + + if(m_sspecs.format != AUD_FORMAT_FLOAT32) + { + delete m_reader; AUD_DELETE("reader") + AUD_THROW(AUD_ERROR_READER); + } + + m_tspecs = specs; + m_tspecs.channels = m_sspecs.channels; + m_tspecs.format = m_sspecs.format; + m_factor = (double)m_tspecs.rate / (double)m_sspecs.rate; + + int error; + m_src = src_callback_new(src_callback, + SRC_SINC_MEDIUM_QUALITY, + m_sspecs.channels, + &error, + this); + + if(!m_src) + { + // XXX printf("%s\n", src_strerror(error)); + delete m_reader; AUD_DELETE("reader") + AUD_THROW(AUD_ERROR_READER); + } + + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") +} + +AUD_SRCResampleReader::~AUD_SRCResampleReader() +{ + delete m_buffer; AUD_DELETE("buffer") + + src_delete(m_src); +} + +long AUD_SRCResampleReader::doCallback(float** data) +{ + int length = m_buffer->getSize() / 4 / m_tspecs.channels; + sample_t* buffer; + + m_reader->read(length, buffer); + + *data = (float*)buffer; + return length; +} + +void AUD_SRCResampleReader::seek(int position) +{ + m_reader->seek(position / m_factor); + src_reset(m_src); +} + +int AUD_SRCResampleReader::getLength() +{ + return m_reader->getLength() * m_factor; +} + +int AUD_SRCResampleReader::getPosition() +{ + return m_reader->getPosition() * m_factor; +} + +AUD_Specs AUD_SRCResampleReader::getSpecs() +{ + return m_tspecs; +} + +void AUD_SRCResampleReader::read(int & length, sample_t* & buffer) +{ + if(m_buffer->getSize() < length * m_tspecs.channels * 4) + m_buffer->resize(length * m_tspecs.channels * 4); + + buffer = m_buffer->getBuffer(); + + length = src_callback_read(m_src, m_factor, length, (float*)buffer); +} diff --git a/intern/audaspace/SRC/AUD_SRCResampleReader.h b/intern/audaspace/SRC/AUD_SRCResampleReader.h new file mode 100644 index 00000000000..1bacdb3965c --- /dev/null +++ b/intern/audaspace/SRC/AUD_SRCResampleReader.h @@ -0,0 +1,102 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SRCRESAMPLEREADER +#define AUD_SRCRESAMPLEREADER + +#include "AUD_EffectReader.h" +class AUD_Buffer; + +#include + +/** + * This class mixes a sound source with help of the SDL library. + * Unfortunately SDL is only capable of 8 and 16 bit audio, mono and stereo, as + * well as resampling only 2^n sample rate relationships where n is a natural + * number. + * \warning Although SDL can only resample 2^n sample rate relationships, this + * class doesn't check for compliance, so in case of other factors, + * the behaviour is undefined. + */ +class AUD_SRCResampleReader : public AUD_EffectReader +{ +private: + /** + * The resampling factor. + */ + double m_factor; + + /** + * The sound output buffer. + */ + AUD_Buffer *m_buffer; + + /** + * The target specification. + */ + AUD_Specs m_tspecs; + + /** + * The sample specification of the source. + */ + AUD_Specs m_sspecs; + + /** + * The src state structure. + */ + SRC_STATE* m_src; + +public: + /** + * Creates a resampling reader. + * \param reader The reader to mix. + * \param specs The target specification. + * \exception AUD_Exception Thrown if the source specification cannot be + * mixed to the target specification or if the reader is + * NULL. + */ + AUD_SRCResampleReader(AUD_IReader* reader, AUD_Specs specs); + + /** + * Destroys the reader. + */ + ~AUD_SRCResampleReader(); + + /** + * The callback function for SRC. + * \warning Do not call! + * \param data The pointer to the float data. + * \return The count of samples in the float data. + */ + long doCallback(float** data); + + virtual void seek(int position); + virtual int getLength(); + virtual int getPosition(); + virtual AUD_Specs getSpecs(); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_SRCRESAMPLEREADER diff --git a/intern/SoundSystem/intern/Makefile b/intern/audaspace/SRC/Makefile similarity index 82% rename from intern/SoundSystem/intern/Makefile rename to intern/audaspace/SRC/Makefile index 7684b6b0bca..5cf5f55b11f 100644 --- a/intern/SoundSystem/intern/Makefile +++ b/intern/audaspace/SRC/Makefile @@ -28,17 +28,17 @@ # # -LIBNAME = SoundSystem -DIR = $(OCGDIR)/intern/SoundSystem +LIBNAME = aud_src +DIR = $(OCGDIR)/intern/audaspace include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) -CPPFLAGS += -I$(NAN_STRING)/include -CPPFLAGS += -I$(NAN_MOTO)/include -CPPFLAGS += -I../../../source/blender/include -CPPFLAGS += -I../dummy -CPPFLAGS += -I../openal +CPPFLAGS += -I$(LCGDIR)/samplerate/include/ +CPPFLAGS += -I../ffmpeg +CPPFLAGS += -I../FX +CPPFLAGS += -I../SDL +CPPFLAGS += -I../intern CPPFLAGS += -I.. CPPFLAGS += -I. diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp new file mode 100644 index 00000000000..5f9006b0ec0 --- /dev/null +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp @@ -0,0 +1,88 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_FFMPEGFactory.h" +#include "AUD_FFMPEGReader.h" +#include "AUD_Space.h" + +extern "C" { +#include +} + +AUD_FFMPEGFactory::AUD_FFMPEGFactory(const char* filename) +{ + if(filename != 0) + { + m_filename = new char[strlen(filename)+1]; AUD_NEW("string") + strcpy(m_filename, filename); + } + else + m_filename = 0; + m_buffer = 0; + m_size = 0; +} + +AUD_FFMPEGFactory::AUD_FFMPEGFactory(unsigned char* buffer, int size) +{ + m_filename = 0; + m_buffer = (unsigned char*)av_malloc(size); AUD_NEW("buffer") + m_size = size; + memcpy(m_buffer, buffer, size); +} + +AUD_FFMPEGFactory::~AUD_FFMPEGFactory() +{ + if(m_filename) + { + delete[] m_filename; AUD_DELETE("string") + } + if(m_buffer) + { + av_free(m_buffer); AUD_DELETE("buffer") + } +} + +AUD_IReader* AUD_FFMPEGFactory::createReader() +{ + try + { + AUD_IReader* reader; + if(m_filename) + reader = new AUD_FFMPEGReader(m_filename); + else + reader = new AUD_FFMPEGReader(m_buffer, m_size); + AUD_NEW("reader") + return reader; + } + catch(AUD_Exception e) + { + // return 0 if ffmpeg cannot read the file + if(e.error == AUD_ERROR_FFMPEG) + return 0; + // but throw an exception if the file doesn't exist + else + throw; + } +} diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h new file mode 100644 index 00000000000..0a9fcc22c8b --- /dev/null +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h @@ -0,0 +1,76 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_FFMPEGFACTORY +#define AUD_FFMPEGFACTORY + +#include "AUD_IFactory.h" + +/** + * This factory reads a sound file via ffmpeg. + * \warning Notice that the needed formats and codecs have to be registered + * for ffmpeg before this class can be used. + */ +class AUD_FFMPEGFactory : public AUD_IFactory +{ +private: + /** + * The filename of the sound source file. + */ + char* m_filename; + + /** + * The buffer to read from. + */ + unsigned char* m_buffer; + + /** + * The size of the buffer. + */ + int m_size; + +public: + /** + * Creates a new factory. + * \param filename The sound file path. + */ + AUD_FFMPEGFactory(const char* filename); + + /** + * Creates a new factory. + * \param buffer The buffer to read from. + * \param size The size of the buffer. + */ + AUD_FFMPEGFactory(unsigned char* buffer, int size); + + /** + * Destroys the factory. + */ + ~AUD_FFMPEGFactory(); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_FFMPEGFACTORY diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp new file mode 100644 index 00000000000..b79375c2dc5 --- /dev/null +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp @@ -0,0 +1,388 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +// needed for INT64_C +#define __STDC_CONSTANT_MACROS + +#include "AUD_FFMPEGReader.h" +#include "AUD_Buffer.h" + +extern "C" { +#include +#include +} + +// This function transforms a FFMPEG SampleFormat to our own sample format +static inline AUD_SampleFormat FFMPEG_TO_AUD(SampleFormat fmt) +{ + switch(fmt) + { + case SAMPLE_FMT_U8: + return AUD_FORMAT_U8; + case SAMPLE_FMT_S16: + return AUD_FORMAT_S16; + case SAMPLE_FMT_S32: + return AUD_FORMAT_S32; + case SAMPLE_FMT_FLT: + return AUD_FORMAT_FLOAT32; + case SAMPLE_FMT_DBL: + return AUD_FORMAT_FLOAT64; + default: + return AUD_FORMAT_INVALID; + } +} + +int AUD_FFMPEGReader::decode(AVPacket* packet, AUD_Buffer* buffer) +{ + // save packet parameters + uint8_t *audio_pkg_data = packet->data; + int audio_pkg_size = packet->size; + + int buf_size = buffer->getSize(); + int buf_pos = 0; + + int read_length, data_size; + + // as long as there is still data in the package + while(audio_pkg_size > 0) + { + // resize buffer if needed + if(buf_size - buf_pos < AVCODEC_MAX_AUDIO_FRAME_SIZE) + { + buffer->resize(buf_size + AVCODEC_MAX_AUDIO_FRAME_SIZE, true); + buf_size += AVCODEC_MAX_AUDIO_FRAME_SIZE; + } + + // read samples from the packet + data_size = buf_size - buf_pos; + /*read_length = avcodec_decode_audio3(m_codecCtx, + (int16_t*)(buffer->getBuffer()+buf_pos), + &data_size, + packet);*/ + read_length = avcodec_decode_audio2(m_codecCtx, + (int16_t*)(buffer->getBuffer()+buf_pos), + &data_size, + audio_pkg_data, + audio_pkg_size); + + buf_pos += data_size; + + // read error, next packet! + if(read_length < 0) + break; + + // move packet parameters + audio_pkg_data += read_length; + audio_pkg_size -= read_length; + } + + return buf_pos; +} + +AUD_FFMPEGReader::AUD_FFMPEGReader(const char* filename) +{ + m_position = 0; + m_pkgbuf_left = 0; + m_byteiocontext = NULL; + + // open file + if(av_open_input_file(&m_formatCtx, filename, NULL, 0, NULL)!=0) + AUD_THROW(AUD_ERROR_FILE); + + try + { + if(av_find_stream_info(m_formatCtx)<0) + AUD_THROW(AUD_ERROR_FFMPEG); + + // find audio stream and codec + m_stream = -1; + + for(int i = 0; i < m_formatCtx->nb_streams; i++) + if((m_formatCtx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) + && (m_stream < 0)) + { + m_stream=i; + break; + } + if(m_stream == -1) + AUD_THROW(AUD_ERROR_FFMPEG); + + m_codecCtx = m_formatCtx->streams[m_stream]->codec; + + // get a decoder and open it + AVCodec *aCodec = avcodec_find_decoder(m_codecCtx->codec_id); + if(!aCodec) + AUD_THROW(AUD_ERROR_FFMPEG); + + if(avcodec_open(m_codecCtx, aCodec)<0) + AUD_THROW(AUD_ERROR_FFMPEG); + + // XXX this prints file information to stdout: + //dump_format(m_formatCtx, 0, filename, 0); + + m_specs.channels = (AUD_Channels) m_codecCtx->channels; + m_specs.format = FFMPEG_TO_AUD(m_codecCtx->sample_fmt); + m_specs.rate = (AUD_SampleRate) m_codecCtx->sample_rate; + } + catch(AUD_Exception e) + { + av_close_input_file(m_formatCtx); + throw; + } + + // last but not least if there hasn't been any error, create the buffers + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") + m_pkgbuf = new AUD_Buffer(AVCODEC_MAX_AUDIO_FRAME_SIZE<<1); + AUD_NEW("buffer") +} + +AUD_FFMPEGReader::AUD_FFMPEGReader(unsigned char* buffer, int size) +{ + m_position = 0; + m_pkgbuf_left = 0; + m_byteiocontext = (ByteIOContext*)av_mallocz(sizeof(ByteIOContext)); + AUD_NEW("byteiocontext") + + if(init_put_byte(m_byteiocontext, buffer, size, 0, + NULL, NULL, NULL, NULL) != 0) + AUD_THROW(AUD_ERROR_FILE); + + AVProbeData probe_data; + probe_data.filename = ""; + probe_data.buf = buffer; + probe_data.buf_size = size; + AVInputFormat* fmt = av_probe_input_format(&probe_data, 1); + + // open stream + if(av_open_input_stream(&m_formatCtx, m_byteiocontext, "", fmt, NULL)!=0) + AUD_THROW(AUD_ERROR_FILE); + + try + { + if(av_find_stream_info(m_formatCtx)<0) + AUD_THROW(AUD_ERROR_FFMPEG); + + // find audio stream and codec + m_stream = -1; + + for(int i = 0; i < m_formatCtx->nb_streams; i++) + if((m_formatCtx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) + && (m_stream < 0)) + { + m_stream=i; + break; + } + if(m_stream == -1) + AUD_THROW(AUD_ERROR_FFMPEG); + + m_codecCtx = m_formatCtx->streams[m_stream]->codec; + + // get a decoder and open it + AVCodec *aCodec = avcodec_find_decoder(m_codecCtx->codec_id); + if(!aCodec) + AUD_THROW(AUD_ERROR_FFMPEG); + + if(avcodec_open(m_codecCtx, aCodec)<0) + AUD_THROW(AUD_ERROR_FFMPEG); + + // XXX this prints stream information to stdout: + //dump_format(m_formatCtx, 0, NULL, 0); + + m_specs.channels = (AUD_Channels) m_codecCtx->channels; + m_specs.format = FFMPEG_TO_AUD(m_codecCtx->sample_fmt); + m_specs.rate = (AUD_SampleRate) m_codecCtx->sample_rate; + } + catch(AUD_Exception e) + { + av_close_input_stream(m_formatCtx); + av_free(m_byteiocontext); AUD_DELETE("byteiocontext") + throw; + } + + // last but not least if there hasn't been any error, create the buffers + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") + m_pkgbuf = new AUD_Buffer(AVCODEC_MAX_AUDIO_FRAME_SIZE<<1); + AUD_NEW("buffer") +} + +AUD_FFMPEGReader::~AUD_FFMPEGReader() +{ + avcodec_close(m_codecCtx); + + if(m_byteiocontext) + { + av_close_input_stream(m_formatCtx); + av_free(m_byteiocontext); AUD_DELETE("byteiocontext") + } + else + av_close_input_file(m_formatCtx); + + delete m_buffer; AUD_DELETE("buffer") + delete m_pkgbuf; AUD_DELETE("buffer") +} + +bool AUD_FFMPEGReader::isSeekable() +{ + return true; +} + +void AUD_FFMPEGReader::seek(int position) +{ + if(position >= 0) + { + // a value < 0 tells us that seeking failed + if(av_seek_frame(m_formatCtx, + -1, + (uint64_t)(((uint64_t)position * + (uint64_t)AV_TIME_BASE) / + (uint64_t)m_specs.rate), + AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_ANY) >= 0) + { + avcodec_flush_buffers(m_codecCtx); + m_position = position; + + AVPacket packet; + bool search = true; + + while(search && av_read_frame(m_formatCtx, &packet) >= 0) + { + // is it a frame from the audio stream? + if(packet.stream_index == m_stream) + { + // decode the package + m_pkgbuf_left = decode(&packet, m_pkgbuf); + search = false; + + // check position + if(packet.pts != AV_NOPTS_VALUE) + { + // calculate real position, and read to frame! + m_position = packet.pts * + av_q2d(m_formatCtx->streams[m_stream]->time_base) * + m_specs.rate; + + if(m_position < position) + { + sample_t* buf; + int length = position - m_position; + read(length, buf); + } + } + } + av_free_packet(&packet); + } + } + else + { + // Seeking failed, do nothing. + } + } +} + +int AUD_FFMPEGReader::getLength() +{ + // return approximated remaning size + return (int)((m_formatCtx->duration * m_codecCtx->sample_rate) + / AV_TIME_BASE)-m_position; +} + +int AUD_FFMPEGReader::getPosition() +{ + return m_position; +} + +AUD_Specs AUD_FFMPEGReader::getSpecs() +{ + return m_specs; +} + +AUD_ReaderType AUD_FFMPEGReader::getType() +{ + return AUD_TYPE_STREAM; +} + +bool AUD_FFMPEGReader::notify(AUD_Message &message) +{ + return false; +} + +void AUD_FFMPEGReader::read(int & length, sample_t* & buffer) +{ + // read packages and decode them + AVPacket packet; + int data_size = 0; + int pkgbuf_size = m_pkgbuf->getSize(); + int pkgbuf_pos; + int left = length; + int sample_size = AUD_SAMPLE_SIZE(m_specs); + + // resize output buffer if necessary + if(m_buffer->getSize() < length*sample_size) + m_buffer->resize(length*sample_size); + + buffer = m_buffer->getBuffer(); + pkgbuf_pos = m_pkgbuf_left; + m_pkgbuf_left = 0; + + // there may still be data in the buffer from the last call + if(pkgbuf_pos > 0) + { + data_size = AUD_MIN(pkgbuf_pos, left * sample_size); + memcpy(buffer, m_pkgbuf->getBuffer(), data_size); + buffer += data_size; + left -= data_size/sample_size; + } + + // for each frame read as long as there isn't enough data already + while((left > 0) && (av_read_frame(m_formatCtx, &packet) >= 0)) + { + // is it a frame from the audio stream? + if(packet.stream_index == m_stream) + { + // decode the package + pkgbuf_pos = decode(&packet, m_pkgbuf); + + // copy to output buffer + data_size = AUD_MIN(pkgbuf_pos, left * sample_size); + memcpy(buffer, m_pkgbuf->getBuffer(), data_size); + buffer += data_size; + left -= data_size/sample_size; + } + av_free_packet(&packet); + } + // read more data than necessary? + if(pkgbuf_pos > data_size) + { + m_pkgbuf_left = pkgbuf_pos-data_size; + memmove(m_pkgbuf->getBuffer(), m_pkgbuf->getBuffer()+data_size, + pkgbuf_pos-data_size); + } + + buffer = m_buffer->getBuffer(); + + if(left > 0) + length -= left; + m_position += length; +} diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h new file mode 100644 index 00000000000..645f5f356f0 --- /dev/null +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h @@ -0,0 +1,133 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_FFMPEGREADER +#define AUD_FFMPEGREADER + +#include "AUD_IReader.h" +class AUD_Buffer; +struct AVCodecContext; +extern "C" { +#include +} + +/** + * This class reads a sound file via ffmpeg. + * \warning Seeking may not be accurate! Moreover the position is updated after + * a buffer reading call. So calling getPosition right after seek + * normally results in a wrong value. + * \warning Playback of an ogg with some outdated ffmpeg versions results in a + * segfault on windows. + */ +class AUD_FFMPEGReader : public AUD_IReader +{ +private: + /** + * The current position in samples. + */ + int m_position; + + /** + * The playback buffer. + */ + AUD_Buffer *m_buffer; + + /** + * The specification of the audio data. + */ + AUD_Specs m_specs; + + /** + * The buffer for package reading. + */ + AUD_Buffer *m_pkgbuf; + + /** + * The count of samples still available from the last read package. + */ + int m_pkgbuf_left; + + /** + * The AVFormatContext structure for using ffmpeg. + */ + AVFormatContext* m_formatCtx; + + /** + * The AVCodecContext structure for using ffmpeg. + */ + AVCodecContext* m_codecCtx; + + /** + * The ByteIOContext to read the data from. + */ + ByteIOContext* m_byteiocontext; + + /** + * The stream ID in the file. + */ + int m_stream; + + /** + * Decodes a packet into the given buffer. + * \param packet The AVPacket to decode. + * \param buffer The target buffer. + * \return The count of read bytes. + */ + int decode(AVPacket* packet, AUD_Buffer* buffer); + +public: + /** + * Creates a new reader. + * \param filename The path to the file to be read. + * \exception AUD_Exception Thrown if the file specified does not exist or + * cannot be read with ffmpeg. + */ + AUD_FFMPEGReader(const char* filename); + + /** + * Creates a new reader. + * \param buffer The buffer to read from. + * \param size The size of the buffer. + * \exception AUD_Exception Thrown if the buffer specified cannot be read + * with ffmpeg. + */ + AUD_FFMPEGReader(unsigned char* buffer, int size); + + /** + * Destroys the reader and closes the file. + */ + virtual ~AUD_FFMPEGReader(); + + virtual bool isSeekable(); + virtual void seek(int position); + virtual int getLength(); + virtual int getPosition(); + virtual AUD_Specs getSpecs(); + virtual AUD_ReaderType getType(); + virtual bool notify(AUD_Message &message); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_FFMPEGREADER diff --git a/intern/SoundSystem/dummy/Makefile b/intern/audaspace/ffmpeg/Makefile similarity index 91% rename from intern/SoundSystem/dummy/Makefile rename to intern/audaspace/ffmpeg/Makefile index 829135dde98..0bfe6494559 100644 --- a/intern/SoundSystem/dummy/Makefile +++ b/intern/audaspace/ffmpeg/Makefile @@ -28,15 +28,14 @@ # # -LIBNAME = DummySoundSystem +LIBNAME = aud_ffmpeg DIR = $(OCGDIR)/intern/$(LIBNAME) include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) -CPPFLAGS += -I$(NAN_STRING)/include -CPPFLAGS += -I$(NAN_MOTO)/include +CPPFLAGS += $(NAN_FFMPEGCFLAGS) CPPFLAGS += -I../intern CPPFLAGS += -I.. CPPFLAGS += -I. diff --git a/intern/audaspace/intern/AUD_Buffer.cpp b/intern/audaspace/intern/AUD_Buffer.cpp new file mode 100644 index 00000000000..71deae0e87e --- /dev/null +++ b/intern/audaspace/intern/AUD_Buffer.cpp @@ -0,0 +1,67 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_Buffer.h" +#include "AUD_Space.h" + +#include +#include + +#define AUD_ALIGN(a) (a + 16 - ((long)a & 15)) + +AUD_Buffer::AUD_Buffer(int size) +{ + m_size = size; + m_buffer = (sample_t*) malloc(size+16); AUD_NEW("buffer") +} + +AUD_Buffer::~AUD_Buffer() +{ + free(m_buffer); AUD_DELETE("buffer") +} + +sample_t* AUD_Buffer::getBuffer() +{ + return AUD_ALIGN(m_buffer); +} + +int AUD_Buffer::getSize() +{ + return m_size; +} + +void AUD_Buffer::resize(int size, bool keep) +{ + sample_t* buffer = (sample_t*) malloc(size+16); AUD_NEW("buffer") + + // copy old data over if wanted + if(keep) + memcpy(AUD_ALIGN(buffer), AUD_ALIGN(m_buffer), AUD_MIN(size, m_size)); + + free(m_buffer); AUD_DELETE("buffer") + + m_buffer = buffer; + m_size = size; +} diff --git a/intern/audaspace/intern/AUD_Buffer.h b/intern/audaspace/intern/AUD_Buffer.h new file mode 100644 index 00000000000..64959b03799 --- /dev/null +++ b/intern/audaspace/intern/AUD_Buffer.h @@ -0,0 +1,75 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_BUFFER +#define AUD_BUFFER + +#include "AUD_Space.h" + +/** + * This class is a simple buffer in RAM which is 16 Byte aligned and provides + * resize functionality. + */ +class AUD_Buffer +{ +private: + /// The size of the buffer in bytes. + int m_size; + + /// The pointer to the buffer memory. + sample_t* m_buffer; + +public: + /** + * Creates a new buffer. + * \param size The size of the buffer in bytes. + */ + AUD_Buffer(int size = 0); + + /** + * Destroys the buffer. + */ + ~AUD_Buffer(); + + /** + * Returns the pointer to the buffer in memory. + */ + sample_t* getBuffer(); + + /** + * Returns the size of the buffer in bytes. + */ + int getSize(); + + /** + * Resizes the buffer. + * \param size The new size of the buffer, measured in bytes. + * \param keep Whether to keep the old data. If the new buffer is smaller, + * the data at the end will be lost. + */ + void resize(int size, bool keep = false); +}; + +#endif //AUD_BUFFER diff --git a/intern/audaspace/intern/AUD_BufferReader.cpp b/intern/audaspace/intern/AUD_BufferReader.cpp new file mode 100644 index 00000000000..47bf5d3d171 --- /dev/null +++ b/intern/audaspace/intern/AUD_BufferReader.cpp @@ -0,0 +1,91 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_BufferReader.h" +#include "AUD_Buffer.h" +#include "AUD_Space.h" + +AUD_BufferReader::AUD_BufferReader(AUD_Reference buffer, + AUD_Specs specs) +{ + m_position = 0; + m_buffer = buffer; + m_specs = specs; +} + +bool AUD_BufferReader::isSeekable() +{ + return true; +} + +void AUD_BufferReader::seek(int position) +{ + if(position < 0) + m_position = 0; + else if(position > m_buffer.get()->getSize() / AUD_SAMPLE_SIZE(m_specs)) + m_position = m_buffer.get()->getSize() / AUD_SAMPLE_SIZE(m_specs); + else + m_position = position; +} + +int AUD_BufferReader::getLength() +{ + return m_buffer.get()->getSize()/AUD_SAMPLE_SIZE(m_specs); +} + +int AUD_BufferReader::getPosition() +{ + return m_position; +} + +AUD_Specs AUD_BufferReader::getSpecs() +{ + return m_specs; +} + +AUD_ReaderType AUD_BufferReader::getType() +{ + return AUD_TYPE_BUFFER; +} + +bool AUD_BufferReader::notify(AUD_Message &message) +{ + return false; +} + +void AUD_BufferReader::read(int & length, sample_t* & buffer) +{ + int sample_size = AUD_SAMPLE_SIZE(m_specs); + + buffer = m_buffer.get()->getBuffer()+m_position*sample_size; + + // in case the end of the buffer is reach + if(m_buffer.get()->getSize() < (m_position+length)*sample_size) + length = m_buffer.get()->getSize()/sample_size-m_position; + + if(length < 0) + length = 0; + m_position += length; +} diff --git a/intern/audaspace/intern/AUD_BufferReader.h b/intern/audaspace/intern/AUD_BufferReader.h new file mode 100644 index 00000000000..f2d8ff6b57d --- /dev/null +++ b/intern/audaspace/intern/AUD_BufferReader.h @@ -0,0 +1,74 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_BUFFERREADER +#define AUD_BUFFERREADER + +#include "AUD_IReader.h" +#include "AUD_Reference.h" +class AUD_Buffer; + +/** + * This class represents a simple reader from a buffer that exists in memory. + * \warning Notice that the buffer used for creating the reader must exist as + * long as the reader exists. + */ +class AUD_BufferReader : public AUD_IReader +{ +private: + /** + * The current position in the buffer. + */ + int m_position; + + /** + * The buffer that is read. + */ + AUD_Reference m_buffer; + + /** + * The specification of the sample data in the buffer. + */ + AUD_Specs m_specs; + +public: + /** + * Creates a new buffer reader. + * \param buffer The buffer to read from. + * \param specs The specification of the sample data in the buffer. + */ + AUD_BufferReader(AUD_Reference buffer, AUD_Specs specs); + + virtual bool isSeekable(); + virtual void seek(int position); + virtual int getLength(); + virtual int getPosition(); + virtual AUD_Specs getSpecs(); + virtual AUD_ReaderType getType(); + virtual bool notify(AUD_Message &message); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_BUFFERREADER diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp new file mode 100644 index 00000000000..d2c8e94c949 --- /dev/null +++ b/intern/audaspace/intern/AUD_C-API.cpp @@ -0,0 +1,568 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_NULLDevice.h" +#include "AUD_I3DDevice.h" +#include "AUD_StreamBufferFactory.h" +#include "AUD_DelayFactory.h" +#include "AUD_LimiterFactory.h" +#include "AUD_PingPongFactory.h" +#include "AUD_LoopFactory.h" +#include "AUD_ReadDevice.h" +#include "AUD_SourceCaps.h" +#include "AUD_IReader.h" + +#ifdef WITH_SDL +#include "AUD_SDLDevice.h" +#include "AUD_FloatMixer.h" +#endif + +#ifdef WITH_OPENAL +#include "AUD_OpenALDevice.h" +#endif + +#ifdef WITH_JACK +#include "AUD_JackDevice.h" +#endif + +#ifdef WITH_FFMPEG +#include "AUD_FFMPEGFactory.h" +extern "C" { +#include +} +#endif + +#include + +typedef AUD_IFactory AUD_Sound; +typedef AUD_ReadDevice AUD_Device; + +#define AUD_CAPI_IMPLEMENTATION +#include "AUD_C-API.h" + +#ifndef NULL +#define NULL 0 +#endif + +static AUD_IDevice* AUD_device = NULL; +static int AUD_available_devices[3]; +static AUD_I3DDevice* AUD_3ddevice = NULL; + +int AUD_init(AUD_DeviceType device, AUD_Specs specs, int buffersize) +{ +#ifdef WITH_FFMPEG + av_register_all(); +#endif + AUD_IDevice* dev = NULL; + + try + { + switch(device) + { + case AUD_NULL_DEVICE: + dev = new AUD_NULLDevice(); + break; +#ifdef WITH_SDL + case AUD_SDL_DEVICE: + { + dev = new AUD_SDLDevice(specs, buffersize); + AUD_FloatMixer* mixer = new AUD_FloatMixer(); + ((AUD_SDLDevice*)dev)->setMixer(mixer); + break; + } +#endif +#ifdef WITH_OPENAL + case AUD_OPENAL_DEVICE: + dev = new AUD_OpenALDevice(specs, buffersize); + break; +#endif +#ifdef WITH_JACK + case AUD_JACK_DEVICE: + dev = new AUD_JackDevice(specs); + break; +#endif + default: + return false; + } + + if(AUD_device) + AUD_exit(); + + AUD_device = dev; + if(AUD_device->checkCapability(AUD_CAPS_3D_DEVICE)) + AUD_3ddevice = dynamic_cast(AUD_device); + + return true; + } + catch(AUD_Exception e) + { + return false; + } +} + +int* AUD_enumDevices() +{ + int i = 0; +#ifdef WITH_SDL + AUD_available_devices[i++] = AUD_SDL_DEVICE; +#endif +#ifdef WITH_OPENAL + AUD_available_devices[i++] = AUD_OPENAL_DEVICE; +#endif +#ifdef WITH_JACK + AUD_available_devices[i++] = AUD_JACK_DEVICE; +#endif + AUD_available_devices[i++] = AUD_NULL_DEVICE; + return AUD_available_devices; +} + +void AUD_exit() +{ + if(AUD_device) + { + delete AUD_device; + AUD_device = NULL; + AUD_3ddevice = NULL; + } +} + +void AUD_lock() +{ + assert(AUD_device); + AUD_device->lock(); +} + +void AUD_unlock() +{ + assert(AUD_device); + AUD_device->unlock(); +} + +AUD_SoundInfo AUD_getInfo(AUD_Sound* sound) +{ + assert(sound); + + AUD_IReader* reader = sound->createReader(); + + AUD_SoundInfo info; + + if(reader) + { + info.specs = reader->getSpecs(); + info.length = reader->getLength() / (float) info.specs.rate; + } + else + { + info.specs.channels = AUD_CHANNELS_INVALID; + info.specs.format = AUD_FORMAT_INVALID; + info.specs.rate = AUD_RATE_INVALID; + info.length = 0.0; + } + + return info; +} + +AUD_Sound* AUD_load(const char* filename) +{ + assert(filename); +#ifdef WITH_FFMPEG + return new AUD_FFMPEGFactory(filename); +#else + return NULL; +#endif +} + +AUD_Sound* AUD_loadBuffer(unsigned char* buffer, int size) +{ + assert(buffer); +#ifdef WITH_FFMPEG + return new AUD_FFMPEGFactory(buffer, size); +#else + return NULL; +#endif +} + +AUD_Sound* AUD_bufferSound(AUD_Sound* sound) +{ + assert(sound); + + try + { + return new AUD_StreamBufferFactory(sound); + } + catch(AUD_Exception e) + { + return NULL; + } +} + +AUD_Sound* AUD_delaySound(AUD_Sound* sound, float delay) +{ + assert(sound); + + try + { + return new AUD_DelayFactory(sound, delay); + } + catch(AUD_Exception e) + { + return NULL; + } +} + +extern AUD_Sound* AUD_limitSound(AUD_Sound* sound, float start, float end) +{ + assert(sound); + + try + { + return new AUD_LimiterFactory(sound, start, end); + } + catch(AUD_Exception e) + { + return NULL; + } +} + +AUD_Sound* AUD_pingpongSound(AUD_Sound* sound) +{ + assert(sound); + + try + { + return new AUD_PingPongFactory(sound); + } + catch(AUD_Exception e) + { + return NULL; + } +} + +AUD_Sound* AUD_loopSound(AUD_Sound* sound) +{ + assert(sound); + + try + { + return new AUD_LoopFactory(sound); + } + catch(AUD_Exception e) + { + return NULL; + } +} + +int AUD_stopLoop(AUD_Handle* handle) +{ + if(handle) + { + AUD_Message message; + message.type = AUD_MSG_LOOP; + message.loopcount = 0; + + try + { + return AUD_device->sendMessage(handle, message); + } + catch(AUD_Exception e) + { + } + } + return false; +} + +void AUD_unload(AUD_Sound* sound) +{ + assert(sound); + delete sound; +} + +AUD_Handle* AUD_play(AUD_Sound* sound, int keep) +{ + assert(AUD_device); + assert(sound); + try + { + return AUD_device->play(sound, keep); + } + catch(AUD_Exception e) + { + return NULL; + } +} + +int AUD_pause(AUD_Handle* handle) +{ + assert(AUD_device); + return AUD_device->pause(handle); +} + +int AUD_resume(AUD_Handle* handle) +{ + assert(AUD_device); + return AUD_device->resume(handle); +} + +int AUD_stop(AUD_Handle* handle) +{ + if(AUD_device) + return AUD_device->stop(handle); + return false; +} + +int AUD_setKeep(AUD_Handle* handle, int keep) +{ + assert(AUD_device); + return AUD_device->setKeep(handle, keep); +} + +int AUD_seek(AUD_Handle* handle, float seekTo) +{ + assert(AUD_device); + return AUD_device->seek(handle, seekTo); +} + +float AUD_getPosition(AUD_Handle* handle) +{ + assert(AUD_device); + return AUD_device->getPosition(handle); +} + +AUD_Status AUD_getStatus(AUD_Handle* handle) +{ + assert(AUD_device); + return AUD_device->getStatus(handle); +} + +AUD_Handle* AUD_play3D(AUD_Sound* sound, int keep) +{ + assert(AUD_device); + assert(sound); + + try + { + if(AUD_3ddevice) + return AUD_3ddevice->play3D(sound, keep); + else + return AUD_device->play(sound, keep); + } + catch(AUD_Exception e) + { + return NULL; + } +} + +int AUD_updateListener(AUD_3DData* data) +{ + assert(AUD_device); + assert(data); + + try + { + if(AUD_3ddevice) + return AUD_3ddevice->updateListener(*data); + } + catch(AUD_Exception e) + { + } + return false; +} + +int AUD_set3DSetting(AUD_3DSetting setting, float value) +{ + assert(AUD_device); + + try + { + if(AUD_3ddevice) + return AUD_3ddevice->setSetting(setting, value); + } + catch(AUD_Exception e) + { + } + return false; +} + +float AUD_get3DSetting(AUD_3DSetting setting) +{ + assert(AUD_device); + + try + { + if(AUD_3ddevice) + return AUD_3ddevice->getSetting(setting); + } + catch(AUD_Exception e) + { + } + return 0.0; +} + +int AUD_update3DSource(AUD_Handle* handle, AUD_3DData* data) +{ + if(handle) + { + assert(AUD_device); + assert(data); + + try + { + if(AUD_3ddevice) + return AUD_3ddevice->updateSource(handle, *data); + } + catch(AUD_Exception e) + { + } + } + return false; +} + +int AUD_set3DSourceSetting(AUD_Handle* handle, + AUD_3DSourceSetting setting, float value) +{ + if(handle) + { + assert(AUD_device); + + try + { + if(AUD_3ddevice) + return AUD_3ddevice->setSourceSetting(handle, setting, value); + } + catch(AUD_Exception e) + { + } + } + return false; +} + +float AUD_get3DSourceSetting(AUD_Handle* handle, AUD_3DSourceSetting setting) +{ + if(handle) + { + assert(AUD_device); + + try + { + if(AUD_3ddevice) + return AUD_3ddevice->getSourceSetting(handle, setting); + } + catch(AUD_Exception e) + { + } + } + return 0.0; +} + +int AUD_setSoundVolume(AUD_Handle* handle, float volume) +{ + if(handle) + { + assert(AUD_device); + AUD_SourceCaps caps; + caps.handle = handle; + caps.value = volume; + + try + { + return AUD_device->setCapability(AUD_CAPS_SOURCE_VOLUME, &caps); + } + catch(AUD_Exception e) {} + } + return false; +} + +int AUD_setSoundPitch(AUD_Handle* handle, float pitch) +{ + if(handle) + { + assert(AUD_device); + AUD_SourceCaps caps; + caps.handle = handle; + caps.value = pitch; + + try + { + return AUD_device->setCapability(AUD_CAPS_SOURCE_PITCH, &caps); + } + catch(AUD_Exception e) {} + } + return false; +} + +AUD_Device* AUD_openReadDevice(AUD_Specs specs) +{ + try + { + return new AUD_ReadDevice(specs); + } + catch(AUD_Exception e) + { + return NULL; + } +} + +int AUD_playDevice(AUD_Device* device, AUD_Sound* sound) +{ + assert(device); + assert(sound); + + try + { + return device->play(sound) != NULL; + } + catch(AUD_Exception e) + { + return false; + } +} + +int AUD_readDevice(AUD_Device* device, sample_t* buffer, int length) +{ + assert(device); + assert(buffer); + + try + { + return device->read(buffer, length); + } + catch(AUD_Exception e) + { + return false; + } +} + +void AUD_closeReadDevice(AUD_Device* device) +{ + assert(device); + + try + { + delete device; + } + catch(AUD_Exception e) + { + } +} diff --git a/intern/audaspace/intern/AUD_C-API.h b/intern/audaspace/intern/AUD_C-API.h new file mode 100644 index 00000000000..6ec5ec87ad5 --- /dev/null +++ b/intern/audaspace/intern/AUD_C-API.h @@ -0,0 +1,331 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_CAPI +#define AUD_CAPI + +#ifdef __cplusplus +extern "C" { +#endif + +#include "AUD_Space.h" + +typedef enum +{ + AUD_NULL_DEVICE = 0, + AUD_SDL_DEVICE, + AUD_OPENAL_DEVICE, + AUD_JACK_DEVICE +} AUD_DeviceType; + +typedef struct +{ + AUD_Specs specs; + float length; +} AUD_SoundInfo; + +#ifndef AUD_CAPI_IMPLEMENTATION + typedef void AUD_Sound; + typedef void AUD_Handle; + typedef void AUD_Device; +#endif + +/** + * Initializes an audio device. + * \param device The device type that should be used. + * \param specs The audio specification to be used. + * \param buffersize The buffersize for the device. + * \return Whether the device has been initialized. + */ +extern int AUD_init(AUD_DeviceType device, AUD_Specs specs, int buffersize); + +/** + * Returns a integer list with available sound devices. The last one is always + * AUD_NULL_DEVICE. + */ +extern int* AUD_enumDevices(); + +/** + * Unitinitializes an audio device. + */ +extern void AUD_exit(); + +/** + * Locks the playback device. + */ +extern void AUD_lock(); + +/** + * Unlocks the device. + */ +extern void AUD_unlock(); + +/** + * Returns information about a sound. + * \param sound The sound to get the info about. + * \return The AUD_SoundInfo structure with filled in data. + */ +extern AUD_SoundInfo AUD_getInfo(AUD_Sound* sound); + +/** + * Loads a sound file. + * \param filename The filename of the sound file. + * \return A handle of the sound file. + */ +extern AUD_Sound* AUD_load(const char* filename); + +/** + * Loads a sound file. + * \param buffer The buffer which contains the sound file. + * \param size The size of the buffer. + * \return A handle of the sound file. + */ +extern AUD_Sound* AUD_loadBuffer(unsigned char* buffer, int size); + +/** + * Buffers a sound. + * \param sound The sound to buffer. + * \return A handle of the sound buffer. + */ +extern AUD_Sound* AUD_bufferSound(AUD_Sound* sound); + +/** + * Delays a sound. + * \param sound The sound to dealy. + * \param delay The delay in seconds. + * \return A handle of the delayed sound. + */ +extern AUD_Sound* AUD_delaySound(AUD_Sound* sound, float delay); + +/** + * Limits a sound. + * \param sound The sound to limit. + * \param start The start time in seconds. + * \param end The stop time in seconds. + * \return A handle of the limited sound. + */ +extern AUD_Sound* AUD_limitSound(AUD_Sound* sound, float start, float end); + +/** + * Ping pongs a sound. + * \param sound The sound to ping pong. + * \return A handle of the ping pong sound. + */ +extern AUD_Sound* AUD_pingpongSound(AUD_Sound* sound); + +/** + * Loops a sound. + * \param sound The sound to loop. + * \return A handle of the looped sound. + */ +extern AUD_Sound* AUD_loopSound(AUD_Sound* sound); + +/** + * Stops a looping sound when the current playback finishes. + * \param handle The playback handle. + * \return Whether the handle is valid. + */ +extern int AUD_stopLoop(AUD_Handle* handle); + +/** + * Unloads a sound of any type. + * \param sound The handle of the sound. + */ +extern void AUD_unload(AUD_Sound* sound); + +/** + * Plays back a sound file. + * \param sound The handle of the sound file. + * \param keep When keep is true the sound source will not be deleted but set to + * paused when its end has been reached. + * \return A handle to the played back sound. + */ +extern AUD_Handle* AUD_play(AUD_Sound* sound, int keep); + +/** + * Pauses a played back sound. + * \param handle The handle to the sound. + * \return Whether the handle has been playing or not. + */ +extern int AUD_pause(AUD_Handle* handle); + +/** + * Resumes a paused sound. + * \param handle The handle to the sound. + * \return Whether the handle has been paused or not. + */ +extern int AUD_resume(AUD_Handle* handle); + +/** + * Stops a playing or paused sound. + * \param handle The handle to the sound. + * \return Whether the handle has been valid or not. + */ +extern int AUD_stop(AUD_Handle* handle); + +/** + * Sets the end behaviour of a playing or paused sound. + * \param handle The handle to the sound. + * \param keep When keep is true the sound source will not be deleted but set to + * paused when its end has been reached. + * \return Whether the handle has been valid or not. + */ +extern int AUD_setKeep(AUD_Handle* handle, int keep); + +/** + * Seeks a playing or paused sound. + * \param handle The handle to the sound. + * \param seekTo From where the sound file should be played back in seconds. + * \return Whether the handle has been valid or not. + */ +extern int AUD_seek(AUD_Handle* handle, float seekTo); + +/** + * Retrieves the playback position of a handle. + * \return The current playback position in seconds or 0.0 if the handle is + * invalid. + */ +extern float AUD_getPosition(AUD_Handle* handle); + +/** + * Returns the status of a playing, paused or stopped sound. + * \param handle The handle to the sound. + * \return The status of the sound behind the handle. + */ +extern AUD_Status AUD_getStatus(AUD_Handle* handle); + +/** + * Plays a 3D sound. + * \param sound The handle of the sound file. + * \param keep When keep is true the sound source will not be deleted but set to + * paused when its end has been reached. + * \return A handle to the played back sound. + * \note The factory must provide a mono (single channel) source and the device + * must support 3D audio, otherwise the sound is played back normally. + */ +extern AUD_Handle* AUD_play3D(AUD_Sound* sound, int keep); + +/** + * Updates the listener 3D data. + * \param data The 3D data. + * \return Whether the action succeeded. + */ +extern int AUD_updateListener(AUD_3DData* data); + +/** + * Sets a 3D device setting. + * \param setting The setting type. + * \param value The new setting value. + * \return Whether the action succeeded. + */ +extern int AUD_set3DSetting(AUD_3DSetting setting, float value); + +/** + * Retrieves a 3D device setting. + * \param setting The setting type. + * \return The setting value. + */ +extern float AUD_get3DSetting(AUD_3DSetting setting); + +/** + * Updates a listeners 3D data. + * \param handle The source handle. + * \param data The 3D data. + * \return Whether the action succeeded. + */ +extern int AUD_update3DSource(AUD_Handle* handle, AUD_3DData* data); + +/** + * Sets a 3D source setting. + * \param handle The source handle. + * \param setting The setting type. + * \param value The new setting value. + * \return Whether the action succeeded. + */ +extern int AUD_set3DSourceSetting(AUD_Handle* handle, + AUD_3DSourceSetting setting, float value); + +/** + * Retrieves a 3D source setting. + * \param handle The source handle. + * \param setting The setting type. + * \return The setting value. + */ +extern float AUD_get3DSourceSetting(AUD_Handle* handle, + AUD_3DSourceSetting setting); + +/** + * Sets the volume of a played back sound. + * \param handle The handle to the sound. + * \param volume The new volume, must be between 0.0 and 1.0. + * \return Whether the action succeeded. + */ +extern int AUD_setSoundVolume(AUD_Handle* handle, float volume); + +/** + * Sets the pitch of a played back sound. + * \param handle The handle to the sound. + * \param pitch The new pitch. + * \return Whether the action succeeded. + */ +extern int AUD_setSoundPitch(AUD_Handle* handle, float pitch); + +/** + * Opens a read device, with which audio data can be read. + * \param specs The specification of the audio data. + * \return A device handle. + */ +extern AUD_Device* AUD_openReadDevice(AUD_Specs specs); + +/** + * Plays back a sound file through a read device. + * \param device The read device. + * \param sound The handle of the sound file. + * \return Whether the sound could be played back. + */ +extern int AUD_playDevice(AUD_Device* device, AUD_Sound* sound); + +/** + * Reads the next samples into the supplied buffer. + * \param device The read device. + * \param buffer The target buffer. + * \param length The length in samples to be filled. + * \return True if the reading succeeded, false if there are no sounds + * played back currently, in that case the buffer is filled with + * silence. + */ +extern int AUD_readDevice(AUD_Device* device, sample_t* buffer, int length); + +/** + * Closes a read device. + * \param device The read device. + */ +extern void AUD_closeReadDevice(AUD_Device* device); + +#ifdef __cplusplus +} +#endif + +#endif //AUD_CAPI diff --git a/intern/audaspace/intern/AUD_ChannelMapperFactory.cpp b/intern/audaspace/intern/AUD_ChannelMapperFactory.cpp new file mode 100644 index 00000000000..66205a58015 --- /dev/null +++ b/intern/audaspace/intern/AUD_ChannelMapperFactory.cpp @@ -0,0 +1,125 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_ChannelMapperFactory.h" +#include "AUD_ChannelMapperReader.h" + +#include + +AUD_ChannelMapperFactory::AUD_ChannelMapperFactory(AUD_IReader* reader, + AUD_Specs specs) : + AUD_MixerFactory(reader, specs) +{ + memset(m_mapping, 0, sizeof(m_mapping)); +} + +AUD_ChannelMapperFactory::AUD_ChannelMapperFactory(AUD_IFactory* factory, + AUD_Specs specs) : + AUD_MixerFactory(factory, specs) +{ + memset(m_mapping, 0, sizeof(m_mapping)); +} + +AUD_ChannelMapperFactory::AUD_ChannelMapperFactory(AUD_Specs specs) : + AUD_MixerFactory(specs) +{ + memset(m_mapping, 0, sizeof(m_mapping)); +} + +AUD_ChannelMapperFactory::~AUD_ChannelMapperFactory() +{ + for(int i = 1; i < 10; i++) + deleteMapping(i); +} + +float** AUD_ChannelMapperFactory::getMapping(int ic) +{ + ic--; + if(ic > 8 || ic < 0) + return 0; + + if(m_mapping[ic]) + { + int channels = -1; + while(m_mapping[ic][++channels] != 0); + if(channels != m_specs.channels) + deleteMapping(ic+1); + } + + if(!m_mapping[ic]) + { + int channels = m_specs.channels; + + m_mapping[ic] = new float*[channels+1]; AUD_NEW("mapping") + m_mapping[ic][channels] = 0; + + for(int i = 0; i < channels; i++) + { + m_mapping[ic][i] = new float[ic+1]; AUD_NEW("mapping") + for(int j = 0; j <= ic; j++) + m_mapping[ic][i][j] = ((i == j) || (channels == 1) || + (ic == 0)) ? 1.0f : 0.0f; + } + } + + return m_mapping[ic]; +} + +void AUD_ChannelMapperFactory::deleteMapping(int ic) +{ + ic--; + if(ic > 8 || ic < 0) + return; + + if(m_mapping[ic]) + { + for(int i = 0; 1; i++) + { + if(m_mapping[ic][i] != 0) + { + delete[] m_mapping[ic][i]; AUD_DELETE("mapping") + } + else + break; + } + delete[] m_mapping[ic]; AUD_DELETE("mapping") + m_mapping[ic] = 0; + } +} + +AUD_IReader* AUD_ChannelMapperFactory::createReader() +{ + AUD_IReader* reader = getReader(); + + if(reader != 0) + { + int ic = reader->getSpecs().channels; + + reader = new AUD_ChannelMapperReader(reader, getMapping(ic)); + AUD_NEW("reader") + } + + return reader; +} diff --git a/intern/audaspace/intern/AUD_ChannelMapperFactory.h b/intern/audaspace/intern/AUD_ChannelMapperFactory.h new file mode 100644 index 00000000000..c2c39f4bdf6 --- /dev/null +++ b/intern/audaspace/intern/AUD_ChannelMapperFactory.h @@ -0,0 +1,65 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_CHANNELMAPPERFACTORY +#define AUD_CHANNELMAPPERFACTORY + +#include "AUD_MixerFactory.h" + +/** + * This factory creates a reader that maps a sound source's channels to a + * specific output channel count. + */ +class AUD_ChannelMapperFactory : public AUD_MixerFactory +{ +private: + /** + * The mapping specification. + */ + float **m_mapping[9]; + +public: + AUD_ChannelMapperFactory(AUD_IReader* reader, AUD_Specs specs); + AUD_ChannelMapperFactory(AUD_IFactory* factory, AUD_Specs specs); + AUD_ChannelMapperFactory(AUD_Specs specs); + + virtual ~AUD_ChannelMapperFactory(); + + /** + * Returns the mapping array for editing. + * \param ic The count of input channels the array should have. + * \note The count of output channels is read of the desired output specs. + */ + float** getMapping(int ic); + + /** + * Deletes the current channel mapping. + */ + void deleteMapping(int ic); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_CHANNELMAPPERFACTORY diff --git a/intern/audaspace/intern/AUD_ChannelMapperReader.cpp b/intern/audaspace/intern/AUD_ChannelMapperReader.cpp new file mode 100644 index 00000000000..61f97c08a8e --- /dev/null +++ b/intern/audaspace/intern/AUD_ChannelMapperReader.cpp @@ -0,0 +1,108 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_ChannelMapperReader.h" +#include "AUD_Buffer.h" + +AUD_ChannelMapperReader::AUD_ChannelMapperReader(AUD_IReader* reader, + float **mapping) : + AUD_EffectReader(reader) +{ + m_specs = reader->getSpecs(); + + if(m_specs.format != AUD_FORMAT_FLOAT32) + { + delete m_reader; AUD_DELETE("reader") + AUD_THROW(AUD_ERROR_READER); + } + + int channels = -1; + m_rch = m_specs.channels; + while(mapping[++channels] != 0); + + m_mapping = new float*[channels]; AUD_NEW("mapping") + m_specs.channels = (AUD_Channels)channels; + + float sum; + int i; + + while(channels--) + { + m_mapping[channels] = new float[m_rch]; AUD_NEW("mapping") + sum = 0.0f; + for(i=0; i < m_rch; i++) + sum += mapping[channels][i]; + for(i=0; i < m_rch; i++) + m_mapping[channels][i] = sum > 0.0 ? mapping[channels][i]/sum : 0.0; + } + + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") +} + +AUD_ChannelMapperReader::~AUD_ChannelMapperReader() +{ + int channels = m_specs.channels; + + while(channels--) + { + delete[] m_mapping[channels]; AUD_DELETE("mapping") + } + + delete[] m_mapping; AUD_DELETE("mapping") + + delete m_buffer; AUD_DELETE("buffer") +} + +AUD_Specs AUD_ChannelMapperReader::getSpecs() +{ + return m_specs; +} + +void AUD_ChannelMapperReader::read(int & length, sample_t* & buffer) +{ + m_reader->read(length, buffer); + + int channels = m_specs.channels; + + if(m_buffer->getSize() < length * 4 * channels) + m_buffer->resize(length * 4 * channels); + + float* in = (float*)buffer; + float* out = (float*)m_buffer->getBuffer(); + float sum; + + for(int i = 0; i < length; i++) + { + for(int j = 0; j < channels; j++) + { + sum = 0; + for(int k = 0; k < m_rch; k++) + sum += m_mapping[j][k] * in[i * m_rch + k]; + out[i * channels + j] = sum; + } + } + + buffer = m_buffer->getBuffer(); +} diff --git a/intern/audaspace/intern/AUD_ChannelMapperReader.h b/intern/audaspace/intern/AUD_ChannelMapperReader.h new file mode 100644 index 00000000000..fe79ab6edd6 --- /dev/null +++ b/intern/audaspace/intern/AUD_ChannelMapperReader.h @@ -0,0 +1,76 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_CHANNELMAPPERREADER +#define AUD_CHANNELMAPPERREADER + +#include "AUD_EffectReader.h" +class AUD_Buffer; + +/** + * This class maps a sound source's channels to a specific output channel count. + * \note The input sample format must be float. + */ +class AUD_ChannelMapperReader : public AUD_EffectReader +{ +private: + /** + * The sound output buffer. + */ + AUD_Buffer *m_buffer; + + /** + * The output specification. + */ + AUD_Specs m_specs; + + /** + * The channel count of the reader. + */ + int m_rch; + + /** + * The mapping specification. + */ + float **m_mapping; + +public: + /** + * Creates a channel mapper reader. + * \param reader The reader to map. + * \param mapping The mapping specification as two dimensional float array. + * \exception AUD_Exception Thrown if the reader is NULL. + */ + AUD_ChannelMapperReader(AUD_IReader* reader, float **mapping); + /** + * Destroys the reader. + */ + ~AUD_ChannelMapperReader(); + + virtual AUD_Specs getSpecs(); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_CHANNELMAPPERREADER diff --git a/intern/audaspace/intern/AUD_ConverterFactory.cpp b/intern/audaspace/intern/AUD_ConverterFactory.cpp new file mode 100644 index 00000000000..a1a86662072 --- /dev/null +++ b/intern/audaspace/intern/AUD_ConverterFactory.cpp @@ -0,0 +1,54 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_ConverterFactory.h" +#include "AUD_ConverterReader.h" + +AUD_ConverterFactory::AUD_ConverterFactory(AUD_IReader* reader, + AUD_Specs specs) : + AUD_MixerFactory(reader, specs) {} + +AUD_ConverterFactory::AUD_ConverterFactory(AUD_IFactory* factory, + AUD_Specs specs) : + AUD_MixerFactory(factory, specs) {} + +AUD_ConverterFactory::AUD_ConverterFactory(AUD_Specs specs) : + AUD_MixerFactory(specs) {} + +AUD_IReader* AUD_ConverterFactory::createReader() +{ + AUD_IReader* reader = getReader(); + + if(reader != 0) + { + if(reader->getSpecs().format != m_specs.format) + { + reader = new AUD_ConverterReader(reader, m_specs); + AUD_NEW("reader") + } + } + + return reader; +} diff --git a/intern/audaspace/intern/AUD_ConverterFactory.h b/intern/audaspace/intern/AUD_ConverterFactory.h new file mode 100644 index 00000000000..3778e8d8f03 --- /dev/null +++ b/intern/audaspace/intern/AUD_ConverterFactory.h @@ -0,0 +1,45 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_CONVERTERFACTORY +#define AUD_CONVERTERFACTORY + +#include "AUD_MixerFactory.h" + +/** + * This factory creates a converter reader that is able to convert from one + * audio format to another. + */ +class AUD_ConverterFactory : public AUD_MixerFactory +{ +public: + AUD_ConverterFactory(AUD_IReader* reader, AUD_Specs specs); + AUD_ConverterFactory(AUD_IFactory* factory, AUD_Specs specs); + AUD_ConverterFactory(AUD_Specs specs); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_CONVERTERFACTORY diff --git a/intern/audaspace/intern/AUD_ConverterFunctions.cpp b/intern/audaspace/intern/AUD_ConverterFunctions.cpp new file mode 100644 index 00000000000..b6d5dffa1a2 --- /dev/null +++ b/intern/audaspace/intern/AUD_ConverterFunctions.cpp @@ -0,0 +1,502 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_ConverterFunctions.h" +#include "AUD_Buffer.h" + +#define AUD_U8_0 0x80 +#define AUD_S16_MAX 0x7FFF +#define AUD_S16_MIN 0x8000 +#define AUD_S16_FLT 32768.0 +#define AUD_S32_MAX 0x7FFFFFFF +#define AUD_S32_MIN 0x80000000 +#define AUD_S32_FLT 2147483648.0 +#define AUD_FLT_MAX 1.0 +#define AUD_FLT_MIN -1.0 + +void AUD_convert_u8_s16(sample_t* target, sample_t* source, int length) +{ + int16_t* t = (int16_t*) target; + for(int i = 0; i < length; i++) + t[i] = (((int16_t)source[i]) - AUD_U8_0) << 8; +} + +void AUD_convert_u8_s24_be(sample_t* target, sample_t* source, int length) +{ + for(int i = 0; i < length; i++) + { + target[i*3] = source[i] - AUD_U8_0; + target[i*3+1] = 0; + target[i*3+2] = 0; + } +} + +void AUD_convert_u8_s24_le(sample_t* target, sample_t* source, int length) +{ + for(int i = 0; i < length; i++) + { + target[i*3+2] = source[i] - AUD_U8_0; + target[i*3+1] = 0; + target[i*3] = 0; + } +} + +void AUD_convert_u8_s32(sample_t* target, sample_t* source, int length) +{ + int32_t* t = (int32_t*) target; + for(int i = 0; i < length; i++) + t[i] = (((int32_t)source[i]) - AUD_U8_0) << 24; +} + +void AUD_convert_u8_float(sample_t* target, sample_t* source, int length) +{ + float* t = (float*) target; + for(int i = 0; i < length; i++) + t[i] = (((int32_t)source[i]) - AUD_U8_0) / ((float)AUD_U8_0); +} + +void AUD_convert_u8_double(sample_t* target, sample_t* source, int length) +{ + double* t = (double*) target; + for(int i = 0; i < length; i++) + t[i] = (((int32_t)source[i]) - AUD_U8_0) / ((double)AUD_U8_0); +} + +void AUD_convert_s16_u8(sample_t* target, sample_t* source, int length) +{ + int16_t* s = (int16_t*) source; + for(int i = 0; i < length; i++) + target[i] = (unsigned char)((s[i] >> 8) + AUD_U8_0); +} + +void AUD_convert_s16_s24_be(sample_t* target, sample_t* source, int length) +{ + int16_t* s = (int16_t*) source; + for(int i = 0; i < length; i++) + { + target[i*3] = s[i] >> 8 & 0xFF; + target[i*3+1] = s[i] & 0xFF; + target[i*3+2] = 0; + } +} + +void AUD_convert_s16_s24_le(sample_t* target, sample_t* source, int length) +{ + int16_t* s = (int16_t*) source; + for(int i = 0; i < length; i++) + { + target[i*3+2] = s[i] >> 8 & 0xFF; + target[i*3+1] = s[i] & 0xFF; + target[i*3] = 0; + } +} + +void AUD_convert_s16_s32(sample_t* target, sample_t* source, int length) +{ + int16_t* s = (int16_t*) source; + int32_t* t = (int32_t*) target; + for(int i = 0; i < length; i++) + t[i] = ((int32_t)s[i]) << 16; +} + +void AUD_convert_s16_float(sample_t* target, sample_t* source, int length) +{ + int16_t* s = (int16_t*) source; + float* t = (float*) target; + for(int i = 0; i < length; i++) + t[i] = s[i] / AUD_S16_FLT; +} + +void AUD_convert_s16_double(sample_t* target, sample_t* source, int length) +{ + int16_t* s = (int16_t*) source; + double* t = (double*) target; + for(int i = 0; i < length; i++) + t[i] = s[i] / AUD_S16_FLT; +} + +void AUD_convert_s24_u8_be(sample_t* target, sample_t* source, int length) +{ + for(int i = 0; i < length; i++) + target[i] = source[i*3] ^ AUD_U8_0; +} + +void AUD_convert_s24_u8_le(sample_t* target, sample_t* source, int length) +{ + for(int i = 0; i < length; i++) + target[i] = source[i*3+2] ^ AUD_U8_0; +} + +void AUD_convert_s24_s16_be(sample_t* target, sample_t* source, int length) +{ + int16_t* t = (int16_t*) target; + for(int i = 0; i < length; i++) + t[i] = source[i*3] << 8 | source[i*3+1]; +} + +void AUD_convert_s24_s16_le(sample_t* target, sample_t* source, int length) +{ + int16_t* t = (int16_t*) target; + for(int i = 0; i < length; i++) + t[i] = source[i*3+2] << 8 | source[i*3+1]; +} + +void AUD_convert_s24_s24(sample_t* target, sample_t* source, int length) +{ + memcpy(target, source, length * 3); +} + +void AUD_convert_s24_s32_be(sample_t* target, sample_t* source, int length) +{ + int32_t* t = (int32_t*) target; + for(int i = 0; i < length; i++) + t[i] = source[i*3] << 24 | source[i*3+1] << 16 | source[i*3+2] << 8; +} + +void AUD_convert_s24_s32_le(sample_t* target, sample_t* source, int length) +{ + int32_t* t = (int32_t*) target; + for(int i = 0; i < length; i++) + t[i] = source[i*3+2] << 24 | source[i*3+1] << 16 | source[i*3] << 8; +} + +void AUD_convert_s24_float_be(sample_t* target, sample_t* source, int length) +{ + float* t = (float*) target; + int32_t s; + for(int i = 0; i < length; i++) + { + s = source[i*3] << 24 | source[i*3+1] << 16 | source[i*3+2] << 8; + t[i] = s / AUD_S32_FLT; + } +} + +void AUD_convert_s24_float_le(sample_t* target, sample_t* source, int length) +{ + float* t = (float*) target; + int32_t s; + for(int i = 0; i < length; i++) + { + s = source[i*3+2] << 24 | source[i*3+1] << 16 | source[i*3] << 8; + t[i] = s / AUD_S32_FLT; + } +} + +void AUD_convert_s24_double_be(sample_t* target, sample_t* source, int length) +{ + double* t = (double*) target; + int32_t s; + for(int i = 0; i < length; i++) + { + s = source[i*3] << 24 | source[i*3+1] << 16 | source[i*3+2] << 8; + t[i] = s / AUD_S32_FLT; + } +} + +void AUD_convert_s24_double_le(sample_t* target, sample_t* source, int length) +{ + double* t = (double*) target; + int32_t s; + for(int i = 0; i < length; i++) + { + s = source[i*3+2] << 24 | source[i*3+1] << 16 | source[i*3] << 8; + t[i] = s / AUD_S32_FLT; + } +} + +void AUD_convert_s32_u8(sample_t* target, sample_t* source, int length) +{ + int16_t* s = (int16_t*) source; + for(int i = 0; i < length; i++) + target[i] = (unsigned char)((s[i] >> 24) + AUD_U8_0); +} + +void AUD_convert_s32_s16(sample_t* target, sample_t* source, int length) +{ + int16_t* t = (int16_t*) target; + int32_t* s = (int32_t*) source; + for(int i = 0; i < length; i++) + t[i] = s[i] >> 16; +} + +void AUD_convert_s32_s24_be(sample_t* target, sample_t* source, int length) +{ + int32_t* s = (int32_t*) source; + for(int i = 0; i < length; i++) + { + target[i*3] = s[i] >> 24 & 0xFF; + target[i*3+1] = s[i] >> 16 & 0xFF; + target[i*3+2] = s[i] >> 8 & 0xFF; + } +} + +void AUD_convert_s32_s24_le(sample_t* target, sample_t* source, int length) +{ + int16_t* s = (int16_t*) source; + for(int i = 0; i < length; i++) + { + target[i*3+2] = s[i] >> 24 & 0xFF; + target[i*3+1] = s[i] >> 16 & 0xFF; + target[i*3] = s[i] >> 8 & 0xFF; + } +} + +void AUD_convert_s32_float(sample_t* target, sample_t* source, int length) +{ + int32_t* s = (int32_t*) source; + float* t = (float*) target; + for(int i = 0; i < length; i++) + t[i] = s[i] / AUD_S32_FLT; +} + +void AUD_convert_s32_double(sample_t* target, sample_t* source, int length) +{ + int32_t* s = (int32_t*) source; + double* t = (double*) target; + for(int i = 0; i < length; i++) + t[i] = s[i] / AUD_S32_FLT; +} + +void AUD_convert_float_u8(sample_t* target, sample_t* source, int length) +{ + float* s = (float*) source; + float t; + for(int i = 0; i < length; i++) + { + t = s[i] + AUD_FLT_MAX; + if(t <= 0.0f) + target[i] = 0; + else if(t >= 2.0f) + target[i] = 255; + else + target[i] = (unsigned char)(t*127); + } +} + +void AUD_convert_float_s16(sample_t* target, sample_t* source, int length) +{ + int16_t* t = (int16_t*) target; + float* s = (float*) source; + for(int i = 0; i < length; i++) + { + if(s[i] <= AUD_FLT_MIN) + t[i] = AUD_S16_MIN; + else if(s[i] >= AUD_FLT_MAX) + t[i] = AUD_S16_MAX; + else + t[i] = (int16_t)(s[i] * AUD_S16_MAX); + } +} + +void AUD_convert_float_s24_be(sample_t* target, sample_t* source, int length) +{ + int32_t t; + float* s = (float*) source; + for(int i = 0; i < length; i++) + { + if(s[i] <= AUD_FLT_MIN) + t = AUD_S32_MIN; + else if(s[i] >= AUD_FLT_MAX) + t = AUD_S32_MAX; + else + t = (int32_t)(s[i]*AUD_S32_MAX); + target[i*3] = t >> 24 & 0xFF; + target[i*3+1] = t >> 16 & 0xFF; + target[i*3+2] = t >> 8 & 0xFF; + } +} + +void AUD_convert_float_s24_le(sample_t* target, sample_t* source, int length) +{ + int32_t t; + float* s = (float*) source; + for(int i = 0; i < length; i++) + { + if(s[i] <= AUD_FLT_MIN) + t = AUD_S32_MIN; + else if(s[i] >= AUD_FLT_MAX) + t = AUD_S32_MAX; + else + t = (int32_t)(s[i]*AUD_S32_MAX); + target[i*3+2] = t >> 24 & 0xFF; + target[i*3+1] = t >> 16 & 0xFF; + target[i*3] = t >> 8 & 0xFF; + } +} + +void AUD_convert_float_s32(sample_t* target, sample_t* source, int length) +{ + int32_t* t = (int32_t*) target; + float* s = (float*) source; + for(int i = 0; i < length; i++) + { + if(s[i] <= AUD_FLT_MIN) + t[i] = AUD_S32_MIN; + else if(s[i] >= AUD_FLT_MAX) + t[i] = AUD_S32_MAX; + else + t[i] = (int32_t)(s[i]*AUD_S32_MAX); + } +} + +void AUD_convert_float_double(sample_t* target, sample_t* source, int length) +{ + float* s = (float*) source; + double* t = (double*) target; + for(int i = 0; i < length; i++) + t[i] = s[i]; +} + +void AUD_convert_double_u8(sample_t* target, sample_t* source, int length) +{ + double* s = (double*) source; + double t; + for(int i = 0; i < length; i++) + { + t = s[i] + AUD_FLT_MAX; + if(t <= 0.0) + target[i] = 0; + else if(t >= 2.0) + target[i] = 255; + else + target[i] = (unsigned char)(t*127); + } +} + +void AUD_convert_double_s16(sample_t* target, sample_t* source, int length) +{ + int16_t* t = (int16_t*) target; + double* s = (double*) source; + for(int i = 0; i < length; i++) + { + if(s[i] <= AUD_FLT_MIN) + t[i] = AUD_S16_MIN; + else if(s[i] >= AUD_FLT_MAX) + t[i] = AUD_S16_MAX; + else + t[i] = (int16_t)(s[i]*AUD_S16_MAX); + } +} + +void AUD_convert_double_s24_be(sample_t* target, sample_t* source, int length) +{ + int32_t t; + double* s = (double*) source; + for(int i = 0; i < length; i++) + { + if(s[i] <= AUD_FLT_MIN) + t = AUD_S32_MIN; + else if(s[i] >= AUD_FLT_MAX) + t = AUD_S32_MAX; + else + t = (int32_t)(s[i]*AUD_S32_MAX); + target[i*3] = t >> 24 & 0xFF; + target[i*3+1] = t >> 16 & 0xFF; + target[i*3+2] = t >> 8 & 0xFF; + } +} + +void AUD_convert_double_s24_le(sample_t* target, sample_t* source, int length) +{ + int32_t t; + double* s = (double*) source; + for(int i = 0; i < length; i++) + { + if(s[i] <= AUD_FLT_MIN) + t = AUD_S32_MIN; + else if(s[i] >= AUD_FLT_MAX) + t = AUD_S32_MAX; + else + t = (int32_t)(s[i]*AUD_S32_MAX); + target[i*3+2] = t >> 24 & 0xFF; + target[i*3+1] = t >> 16 & 0xFF; + target[i*3] = t >> 8 & 0xFF; + } +} + +void AUD_convert_double_s32(sample_t* target, sample_t* source, int length) +{ + int32_t* t = (int32_t*) target; + double* s = (double*) source; + for(int i = 0; i < length; i++) + { + if(s[i] <= AUD_FLT_MIN) + t[i] = AUD_S32_MIN; + else if(s[i] >= AUD_FLT_MAX) + t[i] = AUD_S32_MAX; + else + t[i] = (int32_t)(s[i]*AUD_S32_MAX); + } +} + +void AUD_convert_double_float(sample_t* target, sample_t* source, int length) +{ + double* s = (double*) source; + float* t = (float*) target; + for(int i = 0; i < length; i++) + t[i] = s[i]; +} + +void AUD_volume_adjust_u8(sample_t* target, sample_t* source, + int count, float volume) +{ + for(int i=0; i> 23) * 255) << 24; + value *= volume; + target[i+2] = value >> 16; + target[i+1] = value >> 8; + target[i] = value; + } +} + +void AUD_volume_adjust_s24_be(sample_t* target, sample_t* source, + int count, float volume) +{ + count *= 3; + int value; + + for(int i=0; i < count; i+=3) + { + value = source[i] << 16 | source[i+1] << 8 | source[i+2]; + value |= (((value & 0x800000) >> 23) * 255) << 24; + value *= volume; + target[i] = value >> 16; + target[i+1] = value >> 8; + target[i+2] = value; + } +} + diff --git a/intern/audaspace/intern/AUD_ConverterFunctions.h b/intern/audaspace/intern/AUD_ConverterFunctions.h new file mode 100644 index 00000000000..c1dd0f4a3a2 --- /dev/null +++ b/intern/audaspace/intern/AUD_ConverterFunctions.h @@ -0,0 +1,156 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_CONVERTERFUNCTIONS +#define AUD_CONVERTERFUNCTIONS + +#include "AUD_Space.h" + +#include +#ifdef _MSC_VER +#if (_MSC_VER < 1300) + typedef short int16_t; + typedef int int32_t; +#else + typedef __int16 int16_t; + typedef __int32 int32_t; +#endif +#else +#include +#endif + +typedef void (*AUD_convert_f)(sample_t* target, sample_t* source, int length); + +typedef void (*AUD_volume_adjust_f)(sample_t* target, sample_t* source, + int count, float volume); + +template +void AUD_convert_copy(sample_t* target, sample_t* source, int length) +{ + memcpy(target, source, length*sizeof(T)); +} + +void AUD_convert_u8_s16(sample_t* target, sample_t* source, int length); + +void AUD_convert_u8_s24_be(sample_t* target, sample_t* source, int length); + +void AUD_convert_u8_s24_le(sample_t* target, sample_t* source, int length); + +void AUD_convert_u8_s32(sample_t* target, sample_t* source, int length); + +void AUD_convert_u8_float(sample_t* target, sample_t* source, int length); + +void AUD_convert_u8_double(sample_t* target, sample_t* source, int length); + +void AUD_convert_s16_u8(sample_t* target, sample_t* source, int length); + +void AUD_convert_s16_s24_be(sample_t* target, sample_t* source, int length); + +void AUD_convert_s16_s24_le(sample_t* target, sample_t* source, int length); + +void AUD_convert_s16_s32(sample_t* target, sample_t* source, int length); + +void AUD_convert_s16_float(sample_t* target, sample_t* source, int length); + +void AUD_convert_s16_double(sample_t* target, sample_t* source, int length); + +void AUD_convert_s24_u8_be(sample_t* target, sample_t* source, int length); + +void AUD_convert_s24_u8_le(sample_t* target, sample_t* source, int length); + +void AUD_convert_s24_s16_be(sample_t* target, sample_t* source, int length); + +void AUD_convert_s24_s16_le(sample_t* target, sample_t* source, int length); + +void AUD_convert_s24_s24(sample_t* target, sample_t* source, int length); + +void AUD_convert_s24_s32_be(sample_t* target, sample_t* source, int length); + +void AUD_convert_s24_s32_le(sample_t* target, sample_t* source, int length); + +void AUD_convert_s24_float_be(sample_t* target, sample_t* source, int length); + +void AUD_convert_s24_float_le(sample_t* target, sample_t* source, int length); + +void AUD_convert_s24_double_be(sample_t* target, sample_t* source, int length); + +void AUD_convert_s24_double_le(sample_t* target, sample_t* source, int length); + +void AUD_convert_s32_u8(sample_t* target, sample_t* source, int length); + +void AUD_convert_s32_s16(sample_t* target, sample_t* source, int length); + +void AUD_convert_s32_s24_be(sample_t* target, sample_t* source, int length); + +void AUD_convert_s32_s24_le(sample_t* target, sample_t* source, int length); + +void AUD_convert_s32_float(sample_t* target, sample_t* source, int length); + +void AUD_convert_s32_double(sample_t* target, sample_t* source, int length); + +void AUD_convert_float_u8(sample_t* target, sample_t* source, int length); + +void AUD_convert_float_s16(sample_t* target, sample_t* source, int length); + +void AUD_convert_float_s24_be(sample_t* target, sample_t* source, int length); + +void AUD_convert_float_s24_le(sample_t* target, sample_t* source, int length); + +void AUD_convert_float_s32(sample_t* target, sample_t* source, int length); + +void AUD_convert_float_double(sample_t* target, sample_t* source, int length); + +void AUD_convert_double_u8(sample_t* target, sample_t* source, int length); + +void AUD_convert_double_s16(sample_t* target, sample_t* source, int length); + +void AUD_convert_double_s24_be(sample_t* target, sample_t* source, int length); + +void AUD_convert_double_s24_le(sample_t* target, sample_t* source, int length); + +void AUD_convert_double_s32(sample_t* target, sample_t* source, int length); + +void AUD_convert_double_float(sample_t* target, sample_t* source, int length); + +template +void AUD_volume_adjust(sample_t* target, sample_t* source, + int count, float volume) +{ + T* t = (T*)target; + T* s = (T*)source; + for(int i=0; i < count; i++) + t[i] = (T)(s[i] * volume); +} + +void AUD_volume_adjust_u8(sample_t* target, sample_t* source, + int count, float volume); + +void AUD_volume_adjust_s24_le(sample_t* target, sample_t* source, + int count, float volume); + +void AUD_volume_adjust_s24_be(sample_t* target, sample_t* source, + int count, float volume); + +#endif //AUD_CONVERTERFUNCTIONS diff --git a/intern/audaspace/intern/AUD_ConverterReader.cpp b/intern/audaspace/intern/AUD_ConverterReader.cpp new file mode 100644 index 00000000000..da25a2b7460 --- /dev/null +++ b/intern/audaspace/intern/AUD_ConverterReader.cpp @@ -0,0 +1,260 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_ConverterReader.h" +#include "AUD_Buffer.h" + +AUD_ConverterReader::AUD_ConverterReader(AUD_IReader* reader, AUD_Specs specs) : + AUD_EffectReader(reader) +{ + m_specs = reader->getSpecs(); + + int bigendian = 1; + bigendian = (((char*)&bigendian)[0]) ? 0: 1; // 1 if Big Endian + + switch(m_specs.format) + { + case AUD_FORMAT_U8: + switch(specs.format) + { + case AUD_FORMAT_U8: + m_convert = AUD_convert_copy; + break; + case AUD_FORMAT_S16: + m_convert = AUD_convert_u8_s16; + break; + case AUD_FORMAT_S24: + if(bigendian) + m_convert = AUD_convert_u8_s24_be; + else + m_convert = AUD_convert_u8_s24_le; + break; + case AUD_FORMAT_S32: + m_convert = AUD_convert_u8_s32; + break; + case AUD_FORMAT_FLOAT32: + m_convert = AUD_convert_u8_float; + break; + case AUD_FORMAT_FLOAT64: + m_convert = AUD_convert_u8_double; + break; + default: + break; + } + break; + case AUD_FORMAT_S16: + switch(specs.format) + { + case AUD_FORMAT_U8: + m_convert = AUD_convert_s16_u8; + break; + case AUD_FORMAT_S16: + m_convert = AUD_convert_copy; + break; + case AUD_FORMAT_S24: + if(bigendian) + m_convert = AUD_convert_s16_s24_be; + else + m_convert = AUD_convert_s16_s24_le; + break; + case AUD_FORMAT_S32: + m_convert = AUD_convert_s16_s32; + break; + case AUD_FORMAT_FLOAT32: + m_convert = AUD_convert_s16_float; + break; + case AUD_FORMAT_FLOAT64: + m_convert = AUD_convert_s16_double; + break; + default: + break; + } + break; + case AUD_FORMAT_S24: + if(bigendian) + switch(specs.format) + { + case AUD_FORMAT_U8: + m_convert = AUD_convert_u8_s24_be; + break; + case AUD_FORMAT_S16: + m_convert = AUD_convert_s16_s24_be; + break; + case AUD_FORMAT_S24: + m_convert = AUD_convert_s24_s24; + break; + case AUD_FORMAT_S32: + m_convert = AUD_convert_s32_s24_be; + break; + case AUD_FORMAT_FLOAT32: + m_convert = AUD_convert_float_s24_be; + break; + case AUD_FORMAT_FLOAT64: + m_convert = AUD_convert_double_s24_be; + break; + default: + break; + } + else + switch(specs.format) + { + case AUD_FORMAT_U8: + m_convert = AUD_convert_u8_s24_le; + break; + case AUD_FORMAT_S16: + m_convert = AUD_convert_s16_s24_le; + break; + case AUD_FORMAT_S24: + m_convert = AUD_convert_s24_s24; + break; + case AUD_FORMAT_S32: + m_convert = AUD_convert_s32_s24_le; + break; + case AUD_FORMAT_FLOAT32: + m_convert = AUD_convert_float_s24_le; + break; + case AUD_FORMAT_FLOAT64: + m_convert = AUD_convert_double_s24_le; + break; + default: + break; + } + break; + case AUD_FORMAT_S32: + switch(specs.format) + { + case AUD_FORMAT_U8: + m_convert = AUD_convert_s32_u8; + break; + case AUD_FORMAT_S16: + m_convert = AUD_convert_s32_s16; + break; + case AUD_FORMAT_S24: + if(bigendian) + m_convert = AUD_convert_s32_s24_be; + else + m_convert = AUD_convert_s32_s24_le; + break; + case AUD_FORMAT_S32: + m_convert = AUD_convert_copy; + break; + case AUD_FORMAT_FLOAT32: + m_convert = AUD_convert_s32_float; + break; + case AUD_FORMAT_FLOAT64: + m_convert = AUD_convert_s32_double; + break; + default: + break; + } + break; + case AUD_FORMAT_FLOAT32: + switch(specs.format) + { + case AUD_FORMAT_U8: + m_convert = AUD_convert_float_u8; + break; + case AUD_FORMAT_S16: + m_convert = AUD_convert_float_s16; + break; + case AUD_FORMAT_S24: + if(bigendian) + m_convert = AUD_convert_float_s24_be; + else + m_convert = AUD_convert_float_s24_le; + break; + case AUD_FORMAT_S32: + m_convert = AUD_convert_float_s32; + break; + case AUD_FORMAT_FLOAT32: + m_convert = AUD_convert_copy; + break; + case AUD_FORMAT_FLOAT64: + m_convert = AUD_convert_float_double; + break; + default: + break; + } + break; + case AUD_FORMAT_FLOAT64: + switch(specs.format) + { + case AUD_FORMAT_U8: + m_convert = AUD_convert_double_u8; + break; + case AUD_FORMAT_S16: + m_convert = AUD_convert_double_s16; + break; + case AUD_FORMAT_S24: + if(bigendian) + m_convert = AUD_convert_double_s24_be; + else + m_convert = AUD_convert_double_s24_le; + break; + case AUD_FORMAT_S32: + m_convert = AUD_convert_double_s32; + break; + case AUD_FORMAT_FLOAT32: + m_convert = AUD_convert_double_float; + break; + case AUD_FORMAT_FLOAT64: + m_convert = AUD_convert_copy; + break; + default: + break; + } + break; + default: + break; + } + + m_specs.format = specs.format; + + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") +} + +AUD_ConverterReader::~AUD_ConverterReader() +{ + delete m_buffer; AUD_DELETE("buffer") +} + +AUD_Specs AUD_ConverterReader::getSpecs() +{ + return m_specs; +} + +void AUD_ConverterReader::read(int & length, sample_t* & buffer) +{ + m_reader->read(length, buffer); + + int samplesize = AUD_SAMPLE_SIZE(m_specs); + + if(m_buffer->getSize() < length*samplesize) + m_buffer->resize(length*samplesize); + + m_convert(m_buffer->getBuffer(), buffer, length*m_specs.channels); + + buffer = m_buffer->getBuffer(); +} diff --git a/intern/audaspace/intern/AUD_ConverterReader.h b/intern/audaspace/intern/AUD_ConverterReader.h new file mode 100644 index 00000000000..f855372b636 --- /dev/null +++ b/intern/audaspace/intern/AUD_ConverterReader.h @@ -0,0 +1,71 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_CONVERTERREADER +#define AUD_CONVERTERREADER + +#include "AUD_EffectReader.h" +#include "AUD_ConverterFunctions.h" +class AUD_Buffer; + +/** + * This class converts a sound source from one to another format. + */ +class AUD_ConverterReader : public AUD_EffectReader +{ +private: + /** + * The sound output buffer. + */ + AUD_Buffer *m_buffer; + + /** + * The target specification. + */ + AUD_Specs m_specs; + + /** + * Converter function. + */ + AUD_convert_f m_convert; + +public: + /** + * Creates a converter reader. + * \param reader The reader to convert. + * \param specs The target specification. + * \exception AUD_Exception Thrown if the reader is NULL. + */ + AUD_ConverterReader(AUD_IReader* reader, AUD_Specs specs); + /** + * Destroys the reader. + */ + ~AUD_ConverterReader(); + + virtual AUD_Specs getSpecs(); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_CONVERTERREADER diff --git a/intern/audaspace/intern/AUD_FloatMixer.cpp b/intern/audaspace/intern/AUD_FloatMixer.cpp new file mode 100644 index 00000000000..f7133b9c30e --- /dev/null +++ b/intern/audaspace/intern/AUD_FloatMixer.cpp @@ -0,0 +1,172 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_FloatMixer.h" +#include "AUD_ConverterFactory.h" +#include "AUD_SRCResampleFactory.h" +#include "AUD_ChannelMapperFactory.h" +#include "AUD_IReader.h" +#include "AUD_Buffer.h" + +#include + +AUD_FloatMixer::AUD_FloatMixer() +{ + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") + + m_converter = NULL; + m_resampler = NULL; + m_mapper = NULL; +} + +AUD_FloatMixer::~AUD_FloatMixer() +{ + delete m_buffer; AUD_DELETE("buffer") + + if(m_converter) + { + delete m_converter; AUD_DELETE("factory") + } + if(m_resampler) + { + delete m_resampler; AUD_DELETE("factory") + } + if(m_mapper) + { + delete m_mapper; AUD_DELETE("factory") + } +} + +AUD_IReader* AUD_FloatMixer::prepare(AUD_IReader* reader) +{ + m_converter->setReader(reader); + reader = m_converter->createReader(); + + m_resampler->setReader(reader); + reader = m_resampler->createReader(); + + if(reader->getSpecs().channels != m_specs.channels) + { + m_mapper->setReader(reader); + reader = m_mapper->createReader(); + } + + return reader; +} + +void AUD_FloatMixer::setSpecs(AUD_Specs specs) +{ + m_specs = specs; + + if(m_converter) + { + delete m_converter; AUD_DELETE("factory") + } + if(m_resampler) + { + delete m_resampler; AUD_DELETE("factory") + } + if(m_mapper) + { + delete m_mapper; AUD_DELETE("factory") + } + + specs.format = AUD_FORMAT_FLOAT32; + + m_converter = new AUD_ConverterFactory(specs); AUD_NEW("factory") + m_resampler = new AUD_SRCResampleFactory(specs); AUD_NEW("factory") + m_mapper = new AUD_ChannelMapperFactory(specs); AUD_NEW("factory") + + int bigendian = 1; + bigendian = (((char*)&bigendian)[0]) ? 0: 1; // 1 if Big Endian + + switch(m_specs.format) + { + case AUD_FORMAT_U8: + m_convert = AUD_convert_float_u8; + break; + case AUD_FORMAT_S16: + m_convert = AUD_convert_float_s16; + break; + case AUD_FORMAT_S24: + if(bigendian) + m_convert = AUD_convert_float_s24_be; + else + m_convert = AUD_convert_float_s24_le; + break; + case AUD_FORMAT_S32: + m_convert = AUD_convert_float_s32; + break; + case AUD_FORMAT_FLOAT32: + m_convert = AUD_convert_copy; + break; + case AUD_FORMAT_FLOAT64: + m_convert = AUD_convert_float_double; + break; + default: + break; + } +} + +void AUD_FloatMixer::add(sample_t* buffer, AUD_Specs specs, int length, + float volume) +{ + AUD_FloatMixerBuffer buf; + buf.buffer = buffer; + buf.length = length; + buf.volume = volume; + m_buffers.push_back(buf); +} + +void AUD_FloatMixer::superpose(sample_t* buffer, int length, float volume) +{ + AUD_FloatMixerBuffer buf; + + int channels = m_specs.channels; + + if(m_buffer->getSize() < length * channels * 4) + m_buffer->resize(length * channels * 4); + + float* out = (float*)m_buffer->getBuffer(); + float* in; + + memset(out, 0, length * channels * 4); + + int end; + + while(!m_buffers.empty()) + { + buf = m_buffers.front(); + m_buffers.pop_front(); + + end = buf.length*channels; + in = (float*) buf.buffer; + + for(int i = 0; i < end; i++) + out[i] += in[i]*buf.volume * volume; + } + + m_convert(buffer, (sample_t*) out, length * channels); +} diff --git a/intern/audaspace/intern/AUD_FloatMixer.h b/intern/audaspace/intern/AUD_FloatMixer.h new file mode 100644 index 00000000000..728a0faf3cb --- /dev/null +++ b/intern/audaspace/intern/AUD_FloatMixer.h @@ -0,0 +1,100 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_FLOATMIXER +#define AUD_FLOATMIXER + +#include "AUD_IMixer.h" +#include "AUD_ConverterFunctions.h" +class AUD_ConverterFactory; +class AUD_SRCResampleFactory; +class AUD_ChannelMapperFactory; +class AUD_Buffer; +#include + +struct AUD_FloatMixerBuffer +{ + sample_t* buffer; + int length; + float volume; +}; + +/** + * This class is able to mix two audiosignals with floats. + */ +class AUD_FloatMixer : public AUD_IMixer +{ +private: + /** + * The converter factory that converts all readers for superposition. + */ + AUD_ConverterFactory* m_converter; + + /** + * The resampling factory that resamples all readers for superposition. + */ + AUD_SRCResampleFactory* m_resampler; + + /** + * The channel mapper factory that maps all readers for superposition. + */ + AUD_ChannelMapperFactory* m_mapper; + + /** + * The list of buffers to superpose. + */ + std::list m_buffers; + + /** + * The output specification. + */ + AUD_Specs m_specs; + + /** + * The temporary mixing buffer. + */ + AUD_Buffer* m_buffer; + + /** + * Converter function. + */ + AUD_convert_f m_convert; + +public: + /** + * Creates the mixer. + */ + AUD_FloatMixer(); + + virtual ~AUD_FloatMixer(); + + virtual AUD_IReader* prepare(AUD_IReader* reader); + virtual void setSpecs(AUD_Specs specs); + virtual void add(sample_t* buffer, AUD_Specs specs, int length, + float volume); + virtual void superpose(sample_t* buffer, int length, float volume); +}; + +#endif //AUD_FLOATMIXER diff --git a/intern/audaspace/intern/AUD_I3DDevice.h b/intern/audaspace/intern/AUD_I3DDevice.h new file mode 100644 index 00000000000..c36924160de --- /dev/null +++ b/intern/audaspace/intern/AUD_I3DDevice.h @@ -0,0 +1,103 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_I3DDEVICE +#define AUD_I3DDEVICE + +#include "AUD_Space.h" + +/** + * This class represents an output device for 3D sound. + * Whether a normal device supports this or not can be checked with the + * AUD_CAPS_3D_DEVICE capability. + */ +class AUD_I3DDevice +{ +public: + /** + * Plays a 3D sound source. + * \param factory The factory to create the reader for the sound source. + * \param keep When keep is true the sound source will not be deleted but + * set to paused when its end has been reached. + * \return Returns a handle with which the playback can be controlled. + * This is NULL if the sound couldn't be played back. + * \exception AUD_Exception Thrown if there's an unexpected (from the + * device side) error during creation of the reader. + * \note The factory must provide a mono (single channel) source otherwise + * the sound is played back normally. + */ + virtual AUD_Handle* play3D(AUD_IFactory* factory, bool keep = false)=0; + + /** + * Updates a listeners 3D data. + * \param data The 3D data. + * \return Whether the action succeeded. + */ + virtual bool updateListener(AUD_3DData &data)=0; + + /** + * Sets a 3D device setting. + * \param setting The setting type. + * \param value The new setting value. + * \return Whether the action succeeded. + */ + virtual bool setSetting(AUD_3DSetting setting, float value)=0; + + /** + * Retrieves a 3D device setting. + * \param setting The setting type. + * \return The setting value. + */ + virtual float getSetting(AUD_3DSetting setting)=0; + + /** + * Updates a listeners 3D data. + * \param handle The source handle. + * \param data The 3D data. + * \return Whether the action succeeded. + */ + virtual bool updateSource(AUD_Handle* handle, AUD_3DData &data)=0; + + /** + * Sets a 3D source setting. + * \param handle The source handle. + * \param setting The setting type. + * \param value The new setting value. + * \return Whether the action succeeded. + */ + virtual bool setSourceSetting(AUD_Handle* handle, + AUD_3DSourceSetting setting, float value)=0; + + /** + * Retrieves a 3D source setting. + * \param handle The source handle. + * \param setting The setting type. + * \return The setting value. + */ + virtual float getSourceSetting(AUD_Handle* handle, + AUD_3DSourceSetting setting)=0; +}; + +#endif //AUD_I3DDEVICE diff --git a/intern/audaspace/intern/AUD_IDevice.h b/intern/audaspace/intern/AUD_IDevice.h new file mode 100644 index 00000000000..af2cae206f3 --- /dev/null +++ b/intern/audaspace/intern/AUD_IDevice.h @@ -0,0 +1,191 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_IDEVICE +#define AUD_IDEVICE + +#include "AUD_Space.h" +class AUD_IFactory; + +/// Handle structure, for inherition. +typedef struct +{ +} AUD_Handle; + +/** + * This class represents an output device for sound sources. + * Output devices may be several backends such as plattform independand like + * SDL or OpenAL or plattform specific like DirectSound, but they may also be + * files, RAM buffers or other types of streams. + * \warning Thread safety must be insured so that no reader is beeing called + * twice at the same time. + */ +class AUD_IDevice +{ +public: + /** + * Destroys the device. + */ + virtual ~AUD_IDevice() {} + + /** + * Returns the specification of the device. + */ + virtual AUD_Specs getSpecs()=0; + + /** + * Plays a sound source. + * \param factory The factory to create the reader for the sound source. + * \param keep When keep is true the sound source will not be deleted but + * set to paused when its end has been reached. + * \return Returns a handle with which the playback can be controlled. + * This is NULL if the sound couldn't be played back. + * \exception AUD_Exception Thrown if there's an unexpected (from the + * device side) error during creation of the reader. + */ + virtual AUD_Handle* play(AUD_IFactory* factory, bool keep = false)=0; + + /** + * Pauses a played back sound. + * \param handle The handle returned by the play function. + * \return + * - true if the sound has been paused. + * - false if the sound isn't playing back or the handle is invalid. + */ + virtual bool pause(AUD_Handle* handle)=0; + + /** + * Resumes a paused sound. + * \param handle The handle returned by the play function. + * \return + * - true if the sound has been resumed. + * - false if the sound isn't paused or the handle is invalid. + */ + virtual bool resume(AUD_Handle* handle)=0; + + /** + * Stops a played back or paused sound. The handle is definitely invalid + * afterwards. + * \param handle The handle returned by the play function. + * \return + * - true if the sound has been stopped. + * - false if the handle is invalid. + */ + virtual bool stop(AUD_Handle* handle)=0; + + /** + * Sets the behaviour of the device for a played back sound when the sound + * doesn't return any more samples. + * \param handle The handle returned by the play function. + * \param keep True when the source should be paused and not deleted. + * \return + * - true if the behaviour has been changed. + * - false if the handle is invalid. + */ + virtual bool setKeep(AUD_Handle* handle, bool keep)=0; + + /** + * Sends a message to a sound or all sounds that are currently played or + * paused. + * \param handle The sound that should receive the message or NULL if all + * sounds should receive it. + * \param message The message. + * \return True if the message has been read by at least one sound. + */ + virtual bool sendMessage(AUD_Handle* handle, AUD_Message &message)=0; + + /** + * Seeks in a played back sound. + * \param handle The handle returned by the play function. + * \param position The new position from where to play back, in seconds. + * \return + * - true if the handle is valid. + * - false if the handle is invalid. + * \warning Whether the seek works or not depends on the sound source. + */ + virtual bool seek(AUD_Handle* handle, float position)=0; + + /** + * Retrieves the current playback position of a sound. + * \param handle The handle returned by the play function. + * \return The playback position in seconds, or 0.0 if the handle is + * invalid. + */ + virtual float getPosition(AUD_Handle* handle)=0; + + /** + * Returns the status of a played back sound. + * \param handle The handle returned by the play function. + * \return + * - AUD_STATUS_INVALID if the sound has stopped or the handle is + *. invalid + * - AUD_STATUS_PLAYING if the sound is currently played back. + * - AUD_STATUS_PAUSED if the sound is currently paused. + * \see AUD_Status + */ + virtual AUD_Status getStatus(AUD_Handle* handle)=0; + + /** + * Locks the device. + * Used to make sure that between lock and unlock, no buffers are read, so + * that it is possible to start, resume, pause, stop or seek several + * playback handles simultaneously. + * \warning Make sure the locking time is as small as possible to avoid + * playback delays that result in unexpected noise and cracks. + */ + virtual void lock()=0; + + /** + * Unlocks the previously locked device. + */ + virtual void unlock()=0; + + /** + * Checks if a specific capability as available on a device. + * \param capability The capability. + * \return Whether it is available or not. + */ + virtual bool checkCapability(int capability)=0; + + /** + * Set a value of a capability. The data behind the pointer depends on the + * capability. + * \param capability The capability. + * \param value The value. + * \return Whether the action succeeded or not. + */ + virtual bool setCapability(int capability, void *value)=0; + + /** + * Retrieves a value of a capability. The data behind the pointer depends on + * the capability. + * \param capability The capability. + * \param value The value. + * \return Whether the action succeeded or not. + */ + virtual bool getCapability(int capability, void *value)=0; +}; + +#endif //AUD_IDevice diff --git a/intern/audaspace/intern/AUD_IFactory.h b/intern/audaspace/intern/AUD_IFactory.h new file mode 100644 index 00000000000..f7f29c9e842 --- /dev/null +++ b/intern/audaspace/intern/AUD_IFactory.h @@ -0,0 +1,55 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_IFACTORY +#define AUD_IFACTORY + +#include "AUD_Space.h" +class AUD_IReader; + +/** + * This class represents a type of sound source and saves the necessary values + * for it. It is able to create a reader that is actually usable for playback + * of the respective sound source through the factory method createReader. + */ +class AUD_IFactory +{ +public: + /** + * Destroys the factory. + */ + virtual ~AUD_IFactory(){} + + /** + * Creates a reader for playback of the sound source. + * \return A pointer to an AUD_IReader object or NULL if there has been an + * error. + * \exception AUD_Exception An exception may be thrown if there has been + * a more unexpected error during reader creation. + */ + virtual AUD_IReader* createReader()=0; +}; + +#endif //AUD_IFACTORY diff --git a/intern/audaspace/intern/AUD_IMixer.h b/intern/audaspace/intern/AUD_IMixer.h new file mode 100644 index 00000000000..c65e4c69cf7 --- /dev/null +++ b/intern/audaspace/intern/AUD_IMixer.h @@ -0,0 +1,77 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_IMIXER +#define AUD_IMIXER + +#include "AUD_Space.h" +class AUD_IReader; + +/** + * This class is able to mix audiosignals of different format and channel count. + * \note This class doesn't do resampling! + */ +class AUD_IMixer +{ +public: + /** + * Destroys the mixer. + */ + virtual ~AUD_IMixer(){} + + /** + * This funuction prepares a reader for playback. + * \param reader The reader to prepare. + * \return The reader that should be used for playback. + */ + virtual AUD_IReader* prepare(AUD_IReader* reader)=0; + + /** + * Sets the target specification for superposing. + * \param specs The target specification. + */ + virtual void setSpecs(AUD_Specs specs)=0; + + /** + * Adds a buffer for superposition. + * \param buffer The buffer to superpose. + * \param specs The specification of the buffer. + * \param start The start sample of the buffer. + * \param length The length of the buffer in samples. + * \param volume The mixing volume. Must be a value between 0.0 and 1.0. + */ + virtual void add(sample_t* buffer, AUD_Specs specs, int length, + float volume)=0; + + /** + * Superposes all added buffers into an output buffer. + * \param buffer The target buffer for superposing. + * \param length The length of the buffer in samples. + * \param volume The mixing volume. Must be a value between 0.0 and 1.0. + */ + virtual void superpose(sample_t* buffer, int length, float volume)=0; +}; + +#endif //AUD_IMIXER diff --git a/intern/audaspace/intern/AUD_IReader.h b/intern/audaspace/intern/AUD_IReader.h new file mode 100644 index 00000000000..4b563100659 --- /dev/null +++ b/intern/audaspace/intern/AUD_IReader.h @@ -0,0 +1,117 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_IREADER +#define AUD_IREADER + +#include "AUD_Space.h" + +/** + * This class represents a sound source as stream or as buffer which can be read + * for example by another reader, a device or whatever. + */ +class AUD_IReader +{ +public: + /** + * Destroys the reader. + */ + virtual ~AUD_IReader(){} + + /** + * Tells whether the source provides seeking functionality or not. + * \warning This doesn't mean that the seeking always has to succeed. + * \return Always returns true for readers of the buffer type. + * \see getType + */ + virtual bool isSeekable()=0; + + /** + * Seeks to a specific position in the source. + * This function must work for buffer type readers. + * \param position The position to seek for measured in samples. To get + * from a given time to the samples you simply have to multiply the + * time value in seconds with the sample rate of the reader. + * \warning This may work or not, depending on the actual reader. + * \see getType + */ + virtual void seek(int position)=0; + + /** + * Returns an aproximated length of the source in samples. + * For readers of the type buffer this has to return a correct value! + * \return The length as sample count. May be negative if unknown. + * \see getType + */ + virtual int getLength()=0; + + /** + * Returns the position of the source as a sample count value. + * \return The current position in the source. A negative value indicates + * that the position is unknown. + * \warning The value returned doesn't always have to be correct for readers + * of the stream type, especially after seeking, it must though for + * the buffer ones. + * \see getType + */ + virtual int getPosition()=0; + + /** + * Returns the specification of the reader. + * \return The AUD_Specs structure. + */ + virtual AUD_Specs getSpecs()=0; + + /** + * Returns the type of the reader. There are special conditions for the + * readers of the buffer type. Those have to return correct position and + * length values as well as they must be seekable. + * \return AUD_TYPE_BUFFER or AUD_TYPE_STREAM. + */ + virtual AUD_ReaderType getType()=0; + + /** + * Sends a message to this reader and if it has subreaders it broadcasts + * the message to them. + * \param message The message. + * \return Whether the message has been read by the reader or one of his + * subreaders. + */ + virtual bool notify(AUD_Message &message)=0; + + /** + * Request to read the next length samples out of the source. + * The buffer for reading has to stay valid until the next call of this + * method or until the reader is deleted. + * \param[in,out] length The count of samples that should be read. Shall + * contain the real count of samples after reading, in case + * there were only fewer samples available. + * A smaller value also indicates the end of the reader. + * \param[out] buffer The pointer to the buffer with the samples. + */ + virtual void read(int & length, sample_t* & buffer)=0; +}; + +#endif //AUD_IREADER diff --git a/intern/audaspace/intern/AUD_MixerFactory.cpp b/intern/audaspace/intern/AUD_MixerFactory.cpp new file mode 100644 index 00000000000..db38d1004db --- /dev/null +++ b/intern/audaspace/intern/AUD_MixerFactory.cpp @@ -0,0 +1,109 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_MixerFactory.h" +#include "AUD_IReader.h" + +AUD_IReader* AUD_MixerFactory::getReader() +{ + AUD_IReader* reader; + + // first check for an existing reader + if(m_reader != 0) + { + reader = m_reader; + m_reader = 0; + return reader; + } + + // otherwise create a reader if there is a factory + if(m_factory != 0) + { + reader = m_factory->createReader(); + return reader; + } + + return 0; +} + +AUD_MixerFactory::AUD_MixerFactory(AUD_IReader* reader, + AUD_Specs specs) +{ + m_specs = specs; + m_reader = reader; + m_factory = 0; +} + +AUD_MixerFactory::AUD_MixerFactory(AUD_IFactory* factory, + AUD_Specs specs) +{ + m_specs = specs; + m_reader = 0; + m_factory = factory; +} + +AUD_MixerFactory::AUD_MixerFactory(AUD_Specs specs) +{ + m_specs = specs; + m_reader = 0; + m_factory = 0; +} + +AUD_MixerFactory::~AUD_MixerFactory() +{ + if(m_reader != 0) + { + delete m_reader; AUD_DELETE("reader") + } +} + +AUD_Specs AUD_MixerFactory::getSpecs() +{ + return m_specs; +} + +void AUD_MixerFactory::setSpecs(AUD_Specs specs) +{ + m_specs = specs; +} + +void AUD_MixerFactory::setReader(AUD_IReader* reader) +{ + if(m_reader != 0) + { + delete m_reader; AUD_DELETE("reader") + } + m_reader = reader; +} + +void AUD_MixerFactory::setFactory(AUD_IFactory* factory) +{ + m_factory = factory; +} + +AUD_IFactory* AUD_MixerFactory::getFactory() +{ + return m_factory; +} diff --git a/intern/audaspace/intern/AUD_MixerFactory.h b/intern/audaspace/intern/AUD_MixerFactory.h new file mode 100644 index 00000000000..c61dd283c67 --- /dev/null +++ b/intern/audaspace/intern/AUD_MixerFactory.h @@ -0,0 +1,117 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_MIXERFACTORY +#define AUD_MIXERFACTORY + +#include "AUD_IFactory.h" + +/** + * This factory is a base class for all mixer factories. + */ +class AUD_MixerFactory : public AUD_IFactory +{ +protected: + /** + * The reader that should be mixed later. + */ + AUD_IReader* m_reader; + + /** + * If there is no reader it is created out of this factory. + */ + AUD_IFactory* m_factory; + + /** + * The target specification for resampling. + */ + AUD_Specs m_specs; + + /** + * Returns the reader created out of the factory or taken from m_reader. + * This method can be used for the createReader function of the implementing + * classes. + * \return The reader to mix, or NULL if there is no reader or factory. + */ + AUD_IReader* getReader(); + +public: + /** + * Creates a new factory. + * \param reader The reader to mix. + * \param specs The target specification. + */ + AUD_MixerFactory(AUD_IReader* reader, AUD_Specs specs); + + /** + * Creates a new factory. + * \param factory The factory to create the readers to mix out of. + * \param specs The target specification. + */ + AUD_MixerFactory(AUD_IFactory* factory, AUD_Specs specs); + + /** + * Creates a new factory. + * \param specs The target specification. + */ + AUD_MixerFactory(AUD_Specs specs); + + /** + * Destroys the resampling factory. + */ + virtual ~AUD_MixerFactory(); + + /** + * Returns the target specification for resampling. + */ + AUD_Specs getSpecs(); + + /** + * Sets the target specification for resampling. + * \param specs The specification. + */ + void setSpecs(AUD_Specs specs); + + /** + * Sets the reader for resampling. + * If there has already been a reader, it will be deleted. + * \param reader The reader that should be used as source for resampling. + */ + void setReader(AUD_IReader* reader); + + /** + * Sets the factory for resampling. + * \param factory The factory that should be used as source for resampling. + */ + void setFactory(AUD_IFactory* factory); + + /** + * Returns the saved factory. + * \return The factory or NULL if there has no factory been saved. + */ + AUD_IFactory* getFactory(); +}; + +#endif //AUD_MIXERFACTORY diff --git a/intern/audaspace/intern/AUD_NULLDevice.cpp b/intern/audaspace/intern/AUD_NULLDevice.cpp new file mode 100644 index 00000000000..d237b71b67e --- /dev/null +++ b/intern/audaspace/intern/AUD_NULLDevice.cpp @@ -0,0 +1,108 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_NULLDevice.h" +#include "AUD_IReader.h" +#include "AUD_IFactory.h" + +AUD_NULLDevice::AUD_NULLDevice() +{ + m_specs.channels = AUD_CHANNELS_INVALID; + m_specs.format = AUD_FORMAT_INVALID; + m_specs.rate = AUD_RATE_INVALID; +} + +AUD_Specs AUD_NULLDevice::getSpecs() +{ + return m_specs; +} + +AUD_Handle* AUD_NULLDevice::play(AUD_IFactory* factory, bool keep) +{ + return 0; +} + +bool AUD_NULLDevice::pause(AUD_Handle* handle) +{ + return false; +} + +bool AUD_NULLDevice::resume(AUD_Handle* handle) +{ + return false; +} + +bool AUD_NULLDevice::stop(AUD_Handle* handle) +{ + return false; +} + +bool AUD_NULLDevice::setKeep(AUD_Handle* handle, bool keep) +{ + return false; +} + +bool AUD_NULLDevice::sendMessage(AUD_Handle* handle, AUD_Message &message) +{ + return false; +} + +bool AUD_NULLDevice::seek(AUD_Handle* handle, float position) +{ + return false; +} + +float AUD_NULLDevice::getPosition(AUD_Handle* handle) +{ + return 0.0f; +} + +AUD_Status AUD_NULLDevice::getStatus(AUD_Handle* handle) +{ + return AUD_STATUS_INVALID; +} + +void AUD_NULLDevice::lock() +{ +} + +void AUD_NULLDevice::unlock() +{ +} + +bool AUD_NULLDevice::checkCapability(int capability) +{ + return false; +} + +bool AUD_NULLDevice::setCapability(int capability, void *value) +{ + return false; +} + +bool AUD_NULLDevice::getCapability(int capability, void *value) +{ + return false; +} diff --git a/intern/audaspace/intern/AUD_NULLDevice.h b/intern/audaspace/intern/AUD_NULLDevice.h new file mode 100644 index 00000000000..155f24f8837 --- /dev/null +++ b/intern/audaspace/intern/AUD_NULLDevice.h @@ -0,0 +1,65 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_NULLDEVICE +#define AUD_NULLDEVICE + +#include "AUD_IDevice.h" + +/** + * This device plays nothing. + */ +class AUD_NULLDevice : public AUD_IDevice +{ +private: + /** + * The specs of the device. + */ + AUD_Specs m_specs; + +public: + /** + * Creates a new NULL device. + */ + AUD_NULLDevice(); + + virtual AUD_Specs getSpecs(); + virtual AUD_Handle* play(AUD_IFactory* factory, bool keep = false); + virtual bool pause(AUD_Handle* handle); + virtual bool resume(AUD_Handle* handle); + virtual bool stop(AUD_Handle* handle); + virtual bool setKeep(AUD_Handle* handle, bool keep); + virtual bool sendMessage(AUD_Handle* handle, AUD_Message &message); + virtual bool seek(AUD_Handle* handle, float position); + virtual float getPosition(AUD_Handle* handle); + virtual AUD_Status getStatus(AUD_Handle* handle); + virtual void lock(); + virtual void unlock(); + virtual bool checkCapability(int capability); + virtual bool setCapability(int capability, void *value); + virtual bool getCapability(int capability, void *value); +}; + +#endif //AUD_NULLDEVICE diff --git a/intern/audaspace/intern/AUD_ReadDevice.cpp b/intern/audaspace/intern/AUD_ReadDevice.cpp new file mode 100644 index 00000000000..e2c1d2fac81 --- /dev/null +++ b/intern/audaspace/intern/AUD_ReadDevice.cpp @@ -0,0 +1,64 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_FloatMixer.h" +#include "AUD_ReadDevice.h" +#include "AUD_IReader.h" + +#include + +AUD_ReadDevice::AUD_ReadDevice(AUD_Specs specs) +{ + m_specs = specs; + + m_mixer = new AUD_FloatMixer(); AUD_NEW("mixer") + m_mixer->setSpecs(m_specs); + + m_playing = false; + + create(); +} + +AUD_ReadDevice::~AUD_ReadDevice() +{ + destroy(); +} + +bool AUD_ReadDevice::read(sample_t* buffer, int length) +{ + if(m_playing) + mix(buffer, length); + else + if(m_specs.format == AUD_FORMAT_U8) + memset(buffer, 0x80, length * AUD_SAMPLE_SIZE(m_specs)); + else + memset(buffer, 0, length * AUD_SAMPLE_SIZE(m_specs)); + return m_playing; +} + +void AUD_ReadDevice::playing(bool playing) +{ + m_playing = playing; +} diff --git a/intern/audaspace/intern/AUD_ReadDevice.h b/intern/audaspace/intern/AUD_ReadDevice.h new file mode 100644 index 00000000000..d69b0c31ea5 --- /dev/null +++ b/intern/audaspace/intern/AUD_ReadDevice.h @@ -0,0 +1,68 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_READDEVICE +#define AUD_READDEVICE + +#include "AUD_SoftwareDevice.h" + +/** + * This device enables to let the user read raw data out of it. + */ +class AUD_ReadDevice : public AUD_SoftwareDevice +{ +protected: + virtual void playing(bool playing); + +private: + /** + * Whether the device currently. + */ + bool m_playing; + +public: + /** + * Creates a new read device. + * \param specs The wanted audio specification. + */ + AUD_ReadDevice(AUD_Specs specs); + + /** + * Closes the device. + */ + virtual ~AUD_ReadDevice(); + + /** + * Reads the next bytes into the supplied buffer. + * \param buffer The target buffer. + * \param length The length in samples to be filled. + * \return True if the reading succeeded, false if there are no sounds + * played back currently, in that case the buffer is filled with + * silence. + */ + bool read(sample_t* buffer, int length); +}; + +#endif //AUD_READDEVICE diff --git a/intern/audaspace/intern/AUD_Reference.h b/intern/audaspace/intern/AUD_Reference.h new file mode 100644 index 00000000000..9bb9d7440b3 --- /dev/null +++ b/intern/audaspace/intern/AUD_Reference.h @@ -0,0 +1,115 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_REFERENCE +#define AUD_REFERENCE + +template +/** + * This class provides reference counting functionality. + */ +class AUD_Reference +{ +private: + /// The reference. + T* m_reference; + /// The reference counter. + int* m_refcount; +public: + /** + * Creates a new reference counter. + * \param reference The reference. + */ + AUD_Reference(T* reference = 0) + { + m_reference = reference; + m_refcount = new int; AUD_NEW("int") + *m_refcount = 1; + } + + /** + * Copies a AUD_Reference object. + * \param ref The AUD_Reference object to copy. + */ + AUD_Reference(const AUD_Reference& ref) + { + m_reference = ref.m_reference; + m_refcount = ref.m_refcount; + (*m_refcount)++; + } + + /** + * Destroys a AUD_Reference object, if there's no furthere reference on the + * reference, it is destroyed as well. + */ + ~AUD_Reference() + { + (*m_refcount)--; + if(*m_refcount == 0) + { + if(m_reference != 0) + { + delete m_reference; AUD_DELETE("buffer") + } + delete m_refcount; AUD_DELETE("int") + } + } + + /** + * Copies a AUD_Reference object. + * \param ref The AUD_Reference object to copy. + */ + AUD_Reference& operator=(const AUD_Reference& ref) + { + if(&ref == this) + return *this; + + (*m_refcount)--; + if(*m_refcount == 0) + { + if(m_reference != 0) + { + delete m_reference; AUD_DELETE("buffer") + } + delete m_refcount; AUD_DELETE("int") + } + + m_reference = ref.m_reference; + m_refcount = ref.m_refcount; + (*m_refcount)++; + + return *this; + } + + /** + * Returns the reference. + */ + T* get() + { + return m_reference; + } +}; + +#endif // AUD_REFERENCE diff --git a/intern/audaspace/intern/AUD_ResampleFactory.h b/intern/audaspace/intern/AUD_ResampleFactory.h new file mode 100644 index 00000000000..5493e1005b7 --- /dev/null +++ b/intern/audaspace/intern/AUD_ResampleFactory.h @@ -0,0 +1,33 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_RESAMPLEFACTORY +#define AUD_RESAMPLEFACTORY + +#include "AUD_MixerFactory.h" + +typedef AUD_MixerFactory AUD_ResampleFactory; + +#endif //AUD_RESAMPLEFACTORY diff --git a/intern/audaspace/intern/AUD_SinusFactory.cpp b/intern/audaspace/intern/AUD_SinusFactory.cpp new file mode 100644 index 00000000000..ae878b9df60 --- /dev/null +++ b/intern/audaspace/intern/AUD_SinusFactory.cpp @@ -0,0 +1,51 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SinusFactory.h" +#include "AUD_SinusReader.h" +#include "AUD_Space.h" + +AUD_SinusFactory::AUD_SinusFactory(double frequency, AUD_SampleRate sampleRate) +{ + m_frequency = frequency; + m_sampleRate = sampleRate; +} + +AUD_IReader* AUD_SinusFactory::createReader() +{ + AUD_IReader* reader = new AUD_SinusReader(m_frequency, m_sampleRate); + AUD_NEW("reader") + return reader; +} + +double AUD_SinusFactory::getFrequency() +{ + return m_frequency; +} + +void AUD_SinusFactory::setFrequency(double frequency) +{ + m_frequency = frequency; +} diff --git a/intern/audaspace/intern/AUD_SinusFactory.h b/intern/audaspace/intern/AUD_SinusFactory.h new file mode 100644 index 00000000000..ffb36e741b9 --- /dev/null +++ b/intern/audaspace/intern/AUD_SinusFactory.h @@ -0,0 +1,70 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SINUSFACTORY +#define AUD_SINUSFACTORY + +#include "AUD_IFactory.h" + +/** + * This factory creates a reader that plays a sine tone. + */ +class AUD_SinusFactory : public AUD_IFactory +{ +private: + /** + * The frequence of the sine wave. + */ + double m_frequency; + + /** + * The target sample rate for output. + */ + AUD_SampleRate m_sampleRate; + +public: + /** + * Creates a new sine factory. + * \param frequency The desired frequency. + * \param sampleRate The target sample rate for playback. + */ + AUD_SinusFactory(double frequency, + AUD_SampleRate sampleRate = AUD_RATE_44100); + + /** + * Returns the frequency of the sine wave. + */ + double getFrequency(); + + /** + * Sets the frequency. + * \param frequency The new frequency. + */ + void setFrequency(double frequency); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_SINUSFACTORY diff --git a/intern/audaspace/intern/AUD_SinusReader.cpp b/intern/audaspace/intern/AUD_SinusReader.cpp new file mode 100644 index 00000000000..87e2f789d66 --- /dev/null +++ b/intern/audaspace/intern/AUD_SinusReader.cpp @@ -0,0 +1,104 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SinusReader.h" +#include "AUD_Buffer.h" + +#include + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +AUD_SinusReader::AUD_SinusReader(double frequency, AUD_SampleRate sampleRate) +{ + m_frequency = frequency; + m_position = 0; + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") + m_sampleRate = sampleRate; +} + +AUD_SinusReader::~AUD_SinusReader() +{ + delete m_buffer; AUD_DELETE("buffer") +} + +bool AUD_SinusReader::isSeekable() +{ + return true; +} + +void AUD_SinusReader::seek(int position) +{ + m_position = position; +} + +int AUD_SinusReader::getLength() +{ + return -1; +} + +int AUD_SinusReader::getPosition() +{ + return m_position; +} + +AUD_Specs AUD_SinusReader::getSpecs() +{ + AUD_Specs specs; + specs.rate = m_sampleRate; + specs.format = AUD_FORMAT_S16; + specs.channels = AUD_CHANNELS_STEREO; + return specs; +} + +AUD_ReaderType AUD_SinusReader::getType() +{ + return AUD_TYPE_STREAM; +} + +bool AUD_SinusReader::notify(AUD_Message &message) +{ + return false; +} + +void AUD_SinusReader::read(int & length, sample_t* & buffer) +{ + // resize if necessary + if(m_buffer->getSize() < length*4) + m_buffer->resize(length*4); + + // fill with sine data + short* buf = (short*) m_buffer->getBuffer(); + for(int i=0; i < length; i++) + { + buf[i*2] = sin((m_position + i) * 2.0 * M_PI * m_frequency / + (float)m_sampleRate) * 32700; + buf[i*2+1] = buf[i*2]; + } + + buffer = (sample_t*)buf; + m_position += length; +} diff --git a/intern/audaspace/intern/AUD_SinusReader.h b/intern/audaspace/intern/AUD_SinusReader.h new file mode 100644 index 00000000000..cb060dd8a43 --- /dev/null +++ b/intern/audaspace/intern/AUD_SinusReader.h @@ -0,0 +1,86 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SINUSREADER +#define AUD_SINUSREADER + +#include "AUD_IReader.h" +class AUD_Buffer; + +/** + * This class is used for sine tone playback. + * The output format is in the 16 bit format and stereo, the sample rate can be + * specified. + * As the two channels both play the same the output could also be mono, but + * in most cases this will result in having to resample for output, so stereo + * sound is created directly. + */ +class AUD_SinusReader : public AUD_IReader +{ +private: + /** + * The frequency of the sine wave. + */ + double m_frequency; + + /** + * The current position in samples. + */ + int m_position; + + /** + * The playback buffer. + */ + AUD_Buffer* m_buffer; + + /** + * The sample rate for the output. + */ + AUD_SampleRate m_sampleRate; + +public: + /** + * Creates a new reader. + * \param frequency The frequency of the sine wave. + * \param sampleRate The output sample rate. + */ + AUD_SinusReader(double frequency, AUD_SampleRate sampleRate); + + /** + * Destroys the reader. + */ + virtual ~AUD_SinusReader(); + + virtual bool isSeekable(); + virtual void seek(int position); + virtual int getLength(); + virtual int getPosition(); + virtual AUD_Specs getSpecs(); + virtual AUD_ReaderType getType(); + virtual bool notify(AUD_Message &message); + virtual void read(int & length, sample_t* & buffer); +}; + +#endif //AUD_SINUSREADER diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.cpp b/intern/audaspace/intern/AUD_SoftwareDevice.cpp new file mode 100644 index 00000000000..174ff8c8979 --- /dev/null +++ b/intern/audaspace/intern/AUD_SoftwareDevice.cpp @@ -0,0 +1,444 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SoftwareDevice.h" +#include "AUD_IReader.h" +#include "AUD_IMixer.h" +#include "AUD_IFactory.h" +#include "AUD_SourceCaps.h" + +#include + +/// Saves the data for playback. +struct AUD_SoftwareHandle : AUD_Handle +{ + /// The reader source. + AUD_IReader* reader; + + /// Whether to keep the source if end of it is reached. + bool keep; + + /// The volume of the source. + float volume; +}; + +typedef std::list::iterator AUD_HandleIterator; + +void AUD_SoftwareDevice::create() +{ + m_playingSounds = new std::list(); AUD_NEW("list") + m_pausedSounds = new std::list(); AUD_NEW("list") + m_playback = false; + m_volume = 1.0; + + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + + pthread_mutex_init(&m_mutex, &attr); + + pthread_mutexattr_destroy(&attr); +} + +void AUD_SoftwareDevice::destroy() +{ + if(m_playback) + playing(m_playback = false); + + delete m_mixer; AUD_DELETE("mixer") + + // delete all playing sounds + while(m_playingSounds->begin() != m_playingSounds->end()) + { + delete (*(m_playingSounds->begin()))->reader; AUD_DELETE("reader") + delete *(m_playingSounds->begin()); AUD_DELETE("handle") + m_playingSounds->erase(m_playingSounds->begin()); + } + delete m_playingSounds; AUD_DELETE("list") + + // delete all paused sounds + while(m_pausedSounds->begin() != m_pausedSounds->end()) + { + delete (*(m_pausedSounds->begin()))->reader; AUD_DELETE("reader") + delete *(m_pausedSounds->begin()); AUD_DELETE("handle") + m_pausedSounds->erase(m_pausedSounds->begin()); + } + delete m_pausedSounds; AUD_DELETE("list") + + pthread_mutex_destroy(&m_mutex); +} + +void AUD_SoftwareDevice::mix(sample_t* buffer, int length) +{ + lock(); + + AUD_SoftwareHandle* sound; + int len; + sample_t* buf; + int sample_size = AUD_SAMPLE_SIZE(m_specs); + std::list stopSounds; + + // for all sounds + AUD_HandleIterator it = m_playingSounds->begin(); + while(it != m_playingSounds->end()) + { + sound = *it; + // increment the iterator to make sure it's valid, + // in case the sound gets deleted after stopping + ++it; + + // get the buffer from the source + len = length; + sound->reader->read(len, buf); + + m_mixer->add(buf, sound->reader->getSpecs(), len, sound->volume); + + // in case the end of the sound is reached + if(len < length) + { + if(sound->keep) + pause(sound); + else + stopSounds.push_back(sound); + } + } + + // fill with silence + if(m_specs.format == AUD_FORMAT_U8) + memset(buffer, 0x80, length * sample_size); + else + memset(buffer, 0, length * sample_size); + + // superpose + m_mixer->superpose(buffer, length, m_volume); + + while(!stopSounds.empty()) + { + sound = stopSounds.front(); + stopSounds.pop_front(); + stop(sound); + } + + unlock(); +} + +bool AUD_SoftwareDevice::isValid(AUD_Handle* handle) +{ + for(AUD_HandleIterator i = m_playingSounds->begin(); + i != m_playingSounds->end(); i++) + if(*i == handle) + return true; + for(AUD_HandleIterator i = m_pausedSounds->begin(); + i != m_pausedSounds->end(); i++) + if(*i == handle) + return true; + return false; +} + +void AUD_SoftwareDevice::setMixer(AUD_IMixer* mixer) +{ + delete m_mixer; AUD_DELETE("mixer") + m_mixer = mixer; + mixer->setSpecs(m_specs); +} + +AUD_Specs AUD_SoftwareDevice::getSpecs() +{ + return m_specs; +} + +AUD_Handle* AUD_SoftwareDevice::play(AUD_IFactory* factory, bool keep) +{ + AUD_IReader* reader = factory->createReader(); + + if(reader == NULL) + AUD_THROW(AUD_ERROR_READER); + + // prepare the reader + reader = m_mixer->prepare(reader); + if(reader == NULL) + return NULL; + + AUD_Specs rs = reader->getSpecs(); + + // play sound + AUD_SoftwareHandle* sound = new AUD_SoftwareHandle; AUD_NEW("handle") + sound->keep = keep; + sound->reader = reader; + sound->volume = 1.0; + + lock(); + m_playingSounds->push_back(sound); + + if(!m_playback) + playing(m_playback = true); + unlock(); + + return sound; +} + +bool AUD_SoftwareDevice::pause(AUD_Handle* handle) +{ + // only songs that are played can be paused + lock(); + for(AUD_HandleIterator i = m_playingSounds->begin(); + i != m_playingSounds->end(); i++) + { + if(*i == handle) + { + m_pausedSounds->push_back(*i); + m_playingSounds->erase(i); + if(m_playingSounds->empty()) + playing(m_playback = false); + unlock(); + return true; + } + } + unlock(); + return false; +} + +bool AUD_SoftwareDevice::resume(AUD_Handle* handle) +{ + // only songs that are paused can be resumed + lock(); + for(AUD_HandleIterator i = m_pausedSounds->begin(); + i != m_pausedSounds->end(); i++) + { + if(*i == handle) + { + m_playingSounds->push_back(*i); + m_pausedSounds->erase(i); + if(!m_playback) + playing(m_playback = true); + unlock(); + return true; + } + } + unlock(); + return false; +} + +bool AUD_SoftwareDevice::stop(AUD_Handle* handle) +{ + lock(); + for(AUD_HandleIterator i = m_playingSounds->begin(); + i != m_playingSounds->end(); i++) + { + if(*i == handle) + { + delete (*i)->reader; AUD_DELETE("reader") + delete *i; AUD_DELETE("handle") + m_playingSounds->erase(i); + if(m_playingSounds->empty()) + playing(m_playback = false); + unlock(); + return true; + } + } + for(AUD_HandleIterator i = m_pausedSounds->begin(); + i != m_pausedSounds->end(); i++) + { + if(*i == handle) + { + delete (*i)->reader; AUD_DELETE("reader") + delete *i; AUD_DELETE("handle") + m_pausedSounds->erase(i); + unlock(); + return true; + } + } + unlock(); + return false; +} + +bool AUD_SoftwareDevice::setKeep(AUD_Handle* handle, bool keep) +{ + lock(); + if(isValid(handle)) + { + ((AUD_SoftwareHandle*)handle)->keep = keep; + unlock(); + return true; + } + unlock(); + return false; +} + +bool AUD_SoftwareDevice::sendMessage(AUD_Handle* handle, AUD_Message &message) +{ + lock(); + + bool result = false; + + if(handle == 0) + { + for(AUD_HandleIterator i = m_playingSounds->begin(); + i != m_playingSounds->end(); i++) + result |= (*i)->reader->notify(message); + for(AUD_HandleIterator i = m_pausedSounds->begin(); + i != m_pausedSounds->end(); i++) + result |= (*i)->reader->notify(message); + } + else if(isValid(handle)) + result = ((AUD_SoftwareHandle*)handle)->reader->notify(message); + unlock(); + return result; +} + +bool AUD_SoftwareDevice::seek(AUD_Handle* handle, float position) +{ + lock(); + + if(isValid(handle)) + { + AUD_IReader* reader = ((AUD_SoftwareHandle*)handle)->reader; + reader->seek((int)(position * reader->getSpecs().rate)); + unlock(); + return true; + } + + unlock(); + return false; +} + +float AUD_SoftwareDevice::getPosition(AUD_Handle* handle) +{ + lock(); + + float position = 0.0f; + + if(isValid(handle)) + { + AUD_SoftwareHandle* h = (AUD_SoftwareHandle*)handle; + position = h->reader->getPosition() / (float)m_specs.rate; + } + + unlock(); + return position; +} + +AUD_Status AUD_SoftwareDevice::getStatus(AUD_Handle* handle) +{ + lock(); + for(AUD_HandleIterator i = m_playingSounds->begin(); + i != m_playingSounds->end(); i++) + { + if(*i == handle) + { + unlock(); + return AUD_STATUS_PLAYING; + } + } + for(AUD_HandleIterator i = m_pausedSounds->begin(); + i != m_pausedSounds->end(); i++) + { + if(*i == handle) + { + unlock(); + return AUD_STATUS_PAUSED; + } + } + unlock(); + return AUD_STATUS_INVALID; +} + +void AUD_SoftwareDevice::lock() +{ + pthread_mutex_lock(&m_mutex); +} + +void AUD_SoftwareDevice::unlock() +{ + pthread_mutex_unlock(&m_mutex); +} + +bool AUD_SoftwareDevice::checkCapability(int capability) +{ + return capability == AUD_CAPS_SOFTWARE_DEVICE || + capability == AUD_CAPS_VOLUME || + capability == AUD_CAPS_SOURCE_VOLUME; +} + +bool AUD_SoftwareDevice::setCapability(int capability, void *value) +{ + switch(capability) + { + case AUD_CAPS_VOLUME: + lock(); + m_volume = *((float*)value); + if(m_volume > 1.0) + m_volume = 1.0; + else if(m_volume < 0.0) + m_volume = 0.0; + unlock(); + return true; + case AUD_CAPS_SOURCE_VOLUME: + { + AUD_SourceCaps* caps = (AUD_SourceCaps*) value; + lock(); + if(isValid(caps->handle)) + { + AUD_SoftwareHandle* handle = (AUD_SoftwareHandle*)caps->handle; + handle->volume = caps->value; + if(handle->volume > 1.0) + handle->volume = 1.0; + else if(handle->volume < 0.0) + handle->volume = 0.0; + unlock(); + return true; + } + unlock(); + } + break; + } + return false; +} + +bool AUD_SoftwareDevice::getCapability(int capability, void *value) +{ + switch(capability) + { + case AUD_CAPS_VOLUME: + lock(); + *((float*)value) = m_volume; + unlock(); + return true; + case AUD_CAPS_SOURCE_VOLUME: + { + AUD_SourceCaps* caps = (AUD_SourceCaps*) value; + lock(); + if(isValid(caps->handle)) + { + caps->value = ((AUD_SoftwareHandle*)caps->handle)->volume; + unlock(); + return true; + } + unlock(); + } + break; + } + return false; +} diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.h b/intern/audaspace/intern/AUD_SoftwareDevice.h new file mode 100644 index 00000000000..3768786fa9c --- /dev/null +++ b/intern/audaspace/intern/AUD_SoftwareDevice.h @@ -0,0 +1,137 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SOFTWAREDEVICE +#define AUD_SOFTWAREDEVICE + +#include "AUD_IDevice.h" +struct AUD_SoftwareHandle; +class AUD_IMixer; + +#include +#include + +/** + * This device plays is a generic device with software mixing. + * Classes implementing this have to: + * - Implement the playing function. + * - Prepare the m_specs, m_mixer variables. + * - Call the create and destroy functions. + * - Call the mix function to retrieve their audio data. + */ +class AUD_SoftwareDevice : public AUD_IDevice +{ +protected: + /** + * The specification of the device. + */ + AUD_Specs m_specs; + + /** + * The mixer. Will be deleted by the destroy function. + */ + AUD_IMixer* m_mixer; + + /** + * Initializes member variables. + */ + void create(); + + /** + * Uninitializes member variables. + */ + void destroy(); + + /** + * Mixes the next samples into the buffer. + * \param buffer The target buffer. + * \param length The length in samples to be filled. + */ + void mix(sample_t* buffer, int length); + + /** + * This function tells the device, to start or pause playback. + * \param playing True if device should playback. + */ + virtual void playing(bool playing)=0; + +private: + /** + * The list of sounds that are currently playing. + */ + std::list* m_playingSounds; + + /** + * The list of sounds that are currently paused. + */ + std::list* m_pausedSounds; + + /** + * Whether there is currently playback. + */ + bool m_playback; + + /** + * The mutex for locking. + */ + pthread_mutex_t m_mutex; + + /** + * The overall volume of the device. + */ + float m_volume; + + /** + * Checks if a handle is valid. + * \param handle The handle to check. + * \return Whether the handle is valid. + */ + bool isValid(AUD_Handle* handle); + +public: + /** + * Sets a new mixer. + * \param mixer The new mixer. + */ + void setMixer(AUD_IMixer* mixer); + + virtual AUD_Specs getSpecs(); + virtual AUD_Handle* play(AUD_IFactory* factory, bool keep = false); + virtual bool pause(AUD_Handle* handle); + virtual bool resume(AUD_Handle* handle); + virtual bool stop(AUD_Handle* handle); + virtual bool setKeep(AUD_Handle* handle, bool keep); + virtual bool sendMessage(AUD_Handle* handle, AUD_Message &message); + virtual bool seek(AUD_Handle* handle, float position); + virtual float getPosition(AUD_Handle* handle); + virtual AUD_Status getStatus(AUD_Handle* handle); + virtual void lock(); + virtual void unlock(); + virtual bool checkCapability(int capability); + virtual bool setCapability(int capability, void *value); + virtual bool getCapability(int capability, void *value); +}; + +#endif //AUD_SOFTWAREDEVICE diff --git a/intern/audaspace/intern/AUD_SourceCaps.h b/intern/audaspace/intern/AUD_SourceCaps.h new file mode 100644 index 00000000000..b1edd2b9b4e --- /dev/null +++ b/intern/audaspace/intern/AUD_SourceCaps.h @@ -0,0 +1,41 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SOURCECAPS +#define AUD_SOURCECAPS + +#include "AUD_IDevice.h" + +/// The structure for source capabilities. +typedef struct +{ + /// The source to apply the capability on. + AUD_Handle* handle; + + /// The value for the capability. + float value; +} AUD_SourceCaps; + +#endif //AUD_SOURCECAPS diff --git a/intern/audaspace/intern/AUD_Space.h b/intern/audaspace/intern/AUD_Space.h new file mode 100644 index 00000000000..123d9c272a0 --- /dev/null +++ b/intern/audaspace/intern/AUD_Space.h @@ -0,0 +1,295 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SPACE +#define AUD_SPACE + +/// The size of a format in bytes. +#define AUD_FORMAT_SIZE(format) (format & 0x0F) +/// The size of a sample in the specified format in bytes. +#define AUD_SAMPLE_SIZE(specs) (specs.channels * (specs.format & 0x0F)) +/// Throws a AUD_Exception with the provided error code. +#define AUD_THROW(exception) { AUD_Exception e; e.error = exception; throw e; } + +/// Returns the smaller of the two values. +#define AUD_MIN(a, b) (((a) < (b)) ? (a) : (b)) +/// Returns the bigger of the two values. +#define AUD_MAX(a, b) (((a) > (b)) ? (a) : (b)) + +// 5 sec * 44100 samples/sec * 4 bytes/sample * 6 channels +/// The size by which a buffer should be resized if the final extent is unknown. +#define AUD_BUFFER_RESIZE_BYTES 5292000 + +/// The default playback buffer size of a device. +#define AUD_DEFAULT_BUFFER_SIZE 1024 + +// Capability defines + +/// This capability checks whether a device is a 3D device. See AUD_I3DDevice.h. +#define AUD_CAPS_3D_DEVICE 0x0001 + +/** + * This capability checks whether a device is a software device. See + * AUD_SoftwareDevice. + */ +#define AUD_CAPS_SOFTWARE_DEVICE 0x0002 + +/** + * This capability enables the user to set the overall volume of the device. + * You can set and get it with the pointer pointing to a float value between + * 0.0 (muted) and 1.0 (maximum volume). + */ +#define AUD_CAPS_VOLUME 0x0101 + +/** + * This capability enables the user to set the volume of a source. + * You can set and get it with the pointer pointing to a AUD_SourceValue + * structure defined in AUD_SourceCaps.h. + */ +#define AUD_CAPS_SOURCE_VOLUME 0x1001 + +/** + * This capability enables the user to set the pitch of a source. + * You can set and get it with the pointer pointing to a AUD_SourceValue + * structure defined in AUD_SourceCaps.h. + */ +#define AUD_CAPS_SOURCE_PITCH 0x1002 + +/** + * This capability enables the user to buffer a factory into the device. + * Setting with the factory as pointer loads the factory into a device internal + * buffer. Play function calls with the buffered factory as argument result in + * the internal buffer being played back, so there's no reader created, what + * also results in not being able to send messages to that handle. + * A repeated call with the same factory doesn't do anything. + * A set call with a NULL pointer results in all buffered factories being + * deleted. + * \note This is only possible with factories that create readers of the buffer + * type. + */ +#define AUD_CAPS_BUFFERED_FACTORY 0x2001 + +// Used for debugging memory leaks. +//#define AUD_DEBUG_MEMORY + +#ifdef AUD_DEBUG_MEMORY +int AUD_References(int count = 0, const char* text = ""); +#define AUD_NEW(text) AUD_References(1, text); +#define AUD_DELETE(text) AUD_References(-1, text); +#else +#define AUD_NEW(text) +#define AUD_DELETE(text) +#endif + +/** + * The format of a sample. + * The last 4 bit save the byte count of the format. + */ +typedef enum +{ + AUD_FORMAT_INVALID = 0x00, /// Invalid sample format. + AUD_FORMAT_U8 = 0x01, /// 1 byte unsigned byte. + AUD_FORMAT_S16 = 0x12, /// 2 byte signed integer. + AUD_FORMAT_S24 = 0x13, /// 3 byte signed integer. + AUD_FORMAT_S32 = 0x14, /// 4 byte signed integer. + AUD_FORMAT_FLOAT32 = 0x24, /// 4 byte float. + AUD_FORMAT_FLOAT64 = 0x28 /// 8 byte float. +} AUD_SampleFormat; + +/// The channel count. +typedef enum +{ + AUD_CHANNELS_INVALID = 0, /// Invalid channel count. + AUD_CHANNELS_MONO = 1, /// Mono. + AUD_CHANNELS_STEREO = 2, /// Stereo. + AUD_CHANNELS_STEREO_LFE = 3, /// Stereo with LFE channel. + AUD_CHANNELS_SURROUND4 = 4, /// 4 channel surround sound. + AUD_CHANNELS_SURROUND5 = 5, /// 5 channel surround sound. + AUD_CHANNELS_SURROUND51 = 6, /// 5.1 surround sound. + AUD_CHANNELS_SURROUND61 = 7, /// 6.1 surround sound. + AUD_CHANNELS_SURROUND71 = 8, /// 7.1 surround sound. + AUD_CHANNELS_SURROUND72 = 9 /// 7.2 surround sound. +} AUD_Channels; + +/** + * The sample rate tells how many samples are played back within one second. + * Some exotic formats may use other sample rates than provided here. + */ +typedef enum +{ + AUD_RATE_INVALID = 0, /// Invalid sample rate. + AUD_RATE_8000 = 8000, /// 8000 Hz. + AUD_RATE_16000 = 16000, /// 16000 Hz. + AUD_RATE_11025 = 11025, /// 11025 Hz. + AUD_RATE_22050 = 22050, /// 22050 Hz. + AUD_RATE_32000 = 32000, /// 32000 Hz. + AUD_RATE_44100 = 44100, /// 44100 Hz. + AUD_RATE_48000 = 48000, /// 48000 Hz. + AUD_RATE_88200 = 88200, /// 88200 Hz. + AUD_RATE_96000 = 96000, /// 96000 Hz. + AUD_RATE_192000 = 192000 /// 192000 Hz. +} AUD_SampleRate; + +/** + * Type of a reader. + * @see AUD_IReader for details. + */ +typedef enum +{ + AUD_TYPE_INVALID = 0, /// Invalid reader type. + AUD_TYPE_BUFFER, /// Reader reads from a buffer. + AUD_TYPE_STREAM /// Reader reads from a stream. +} AUD_ReaderType; + +/// Status of a playback handle. +typedef enum +{ + AUD_STATUS_INVALID = 0, /// Invalid handle. Maybe due to stopping. + AUD_STATUS_PLAYING, /// Sound is playing. + AUD_STATUS_PAUSED /// Sound is being paused. +} AUD_Status; + +/// Error codes for exceptions (C++ library) or for return values (C API). +typedef enum +{ + AUD_NO_ERROR = 0, + AUD_ERROR_READER, + AUD_ERROR_FACTORY, + AUD_ERROR_FILE, + AUD_ERROR_FFMPEG, + AUD_ERROR_SDL, + AUD_ERROR_OPENAL, + AUD_ERROR_JACK +} AUD_Error; + +/// Message codes. +typedef enum +{ + AUD_MSG_INVALID = 0, /// Invalid message. + AUD_MSG_LOOP, /// Loop reader message. + AUD_MSG_VOLUME /// Volume reader message. +} AUD_MessageType; + +/// Fading types. +typedef enum +{ + AUD_FADE_IN, + AUD_FADE_OUT +} AUD_FadeType; + +/// 3D device settings. +typedef enum +{ + AUD_3DS_NONE, /// No setting. + AUD_3DS_SPEED_OF_SOUND, /// Speed of sound. + AUD_3DS_DOPPLER_FACTOR, /// Doppler factor. + AUD_3DS_DISTANCE_MODEL /// Distance model. +} AUD_3DSetting; + +/// Possible distance models for the 3D device. +#define AUD_DISTANCE_MODEL_NONE 0.0f +#define AUD_DISTANCE_MODEL_INVERSE 1.0f +#define AUD_DISTANCE_MODEL_INVERSE_CLAMPED 2.0f +#define AUD_DISTANCE_MODEL_LINEAR 3.0f +#define AUD_DISTANCE_MODEL_LINEAR_CLAMPED 4.0f +#define AUD_DISTANCE_MODEL_EXPONENT 5.0f +#define AUD_DISTANCE_MODEL_EXPONENT_CLAMPED 6.0f + +/// 3D source settings. +typedef enum +{ + AUD_3DSS_NONE, /// No setting. + AUD_3DSS_IS_RELATIVE, /// > 0 tells that the sound source is + /// relative to the listener + AUD_3DSS_MIN_GAIN, /// Minimum gain. + AUD_3DSS_MAX_GAIN, /// Maximum gain. + AUD_3DSS_REFERENCE_DISTANCE, /// Reference distance. + AUD_3DSS_MAX_DISTANCE, /// Maximum distance. + AUD_3DSS_ROLLOFF_FACTOR, /// Rolloff factor. + AUD_3DSS_CONE_INNER_ANGLE, /// Cone inner angle. + AUD_3DSS_CONE_OUTER_ANGLE, /// Cone outer angle. + AUD_3DSS_CONE_OUTER_GAIN /// Cone outer gain. +} AUD_3DSourceSetting; + +/// Sample pointer type. +typedef unsigned char sample_t; + +/// Specification of a sound source or device. +typedef struct +{ + /// Sample rate in Hz. + AUD_SampleRate rate; + + /// Sample format. + AUD_SampleFormat format; + + /// Channel count. + AUD_Channels channels; +} AUD_Specs; + +/// Exception structure. +typedef struct +{ + /** + * Error code. + * \see AUD_Error + */ + AUD_Error error; + + // void* userData; - for the case it is needed someday +} AUD_Exception; + +/// Message structure. +typedef struct +{ + /** + * The message type. + */ + AUD_MessageType type; + + union + { + // loop reader + int loopcount; + + // volume reader + float volume; + }; +} AUD_Message; + +/// Handle structure, for inherition. +typedef struct +{ + /// x, y and z coordinates of the object. + float position[3]; + + /// x, y and z coordinates telling the velocity and direction of the object. + float velocity[3]; + + /// 3x3 matrix telling the orientation of the object. + float orientation[9]; +} AUD_3DData; + +#endif //AUD_SPACE diff --git a/intern/audaspace/intern/AUD_StreamBufferFactory.cpp b/intern/audaspace/intern/AUD_StreamBufferFactory.cpp new file mode 100644 index 00000000000..11391fa4a08 --- /dev/null +++ b/intern/audaspace/intern/AUD_StreamBufferFactory.cpp @@ -0,0 +1,80 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_StreamBufferFactory.h" +#include "AUD_BufferReader.h" +#include "AUD_Buffer.h" + +#include + +AUD_StreamBufferFactory::AUD_StreamBufferFactory(AUD_IFactory* factory) +{ + AUD_IReader* reader = factory->createReader(); + + if(reader == NULL) + AUD_THROW(AUD_ERROR_READER); + + m_specs = reader->getSpecs(); + m_buffer = AUD_Reference(new AUD_Buffer()); AUD_NEW("buffer") + + int sample_size = AUD_SAMPLE_SIZE(m_specs); + int length; + int index = 0; + sample_t* buffer; + + // get an aproximated size if possible + int size = reader->getLength(); + + if(size <= 0) + size = AUD_BUFFER_RESIZE_BYTES / sample_size; + else + size += m_specs.rate; + + // as long as we fill our buffer to the end + while(index == m_buffer.get()->getSize() / sample_size) + { + // increase + m_buffer.get()->resize(size*sample_size, true); + + // read more + length = size-index; + reader->read(length, buffer); + memcpy(m_buffer.get()->getBuffer()+index*sample_size, + buffer, + length*sample_size); + size += AUD_BUFFER_RESIZE_BYTES / sample_size; + index += length; + } + + m_buffer.get()->resize(index*sample_size, true); + delete reader; AUD_DELETE("reader") +} + +AUD_IReader* AUD_StreamBufferFactory::createReader() +{ + AUD_IReader* reader = new AUD_BufferReader(m_buffer, m_specs); + AUD_NEW("reader") + return reader; +} diff --git a/intern/audaspace/intern/AUD_StreamBufferFactory.h b/intern/audaspace/intern/AUD_StreamBufferFactory.h new file mode 100644 index 00000000000..eda06f6c10c --- /dev/null +++ b/intern/audaspace/intern/AUD_StreamBufferFactory.h @@ -0,0 +1,62 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_STREAMBUFFERFACTORY +#define AUD_STREAMBUFFERFACTORY + +#include "AUD_IFactory.h" +#include "AUD_Reference.h" +class AUD_Buffer; + +/** + * This factory creates a buffer out of a reader. This way normally streamed + * sound sources can be loaded into memory for buffered playback. + */ +class AUD_StreamBufferFactory : public AUD_IFactory +{ +private: + /** + * The buffer that holds the audio data. + */ + AUD_Reference m_buffer; + + /** + * The specification of the samples. + */ + AUD_Specs m_specs; + +public: + /** + * Creates the factory and reads the reader created by the factory supplied + * to the buffer. + * \param factory The factory that creates the reader for buffering. + * \exception AUD_Exception Thrown if the reader cannot be created. + */ + AUD_StreamBufferFactory(AUD_IFactory* factory); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_STREAMBUFFERFACTORY diff --git a/intern/audaspace/intern/Makefile b/intern/audaspace/intern/Makefile new file mode 100644 index 00000000000..2dcc7798f1c --- /dev/null +++ b/intern/audaspace/intern/Makefile @@ -0,0 +1,44 @@ +# +# $Id$ +# +# ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL LICENSE BLOCK ***** +# +# + +LIBNAME = audaspace +DIR = $(OCGDIR)/intern/audaspace + +include nan_compile.mk + +CCFLAGS += $(LEVEL_1_CPP_WARNINGS) + +CPPFLAGS += -I$(LCGDIR)/samplerate/include/ +CPPFLAGS += -I../ffmpeg +CPPFLAGS += -I../FX +CPPFLAGS += -I../SDL +CPPFLAGS += -I../SRC +CPPFLAGS += -I.. +CPPFLAGS += -I. diff --git a/intern/audaspace/jack/AUD_JackDevice.cpp b/intern/audaspace/jack/AUD_JackDevice.cpp new file mode 100644 index 00000000000..445e68e1a9a --- /dev/null +++ b/intern/audaspace/jack/AUD_JackDevice.cpp @@ -0,0 +1,149 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_FloatMixer.h" +#include "AUD_JackDevice.h" +#include "AUD_IReader.h" +#include "AUD_Buffer.h" + +#include +#include + +// AUD_XXX this is not realtime suitable! +int AUD_JackDevice::jack_mix(jack_nframes_t length, void *data) +{ + AUD_JackDevice* device = (AUD_JackDevice*)data; + int samplesize = AUD_SAMPLE_SIZE(device->m_specs); + if(device->m_buffer->getSize() < samplesize * length) + device->m_buffer->resize(samplesize * length); + device->mix(device->m_buffer->getBuffer(), length); + + float* in = (float*) device->m_buffer->getBuffer(); + float* out; + int count = device->m_specs.channels; + + for(int i = 0; i < count; i++) + { + out = (float*)jack_port_get_buffer(device->m_ports[i], length); + for(int j = 0; j < length; j++) + out[j] = in[j * count + i]; + } + + return 0; +} + +void AUD_JackDevice::jack_shutdown(void *data) +{ + AUD_JackDevice* device = (AUD_JackDevice*)data; + device->m_valid = false; +} + +AUD_JackDevice::AUD_JackDevice(AUD_Specs specs) +{ + if(specs.channels == AUD_CHANNELS_INVALID) + specs.channels = AUD_CHANNELS_STEREO; + + // jack uses floats + m_specs = specs; + m_specs.format = AUD_FORMAT_FLOAT32; + + jack_options_t options = JackNullOption; + jack_status_t status; + + // open client + m_client = jack_client_open("Blender", options, &status); + if(m_client == NULL) + AUD_THROW(AUD_ERROR_JACK); + + m_buffer = new AUD_Buffer(); AUD_NEW("buffer"); + + // set callbacks + jack_set_process_callback(m_client, AUD_JackDevice::jack_mix, this); + jack_on_shutdown(m_client, AUD_JackDevice::jack_shutdown, this); + + // register our output channels which are called ports in jack + m_ports = new jack_port_t*[m_specs.channels]; AUD_NEW("jack_port") + + try + { + char portname[64]; + for(int i = 0; i < m_specs.channels; i++) + { + sprintf(portname, "out %d", i+1); + m_ports[i] = jack_port_register(m_client, portname, + JACK_DEFAULT_AUDIO_TYPE, + JackPortIsOutput, 0); + if(m_ports[i] == NULL) + AUD_THROW(AUD_ERROR_JACK); + } + + m_specs.rate = (AUD_SampleRate)jack_get_sample_rate(m_client); + + // activate the client + if(jack_activate(m_client)) + AUD_THROW(AUD_ERROR_JACK); + } + catch(AUD_Exception e) + { + jack_client_close(m_client); + delete[] m_ports; AUD_DELETE("jack_port") + delete m_buffer; AUD_DELETE("buffer"); + throw; + } + + const char** ports = jack_get_ports(m_client, NULL, NULL, + JackPortIsPhysical | JackPortIsInput); + if(ports != NULL) + { + for(int i = 0; i < m_specs.channels && ports[i]; i++) + jack_connect(m_client, jack_port_name(m_ports[i]), ports[i]); + + free(ports); + } + + m_mixer = new AUD_FloatMixer(); AUD_NEW("mixer") + m_mixer->setSpecs(m_specs); + + m_valid = true; + + create(); +} + +AUD_JackDevice::~AUD_JackDevice() +{ + lock(); + if(m_valid) + jack_client_close(m_client); + delete[] m_ports; AUD_DELETE("jack_port") + delete m_buffer; AUD_DELETE("buffer"); + unlock(); + + destroy(); +} + +void AUD_JackDevice::playing(bool playing) +{ + // Do nothing. +} diff --git a/intern/audaspace/jack/AUD_JackDevice.h b/intern/audaspace/jack/AUD_JackDevice.h new file mode 100644 index 00000000000..0b09e20b354 --- /dev/null +++ b/intern/audaspace/jack/AUD_JackDevice.h @@ -0,0 +1,91 @@ +/* + * $Id$ + * + * ***** BEGIN LGPL LICENSE BLOCK ***** + * + * Copyright 2009 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * AudaSpace is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AudaSpace 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with AudaSpace. If not, see . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_JACKDEVICE +#define AUD_JACKDEVICE + +#include "AUD_SoftwareDevice.h" +class AUD_Buffer; + +#include + +/** + * This device plays back through Jack. + */ +class AUD_JackDevice : public AUD_SoftwareDevice +{ +private: + /** + * The output ports of jack. + */ + jack_port_t** m_ports; + + /** + * The jack client. + */ + jack_client_t* m_client; + + /** + * The output buffer. + */ + AUD_Buffer* m_buffer; + + /** + * Whether the device is valid. + */ + bool m_valid; + + /** + * Invalidates the jack device. + * \param data The jack device that gets invalidet by jack. + */ + static void jack_shutdown(void *data); + + /** + * Mixes the next bytes into the buffer. + * \param length The length in samples to be filled. + * \param data A pointer to the jack device. + * \return 0 what shows success. + */ + static int jack_mix(jack_nframes_t length, void *data); + +protected: + virtual void playing(bool playing); + +public: + /** + * Creates a Jack client for audio output. + * \param specs The wanted audio specification, where only the channel count is important. + * \exception AUD_Exception Thrown if the audio device cannot be opened. + */ + AUD_JackDevice(AUD_Specs specs); + + /** + * Closes the Jack client. + */ + virtual ~AUD_JackDevice(); +}; + +#endif //AUD_JACKDEVICE diff --git a/intern/audaspace/jack/Makefile b/intern/audaspace/jack/Makefile new file mode 100644 index 00000000000..a6cc9119c6d --- /dev/null +++ b/intern/audaspace/jack/Makefile @@ -0,0 +1,40 @@ +# +# $Id$ +# +# ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): GSR +# +# ***** END GPL LICENSE BLOCK ***** +# +# + +LIBNAME = aud_jack +DIR = $(OCGDIR)/intern/audaspace + +include nan_compile.mk + +CCFLAGS += $(LEVEL_1_CPP_WARNINGS) + +CPPFLAGS += -I../intern +CPPFLAGS += -I.. +CPPFLAGS += -I. diff --git a/intern/audaspace/make/msvc_9_0/audaspace.vcproj b/intern/audaspace/make/msvc_9_0/audaspace.vcproj new file mode 100644 index 00000000000..2bb97502c4e --- /dev/null +++ b/intern/audaspace/make/msvc_9_0/audaspace.vcproj @@ -0,0 +1,727 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/intern/elbeem/CMakeLists.txt b/intern/elbeem/CMakeLists.txt index 03fd4a3fefc..8b8a3000efd 100644 --- a/intern/elbeem/CMakeLists.txt +++ b/intern/elbeem/CMakeLists.txt @@ -24,7 +24,7 @@ # # ***** END GPL LICENSE BLOCK ***** -SET(INC ${PNG_INC} ${ZLIB_INC} ${SDL_INC} extern) +SET(INC ${PNG_INC} ${ZLIB_INC} extern) FILE(GLOB SRC intern/*.cpp) diff --git a/intern/elbeem/intern/paraloopend.h b/intern/elbeem/intern/paraloopend.h index 6bb224b625a..a396e395126 100644 --- a/intern/elbeem/intern/paraloopend.h +++ b/intern/elbeem/intern/paraloopend.h @@ -22,9 +22,9 @@ { if(doReduce) { // synchronize global vars - for(int j=0; jaddFullParticle( calcListParts[j] ); + for(size_t j=0; jaddFullParticle( calcListParts[j] ); if(calcMaxVlen>mMaxVlen) { mMxvx = calcMxvx; mMxvy = calcMxvy; diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index b559d49958c..3d588ecfd00 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -24,7 +24,7 @@ # # ***** END GPL LICENSE BLOCK ***** -SET(INC . ../string ${WINTAB_INC}) +SET(INC . ../string) FILE(GLOB SRC intern/*.cpp) @@ -37,6 +37,7 @@ IF(APPLE) LIST(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_WindowX11.cpp") ELSE(APPLE) IF(WIN32) + SET(INC ${INC} ${WINTAB_INC}) LIST(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_DisplayManagerCarbon.cpp") LIST(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_SystemCarbon.cpp") LIST(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_WindowCarbon.cpp") @@ -44,6 +45,7 @@ ELSE(APPLE) LIST(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_SystemX11.cpp") LIST(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_WindowX11.cpp") ELSE(WIN32) + SET(INC ${INC} ${X11_X11_INCLUDE_PATH}) LIST(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_DisplayManagerWin32.cpp") LIST(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_SystemWin32.cpp") LIST(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_WindowWin32.cpp") diff --git a/intern/ghost/intern/GHOST_EventManager.cpp b/intern/ghost/intern/GHOST_EventManager.cpp index f9b13115f32..92cea8d8ff7 100644 --- a/intern/ghost/intern/GHOST_EventManager.cpp +++ b/intern/ghost/intern/GHOST_EventManager.cpp @@ -51,6 +51,15 @@ GHOST_EventManager::GHOST_EventManager() GHOST_EventManager::~GHOST_EventManager() { disposeEvents(); + + TConsumerVector::iterator iter= m_consumers.begin(); + while (iter != m_consumers.end()) + { + GHOST_IEventConsumer* consumer = *iter; + delete consumer; + m_consumers.erase(iter); + iter = m_consumers.begin(); + } } diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 87e5f375958..603452cfcbd 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -289,8 +289,9 @@ GHOST_TSuccess GHOST_System::init() #endif #ifdef GHOST_DEBUG + m_eventPrinter = new GHOST_EventPrinter(); if (m_eventManager) { - m_eventManager->addConsumer(&m_eventPrinter); + m_eventManager->addConsumer(m_eventPrinter); } #endif // GHOST_DEBUG diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index 9310e9b2591..066fe4b93d3 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -335,7 +335,7 @@ protected: /** Prints all the events. */ #ifdef GHOST_DEBUG - GHOST_EventPrinter m_eventPrinter; + GHOST_EventPrinter* m_eventPrinter; #endif // GHOST_DEBUG /** Settings of the display before the display went fullscreen. */ diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index dbdb65a14f4..5dba76adb02 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -148,6 +148,13 @@ GHOST_SystemX11( } +GHOST_SystemX11:: +~GHOST_SystemX11() +{ + XCloseDisplay(m_display); +} + + GHOST_TSuccess GHOST_SystemX11:: init( diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h index afd960d1ec3..782f08f6737 100644 --- a/intern/ghost/intern/GHOST_SystemX11.h +++ b/intern/ghost/intern/GHOST_SystemX11.h @@ -59,6 +59,12 @@ public: GHOST_SystemX11( ); + /** + * Destructor. + */ + virtual ~GHOST_SystemX11(); + + GHOST_TSuccess init( ); diff --git a/intern/ghost/intern/GHOST_WindowManager.cpp b/intern/ghost/intern/GHOST_WindowManager.cpp index 2b0809929c5..af96653db13 100644 --- a/intern/ghost/intern/GHOST_WindowManager.cpp +++ b/intern/ghost/intern/GHOST_WindowManager.cpp @@ -54,6 +54,7 @@ GHOST_WindowManager::GHOST_WindowManager() : GHOST_WindowManager::~GHOST_WindowManager() { + /* m_windows is freed by GHOST_System::disposeWindow */ } diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 41c62be0966..88ae8afd0ce 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -42,6 +42,9 @@ #include #include +#include +#include + // For obscure full screen mode stuuf // lifted verbatim from blut. @@ -428,7 +431,20 @@ void GHOST_WindowX11::initXInputDevices() old_handler = XSetErrorHandler(ApplicationErrorHandler) ; for(int i=0; i diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt index af64fb99d58..b29837fac7d 100644 --- a/intern/guardedalloc/CMakeLists.txt +++ b/intern/guardedalloc/CMakeLists.txt @@ -29,4 +29,9 @@ SET(INC .) FILE(GLOB SRC intern/*.c) BLENDERLIB(bf_guardedalloc "${SRC}" "${INC}") -#, libtype=['intern', 'player'], priority = [10, 175] ) + +# Override C++ alloc optional +IF(WITH_CXX_GUARDEDALLOC) + FILE(GLOB SRC cpp/*.cpp) + BLENDERLIB(bf_guardedalloc_cpp "${SRC}" "${INC}") +ENDIF(WITH_CXX_GUARDEDALLOC) diff --git a/intern/SoundSystem/SND_DependKludge.h b/intern/guardedalloc/cpp/mallocn.cpp similarity index 60% rename from intern/SoundSystem/SND_DependKludge.h rename to intern/guardedalloc/cpp/mallocn.cpp index 06d4ec9c0c9..0ee22e734b9 100644 --- a/intern/SoundSystem/SND_DependKludge.h +++ b/intern/guardedalloc/cpp/mallocn.cpp @@ -1,10 +1,5 @@ -/* - * SND_DependKludge.h - * - * who needs what? - * +/** * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -21,30 +16,26 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. + * Contributor(s): Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ -#ifndef HAVE_CONFIG_H +#include +#include "../MEM_guardedalloc.h" -#ifndef NO_SOUND +void* operator new (size_t size) +{ + return MEM_mallocN(size, "c++/anonymous"); +} -#if defined (_WIN32) && !defined(FREE_WINDOWS) -# define USE_OPENAL -#elif defined (__linux__) || (__FreeBSD__) || defined(__APPLE__) || defined(__sun) -# define USE_OPENAL -#else -# ifdef USE_OPENAL -# undef USE_OPENAL -# endif -#endif +/* not default but can be used when needing to set a string */ +void* operator new (size_t size, const char *str) +{ + return MEM_mallocN(size, str); +} -#endif /* NO_SOUND */ - -#endif /* HAVE_CONFIG_H */ +void operator delete (void *p) +{ + MEM_freeN(p); +} diff --git a/intern/opennl/superlu/BLO_sys_types.h b/intern/opennl/superlu/BLO_sys_types.h index 411a8582f96..56a27ec17ce 100644 --- a/intern/opennl/superlu/BLO_sys_types.h +++ b/intern/opennl/superlu/BLO_sys_types.h @@ -83,7 +83,7 @@ typedef unsigned long uintptr_t; #define _UINTPTR_T_DEFINED #endif -#elif defined(__linux__) +#elif defined(__linux__) || defined(__NetBSD__) /* Linux-i386, Linux-Alpha, Linux-ppc */ #include diff --git a/intern/smoke/CMakeLists.txt b/intern/smoke/CMakeLists.txt index 90768e58be0..0db6acb683f 100644 --- a/intern/smoke/CMakeLists.txt +++ b/intern/smoke/CMakeLists.txt @@ -25,7 +25,6 @@ # ***** END GPL LICENSE BLOCK ***** SET(INC ${PNG_INC} ${ZLIB_INC} intern ../../extern/bullet2/src ../memutil ../guardealloc) -# ${FFTW3_INC} FILE(GLOB SRC intern/*.cpp) @@ -33,6 +32,11 @@ IF(WITH_OPENMP) ADD_DEFINITIONS(-DPARALLEL=1) ENDIF(WITH_OPENMP) +IF(WITH_FFTW3) + ADD_DEFINITIONS(-DFFTW3=1) + SET(INC ${INC} ${FFTW3_INC}) +ENDIF(WITH_FFTW3) + BLENDERLIB(bf_smoke "${SRC}" "${INC}") #, libtype='blender', priority = 0 ) diff --git a/intern/smoke/SConscript b/intern/smoke/SConscript index c427764e19e..af5bf1aeb20 100644 --- a/intern/smoke/SConscript +++ b/intern/smoke/SConscript @@ -10,6 +10,9 @@ if env['WITH_BF_OPENMP']: incs = env['BF_PNG_INC'] + ' ' + env['BF_ZLIB_INC'] incs += ' intern ../../extern/bullet2/src ../memutil ../guardealloc ' -# incs += env['BF_FFTW3_INC'] + +if env['WITH_BF_FFTW3']: + defs += ' FFTW3=1' + incs += env['BF_FFTW3_INC'] env.BlenderLib ('bf_smoke', sources, Split(incs), Split(defs), libtype=['intern'], priority=[40] ) diff --git a/intern/smoke/extern/smoke_API.h b/intern/smoke/extern/smoke_API.h index b7819d06edc..f0dba3cc7a4 100644 --- a/intern/smoke/extern/smoke_API.h +++ b/intern/smoke/extern/smoke_API.h @@ -32,15 +32,13 @@ extern "C" { #endif -struct FLUID_3D *smoke_init(int *res, int amplify, float *p0, float *p1, float dt); +struct FLUID_3D *smoke_init(int *res, float *p0, float dt); void smoke_free(struct FLUID_3D *fluid); void smoke_initBlenderRNA(struct FLUID_3D *fluid, float *alpha, float *beta); - -void smoke_step(struct FLUID_3D *fluid); +void smoke_step(struct FLUID_3D *fluid, size_t framenr); float *smoke_get_density(struct FLUID_3D *fluid); -float *smoke_get_bigdensity(struct FLUID_3D *fluid); float *smoke_get_heat(struct FLUID_3D *fluid); float *smoke_get_velocity_x(struct FLUID_3D *fluid); float *smoke_get_velocity_y(struct FLUID_3D *fluid); @@ -51,9 +49,19 @@ unsigned char *smoke_get_obstacle(struct FLUID_3D *fluid); size_t smoke_get_index(int x, int max_x, int y, int max_y, int z); size_t smoke_get_index2d(int x, int max_x, int y); -void smoke_set_noise(struct FLUID_3D *fluid, int type); +void smoke_dissolve(struct FLUID_3D *fluid, int speed, int log); -void smoke_get_bigres(struct FLUID_3D *fluid, int *res); +// wavelet turbulence functions +struct WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int noisetype); +void smoke_turbulence_free(struct WTURBULENCE *wt); +void smoke_turbulence_step(struct WTURBULENCE *wt, struct FLUID_3D *fluid); + +float *smoke_turbulence_get_density(struct WTURBULENCE *wt); +void smoke_turbulence_get_res(struct WTURBULENCE *wt, int *res); +void smoke_turbulence_set_noise(struct WTURBULENCE *wt, int type); +void smoke_initWaveletBlenderRNA(struct WTURBULENCE *wt, float *strength); + +void smoke_dissolve_wavelet(struct WTURBULENCE *wt, int speed, int log); #ifdef __cplusplus } diff --git a/intern/smoke/intern/FFT_NOISE.h b/intern/smoke/intern/FFT_NOISE.h index 9ae9682e2a0..2c278cdc4fc 100644 --- a/intern/smoke/intern/FFT_NOISE.h +++ b/intern/smoke/intern/FFT_NOISE.h @@ -22,7 +22,7 @@ #ifndef FFT_NOISE_H_ #define FFT_NOISE_H_ -#if 0 +#if FFTW3==1 #include #include #include @@ -41,7 +41,7 @@ static void shift3D(float*& field, int xRes, int yRes, int zRes) int xHalf = xRes / 2; int yHalf = yRes / 2; int zHalf = zRes / 2; - int slabSize = xRes * yRes; + // int slabSize = xRes * yRes; for (int z = 0; z < zHalf; z++) for (int y = 0; y < yHalf; y++) for (int x = 0; x < xHalf; x++) diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp index 344883866a8..ff66f29143c 100644 --- a/intern/smoke/intern/FLUID_3D.cpp +++ b/intern/smoke/intern/FLUID_3D.cpp @@ -38,7 +38,7 @@ // Construction/Destruction ////////////////////////////////////////////////////////////////////// -FLUID_3D::FLUID_3D(int *res, int amplify, float *p0, float dt) : +FLUID_3D::FLUID_3D(int *res, float *p0, float dt) : _xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f), _dt(dt) { // set simulation consts @@ -59,7 +59,12 @@ FLUID_3D::FLUID_3D(int *res, int amplify, float *p0, float dt) : _maxRes = MAX3(_xRes, _yRes, _zRes); // initialize wavelet turbulence - _wTurbulence = new WTURBULENCE(_res[0],_res[1],_res[2], amplify); + /* + if(amplify) + _wTurbulence = new WTURBULENCE(_res[0],_res[1],_res[2], amplify, noisetype); + else + _wTurbulence = NULL; + */ // scale the constants according to the refinement of the grid _dx = 1.0f / (float)_maxRes; @@ -93,6 +98,10 @@ FLUID_3D::FLUID_3D(int *res, int amplify, float *p0, float dt) : _xVorticity = new float[_totalCells]; _yVorticity = new float[_totalCells]; _zVorticity = new float[_totalCells]; + _h = new float[_totalCells]; + _Precond = new float[_totalCells]; + + // DG TODO: check if alloc went fine for (int x = 0; x < _totalCells; x++) { @@ -115,6 +124,10 @@ FLUID_3D::FLUID_3D(int *res, int amplify, float *p0, float dt) : _yVorticity[x] = 0.0f; _zVorticity[x] = 0.0f; _residual[x] = 0.0f; + _q[x] = 0.0f; + _direction[x] = 0.0f; + _h[x] = 0.0f; + _Precond[x] = 0.0f; _obstacles[x] = false; } @@ -186,8 +199,10 @@ FLUID_3D::~FLUID_3D() if (_yVorticity) delete[] _yVorticity; if (_zVorticity) delete[] _zVorticity; if (_vorticity) delete[] _vorticity; + if (_h) delete[] _h; + if (_Precond) delete[] _Precond; if (_obstacles) delete[] _obstacles; - if (_wTurbulence) delete _wTurbulence; + // if (_wTurbulence) delete _wTurbulence; printf("deleted fluid\n"); } @@ -197,10 +212,6 @@ void FLUID_3D::initBlenderRNA(float *alpha, float *beta) { _alpha = alpha; _beta = beta; - - // XXX TODO DEBUG - // *_alpha = 0; - // *_beta = 0; } ////////////////////////////////////////////////////////////////////// @@ -210,26 +221,29 @@ void FLUID_3D::step() { // wipe forces for (int i = 0; i < _totalCells; i++) + { _xForce[i] = _yForce[i] = _zForce[i] = 0.0f; + _obstacles[i] &= ~2; + } wipeBoundaries(); // run the solvers - addVorticity(); - addBuoyancy(_heat, _density); + addVorticity(); + addBuoyancy(_heat, _density); addForce(); project(); - diffuseHeat(); + diffuseHeat(); // advect everything advectMacCormack(); - if(_wTurbulence) { - _wTurbulence->stepTurbulenceFull(_dt/_dx, - _xVelocity, _yVelocity, _zVelocity, _obstacles); + // if(_wTurbulence) { + // _wTurbulence->stepTurbulenceFull(_dt/_dx, + // _xVelocity, _yVelocity, _zVelocity, _obstacles); // _wTurbulence->stepTurbulenceReadable(_dt/_dx, // _xVelocity, _yVelocity, _zVelocity, _obstacles); - } + // } /* // no file output float *src = _density; @@ -248,7 +262,7 @@ void FLUID_3D::step() IMAGE::dumpPBRT(_totalSteps, pbrtPrefix, _density, _res[0],_res[1],_res[2]); */ _totalTime += _dt; - _totalSteps++; + _totalSteps++; } ////////////////////////////////////////////////////////////////////// @@ -354,6 +368,7 @@ void FLUID_3D::addForce() void FLUID_3D::project() { int index, x, y, z; + setObstacleBoundaries(); // copy out the boundaries @@ -390,12 +405,16 @@ void FLUID_3D::project() xright - xleft + yup - ydown + ztop - zbottom ); - _pressure[index] = 0.0f; + + // DG: commenting this helps CG to get a better start, 10-20% speed improvement + // _pressure[index] = 0.0f; } copyBorderAll(_pressure); // solve Poisson equation - solvePressure(_pressure, _divergence, _obstacles); + solvePressurePre(_pressure, _divergence, _obstacles); + + setObstaclePressure(); // project out solution float invDx = 1.0f / _dx; @@ -404,9 +423,12 @@ void FLUID_3D::project() for (y = 1; y < _yRes - 1; y++, index += 2) for (x = 1; x < _xRes - 1; x++, index++) { - _xVelocity[index] -= 0.5f * (_pressure[index + 1] - _pressure[index - 1]) * invDx; - _yVelocity[index] -= 0.5f * (_pressure[index + _xRes] - _pressure[index - _xRes]) * invDx; - _zVelocity[index] -= 0.5f * (_pressure[index + _slabSize] - _pressure[index - _slabSize]) * invDx; + if(!_obstacles[index]) + { + _xVelocity[index] -= 0.5f * (_pressure[index + 1] - _pressure[index - 1]) * invDx; + _yVelocity[index] -= 0.5f * (_pressure[index + _xRes] - _pressure[index - _xRes]) * invDx; + _zVelocity[index] -= 0.5f * (_pressure[index + _slabSize] - _pressure[index - _slabSize]) * invDx; + } } } @@ -443,34 +465,8 @@ void FLUID_3D::addObstacle(OBSTACLE* obstacle) ////////////////////////////////////////////////////////////////////// // calculate the obstacle directional types ////////////////////////////////////////////////////////////////////// -void FLUID_3D::setObstacleBoundaries() +void FLUID_3D::setObstaclePressure() { - // cull degenerate obstacles , move to addObstacle? - for (int z = 1, index = _slabSize + _xRes + 1; - z < _zRes - 1; z++, index += 2 * _xRes) - for (int y = 1; y < _yRes - 1; y++, index += 2) - for (int x = 1; x < _xRes - 1; x++, index++) - if (_obstacles[index] != EMPTY) - { - const int top = _obstacles[index + _slabSize]; - const int bottom= _obstacles[index - _slabSize]; - const int up = _obstacles[index + _xRes]; - const int down = _obstacles[index - _xRes]; - const int left = _obstacles[index - 1]; - const int right = _obstacles[index + 1]; - - int counter = 0; - if (up) counter++; - if (down) counter++; - if (left) counter++; - if (right) counter++; - if (top) counter++; - if (bottom) counter++; - - if (counter < 3) - _obstacles[index] = EMPTY; - } - // tag remaining obstacle blocks for (int z = 1, index = _slabSize + _xRes + 1; z < _zRes - 1; z++, index += 2 * _xRes) @@ -478,7 +474,7 @@ void FLUID_3D::setObstacleBoundaries() for (int x = 1; x < _xRes - 1; x++, index++) { // could do cascade of ifs, but they are a pain - if (_obstacles[index] != EMPTY) + if (_obstacles[index]) { const int top = _obstacles[index + _slabSize]; const int bottom= _obstacles[index - _slabSize]; @@ -516,14 +512,24 @@ void FLUID_3D::setObstacleBoundaries() pcnt += 1.; } if (top && !bottom) { - _pressure[index] += _pressure[index - _xRes]; + _pressure[index] += _pressure[index - _slabSize]; pcnt += 1.; + // _zVelocity[index] += - _zVelocity[index - _slabSize]; + // vp += 1.0; } if (!top && bottom) { - _pressure[index] += _pressure[index + _xRes]; + _pressure[index] += _pressure[index + _slabSize]; pcnt += 1.; + // _zVelocity[index] += - _zVelocity[index + _slabSize]; + // vp += 1.0; } - _pressure[index] /= pcnt; + + if(pcnt > 0.000001f) + _pressure[index] /= pcnt; + + // test - dg + // if(vp > 0.000001f) + // _zVelocity[index] /= vp; // TODO? set correct velocity bc's // velocities are only set to zero right now @@ -533,6 +539,44 @@ void FLUID_3D::setObstacleBoundaries() } } +void FLUID_3D::setObstacleBoundaries() +{ + // cull degenerate obstacles , move to addObstacle? + for (int z = 1, index = _slabSize + _xRes + 1; + z < _zRes - 1; z++, index += 2 * _xRes) + for (int y = 1; y < _yRes - 1; y++, index += 2) + for (int x = 1; x < _xRes - 1; x++, index++) + { + if (_obstacles[index] != EMPTY) + { + const int top = _obstacles[index + _slabSize]; + const int bottom= _obstacles[index - _slabSize]; + const int up = _obstacles[index + _xRes]; + const int down = _obstacles[index - _xRes]; + const int left = _obstacles[index - 1]; + const int right = _obstacles[index + 1]; + + int counter = 0; + if (up) counter++; + if (down) counter++; + if (left) counter++; + if (right) counter++; + if (top) counter++; + if (bottom) counter++; + + if (counter < 3) + _obstacles[index] = EMPTY; + } + if (_obstacles[index]) + { + _xVelocity[index] = + _yVelocity[index] = + _zVelocity[index] = 0.0f; + _pressure[index] = 0.0f; + } + } +} + ////////////////////////////////////////////////////////////////////// // add buoyancy forces ////////////////////////////////////////////////////////////////////// @@ -644,16 +688,17 @@ void FLUID_3D::advectMacCormack() const float dt0 = _dt / _dx; // use force arrays as temp arrays - for (int x = 0; x < _totalCells; x++) - _xForce[x] = _yForce[x] = 0.0; + for (int x = 0; x < _totalCells; x++) + _xForce[x] = _yForce[x] = 0.0; + float* t1 = _xForce; float* t2 = _yForce; - advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _densityOld, _density, t1,t2, res, NULL); - advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _heatOld, _heat, t1,t2, res, NULL); - advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _xVelocityOld, _xVelocity, t1,t2, res, NULL); - advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _yVelocityOld, _yVelocity, t1,t2, res, NULL); - advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _zVelocityOld, _zVelocity, t1,t2, res, NULL); + advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _densityOld, _density, t1,t2, res, _obstacles); + advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _heatOld, _heat, t1,t2, res, _obstacles); + advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _xVelocityOld, _xVelocity, t1,t2, res, _obstacles); + advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _yVelocityOld, _yVelocity, t1,t2, res, _obstacles); + advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _zVelocityOld, _zVelocity, t1,t2, res, _obstacles); if(DOMAIN_BC_LEFT == 0) copyBorderX(_xVelocity, res); else setZeroX(_xVelocity, res); diff --git a/intern/smoke/intern/FLUID_3D.h b/intern/smoke/intern/FLUID_3D.h index 2d212caa6d3..78a4cf076e3 100644 --- a/intern/smoke/intern/FLUID_3D.h +++ b/intern/smoke/intern/FLUID_3D.h @@ -27,7 +27,7 @@ #include #include #include "OBSTACLE.h" -#include "WTURBULENCE.h" +// #include "WTURBULENCE.h" #include "VEC3.h" using namespace std; @@ -37,7 +37,7 @@ class WTURBULENCE; class FLUID_3D { public: - FLUID_3D(int *res, int amplify, float *p0, float dt); + FLUID_3D(int *res, /* int amplify, */ float *p0, float dt); FLUID_3D() {}; virtual ~FLUID_3D(); @@ -96,6 +96,8 @@ class FLUID_3D float* _yVorticity; float* _zVorticity; float* _vorticity; + float* _h; + float* _Precond; unsigned char* _obstacles; // CG fields @@ -113,7 +115,7 @@ class FLUID_3D float _tempAmb; /* ambient temperature */ // WTURBULENCE object, if active - WTURBULENCE* _wTurbulence; + // WTURBULENCE* _wTurbulence; // boundary setting functions void copyBorderAll(float* field); @@ -128,10 +130,12 @@ class FLUID_3D void project(); void diffuseHeat(); void solvePressure(float* field, float* b, unsigned char* skip); + void solvePressurePre(float* field, float* b, unsigned char* skip); void solveHeat(float* field, float* b, unsigned char* skip); // handle obstacle boundaries void setObstacleBoundaries(); + void setObstaclePressure(); public: // advection, accessed e.g. by WTURBULENCE class @@ -157,13 +161,13 @@ class FLUID_3D static void advectFieldSemiLagrange(const float dt, const float* velx, const float* vely, const float* velz, float* oldField, float* newField, Vec3Int res); static void advectFieldMacCormack(const float dt, const float* xVelocity, const float* yVelocity, const float* zVelocity, - float* oldField, float* newField, float* temp1, float* temp2, Vec3Int res, const float* obstacles); + float* oldField, float* newField, float* temp1, float* temp2, Vec3Int res, const unsigned char* obstacles); // maccormack helper functions static void clampExtrema(const float dt, const float* xVelocity, const float* yVelocity, const float* zVelocity, float* oldField, float* newField, Vec3Int res); static void clampOutsideRays(const float dt, const float* xVelocity, const float* yVelocity, const float* zVelocity, - float* oldField, float* newField, Vec3Int res, const float* obstacles, const float *oldAdvection); + float* oldField, float* newField, Vec3Int res, const unsigned char* obstacles, const float *oldAdvection); // output helper functions // static void writeImageSliceXY(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale=1.); diff --git a/intern/smoke/intern/FLUID_3D_SOLVERS.cpp b/intern/smoke/intern/FLUID_3D_SOLVERS.cpp index 5fd8f72d79d..a35beaa05d7 100644 --- a/intern/smoke/intern/FLUID_3D_SOLVERS.cpp +++ b/intern/smoke/intern/FLUID_3D_SOLVERS.cpp @@ -21,17 +21,192 @@ ////////////////////////////////////////////////////////////////////// #include "FLUID_3D.h" +#include #define SOLVER_ACCURACY 1e-06 +void FLUID_3D::solvePressurePre(float* field, float* b, unsigned char* skip) +{ + int x, y, z; + size_t index; + + // i = 0 + int i = 0; + + memset(_residual, 0, sizeof(float)*_xRes*_yRes*_zRes); + memset(_q, 0, sizeof(float)*_xRes*_yRes*_zRes); + memset(_direction, 0, sizeof(float)*_xRes*_yRes*_zRes); + memset(_h, 0, sizeof(float)*_xRes*_yRes*_zRes); + memset(_Precond, 0, sizeof(float)*_xRes*_yRes*_zRes); + + // r = b - Ax + index = _slabSize + _xRes + 1; + for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes) + for (y = 1; y < _yRes - 1; y++, index += 2) + for (x = 1; x < _xRes - 1; x++, index++) + { + // if the cell is a variable + float Acenter = 0.0f; + if (!skip[index]) + { + // set the matrix to the Poisson stencil in order + if (!skip[index + 1]) Acenter += 1.; + if (!skip[index - 1]) Acenter += 1.; + if (!skip[index + _xRes]) Acenter += 1.; + if (!skip[index - _xRes]) Acenter += 1.; + if (!skip[index + _slabSize]) Acenter += 1.; + if (!skip[index - _slabSize]) Acenter += 1.; + } + + _residual[index] = b[index] - (Acenter * field[index] + + field[index - 1] * (skip[index - 1] ? 0.0 : -1.0f)+ + field[index + 1] * (skip[index + 1] ? 0.0 : -1.0f)+ + field[index - _xRes] * (skip[index - _xRes] ? 0.0 : -1.0f)+ + field[index + _xRes] * (skip[index + _xRes] ? 0.0 : -1.0f)+ + field[index - _slabSize] * (skip[index - _slabSize] ? 0.0 : -1.0f)+ + field[index + _slabSize] * (skip[index + _slabSize] ? 0.0 : -1.0f) ); + _residual[index] = (skip[index]) ? 0.0f : _residual[index]; + + // P^-1 + if(Acenter < 1.0) + _Precond[index] = 0.0; + else + _Precond[index] = 1.0 / Acenter; + + // p = P^-1 * r + _direction[index] = _residual[index] * _Precond[index]; + } + + // deltaNew = transpose(r) * p + float deltaNew = 0.0f; + index = _slabSize + _xRes + 1; + for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes) + for (y = 1; y < _yRes - 1; y++, index += 2) + for (x = 1; x < _xRes - 1; x++, index++) + deltaNew += _residual[index] * _direction[index]; + + // delta0 = deltaNew + // float delta0 = deltaNew; + + // While deltaNew > (eps^2) * delta0 + const float eps = SOLVER_ACCURACY; + //while ((i < _iterations) && (deltaNew > eps*delta0)) + float maxR = 2.0f * eps; + // while (i < _iterations) + while ((i < _iterations) && (maxR > 0.001*eps)) + { + // (s) q = Ad (p) + index = _slabSize + _xRes + 1; + for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes) + for (y = 1; y < _yRes - 1; y++, index += 2) + for (x = 1; x < _xRes - 1; x++, index++) + { + // if the cell is a variable + float Acenter = 0.0f; + if (!skip[index]) + { + // set the matrix to the Poisson stencil in order + if (!skip[index + 1]) Acenter += 1.; + if (!skip[index - 1]) Acenter += 1.; + if (!skip[index + _xRes]) Acenter += 1.; + if (!skip[index - _xRes]) Acenter += 1.; + if (!skip[index + _slabSize]) Acenter += 1.; + if (!skip[index - _slabSize]) Acenter += 1.; + } + + _q[index] = Acenter * _direction[index] + + _direction[index - 1] * (skip[index - 1] ? 0.0 : -1.0f) + + _direction[index + 1] * (skip[index + 1] ? 0.0 : -1.0f) + + _direction[index - _xRes] * (skip[index - _xRes] ? 0.0 : -1.0f) + + _direction[index + _xRes] * (skip[index + _xRes] ? 0.0 : -1.0f)+ + _direction[index - _slabSize] * (skip[index - _slabSize] ? 0.0 : -1.0f) + + _direction[index + _slabSize] * (skip[index + _slabSize] ? 0.0 : -1.0f); + _q[index] = (skip[index]) ? 0.0f : _q[index]; + } + + // alpha = deltaNew / (transpose(d) * q) + float alpha = 0.0f; + index = _slabSize + _xRes + 1; + for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes) + for (y = 1; y < _yRes - 1; y++, index += 2) + for (x = 1; x < _xRes - 1; x++, index++) + alpha += _direction[index] * _q[index]; + if (fabs(alpha) > 0.0f) + alpha = deltaNew / alpha; + + // x = x + alpha * d + index = _slabSize + _xRes + 1; + for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes) + for (y = 1; y < _yRes - 1; y++, index += 2) + for (x = 1; x < _xRes - 1; x++, index++) + field[index] += alpha * _direction[index]; + + // r = r - alpha * q + maxR = 0.0; + index = _slabSize + _xRes + 1; + for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes) + for (y = 1; y < _yRes - 1; y++, index += 2) + for (x = 1; x < _xRes - 1; x++, index++) + { + _residual[index] -= alpha * _q[index]; + // maxR = (_residual[index] > maxR) ? _residual[index] : maxR; + } + + // if(maxR <= eps) + // break; + + // h = P^-1 * r + index = _slabSize + _xRes + 1; + for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes) + for (y = 1; y < _yRes - 1; y++, index += 2) + for (x = 1; x < _xRes - 1; x++, index++) + { + _h[index] = _Precond[index] * _residual[index]; + } + + // deltaOld = deltaNew + float deltaOld = deltaNew; + + // deltaNew = transpose(r) * h + deltaNew = 0.0f; + index = _slabSize + _xRes + 1; + for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes) + for (y = 1; y < _yRes - 1; y++, index += 2) + for (x = 1; x < _xRes - 1; x++, index++) + { + deltaNew += _residual[index] * _h[index]; + maxR = (_residual[index]* _h[index] > maxR) ? _residual[index]* _h[index] : maxR; + } + + // beta = deltaNew / deltaOld + float beta = deltaNew / deltaOld; + + // d = h + beta * d + index = _slabSize + _xRes + 1; + for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes) + for (y = 1; y < _yRes - 1; y++, index += 2) + for (x = 1; x < _xRes - 1; x++, index++) + _direction[index] = _h[index] + beta * _direction[index]; + + // i = i + 1 + i++; + } + // cout << i << " iterations converged to " << sqrt(maxR) << endl; +} + ////////////////////////////////////////////////////////////////////// // solve the poisson equation with CG ////////////////////////////////////////////////////////////////////// void FLUID_3D::solvePressure(float* field, float* b, unsigned char* skip) { - int x, y, z, index; + int x, y, z; + size_t index; - // i = 0 - int i = 0; + // i = 0 + int i = 0; + + memset(_residual, 0, sizeof(float)*_xRes*_yRes*_zRes); + memset(_q, 0, sizeof(float)*_xRes*_yRes*_zRes); + memset(_direction, 0, sizeof(float)*_xRes*_yRes*_zRes); // r = b - Ax index = _slabSize + _xRes + 1; @@ -61,6 +236,7 @@ void FLUID_3D::solvePressure(float* field, float* b, unsigned char* skip) field[index + _slabSize] * (skip[index + _slabSize] ? 0.0 : -1.0f) ); _residual[index] = (skip[index]) ? 0.0f : _residual[index]; } + // d = r index = _slabSize + _xRes + 1; @@ -166,7 +342,7 @@ void FLUID_3D::solvePressure(float* field, float* b, unsigned char* skip) // i = i + 1 i++; } - cout << i << " iterations converged to " << maxR << endl; + // cout << i << " iterations converged to " << maxR << endl; } ////////////////////////////////////////////////////////////////////// @@ -174,11 +350,16 @@ void FLUID_3D::solvePressure(float* field, float* b, unsigned char* skip) ////////////////////////////////////////////////////////////////////// void FLUID_3D::solveHeat(float* field, float* b, unsigned char* skip) { - int x, y, z, index; - const float heatConst = _dt * _heatDiffusion / (_dx * _dx); + int x, y, z; + size_t index; + const float heatConst = _dt * _heatDiffusion / (_dx * _dx); - // i = 0 - int i = 0; + // i = 0 + int i = 0; + + memset(_residual, 0, sizeof(float)*_xRes*_yRes*_zRes); + memset(_q, 0, sizeof(float)*_xRes*_yRes*_zRes); + memset(_direction, 0, sizeof(float)*_xRes*_yRes*_zRes); // r = b - Ax index = _slabSize + _xRes + 1; @@ -314,6 +495,6 @@ void FLUID_3D::solveHeat(float* field, float* b, unsigned char* skip) // i = i + 1 i++; } - cout << i << " iterations converged to " << maxR << endl; + // cout << i << " iterations converged to " << maxR << endl; } diff --git a/intern/smoke/intern/FLUID_3D_STATIC.cpp b/intern/smoke/intern/FLUID_3D_STATIC.cpp index f2bbcf33075..4474129beea 100644 --- a/intern/smoke/intern/FLUID_3D_STATIC.cpp +++ b/intern/smoke/intern/FLUID_3D_STATIC.cpp @@ -80,7 +80,7 @@ void FLUID_3D::addSmokeTestCase(float* field, Vec3Int res, float value) void FLUID_3D::setNeumannX(float* field, Vec3Int res) { const int slabSize = res[0] * res[1]; - int index; + size_t index; for (int z = 0; z < res[2]; z++) for (int y = 0; y < res[1]; y++) { @@ -100,7 +100,7 @@ void FLUID_3D::setNeumannX(float* field, Vec3Int res) void FLUID_3D::setNeumannY(float* field, Vec3Int res) { const int slabSize = res[0] * res[1]; - int index; + size_t index; for (int z = 0; z < res[2]; z++) for (int x = 0; x < res[0]; x++) { @@ -121,7 +121,7 @@ void FLUID_3D::setNeumannZ(float* field, Vec3Int res) { const int slabSize = res[0] * res[1]; const int totalCells = res[0] * res[1] * res[2]; - int index; + size_t index; for (int y = 0; y < res[1]; y++) for (int x = 0; x < res[0]; x++) { @@ -141,10 +141,11 @@ void FLUID_3D::setNeumannZ(float* field, Vec3Int res) // top slab index = x + y * res[0]; index += totalCells - slabSize; - if(field[index]<0.) field[index] = 0.; + if(field[index]<0.) field[index] = 0.0f; index -= slabSize; - if(field[index]<0.) field[index] = 0.; + if(field[index]<0.) field[index] = 0.0f; } + } ////////////////////////////////////////////////////////////////////// @@ -337,7 +338,7 @@ void FLUID_3D::advectFieldSemiLagrange(const float dt, const float* velx, const // comments are the pseudocode from selle's paper ////////////////////////////////////////////////////////////////////// void FLUID_3D::advectFieldMacCormack(const float dt, const float* xVelocity, const float* yVelocity, const float* zVelocity, - float* oldField, float* newField, float* temp1, float* temp2, Vec3Int res, const float* obstacles) + float* oldField, float* newField, float* temp1, float* temp2, Vec3Int res, const unsigned char* obstacles) { float* phiHatN = temp1; float* phiHatN1 = temp2; @@ -458,7 +459,7 @@ void FLUID_3D::clampExtrema(const float dt, const float* velx, const float* vely // incorrect ////////////////////////////////////////////////////////////////////// void FLUID_3D::clampOutsideRays(const float dt, const float* velx, const float* vely, const float* velz, - float* oldField, float* newField, Vec3Int res, const float* obstacles, const float *oldAdvection) + float* oldField, float* newField, Vec3Int res, const unsigned char* obstacles, const float *oldAdvection) { const int sx= res[0]; const int sy= res[1]; @@ -599,6 +600,7 @@ void FLUID_3D::writeImageSliceXZ(const float *field, Vec3Int res, int slice, str ////////////////////////////////////////////////////////////////////// // Helper function for projecting densities along a dimension ////////////////////////////////////////////////////////////////////// +/* static int getOtherDir(int dir1, int dir2) { switch(dir1) { case 0: @@ -621,6 +623,7 @@ static int getOtherDir(int dir1, int dir2) { } return 0; } +*/ ////////////////////////////////////////////////////////////////////// // average densities along third spatial direction diff --git a/intern/smoke/intern/VEC3.h b/intern/smoke/intern/VEC3.h index 607f68279a2..98c4555ac5f 100644 --- a/intern/smoke/intern/VEC3.h +++ b/intern/smoke/intern/VEC3.h @@ -926,7 +926,9 @@ inline void hsvToRgb( VECTOR_TYPE &V ) //! global string for formatting vector output in utilities.cpp //extern const char *globVecFormatStr; +#if 0 static const char *globVecFormatStr = "[%6.4f,%6.4f,%6.4f]"; +#endif /************************************************************************* Outputs the object in human readable form using the format diff --git a/intern/smoke/intern/WAVELET_NOISE.h b/intern/smoke/intern/WAVELET_NOISE.h index 493ed1642fc..4c2e7514af7 100644 --- a/intern/smoke/intern/WAVELET_NOISE.h +++ b/intern/smoke/intern/WAVELET_NOISE.h @@ -220,7 +220,7 @@ static bool loadTile(float* const noiseTileData, std::string filename) } // dimensions - int gridSize = noiseTileSize * noiseTileSize * noiseTileSize; + size_t gridSize = noiseTileSize * noiseTileSize * noiseTileSize; // noiseTileData memory is managed by caller size_t bread = fread((void*)noiseTileData, sizeof(float), gridSize, file); @@ -228,7 +228,7 @@ static bool loadTile(float* const noiseTileData, std::string filename) printf("Noise tile file '%s' loaded.\n", filename.c_str()); if (bread != gridSize) { - printf("loadTile: Noise tile '%s' is wrong size %d.\n", filename.c_str(), bread); + printf("loadTile: Noise tile '%s' is wrong size %d.\n", filename.c_str(), (int)bread); return false; } return true; diff --git a/intern/smoke/intern/WTURBULENCE.cpp b/intern/smoke/intern/WTURBULENCE.cpp index 022c8f28252..db7a1b55afa 100644 --- a/intern/smoke/intern/WTURBULENCE.cpp +++ b/intern/smoke/intern/WTURBULENCE.cpp @@ -43,7 +43,7 @@ static const float persistence = 0.56123f; ////////////////////////////////////////////////////////////////////// // constructor ////////////////////////////////////////////////////////////////////// -WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify) +WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int noisetype) { // if noise magnitude is below this threshold, its contribution // is negilgible, so stop evaluating new octaves @@ -53,10 +53,10 @@ WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify) _amplify = amplify; // manually adjust the overall amount of turbulence - _strength = 2.; + // DG - RNA-fied _strength = 2.; // add the corresponding octaves of noise - _octaves = (int)log((float)_amplify) / log(2.0f); // XXX DEBUG/ TODO: int casting correct? - dg + _octaves = (int)(log((float)_amplify) / log(2.0f) + 0.5); // XXX DEBUG/ TODO: int casting correct? - dg // noise resolution _xResBig = _amplify * xResSm; @@ -136,8 +136,11 @@ WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify) // noise tiles _noiseTile = new float[noiseTileSize * noiseTileSize * noiseTileSize]; + /* std::string noiseTileFilename = std::string("noise.wavelets"); generateTile_WAVELET(_noiseTile, noiseTileFilename); + */ + setNoise(noisetype); /* std::string noiseTileFilename = std::string("noise.fft"); generatTile_FFT(_noiseTile, noiseTileFilename); @@ -173,19 +176,21 @@ WTURBULENCE::~WTURBULENCE() { ////////////////////////////////////////////////////////////////////// // Change noise type // -// type (1<<1) = wavelet / 2 -// type (1<<2) = FFT / 4 -// type (1<<3) = curl / 8 +// type (1<<0) = wavelet / 2 +// type (1<<1) = FFT / 4 +// type (1<<2) = curl / 8 ////////////////////////////////////////////////////////////////////// void WTURBULENCE::setNoise(int type) { - if(type == 4) // FFT + if(type == (1<<1)) // FFT { // needs fft - // std::string noiseTileFilename = std::string("noise.fft"); - // generatTile_FFT(_noiseTile, noiseTileFilename); + #if FFTW3==1 + std::string noiseTileFilename = std::string("noise.fft"); + generatTile_FFT(_noiseTile, noiseTileFilename); + #endif } - else if(type == 8) // curl + else if(type == (1<<2)) // curl { // TODO: not supported yet } @@ -196,6 +201,12 @@ void WTURBULENCE::setNoise(int type) } } +// init direct access functions from blender +void WTURBULENCE::initBlenderRNA(float *strength) +{ + _strength = strength; +} + ////////////////////////////////////////////////////////////////////// // Get the smallest valid x derivative // @@ -642,7 +653,7 @@ void WTURBULENCE::stepTurbulenceReadable(float dtOrg, float* xvel, float* yvel, // base amplitude for octave 0 float coefficient = sqrtf(2.0f * fabs(energy)); - const float amplitude = _strength * fabs(0.5 * coefficient) * persistence; + const float amplitude = *_strength * fabs(0.5 * coefficient) * persistence; // add noise to velocity, but only if the turbulence is // sufficiently undeformed, and the energy is large enough @@ -763,7 +774,7 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa #endif { float maxVelMag1 = 0.; #if PARALLEL==1 - const int id = omp_get_thread_num(), num = omp_get_num_threads(); + const int id = omp_get_thread_num(); /*, num = omp_get_num_threads(); */ #endif // vector noise main loop @@ -854,7 +865,7 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa // base amplitude for octave 0 float coefficient = sqrtf(2.0f * fabs(energy)); - const float amplitude = _strength * fabs(0.5 * coefficient) * persistence; + const float amplitude = *_strength * fabs(0.5 * coefficient) * persistence; // add noise to velocity, but only if the turbulence is // sufficiently undeformed, and the energy is large enough @@ -925,7 +936,7 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa maxVelMag = sqrt(maxVelMag) * dt; int totalSubsteps = (int)(maxVelMag / (float)maxVel); totalSubsteps = (totalSubsteps < 1) ? 1 : totalSubsteps; - + // printf("totalSubsteps: %d\n", totalSubsteps); totalSubsteps = (totalSubsteps > maxSubSteps) ? maxSubSteps : totalSubsteps; const float dtSubdiv = dt / (float)totalSubsteps; diff --git a/intern/smoke/intern/WTURBULENCE.h b/intern/smoke/intern/WTURBULENCE.h index 858a47b7dd1..d4e6b0c6a17 100644 --- a/intern/smoke/intern/WTURBULENCE.h +++ b/intern/smoke/intern/WTURBULENCE.h @@ -33,12 +33,13 @@ class WTURBULENCE { public: // both config files can be NULL, altCfg might override values from noiseCfg - WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify); + WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int noisetype); /// destructor virtual ~WTURBULENCE(); void setNoise(int type); + void initBlenderRNA(float *strength); // step more readable version -- no rotation correction void stepTurbulenceReadable(float dt, float* xvel, float* yvel, float* zvel, unsigned char *obstacles); @@ -69,13 +70,15 @@ class WTURBULENCE inline Vec3Int getResBig() { return _resBig; } inline int getOctaves() { return _octaves; } + // is accessed on through rna gui + float *_strength; + protected: // enlargement factor from original velocity field / simulation // _Big = _amplify * _Sm int _amplify; int _octaves; - float _strength; - + // noise settings float _cullingThreshold; float _noiseStrength; diff --git a/intern/smoke/intern/smoke_API.cpp b/intern/smoke/intern/smoke_API.cpp index 9c835cf87ee..2e95a576eaf 100644 --- a/intern/smoke/intern/smoke_API.cpp +++ b/intern/smoke/intern/smoke_API.cpp @@ -26,37 +26,157 @@ */ #include "FLUID_3D.h" +#include "WTURBULENCE.h" #include #include // y in smoke is z in blender -extern "C" FLUID_3D *smoke_init(int *res, int amplify, float *p0, float *p1, float dt) +extern "C" FLUID_3D *smoke_init(int *res, float *p0, float dt) { // smoke lib uses y as top-bottom/vertical axis where blender uses z - FLUID_3D *fluid = new FLUID_3D(res, amplify, p0, dt); + FLUID_3D *fluid = new FLUID_3D(res, p0, dt); // printf("xres: %d, yres: %d, zres: %d\n", res[0], res[1], res[2]); return fluid; } +extern "C" WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int noisetype) +{ + // initialize wavelet turbulence + if(amplify) + return new WTURBULENCE(res[0],res[1],res[2], amplify, noisetype); + else + return NULL; +} + extern "C" void smoke_free(FLUID_3D *fluid) { delete fluid; fluid = NULL; } -extern "C" void smoke_step(FLUID_3D *fluid) +extern "C" void smoke_turbulence_free(WTURBULENCE *wt) +{ + delete wt; + wt = NULL; +} + +extern "C" size_t smoke_get_index(int x, int max_x, int y, int max_y, int z /*, int max_z */) +{ + // // const int index = x + y * smd->res[0] + z * smd->res[0]*smd->res[1]; + return x + y * max_x + z * max_x*max_y; +} + +extern "C" size_t smoke_get_index2d(int x, int max_x, int y /*, int max_y, int z, int max_z */) +{ + return x + y * max_x; +} + +extern "C" void smoke_step(FLUID_3D *fluid, size_t framenr) { fluid->step(); } +extern "C" void smoke_turbulence_step(WTURBULENCE *wt, FLUID_3D *fluid) +{ + if(wt) + wt->stepTurbulenceFull(fluid->_dt/fluid->_dx, fluid->_xVelocity, fluid->_yVelocity, fluid->_zVelocity, fluid->_obstacles); +} + extern "C" void smoke_initBlenderRNA(FLUID_3D *fluid, float *alpha, float *beta) { fluid->initBlenderRNA(alpha, beta); } +extern "C" void smoke_dissolve(FLUID_3D *fluid, int speed, int log) +{ + float *density = fluid->_density; + //float *densityOld = fluid->_densityOld; + float *heat = fluid->_heat; + + if(log) + { + /* max density/speed = dydx */ + float dydx = 1.0 / (float)speed; + size_t size= fluid->_xRes * fluid->_yRes * fluid->_zRes; + + for(size_t i = 0; i < size; i++) + { + density[i] *= (1.0 - dydx); + + if(density[i] < 0.0f) + density[i] = 0.0f; + + heat[i] *= (1.0 - dydx); + + if(heat[i] < 0.0f) + heat[i] = 0.0f; + } + } + else // linear falloff + { + /* max density/speed = dydx */ + float dydx = 1.0 / (float)speed; + size_t size= fluid->_xRes * fluid->_yRes * fluid->_zRes; + + for(size_t i = 0; i < size; i++) + { + density[i] -= dydx; + + if(density[i] < 0.0f) + density[i] = 0.0f; + + heat[i] -= dydx; + + if(heat[i] < 0.0f) + heat[i] = 0.0f; + + } + } +} + +extern "C" void smoke_dissolve_wavelet(WTURBULENCE *wt, int speed, int log) +{ + float *density = wt->getDensityBig(); + Vec3Int r = wt->getResBig(); + + if(log) + { + /* max density/speed = dydx */ + float dydx = 1.0 / (float)speed; + size_t size= r[0] * r[1] * r[2]; + + for(size_t i = 0; i < size; i++) + { + density[i] *= (1.0 - dydx); + + if(density[i] < 0.0f) + density[i] = 0.0f; + } + } + else // linear falloff + { + /* max density/speed = dydx */ + float dydx = 1.0 / (float)speed; + size_t size= r[0] * r[1] * r[2]; + + for(size_t i = 0; i < size; i++) + { + density[i] -= dydx; + + if(density[i] < 0.0f) + density[i] = 0.0f; + } + } +} + +extern "C" void smoke_initWaveletBlenderRNA(WTURBULENCE *wt, float *strength) +{ + wt->initBlenderRNA(strength); +} + template < class T > inline T ABS( T a ) { return (0 < a) ? a : -a ; } @@ -86,17 +206,20 @@ extern "C" float *smoke_get_velocity_z(FLUID_3D *fluid) return fluid->_zVorticity; } -extern "C" float *smoke_get_bigdensity(FLUID_3D *fluid) +extern "C" float *smoke_turbulence_get_density(WTURBULENCE *wt) { - return fluid->_wTurbulence->getDensityBig(); + return wt ? wt->getDensityBig() : NULL; } -extern "C" void smoke_get_bigres(FLUID_3D *fluid, int *res) +extern "C" void smoke_turbulence_get_res(WTURBULENCE *wt, int *res) { - Vec3Int r = fluid->_wTurbulence->getResBig(); - res[0] = r[0]; - res[1] = r[1]; - res[2] = r[2]; + if(wt) + { + Vec3Int r = wt->getResBig(); + res[0] = r[0]; + res[1] = r[1]; + res[2] = r[2]; + } } extern "C" unsigned char *smoke_get_obstacle(FLUID_3D *fluid) @@ -104,18 +227,7 @@ extern "C" unsigned char *smoke_get_obstacle(FLUID_3D *fluid) return fluid->_obstacles; } -extern "C" size_t smoke_get_index(int x, int max_x, int y, int max_y, int z /*, int max_z */) +extern "C" void smoke_turbulence_set_noise(WTURBULENCE *wt, int type) { - // // const int index = x + y * smd->res[0] + z * smd->res[0]*smd->res[1]; - return x + y * max_x + z * max_x*max_y; -} - -extern "C" size_t smoke_get_index2d(int x, int max_x, int y /*, int max_y, int z, int max_z */) -{ - return x + y * max_x; -} - -extern "C" void smoke_set_noise(FLUID_3D *fluid, int type) -{ - fluid->_wTurbulence->setNoise(type); + wt->setNoise(type); } diff --git a/projectfiles_vc9/blender/BPY_python/BPY_python.vcproj b/projectfiles_vc9/blender/BPY_python/BPY_python.vcproj index 42576c2733b..d0872a43403 100644 --- a/projectfiles_vc9/blender/BPY_python/BPY_python.vcproj +++ b/projectfiles_vc9/blender/BPY_python/BPY_python.vcproj @@ -43,7 +43,7 @@ - - diff --git a/projectfiles_vc9/blender/blender.sln b/projectfiles_vc9/blender/blender.sln index c925cfa8fbe..602105dc501 100644 --- a/projectfiles_vc9/blender/blender.sln +++ b/projectfiles_vc9/blender/blender.sln @@ -6,14 +6,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blender", "blender.vcproj", {6E24BF09-9653-4166-A871-F65CC9E98A9B} = {6E24BF09-9653-4166-A871-F65CC9E98A9B} {A90C4918-4B21-4277-93BD-AF65F30951D9} = {A90C4918-4B21-4277-93BD-AF65F30951D9} {FB88301F-F725-401B-ACD7-D2ABBF333B71} = {FB88301F-F725-401B-ACD7-D2ABBF333B71} - {98330220-47A6-42E0-9DE4-AD0FF5D204D6} = {98330220-47A6-42E0-9DE4-AD0FF5D204D6} {BAAE3F2B-BCF8-4E84-B8BA-CFB2D64945FE} = {BAAE3F2B-BCF8-4E84-B8BA-CFB2D64945FE} {C66F722C-46BE-40C9-ABAE-2EAC7A697EB8} = {C66F722C-46BE-40C9-ABAE-2EAC7A697EB8} {D1A9312F-4557-4982-A0F4-4D08508235F4} = {D1A9312F-4557-4982-A0F4-4D08508235F4} {884D8731-654C-4C7F-9A75-8F37A305BE1E} = {884D8731-654C-4C7F-9A75-8F37A305BE1E} {E645CC32-4823-463E-82F0-46ADDE664018} = {E645CC32-4823-463E-82F0-46ADDE664018} {7495FE37-933A-4AC1-BB2A-B3FDB4DE4284} = {7495FE37-933A-4AC1-BB2A-B3FDB4DE4284} - {FAF46346-65CC-4DB2-85C4-B99826F79D0C} = {FAF46346-65CC-4DB2-85C4-B99826F79D0C} {51FB3D48-2467-4BFA-A321-D848252B437E} = {51FB3D48-2467-4BFA-A321-D848252B437E} {FFD3C64A-30E2-4BC7-BC8F-51818C320400} = {FFD3C64A-30E2-4BC7-BC8F-51818C320400} {31628053-825D-4C06-8A21-D13883489718} = {31628053-825D-4C06-8A21-D13883489718} @@ -37,13 +35,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blender", "blender.vcproj", {3648FB9A-C36F-43AB-AED0-1F1361E67FC7} = {3648FB9A-C36F-43AB-AED0-1F1361E67FC7} {542A9FA1-B7FF-441C-AE15-054DB31D3488} = {542A9FA1-B7FF-441C-AE15-054DB31D3488} {E109F1A5-FDD3-4F56-A1C4-96867EEA4C5B} = {E109F1A5-FDD3-4F56-A1C4-96867EEA4C5B} - {213356A9-3A1F-41DA-9819-1297BCD17DEE} = {213356A9-3A1F-41DA-9819-1297BCD17DEE} {727F90AC-ABE6-40BF-8937-C2F2F1D13DEA} = {727F90AC-ABE6-40BF-8937-C2F2F1D13DEA} {BAC615B0-F1AF-418B-8D23-A10FD8870D6A} = {BAC615B0-F1AF-418B-8D23-A10FD8870D6A} {E8904FB3-F8F7-BC21-87A6-029A57B901F4} = {E8904FB3-F8F7-BC21-87A6-029A57B901F4} {E90C7BC2-CF30-4A60-A8F2-0050D592E358} = {E90C7BC2-CF30-4A60-A8F2-0050D592E358} {8B8D4FC3-3234-4E54-8376-5AB83D00D164} = {8B8D4FC3-3234-4E54-8376-5AB83D00D164} {4B6AFCC5-968C-424A-8F20-76E41B3BEF74} = {4B6AFCC5-968C-424A-8F20-76E41B3BEF74} + {87032FD2-9BA0-6B43-BE33-8902BA8F9172} = {87032FD2-9BA0-6B43-BE33-8902BA8F9172} {EB75F4D6-2970-4A3A-8D99-2BAD7201C0E9} = {EB75F4D6-2970-4A3A-8D99-2BAD7201C0E9} {5A2EA6DC-1A53-4E87-9166-52870CE3B4EA} = {5A2EA6DC-1A53-4E87-9166-52870CE3B4EA} {E86B7BDE-C33C-4E55-9433-E74C141D7538} = {E86B7BDE-C33C-4E55-9433-E74C141D7538} @@ -126,13 +124,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blenderplayer", "..\gameeng {02110D03-59DB-4571-8787-72B3C03B2F2D} = {02110D03-59DB-4571-8787-72B3C03B2F2D} {E5F2F004-C704-4DCC-A08F-6EB1E38EAB9F} = {E5F2F004-C704-4DCC-A08F-6EB1E38EAB9F} {6E24BF09-9653-4166-A871-F65CC9E98A9B} = {6E24BF09-9653-4166-A871-F65CC9E98A9B} - {98330220-47A6-42E0-9DE4-AD0FF5D204D6} = {98330220-47A6-42E0-9DE4-AD0FF5D204D6} {BAAE3F2B-BCF8-4E84-B8BA-CFB2D64945FE} = {BAAE3F2B-BCF8-4E84-B8BA-CFB2D64945FE} {C66F722C-46BE-40C9-ABAE-2EAC7A697EB8} = {C66F722C-46BE-40C9-ABAE-2EAC7A697EB8} {D1A9312F-4557-4982-A0F4-4D08508235F4} = {D1A9312F-4557-4982-A0F4-4D08508235F4} {E645CC32-4823-463E-82F0-46ADDE664018} = {E645CC32-4823-463E-82F0-46ADDE664018} {7495FE37-933A-4AC1-BB2A-B3FDB4DE4284} = {7495FE37-933A-4AC1-BB2A-B3FDB4DE4284} - {FAF46346-65CC-4DB2-85C4-B99826F79D0C} = {FAF46346-65CC-4DB2-85C4-B99826F79D0C} {51FB3D48-2467-4BFA-A321-D848252B437E} = {51FB3D48-2467-4BFA-A321-D848252B437E} {FFD3C64A-30E2-4BC7-BC8F-51818C320400} = {FFD3C64A-30E2-4BC7-BC8F-51818C320400} {31628053-825D-4C06-8A21-D13883489718} = {31628053-825D-4C06-8A21-D13883489718} @@ -156,12 +152,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blenderplayer", "..\gameeng {542A9FA1-B7FF-441C-AE15-054DB31D3488} = {542A9FA1-B7FF-441C-AE15-054DB31D3488} {D8ABD6A5-1B36-4D62-934E-B5C6801130B0} = {D8ABD6A5-1B36-4D62-934E-B5C6801130B0} {E109F1A5-FDD3-4F56-A1C4-96867EEA4C5B} = {E109F1A5-FDD3-4F56-A1C4-96867EEA4C5B} - {213356A9-3A1F-41DA-9819-1297BCD17DEE} = {213356A9-3A1F-41DA-9819-1297BCD17DEE} {727F90AC-ABE6-40BF-8937-C2F2F1D13DEA} = {727F90AC-ABE6-40BF-8937-C2F2F1D13DEA} {BAC615B0-F1AF-418B-8D23-A10FD8870D6A} = {BAC615B0-F1AF-418B-8D23-A10FD8870D6A} {E90C7BC2-CF30-4A60-A8F2-0050D592E358} = {E90C7BC2-CF30-4A60-A8F2-0050D592E358} {8B8D4FC3-3234-4E54-8376-5AB83D00D164} = {8B8D4FC3-3234-4E54-8376-5AB83D00D164} {4B6AFCC5-968C-424A-8F20-76E41B3BEF74} = {4B6AFCC5-968C-424A-8F20-76E41B3BEF74} + {87032FD2-9BA0-6B43-BE33-8902BA8F9172} = {87032FD2-9BA0-6B43-BE33-8902BA8F9172} {5A2EA6DC-1A53-4E87-9166-52870CE3B4EA} = {5A2EA6DC-1A53-4E87-9166-52870CE3B4EA} {E86B7BDE-C33C-4E55-9433-E74C141D7538} = {E86B7BDE-C33C-4E55-9433-E74C141D7538} {32CC75E2-EE85-45E6-8E3D-513F58464F43} = {32CC75E2-EE85-45E6-8E3D-513F58464F43} @@ -243,8 +239,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_container", "..\..\inte EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_decimation", "..\..\intern\decimation\make\msvc_9_0\decimation.vcproj", "{C66F722C-46BE-40C9-ABAE-2EAC7A697EB8}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_DummySoundSystem", "..\..\intern\SoundSystem\make\msvc_9_0\dummy\DummySoundSystem.vcproj", "{FAF46346-65CC-4DB2-85C4-B99826F79D0C}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_elbeem", "..\..\intern\elbeem\make\msvc_9_0\elbeem.vcproj", "{A90C4918-4B21-4277-93BD-AF65F30951D9}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_ghost", "..\..\intern\ghost\make\msvc_9_0\ghost.vcproj", "{76D90B92-ECC7-409C-9F98-A8814B90F3C0}" @@ -257,35 +251,22 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_memutil", "..\..\intern EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_MoTo", "..\..\intern\moto\make\msvc_9_0\moto.vcproj", "{4B6AFCC5-968C-424A-8F20-76E41B3BEF74}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_OpenALSoundSystem", "..\..\intern\SoundSystem\make\msvc_9_0\openal\OpenALSoundSystem.vcproj", "{213356A9-3A1F-41DA-9819-1297BCD17DEE}" - ProjectSection(ProjectDependencies) = postProject - {98330220-47A6-42E0-9DE4-AD0FF5D204D6} = {98330220-47A6-42E0-9DE4-AD0FF5D204D6} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_opennl", "..\..\intern\opennl\make\msvc_9_0\opennl.vcproj", "{8B8D4FC3-3234-4E54-8376-5AB83D00D164}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_SoundSystem", "..\..\intern\SoundSystem\make\msvc_9_0\SoundSystem.vcproj", "{98330220-47A6-42E0-9DE4-AD0FF5D204D6}" - ProjectSection(ProjectDependencies) = postProject - {4B6AFCC5-968C-424A-8F20-76E41B3BEF74} = {4B6AFCC5-968C-424A-8F20-76E41B3BEF74} - {B789C2F3-279E-4A85-8F0A-7F7AC068E598} = {B789C2F3-279E-4A85-8F0A-7F7AC068E598} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_string", "..\..\intern\string\make\msvc_9_0\string.vcproj", "{B789C2F3-279E-4A85-8F0A-7F7AC068E598}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_build_install_all", "..\..\intern\make\msvc_9_0\INT_build_install_all.vcproj", "{02110D03-59DB-4571-8787-72B3C03B2F2D}" ProjectSection(ProjectDependencies) = postProject {A90C4918-4B21-4277-93BD-AF65F30951D9} = {A90C4918-4B21-4277-93BD-AF65F30951D9} - {98330220-47A6-42E0-9DE4-AD0FF5D204D6} = {98330220-47A6-42E0-9DE4-AD0FF5D204D6} {C66F722C-46BE-40C9-ABAE-2EAC7A697EB8} = {C66F722C-46BE-40C9-ABAE-2EAC7A697EB8} - {FAF46346-65CC-4DB2-85C4-B99826F79D0C} = {FAF46346-65CC-4DB2-85C4-B99826F79D0C} {B093415D-C0F6-4E76-8F5A-6BC1917BCE9E} = {B093415D-C0F6-4E76-8F5A-6BC1917BCE9E} {76D90B92-ECC7-409C-9F98-A8814B90F3C0} = {76D90B92-ECC7-409C-9F98-A8814B90F3C0} {542A9FA1-B7FF-441C-AE15-054DB31D3488} = {542A9FA1-B7FF-441C-AE15-054DB31D3488} - {213356A9-3A1F-41DA-9819-1297BCD17DEE} = {213356A9-3A1F-41DA-9819-1297BCD17DEE} {E8904FB3-F8F7-BC21-87A6-029A57B901F4} = {E8904FB3-F8F7-BC21-87A6-029A57B901F4} {51A348C1-8684-4D67-B980-97B1FC74159B} = {51A348C1-8684-4D67-B980-97B1FC74159B} {8B8D4FC3-3234-4E54-8376-5AB83D00D164} = {8B8D4FC3-3234-4E54-8376-5AB83D00D164} {4B6AFCC5-968C-424A-8F20-76E41B3BEF74} = {4B6AFCC5-968C-424A-8F20-76E41B3BEF74} + {87032FD2-9BA0-6B43-BE33-8902BA8F9172} = {87032FD2-9BA0-6B43-BE33-8902BA8F9172} {EB75F4D6-2970-4A3A-8D99-2BAD7201C0E9} = {EB75F4D6-2970-4A3A-8D99-2BAD7201C0E9} {E86B7BDE-C33C-4E55-9433-E74C141D7538} = {E86B7BDE-C33C-4E55-9433-E74C141D7538} {1CC733F1-6AB5-4904-8F63-C08C46B79DD9} = {1CC733F1-6AB5-4904-8F63-C08C46B79DD9} @@ -318,6 +299,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BLF_blenfont", "blenfont\BL EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_smoke", "..\..\intern\smoke\make\msvc_9_0\smoke.vcproj", "{E8904FB3-F8F7-BC21-87A6-029A57B901F4}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INT_audaspace", "..\..\intern\audaspace\make\msvc_9_0\audaspace.vcproj", "{87032FD2-9BA0-6B43-BE33-8902BA8F9172}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution 3D Plugin Debug|Win32 = 3D Plugin Debug|Win32 @@ -1126,26 +1109,6 @@ Global {C66F722C-46BE-40C9-ABAE-2EAC7A697EB8}.Debug|Win32.Build.0 = 3DPlugin Debug|Win32 {C66F722C-46BE-40C9-ABAE-2EAC7A697EB8}.Release|Win32.ActiveCfg = 3DPlugin Release|Win32 {C66F722C-46BE-40C9-ABAE-2EAC7A697EB8}.Release|Win32.Build.0 = 3DPlugin Release|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.3D Plugin Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.3D Plugin Debug|Win32.Build.0 = 3DPlugin Debug|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.3D Plugin Release|Win32.ActiveCfg = 3DPlugin Debug|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.3D Plugin Release|Win32.Build.0 = 3DPlugin Debug|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.3DPlugin Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.3DPlugin Debug|Win32.Build.0 = 3DPlugin Debug|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.3DPlugin Release|Win32.ActiveCfg = 3DPlugin Release|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.3DPlugin Release|Win32.Build.0 = 3DPlugin Release|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.Blender Debug|Win32.ActiveCfg = Blender Debug|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.Blender Debug|Win32.Build.0 = Blender Debug|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.Blender Release|Win32.ActiveCfg = Blender Release|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.Blender Release|Win32.Build.0 = Blender Release|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.BlenderPlayer Debug|Win32.ActiveCfg = Blender Debug|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.BlenderPlayer Debug|Win32.Build.0 = Blender Debug|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.BlenderPlayer Release|Win32.ActiveCfg = Blender Release|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.BlenderPlayer Release|Win32.Build.0 = Blender Release|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.Debug|Win32.Build.0 = 3DPlugin Debug|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.Release|Win32.ActiveCfg = 3DPlugin Release|Win32 - {FAF46346-65CC-4DB2-85C4-B99826F79D0C}.Release|Win32.Build.0 = 3DPlugin Release|Win32 {A90C4918-4B21-4277-93BD-AF65F30951D9}.3D Plugin Debug|Win32.ActiveCfg = 3DPlugin Release|Win32 {A90C4918-4B21-4277-93BD-AF65F30951D9}.3D Plugin Debug|Win32.Build.0 = 3DPlugin Release|Win32 {A90C4918-4B21-4277-93BD-AF65F30951D9}.3D Plugin Release|Win32.ActiveCfg = 3DPlugin Release|Win32 @@ -1264,26 +1227,6 @@ Global {4B6AFCC5-968C-424A-8F20-76E41B3BEF74}.Debug|Win32.Build.0 = 3DPlugin Debug|Win32 {4B6AFCC5-968C-424A-8F20-76E41B3BEF74}.Release|Win32.ActiveCfg = 3DPlugin Release|Win32 {4B6AFCC5-968C-424A-8F20-76E41B3BEF74}.Release|Win32.Build.0 = 3DPlugin Release|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.3D Plugin Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.3D Plugin Debug|Win32.Build.0 = 3DPlugin Debug|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.3D Plugin Release|Win32.ActiveCfg = 3DPlugin Debug|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.3D Plugin Release|Win32.Build.0 = 3DPlugin Debug|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.3DPlugin Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.3DPlugin Debug|Win32.Build.0 = 3DPlugin Debug|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.3DPlugin Release|Win32.ActiveCfg = 3DPlugin Release|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.3DPlugin Release|Win32.Build.0 = 3DPlugin Release|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.Blender Debug|Win32.ActiveCfg = Blender Debug|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.Blender Debug|Win32.Build.0 = Blender Debug|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.Blender Release|Win32.ActiveCfg = Blender Release|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.Blender Release|Win32.Build.0 = Blender Release|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.BlenderPlayer Debug|Win32.ActiveCfg = Blender Debug|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.BlenderPlayer Debug|Win32.Build.0 = Blender Debug|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.BlenderPlayer Release|Win32.ActiveCfg = Blender Release|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.BlenderPlayer Release|Win32.Build.0 = Blender Release|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.Debug|Win32.Build.0 = 3DPlugin Debug|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.Release|Win32.ActiveCfg = 3DPlugin Release|Win32 - {213356A9-3A1F-41DA-9819-1297BCD17DEE}.Release|Win32.Build.0 = 3DPlugin Release|Win32 {8B8D4FC3-3234-4E54-8376-5AB83D00D164}.3D Plugin Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 {8B8D4FC3-3234-4E54-8376-5AB83D00D164}.3D Plugin Debug|Win32.Build.0 = 3DPlugin Debug|Win32 {8B8D4FC3-3234-4E54-8376-5AB83D00D164}.3D Plugin Release|Win32.ActiveCfg = 3DPlugin Debug|Win32 @@ -1304,26 +1247,6 @@ Global {8B8D4FC3-3234-4E54-8376-5AB83D00D164}.Debug|Win32.Build.0 = 3DPlugin Debug|Win32 {8B8D4FC3-3234-4E54-8376-5AB83D00D164}.Release|Win32.ActiveCfg = 3DPlugin Release|Win32 {8B8D4FC3-3234-4E54-8376-5AB83D00D164}.Release|Win32.Build.0 = 3DPlugin Release|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.3D Plugin Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.3D Plugin Debug|Win32.Build.0 = 3DPlugin Debug|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.3D Plugin Release|Win32.ActiveCfg = 3DPlugin Debug|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.3D Plugin Release|Win32.Build.0 = 3DPlugin Debug|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.3DPlugin Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.3DPlugin Debug|Win32.Build.0 = 3DPlugin Debug|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.3DPlugin Release|Win32.ActiveCfg = 3DPlugin Release|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.3DPlugin Release|Win32.Build.0 = 3DPlugin Release|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.Blender Debug|Win32.ActiveCfg = Blender Debug|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.Blender Debug|Win32.Build.0 = Blender Debug|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.Blender Release|Win32.ActiveCfg = Blender Release|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.Blender Release|Win32.Build.0 = Blender Release|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.BlenderPlayer Debug|Win32.ActiveCfg = Blender Debug|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.BlenderPlayer Debug|Win32.Build.0 = Blender Debug|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.BlenderPlayer Release|Win32.ActiveCfg = Blender Release|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.BlenderPlayer Release|Win32.Build.0 = Blender Release|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.Debug|Win32.Build.0 = 3DPlugin Debug|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.Release|Win32.ActiveCfg = 3DPlugin Release|Win32 - {98330220-47A6-42E0-9DE4-AD0FF5D204D6}.Release|Win32.Build.0 = 3DPlugin Release|Win32 {B789C2F3-279E-4A85-8F0A-7F7AC068E598}.3D Plugin Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 {B789C2F3-279E-4A85-8F0A-7F7AC068E598}.3D Plugin Debug|Win32.Build.0 = 3DPlugin Debug|Win32 {B789C2F3-279E-4A85-8F0A-7F7AC068E598}.3D Plugin Release|Win32.ActiveCfg = 3DPlugin Debug|Win32 @@ -1500,6 +1423,26 @@ Global {E8904FB3-F8F7-BC21-87A6-029A57B901F4}.Debug|Win32.Build.0 = 3DPlugin Debug|Win32 {E8904FB3-F8F7-BC21-87A6-029A57B901F4}.Release|Win32.ActiveCfg = 3DPlugin Release|Win32 {E8904FB3-F8F7-BC21-87A6-029A57B901F4}.Release|Win32.Build.0 = 3DPlugin Release|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.3D Plugin Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.3D Plugin Debug|Win32.Build.0 = 3DPlugin Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.3D Plugin Release|Win32.ActiveCfg = 3DPlugin Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.3D Plugin Release|Win32.Build.0 = 3DPlugin Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.3DPlugin Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.3DPlugin Debug|Win32.Build.0 = 3DPlugin Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.3DPlugin Release|Win32.ActiveCfg = 3DPlugin Release|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.3DPlugin Release|Win32.Build.0 = 3DPlugin Release|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.Blender Debug|Win32.ActiveCfg = Blender Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.Blender Debug|Win32.Build.0 = Blender Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.Blender Release|Win32.ActiveCfg = Blender Release|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.Blender Release|Win32.Build.0 = Blender Release|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.BlenderPlayer Debug|Win32.ActiveCfg = Blender Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.BlenderPlayer Debug|Win32.Build.0 = Blender Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.BlenderPlayer Release|Win32.ActiveCfg = Blender Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.BlenderPlayer Release|Win32.Build.0 = Blender Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.Debug|Win32.ActiveCfg = 3DPlugin Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.Debug|Win32.Build.0 = 3DPlugin Debug|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.Release|Win32.ActiveCfg = 3DPlugin Release|Win32 + {87032FD2-9BA0-6B43-BE33-8902BA8F9172}.Release|Win32.Build.0 = 3DPlugin Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/projectfiles_vc9/blender/blender.vcproj b/projectfiles_vc9/blender/blender.vcproj index 37824155bb7..7b71ee49870 100644 --- a/projectfiles_vc9/blender/blender.vcproj +++ b/projectfiles_vc9/blender/blender.vcproj @@ -73,12 +73,12 @@ diff --git a/projectfiles_vc9/blender/blenkernel/BKE_blenkernel.vcproj b/projectfiles_vc9/blender/blenkernel/BKE_blenkernel.vcproj index b7de1c82c69..7ba3aac65f0 100644 --- a/projectfiles_vc9/blender/blenkernel/BKE_blenkernel.vcproj +++ b/projectfiles_vc9/blender/blenkernel/BKE_blenkernel.vcproj @@ -43,7 +43,7 @@ + + @@ -1090,6 +1094,10 @@ RelativePath="..\..\..\source\blender\blenkernel\BKE_texture.h" > + + diff --git a/projectfiles_vc9/blender/blenlib/BLI_blenlib.vcproj b/projectfiles_vc9/blender/blenlib/BLI_blenlib.vcproj index d31a7fb4500..c2268694735 100644 --- a/projectfiles_vc9/blender/blenlib/BLI_blenlib.vcproj +++ b/projectfiles_vc9/blender/blenlib/BLI_blenlib.vcproj @@ -574,10 +574,6 @@ RelativePath="..\..\..\source\blender\blenlib\intern\noise.c" > - - diff --git a/projectfiles_vc9/blender/editors/ED_editors.vcproj b/projectfiles_vc9/blender/editors/ED_editors.vcproj index 11ab3b0079b..174ceb5ca99 100644 --- a/projectfiles_vc9/blender/editors/ED_editors.vcproj +++ b/projectfiles_vc9/blender/editors/ED_editors.vcproj @@ -43,7 +43,7 @@ + + @@ -42,7 +43,7 @@ @@ -42,7 +43,7 @@ diff --git a/projectfiles_vc9/gameengine/ketsji/KX_ketsji.vcproj b/projectfiles_vc9/gameengine/ketsji/KX_ketsji.vcproj index d57e8d7f6a7..f709e0b7d29 100644 --- a/projectfiles_vc9/gameengine/ketsji/KX_ketsji.vcproj +++ b/projectfiles_vc9/gameengine/ketsji/KX_ketsji.vcproj @@ -4,6 +4,7 @@ Version="9,00" Name="KX_ketsji" ProjectGUID="{E645CC32-4823-463E-82F0-46ADDE664018}" + RootNamespace="KX_ketsji" TargetFrameworkVersion="131072" > @@ -42,7 +43,7 @@ - - @@ -941,10 +938,6 @@ RelativePath="..\..\..\source\gameengine\Ketsji\KX_CameraActuator.h" > - - diff --git a/projectfiles_vc9/gameengine/ketsji/network/KX_network.vcproj b/projectfiles_vc9/gameengine/ketsji/network/KX_network.vcproj index c6edae137b7..36c8218b803 100644 --- a/projectfiles_vc9/gameengine/ketsji/network/KX_network.vcproj +++ b/projectfiles_vc9/gameengine/ketsji/network/KX_network.vcproj @@ -43,7 +43,7 @@ \'":;~!@#$%^&*|?': - name = name.replace(ch, '_') + render = scene.render_data + world = scene.world + + # --- taken from fbx exporter + ## This was used to make V, but faster not to do all that + ##valid = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_,.()[]{}' + ##v = range(255) + ##for c in valid: v.remove(ord(c)) + v = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,42,43,46,47,58,59,60,61,62,63,64,92,94,96,124,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254] + invalid = ''.join([chr(i) for i in v]) + def cleanName(name): + for ch in invalid: name = name.replace(ch, '_') return name + del v + + # --- done with clean name. + + def uniqueName(name, nameSeq): + + if name not in nameSeq: + return name + + name_orig = name + i = 1 + while name in nameSeq: + name = '%s_%.3d' % (name_orig, i) + i+=1 + + return name + def writeMatrix(matrix): file.write('\tmatrix <%.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f>\n' %\ (matrix[0][0], matrix[0][1], matrix[0][2], matrix[1][0], matrix[1][1], matrix[1][2], matrix[2][0], matrix[2][1], matrix[2][2], matrix[3][0], matrix[3][1], matrix[3][2]) ) + def writeObjectMaterial(material): + if material and material.transparency_method=='RAYTRACE': + file.write('\tinterior { ior %.6f }\n' % material.raytrace_transparency.ior) + + # Other interior args + # fade_distance 2 + # fade_power [Value] + # fade_color + + # dispersion + # dispersion_samples + + materialNames = {} + DEF_MAT_NAME = 'Default' + def writeMaterial(material): + # Assumes only called once on each material + + if material: + name_orig = material.name + else: + name_orig = DEF_MAT_NAME + + name = materialNames[name_orig] = uniqueName(cleanName(name_orig), materialNames) + + file.write('#declare %s = finish {\n' % name) + + if material: + file.write('\tdiffuse %.3g\n' % material.diffuse_reflection) + file.write('\tspecular %.3g\n' % material.specular_reflection) + + file.write('\tambient %.3g\n' % material.ambient) + #file.write('\tambient rgb <%.3g, %.3g, %.3g>\n' % tuple([c*material.ambient for c in world.ambient_color])) # povray blends the global value + + # map hardness between 0.0 and 1.0 + roughness = ((1.0 - ((material.specular_hardness-1.0)/510.0))) + # scale from 0.0 to 0.1 + roughness *= 0.1 + # add a small value because 0.0 is invalid + roughness += (1/511.0) + + file.write('\troughness %.3g\n' % roughness) + + # 'phong 70.0 ' + + if material.raytrace_mirror.enabled: + raytrace_mirror= material.raytrace_mirror + if raytrace_mirror.reflect: + file.write('\treflection {\n') + file.write('\t\trgb <%.3g, %.3g, %.3g>' % tuple(material.mirror_color)) + file.write('\t\tfresnel 1 falloff %.3g exponent %.3g metallic %.3g} ' % (raytrace_mirror.fresnel, raytrace_mirror.fresnel_fac, raytrace_mirror.reflect)) + + else: + file.write('\tdiffuse 0.8\n') + file.write('\tspecular 0.2\n') + + + + # This is written into the object + ''' + if material and material.transparency_method=='RAYTRACE': + 'interior { ior %.3g} ' % material.raytrace_transparency.ior + ''' + + #file.write('\t\t\tcrand 1.0\n') # Sand granyness + #file.write('\t\t\tmetallic %.6f\n' % material.spec) + #file.write('\t\t\tphong %.6f\n' % material.spec) + #file.write('\t\t\tphong_size %.6f\n' % material.spec) + #file.write('\t\t\tbrilliance %.6f ' % (material.specular_hardness/256.0) # Like hardness + + file.write('}\n') + def exportCamera(): camera = scene.camera matrix = camera.matrix @@ -79,6 +172,10 @@ def write_pov(filename, scene=None, info_callback = None): file.write('\ttightness 0\n') # 0:10f file.write('\tpoint_at <0, 0, -1>\n') + elif lamp.type == 'SUN': + file.write('\tparallel\n') + file.write('\tpoint_at <0, 0, -1>\n') # *must* be after 'parallel' + elif lamp.type == 'AREA': size_x = lamp.size @@ -109,47 +206,69 @@ def write_pov(filename, scene=None, info_callback = None): file.write('}\n') - def exportMeshs(sel): - def bMat2PovString(material): - povstring = 'finish {' - if world != None: - povstring += 'ambient <%.6f, %.6f, %.6f> ' % tuple([c*material.ambient for c in world.ambient_color]) + def exportMeta(metas): + + # TODO - blenders 'motherball' naming is not supported. + + for ob in metas: + meta = ob.data - povstring += 'diffuse %.6f ' % material.diffuse_reflection - povstring += 'specular %.6f ' % material.specular_reflection + file.write('blob {\n') + file.write('\t\tthreshold %.4g\n' % meta.threshold) + try: + material= meta.materials[0] # lame! - blender cant do enything else. + except: + material= None - if material.raytrace_mirror.enabled: - #povstring += 'interior { ior %.6f } ' % material.IOR - raytrace_mirror= material.raytrace_mirror - if raytrace_mirror.reflect: - povstring += 'reflection {' - povstring += '<%.6f, %.6f, %.6f>' % tuple(material.mirror_color) # Should ask for ray mirror flag - povstring += 'fresnel 1 falloff %.6f exponent %.6f metallic %.6f} ' % (raytrace_mirror.fresnel, raytrace_mirror.fresnel_fac, raytrace_mirror.reflect) + for elem in meta.elements: + if elem.type not in ('BALL', 'ELLIPSOID'): + continue # Not supported + loc = elem.location + + stiffness= elem.stiffness + if elem.negative: + stiffness = -stiffness + + if elem.type == 'BALL': - if material.raytrace_transparency.enabled: - #povstring += 'interior { ior %.6f } ' % material.IOR - pass + file.write('\tsphere { <%.6g, %.6g, %.6g>, %.4g, %.4g ' % (loc.x, loc.y, loc.z, elem.radius, stiffness)) + + # After this wecould do something simple like... + # "pigment {Blue} }" + # except we'll write the color + + elif elem.type == 'ELLIPSOID': + # location is modified by scale + file.write('\tsphere { <%.6g, %.6g, %.6g>, %.4g, %.4g ' % (loc.x/elem.size_x, loc.y/elem.size_y, loc.z/elem.size_z, elem.radius, stiffness)) + file.write( 'scale <%.6g, %.6g, %.6g> ' % (elem.size_x, elem.size_y, elem.size_z)) + + if material: + diffuse_color = material.diffuse_color + + if material.transparency and material.transparency_method=='RAYTRACE': trans = 1-material.raytrace_transparency.filter + else: trans = 0.0 + + file.write( + 'pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>} finish {%s} }\n' % \ + (diffuse_color[0], diffuse_color[1], diffuse_color[2], 1-material.alpha, trans, materialNames[material.name]) + ) + + else: + file.write('pigment {rgb<1 1 1>} finish {%s} }\n' % DEF_MAT_NAME) # Write the finish last. - #file.write('\t\troughness %.6f\n' % (material.hard*0.5)) - #file.write('\t\t\tcrand 0.0\n') # Sand granyness - #file.write('\t\t\tmetallic %.6f\n' % material.spec) - #file.write('\t\t\tphong %.6f\n' % material.spec) - #file.write('\t\t\tphong_size %.6f\n' % material.spec) - povstring += 'brilliance %.6f ' % (material.specular_hardness/256.0) # Like hardness - povstring += '}' - #file.write('\t}\n') - return povstring + writeObjectMaterial(material) + + writeMatrix(ob.matrix) + file.write('}\n') - world = scene.world - - # Convert all materials to strings we can access directly per vertex. - for material in bpy.data.materials: - materialTable[material.name] = bMat2PovString(material) + + + def exportMeshs(sel): ob_num = 0 @@ -304,13 +423,19 @@ def write_pov(filename, scene=None, info_callback = None): if me_materials: material = me_materials[col[3]] - materialString = materialTable[material.name] + material_finish = materialNames[material.name] + + if material.transparency and material.transparency_method=='RAYTRACE': trans = 1-material.raytrace_transparency.filter + else: trans = 0.0 + else: - materialString = '' # Dont write anything + material_finish = DEF_MAT_NAME # not working properly, + trans = 0.0 - float_col = col[0], col[1], col[2], 1-material.alpha, materialString #print material.apl - file.write(',\n\t\ttexture { pigment {rgbf<%.3g, %.3g, %.3g, %.3g>}%s}' % float_col) + file.write( ',\n\t\ttexture { pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>} finish {%s}}' % + (col[0], col[1], col[2], 1-material.alpha, trans, material_finish) ) + index[0] = idx idx+=1 @@ -404,8 +529,7 @@ def write_pov(filename, scene=None, info_callback = None): if me.materials: material = me.materials[0] # dodgy - if material and material.raytrace_transparency.enabled: - file.write('\tinterior { ior %.6f }\n' % material.raytrace_transparency.ior) + writeObjectMaterial(material) writeMatrix(matrix) file.write('}\n') @@ -442,22 +566,30 @@ def write_pov(filename, scene=None, info_callback = None): file.write("\t\terror_bound %.4g\n" % scene.pov_radio_error_bound) file.write("\t\tgray_threshold %.4g\n" % scene.pov_radio_gray_threshold) file.write("\t\tlow_error_factor %.4g\n" % scene.pov_radio_low_error_factor) + file.write("\t\tmedia %d\n" % scene.pov_radio_media) file.write("\t\tminimum_reuse %.4g\n" % scene.pov_radio_minimum_reuse) file.write("\t\tnearest_count %d\n" % scene.pov_radio_nearest_count) file.write("\t\tnormal %d\n" % scene.pov_radio_normal) file.write("\t\trecursion_limit %d\n" % scene.pov_radio_recursion_limit) file.write('\t}\n') - file.write('}\n') - - + if world: + file.write("\tambient_light rgb<%.3g, %.3g, %.3g>\n" % tuple(world.ambient_color)) + file.write('}\n') + + + # Convert all materials to strings we can access directly per vertex. + writeMaterial(None) # default material + + for material in bpy.data.materials: + writeMaterial(material) exportCamera() #exportMaterials() sel = scene.objects - lamps = [l for l in sel if l.type == 'LAMP'] - exportLamps(lamps) + exportLamps([l for l in sel if l.type == 'LAMP']) + exportMeta([l for l in sel if l.type == 'META']) exportMeshs(sel) exportWorld(scene.world) exportGlobalSettings(scene) @@ -533,8 +665,6 @@ class PovrayRender(bpy.types.RenderEngine): write_pov_ini(self.temp_file_ini, self.temp_file_in, self.temp_file_out) print ("***-STARTING-***") - # This works too but means we have to wait until its done - # os.system('povray %s' % self.temp_file_ini) pov_binary = "povray" @@ -544,7 +674,11 @@ class PovrayRender(bpy.types.RenderEngine): else: pov_binary = "pvengine" - self.process = subprocess.Popen([pov_binary, self.temp_file_ini]) # stdout=subprocess.PIPE, stderr=subprocess.PIPE + if 1: + self.process = subprocess.Popen([pov_binary, self.temp_file_ini]) # stdout=subprocess.PIPE, stderr=subprocess.PIPE + else: + # This works too but means we have to wait until its done + os.system('%s %s' % (pov_binary, self.temp_file_ini)) print ("***-DONE-***") @@ -593,7 +727,7 @@ class PovrayRender(bpy.types.RenderEngine): result = self.begin_result(0, 0, x, y) lay = result.layers[0] # possible the image wont load early on. - try: lay.rect_from_file(self.temp_file_out, 0, 0) + try: lay.load_from_file(self.temp_file_out) except: pass self.end_result(result) @@ -657,7 +791,7 @@ for member in dir(buttons_material): del buttons_material class RenderButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "scene" # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here @@ -699,6 +833,7 @@ class SCENE_PT_povray_radiosity(RenderButtonsPanel): col.itemR(scene, "pov_radio_gray_threshold") col.itemR(scene, "pov_radio_low_error_factor") col.itemR(scene, "pov_radio_minimum_reuse") + col.itemR(scene, "pov_radio_media") col.itemR(scene, "pov_radio_nearest_count") col.itemR(scene, "pov_radio_normal") col.itemR(scene, "pov_radio_always_sample") @@ -759,6 +894,11 @@ FloatProperty( attr="pov_radio_low_error_factor", # max_sample - not available yet +BoolProperty( attr="pov_radio_media", + name="Use Media", + description="Radiosity estimation can be affected by media.", + default= False) + FloatProperty( attr="pov_radio_minimum_reuse", name="Minimum Reuse", description="Fraction of the screen width which sets the minimum radius of reuse for each sample point (At values higher than 2% expect errors).", diff --git a/release/io/export_fbx.py b/release/io/export_fbx.py index 2a3ea5fc30e..3515170528f 100644 --- a/release/io/export_fbx.py +++ b/release/io/export_fbx.py @@ -598,7 +598,7 @@ def write(filename, batch_objects = None, \ print('\nFBX export starting...', filename) - start_time = bpy.sys.time() + start_time = time.clock() # start_time = Blender.sys.time() try: file = open(filename, 'w') @@ -3050,7 +3050,7 @@ Takes: {''') # # copy_images( basepath, [ tex[1] for tex in textures if tex[1] != None ]) # bpy.util.copy_images( [ tex[1] for tex in textures if tex[1] != None ], basepath) - print('export finished in %.4f sec.' % (bpy.sys.time() - start_time)) + print('export finished in %.4f sec.' % (time.clock() - start_time)) # print 'export finished in %.4f sec.' % (Blender.sys.time() - start_time) return True diff --git a/release/scripts/export_map.py b/release/scripts/export_map.py index ab32f6d5ff5..aca02288c7a 100644 --- a/release/scripts/export_map.py +++ b/release/scripts/export_map.py @@ -249,6 +249,10 @@ def write_node_map(file, ob): file.write('{\n') for name_value in props: file.write('"%s" "%s"\n' % name_value) + if PREF_GRID_SNAP.val: + file.write('"origin" "%d %d %d"\n' % tuple([round(axis*PREF_SCALE.val) for axis in ob.getLocation('worldspace')]) ) + else: + file.write('"origin" "%.6f %.6f %.6f"\n' % tuple([axis*PREF_SCALE.val for axis in ob.getLocation('worldspace')]) ) file.write('}\n') return True @@ -447,4 +451,4 @@ def main(): Window.FileSelector(export_map, 'EXPORT MAP', '*.map') if __name__ == '__main__': main() -# export_map('/foo.map') \ No newline at end of file +# export_map('/foo.map') diff --git a/release/scripts/md2_export.py b/release/scripts/md2_export.py index cf5752597da..f0fe6b9af40 100644 --- a/release/scripts/md2_export.py +++ b/release/scripts/md2_export.py @@ -923,7 +923,8 @@ def fill_md2(md2, object): maxdot = dot; maxdotindex = j; - md2.frames[frame_counter].vertices[vert_counter].lightnormalindex=maxdotindex+2 + # See patch [#19206], gives good info on this line below. + md2.frames[frame_counter].vertices[vert_counter].lightnormalindex=maxdotindex del maxdot, maxdotindex del new_x, new_y, new_z diff --git a/release/scripts/textplugin_convert_ge.py b/release/scripts/textplugin_convert_ge.py index 21e065bcfd7..fb17367d622 100644 --- a/release/scripts/textplugin_convert_ge.py +++ b/release/scripts/textplugin_convert_ge.py @@ -537,7 +537,7 @@ attributeRenameDict = { 'getFrameMessageCount': (replaceSimpleGetter, 'frameMessageCount'), # KX_NetworkMessageSensor 'getFrameProperty': (replaceSimpleGetter, 'framePropName'), # BL_ShapeActionActuator, BL_ActionActuator 'getFrequency': (replaceSimpleGetter, 'frequency'), # SCA_ISensor - 'getGain': (replaceSimpleGetter, 'volume'), # KX_SoundActuator, KX_CDActuator + 'getGain': (replaceSimpleGetter, 'volume'), # KX_SoundActuator 'getHat': (replaceSimpleGetter, 'hat'), # SCA_JoystickSensor 'getHeight': (replaceSimpleGetter, 'height'), # KX_CameraActuator 'getHitNormal': (replaceSimpleGetter, 'hitNormal'), # KX_MouseFocusSensor, KX_RaySensor @@ -620,7 +620,7 @@ attributeRenameDict = { 'setFrame': (replaceSimpleSetter, 'frame'), # BL_ShapeActionActuator, BL_ActionActuator 'setFrameProperty': (replaceSimpleSetter, 'framePropName'), # BL_ShapeActionActuator, BL_ActionActuator 'setFrequency': (replaceSimpleSetter, 'frequency'), # SCA_ISensor - 'setGain': (replaceSimpleSetter, 'volume'), # KX_SoundActuator, KX_CDActuator + 'setGain': (replaceSimpleSetter, 'volume'), # KX_SoundActuator 'setHeight': (replaceSimpleSetter, 'height'), # KX_CameraActuator 'setHold1': (replaceSimpleSetter, 'hold1'), # SCA_KeyboardSensor 'setHold2': (replaceSimpleSetter, 'hold2'), # SCA_KeyboardSensor diff --git a/release/ui/buttons_data_armature.py b/release/ui/buttons_data_armature.py index 6f467ee30da..9b640776a9e 100644 --- a/release/ui/buttons_data_armature.py +++ b/release/ui/buttons_data_armature.py @@ -2,7 +2,7 @@ import bpy class DataButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "data" @@ -43,7 +43,7 @@ class DATA_PT_skeleton(DataButtonsPanel): col = split.column() col.itemR(arm, "rest_position") col.itemL(text="Deform:") - col.itemR(arm, "deform_vertexgroups", text="Vertes Groups") + col.itemR(arm, "deform_vertexgroups", text="Vertex Groups") col.itemR(arm, "deform_envelope", text="Envelopes") col.itemR(arm, "deform_quaternion", text="Quaternion") col.itemR(arm, "deform_bbone_rest", text="B-Bones Rest") diff --git a/release/ui/buttons_data_bone.py b/release/ui/buttons_data_bone.py index e05b64e5e11..1eb09377892 100644 --- a/release/ui/buttons_data_bone.py +++ b/release/ui/buttons_data_bone.py @@ -2,7 +2,7 @@ import bpy class BoneButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "bone" diff --git a/release/ui/buttons_data_camera.py b/release/ui/buttons_data_camera.py index 811858e3627..f2fa4207ec8 100644 --- a/release/ui/buttons_data_camera.py +++ b/release/ui/buttons_data_camera.py @@ -2,12 +2,12 @@ import bpy class DataButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "data" def poll(self, context): - return (context.camera) + return (context.camera != None) class DATA_PT_context_camera(DataButtonsPanel): __show_header__ = False diff --git a/release/ui/buttons_data_curve.py b/release/ui/buttons_data_curve.py index d0e1756986d..35d557afe32 100644 --- a/release/ui/buttons_data_curve.py +++ b/release/ui/buttons_data_curve.py @@ -2,7 +2,7 @@ import bpy class DataButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "data" diff --git a/release/ui/buttons_data_empty.py b/release/ui/buttons_data_empty.py index 09868eeb542..02fea15dc2a 100644 --- a/release/ui/buttons_data_empty.py +++ b/release/ui/buttons_data_empty.py @@ -2,7 +2,7 @@ import bpy class DataButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "data" diff --git a/release/ui/buttons_data_lamp.py b/release/ui/buttons_data_lamp.py index 6fb021802f0..a00bb23d5b5 100644 --- a/release/ui/buttons_data_lamp.py +++ b/release/ui/buttons_data_lamp.py @@ -2,7 +2,7 @@ import bpy class DataButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "data" @@ -319,4 +319,4 @@ bpy.types.register(DATA_PT_falloff_curve) bpy.types.register(DATA_PT_area) bpy.types.register(DATA_PT_spot) bpy.types.register(DATA_PT_shadow) -bpy.types.register(DATA_PT_sunsky) \ No newline at end of file +bpy.types.register(DATA_PT_sunsky) diff --git a/release/ui/buttons_data_lattice.py b/release/ui/buttons_data_lattice.py index 3766b9ff1a5..5d8a07c7d44 100644 --- a/release/ui/buttons_data_lattice.py +++ b/release/ui/buttons_data_lattice.py @@ -2,7 +2,7 @@ import bpy class DataButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "data" diff --git a/release/ui/buttons_data_mesh.py b/release/ui/buttons_data_mesh.py index e8ab59a96dd..b681218a8fe 100644 --- a/release/ui/buttons_data_mesh.py +++ b/release/ui/buttons_data_mesh.py @@ -2,7 +2,7 @@ import bpy class DataButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "data" @@ -44,9 +44,39 @@ class DATA_PT_normals(DataButtonsPanel): sub.active = mesh.autosmooth sub.itemR(mesh, "autosmooth_angle", text="Angle") - sub = split.column() - sub.itemR(mesh, "vertex_normal_flip") - sub.itemR(mesh, "double_sided") + col = split.column() + col.itemR(mesh, "vertex_normal_flip") + col.itemR(mesh, "double_sided") + +class DATA_PT_meshdraw(DataButtonsPanel): + __label__ = "Draw" + + def draw(self, context): + layout = self.layout + + mesh = context.mesh + + layout.itemL(text="Edit Mode only, WIP") + + split = layout.split() + + col = split.column() + col.itemR(mesh, "draw_edges", text="Edges") + col.itemR(mesh, "draw_faces", text="Faces") + col.itemR(mesh, "draw_creases", text="Creases") + col.itemR(mesh, "draw_bevel_weights", text="Bevel Weights") + col.itemR(mesh, "draw_seams", text="Seams") + col.itemR(mesh, "draw_sharp", text="Sharp") + + col = split.column() + col.itemR(mesh, "draw_normals", text="Face Normals") + col.itemR(mesh, "draw_vertex_normals", text="Vertex Normals") + + col.itemS() + + col.itemR(mesh, "draw_edge_lenght") + col.itemR(mesh, "draw_edge_angle") + col.itemR(mesh, "draw_face_area") class DATA_PT_vertex_groups(DataButtonsPanel): __label__ = "Vertex Groups" @@ -76,12 +106,15 @@ class DATA_PT_vertex_groups(DataButtonsPanel): row.itemR(group, "name") if context.edit_object: - row = layout.row(align=True) - - row.itemO("object.vertex_group_assign", text="Assign") - row.itemO("object.vertex_group_remove_from", text="Remove") - row.itemO("object.vertex_group_select", text="Select") - row.itemO("object.vertex_group_deselect", text="Deselect") + row = layout.row() + + sub = row.row(align=True) + sub.itemO("object.vertex_group_assign", text="Assign") + sub.itemO("object.vertex_group_remove_from", text="Remove") + + sub = row.row(align=True) + sub.itemO("object.vertex_group_select", text="Select") + sub.itemO("object.vertex_group_deselect", text="Deselect") layout.itemR(context.tool_settings, "vertex_group_weight", text="Weight") @@ -129,7 +162,7 @@ class DATA_PT_shape_keys(DataButtonsPanel): row.itemR(kb, "value", slider=True) split = layout.split() - sub = split.column() + sub = split.column(align=True) sub.enabled = ob.shape_key_lock == False sub.itemL(text="Range:") sub.itemR(kb, "slider_min", text="Min") @@ -194,6 +227,7 @@ class DATA_PT_vertex_colors(DataButtonsPanel): bpy.types.register(DATA_PT_context_mesh) bpy.types.register(DATA_PT_normals) +bpy.types.register(DATA_PT_meshdraw) bpy.types.register(DATA_PT_vertex_groups) bpy.types.register(DATA_PT_shape_keys) bpy.types.register(DATA_PT_uv_texture) diff --git a/release/ui/buttons_data_metaball.py b/release/ui/buttons_data_metaball.py index 74731473683..e31c3d7fcd0 100644 --- a/release/ui/buttons_data_metaball.py +++ b/release/ui/buttons_data_metaball.py @@ -1,7 +1,7 @@ import bpy class DataButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "data" @@ -54,12 +54,12 @@ class DATA_PT_metaball_element(DataButtonsPanel): __label__ = "Active Element" def poll(self, context): - return (context.meta_ball and context.meta_ball.last_selected_element) + return (context.meta_ball and context.meta_ball.active_element) def draw(self, context): layout = self.layout - metaelem = context.meta_ball.last_selected_element + metaelem = context.meta_ball.active_element split = layout.split(percentage=0.3) split.itemL(text="Type:") @@ -81,32 +81,32 @@ class DATA_PT_metaball_element(DataButtonsPanel): col = split.column(align=True) col.itemL(text="Size:") - col.itemR(metaelem, "sizex", text="X") - col.itemR(metaelem, "sizey", text="Y") - col.itemR(metaelem, "sizez", text="Z") + col.itemR(metaelem, "size_x", text="X") + col.itemR(metaelem, "size_y", text="Y") + col.itemR(metaelem, "size_z", text="Z") elif metaelem.type == 'TUBE': col = split.column(align=True) col.itemL(text="Size:") - col.itemR(metaelem, "sizex", text="X") + col.itemR(metaelem, "size_x", text="X") elif metaelem.type == 'PLANE': col = split.column(align=True) col.itemL(text="Size:") - col.itemR(metaelem, "sizex", text="X") - col.itemR(metaelem, "sizey", text="Y") + col.itemR(metaelem, "size_x", text="X") + col.itemR(metaelem, "size_y", text="Y") elif metaelem.type == 'ELLIPSOID': col = split.column(align=True) col.itemL(text="Size:") - col.itemR(metaelem, "sizex", text="X") - col.itemR(metaelem, "sizey", text="Y") - col.itemR(metaelem, "sizez", text="Z") + col.itemR(metaelem, "size_x", text="X") + col.itemR(metaelem, "size_y", text="Y") + col.itemR(metaelem, "size_z", text="Z") bpy.types.register(DATA_PT_context_metaball) bpy.types.register(DATA_PT_metaball) -bpy.types.register(DATA_PT_metaball_element) \ No newline at end of file +bpy.types.register(DATA_PT_metaball_element) diff --git a/release/ui/buttons_data_modifier.py b/release/ui/buttons_data_modifier.py index bd39ff1e70e..436baa540d4 100644 --- a/release/ui/buttons_data_modifier.py +++ b/release/ui/buttons_data_modifier.py @@ -2,7 +2,7 @@ import bpy class DataButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "modifier" @@ -16,89 +16,43 @@ class DATA_PT_modifiers(DataButtonsPanel): row = layout.row() row.item_menu_enumO("object.modifier_add", "type") - row.itemL(); + row.itemL() for md in ob.modifiers: box = layout.template_modifier(md) - if box: - if md.type == 'ARMATURE': - self.armature(box, ob, md) - elif md.type == 'ARRAY': - self.array(box, ob, md) - elif md.type == 'BEVEL': - self.bevel(box, ob, md) - elif md.type == 'BOOLEAN': - self.boolean(box, ob, md) - elif md.type == 'BUILD': - self.build(box, ob, md) - elif md.type == 'CAST': - self.cast(box, ob, md) - elif md.type == 'CLOTH': - self.cloth(box, ob, md) - elif md.type == 'COLLISION': - self.collision(box, ob, md) - elif md.type == 'CURVE': - self.curve(box, ob, md) - elif md.type == 'DECIMATE': - self.decimate(box, ob, md) - elif md.type == 'DISPLACE': - self.displace(box, ob, md) - elif md.type == 'EDGE_SPLIT': - self.edgesplit(box, ob, md) - elif md.type == 'EXPLODE': - self.explode(box, ob, md) - elif md.type == 'FLUID_SIMULATION': - self.fluid(box, ob, md) - elif md.type == 'HOOK': - self.hook(box, ob, md) - elif md.type == 'LATTICE': - self.lattice(box, ob, md) - elif md.type == 'MASK': - self.mask(box, ob, md) - elif md.type == 'MESH_DEFORM': - self.mesh_deform(box, ob, md) - elif md.type == 'MIRROR': - self.mirror(box, ob, md) - elif md.type == 'MULTIRES': - self.multires(box, ob, md) - elif md.type == 'PARTICLE_INSTANCE': - self.particleinstance(box, ob, md) - elif md.type == 'PARTICLE_SYSTEM': - self.particlesystem(box, ob, md) - elif md.type == 'SHRINKWRAP': - self.shrinkwrap(box, ob, md) - elif md.type == 'SIMPLE_DEFORM': - self.simpledeform(box, ob, md) - elif md.type == 'SMOKE': - self.smoke(box, ob, md) - elif md.type == 'SMOOTH': - self.smooth(box, ob, md) - elif md.type == 'SOFTBODY': - self.softbody(box, ob, md) - elif md.type == 'SUBSURF': - self.subsurf(box, ob, md) - elif md.type == 'SURFACE': - self.surface(box, ob, md) - elif md.type == 'UV_PROJECT': - self.uvproject(box, ob, md) - elif md.type == 'WAVE': - self.wave(box, ob, md) - - def armature(self, layout, ob, md): + # match enum type to our functions, avoids a lookup table. + getattr(self, md.type)(box, ob, md) + + # the mt.type enum is (ab)used for a lookup on function names + # ...to avoid lengthy if statements + # so each type must have a function here. + def ARMATURE(self, layout, ob, md): layout.itemR(md, "object") - row = layout.row() - row.item_pointerR(md, "vertex_group", ob, "vertex_groups") - row.itemR(md, "invert") + split = layout.split(percentage=0.5) + split.itemL(text="Vertex Group:") + sub = split.split(percentage=0.7) + sub.item_pointerR(md, "vertex_group", ob, "vertex_groups", text="") + subsub = sub.row() + subsub.active = md.vertex_group + subsub.itemR(md, "invert") - flow = layout.column_flow() - flow.itemR(md, "use_vertex_groups", text="Vertex Groups") - flow.itemR(md, "use_bone_envelopes", text="Bone Envelopes") - flow.itemR(md, "quaternion") - flow.itemR(md, "multi_modifier") + layout.itemS() - def array(self, layout, ob, md): + split = layout.split() + + col = split.column() + col.itemL(text="Bind To:") + col.itemR(md, "use_vertex_groups", text="Vertex Groups") + col.itemR(md, "use_bone_envelopes", text="Bone Envelopes") + + col = split.column() + col.itemL(text="Deformation:") + col.itemR(md, "quaternion") + col.itemR(md, "multi_modifier") + + def ARRAY(self, layout, ob, md): layout.itemR(md, "fit_type") if md.fit_type == 'FIXED_COUNT': layout.itemR(md, "count") @@ -144,7 +98,7 @@ class DATA_PT_modifiers(DataButtonsPanel): col.itemR(md, "start_cap") col.itemR(md, "end_cap") - def bevel(self, layout, ob, md): + def BEVEL(self, layout, ob, md): row = layout.row() row.itemR(md, "width") row.itemR(md, "only_vertices") @@ -156,11 +110,11 @@ class DATA_PT_modifiers(DataButtonsPanel): elif md.limit_method == 'WEIGHT': layout.row().itemR(md, "edge_weight_method", expand=True) - def boolean(self, layout, ob, md): + def BOOLEAN(self, layout, ob, md): layout.itemR(md, "operation") layout.itemR(md, "object") - def build(self, layout, ob, md): + def BUILD(self, layout, ob, md): split = layout.split() col = split.column() @@ -173,7 +127,7 @@ class DATA_PT_modifiers(DataButtonsPanel): sub.active = md.randomize sub.itemR(md, "seed") - def cast(self, layout, ob, md): + def CAST(self, layout, ob, md): layout.itemR(md, "cast_type") layout.itemR(md, "object") if md.object: @@ -191,22 +145,22 @@ class DATA_PT_modifiers(DataButtonsPanel): layout.item_pointerR(md, "vertex_group", ob, "vertex_groups") - def cloth(self, layout, ob, md): + def CLOTH(self, layout, ob, md): layout.itemL(text="See Cloth panel.") - def collision(self, layout, ob, md): + def COLLISION(self, layout, ob, md): layout.itemL(text="See Collision panel.") - def curve(self, layout, ob, md): + def CURVE(self, layout, ob, md): layout.itemR(md, "object") layout.item_pointerR(md, "vertex_group", ob, "vertex_groups") layout.itemR(md, "deform_axis") - def decimate(self, layout, ob, md): + def DECIMATE(self, layout, ob, md): layout.itemR(md, "ratio") layout.itemR(md, "face_count") - def displace(self, layout, ob, md): + def DISPLACE(self, layout, ob, md): layout.item_pointerR(md, "vertex_group", ob, "vertex_groups") layout.itemR(md, "texture") layout.itemR(md, "midlevel") @@ -218,7 +172,7 @@ class DATA_PT_modifiers(DataButtonsPanel): elif md.texture_coordinates == 'UV' and ob.type == 'MESH': layout.item_pointerR(md, "uv_layer", ob.data, "uv_layers") - def edgesplit(self, layout, ob, md): + def EDGE_SPLIT(self, layout, ob, md): split = layout.split() col = split.column() @@ -230,7 +184,7 @@ class DATA_PT_modifiers(DataButtonsPanel): col = split.column() col.itemR(md, "use_sharp", text="Sharp Edges") - def explode(self, layout, ob, md): + def EXPLODE(self, layout, ob, md): layout.item_pointerR(md, "vertex_group", ob, "vertex_groups") layout.itemR(md, "protect") layout.itemR(md, "split_edges") @@ -239,21 +193,21 @@ class DATA_PT_modifiers(DataButtonsPanel): layout.itemR(md, "dead") # Missing: "Refresh" and "Clear Vertex Group" Operator - def fluid(self, layout, ob, md): + def FLUID_SIMULATION(self, layout, ob, md): layout.itemL(text="See Fluid panel.") - def hook(self, layout, ob, md): + def HOOK(self, layout, ob, md): layout.itemR(md, "falloff") layout.itemR(md, "force", slider=True) layout.itemR(md, "object") layout.item_pointerR(md, "vertex_group", ob, "vertex_groups") # Missing: "Reset" and "Recenter" Operator - def lattice(self, layout, ob, md): + def LATTICE(self, layout, ob, md): layout.itemR(md, "object") layout.item_pointerR(md, "vertex_group", ob, "vertex_groups") - def mask(self, layout, ob, md): + def MASK(self, layout, ob, md): layout.itemR(md, "mode") if md.mode == 'ARMATURE': layout.itemR(md, "armature") @@ -261,7 +215,7 @@ class DATA_PT_modifiers(DataButtonsPanel): layout.item_pointerR(md, "vertex_group", ob, "vertex_groups") layout.itemR(md, "inverse") - def mesh_deform(self, layout, ob, md): + def MESH_DEFORM(self, layout, ob, md): layout.itemR(md, "object") layout.item_pointerR(md, "vertex_group", ob, "vertex_groups") layout.itemR(md, "invert") @@ -273,7 +227,7 @@ class DATA_PT_modifiers(DataButtonsPanel): row.itemR(md, "precision") row.itemR(md, "dynamic") - def mirror(self, layout, ob, md): + def MIRROR(self, layout, ob, md): layout.itemR(md, "merge_limit") split = layout.split() @@ -293,12 +247,12 @@ class DATA_PT_modifiers(DataButtonsPanel): layout.itemR(md, "mirror_object") - def multires(self, layout, ob, md): + def MULTIRES(self, layout, ob, md): layout.itemR(md, "subdivision_type") layout.itemO("object.multires_subdivide", text="Subdivide") layout.itemR(md, "level") - def particleinstance(self, layout, ob, md): + def PARTICLE_INSTANCE(self, layout, ob, md): layout.itemR(md, "object") layout.itemR(md, "particle_system_number") @@ -321,10 +275,10 @@ class DATA_PT_modifiers(DataButtonsPanel): row.itemR(md, "position", slider=True) row.itemR(md, "random_position", text = "Random", slider=True) - def particlesystem(self, layout, ob, md): + def PARTICLE_SYSTEM(self, layout, ob, md): layout.itemL(text="See Particle panel.") - def shrinkwrap(self, layout, ob, md): + def SHRINKWRAP(self, layout, ob, md): layout.itemR(md, "target") layout.item_pointerR(md, "vertex_group", ob, "vertex_groups") layout.itemR(md, "offset") @@ -347,7 +301,7 @@ class DATA_PT_modifiers(DataButtonsPanel): elif md.mode == 'NEAREST_SURFACEPOINT': layout.itemR(md, "keep_above_surface") - def simpledeform(self, layout, ob, md): + def SIMPLE_DEFORM(self, layout, ob, md): layout.itemR(md, "mode") layout.item_pointerR(md, "vertex_group", ob, "vertex_groups") layout.itemR(md, "origin") @@ -358,32 +312,10 @@ class DATA_PT_modifiers(DataButtonsPanel): layout.itemR(md, "lock_x_axis") layout.itemR(md, "lock_y_axis") - def smoke(self, layout, ob, md): - layout.itemR(md, "smoke_type") - - if md.smoke_type == 'TYPE_DOMAIN': - layout.itemS() - layout.itemR(md.domain_settings, "maxres") - layout.itemR(md.domain_settings, "color") - layout.itemR(md.domain_settings, "amplify") - layout.itemR(md.domain_settings, "highres") - layout.itemR(md.domain_settings, "noise_type") - layout.itemR(md.domain_settings, "visibility") - layout.itemR(md.domain_settings, "alpha") - layout.itemR(md.domain_settings, "beta") - layout.itemR(md.domain_settings, "fluid_group") - layout.itemR(md.domain_settings, "eff_group") - layout.itemR(md.domain_settings, "coll_group") - elif md.smoke_type == 'TYPE_FLOW': - layout.itemS() - layout.itemR(md.flow_settings, "outflow") - layout.itemR(md.flow_settings, "density") - layout.itemR(md.flow_settings, "temperature") - layout.item_pointerR(md.flow_settings, "psys", ob, "particle_systems") - elif md.smoke_type == 'TYPE_COLL': - layout.itemS() + def SMOKE(self, layout, ob, md): + layout.itemL(text="See Smoke panel.") - def smooth(self, layout, ob, md): + def SMOOTH(self, layout, ob, md): split = layout.split() col = split.column() @@ -397,11 +329,11 @@ class DATA_PT_modifiers(DataButtonsPanel): layout.item_pointerR(md, "vertex_group", ob, "vertex_groups") - def softbody(self, layout, ob, md): + def SOFT_BODY(self, layout, ob, md): layout.itemL(text="See Soft Body panel.") - def subsurf(self, layout, ob, md): - layout.itemR(md, "subdivision_type") + def SUBSURF(self, layout, ob, md): + layout.row().itemR(md, "subdivision_type", expand=True) flow = layout.column_flow() flow.itemR(md, "levels", text="Preview") @@ -409,20 +341,23 @@ class DATA_PT_modifiers(DataButtonsPanel): flow.itemR(md, "optimal_draw", text="Optimal Display") flow.itemR(md, "subsurf_uv") - def surface(self, layout, ob, md): + def SURFACE(self, layout, ob, md): layout.itemL(text="See Fields panel.") - def uvproject(self, layout, ob, md): + def UV_PROJECT(self, layout, ob, md): if ob.type == 'MESH': layout.item_pointerR(md, "uv_layer", ob.data, "uv_layers") #layout.itemR(md, "projectors") layout.itemR(md, "image") - layout.itemR(md, "horizontal_aspect_ratio") - layout.itemR(md, "vertical_aspect_ratio") layout.itemR(md, "override_image") + layout.itemL(text="Aspect Ratio:") + col = layout.column(align=True) + col.itemR(md, "horizontal_aspect_ratio", text="Horizontal") + col.itemR(md, "vertical_aspect_ratio", text="Vertical") + #"Projectors" don't work. - def wave(self, layout, ob, md): + def WAVE(self, layout, ob, md): split = layout.split() col = split.column() diff --git a/release/ui/buttons_data_text.py b/release/ui/buttons_data_text.py index 757e61307df..754d6fcda39 100644 --- a/release/ui/buttons_data_text.py +++ b/release/ui/buttons_data_text.py @@ -2,7 +2,7 @@ import bpy class DataButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "data" diff --git a/release/ui/buttons_game.py b/release/ui/buttons_game.py index 9635ecfa67c..7334b453e91 100644 --- a/release/ui/buttons_game.py +++ b/release/ui/buttons_game.py @@ -2,7 +2,7 @@ import bpy class PhysicsButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "physics" @@ -19,72 +19,133 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel): ob = context.active_object game = ob.game + soft = ob.game.soft_body layout.itemR(game, "physics_type") layout.itemS() - split = layout.split() - - col = split.column() - col.itemR(game, "actor") - col.itemR(game, "ghost") - col.itemR(ob, "restrict_render", text="Invisible") # out of place but useful - - col = split.column() - col.itemR(game, "do_fh", text="Use Material Physics") - col.itemR(game, "rotation_fh", text="Rotate From Normal") - col.itemR(game, "no_sleeping") - - layout.itemS() - - split = layout.split() - - col = split.column() - col.itemL(text="Attributes:") - sub = col.column(align=True) - sub.itemR(game, "mass") - sub.itemR(game, "radius") - sub.itemR(game, "form_factor") - - col.itemS() - - col.itemL(text="Damping:") - sub = col.column(align=True) - sub.itemR(game, "damping", text="Translation", slider=True) - sub.itemR(game, "rotation_damping", text="Rotation", slider=True) - - col = split.column() - col.itemL(text="Velocity:") - sub = col.column(align=True) - sub.itemR(game, "minimum_velocity", text="Minimum") - sub.itemR(game, "maximum_velocity", text="Maximum") - - col.itemS() - - col.itemR(game, "anisotropic_friction") - sub = col.column() - sub.active = game.anisotropic_friction - sub.itemR(game, "friction_coefficients", text="", slider=True) - - layout.itemS() - - split = layout.split() - - col = split.column() - col.itemL(text="Lock Translation:") - col.itemR(game, "lock_x_axis", text="X") - col.itemR(game, "lock_y_axis", text="Y") - col.itemR(game, "lock_z_axis", text="Z") - - col = split.column() - col.itemL(text="Lock Rotation:") - col.itemR(game, "lock_x_rot_axis", text="X") - col.itemR(game, "lock_y_rot_axis", text="Y") - col.itemR(game, "lock_z_rot_axis", text="Z") + #if game.physics_type == 'DYNAMIC': + if game.physics_type in ('DYNAMIC', 'RIGID_BODY'): + split = layout.split() + + col = split.column() + col.itemR(game, "actor") + col.itemR(game, "ghost") + col.itemR(ob, "restrict_render", text="Invisible") # out of place but useful + + col = split.column() + col.itemR(game, "material_physics") + col.itemR(game, "rotate_from_normal") + col.itemR(game, "no_sleeping") + + layout.itemS() + + split = layout.split() + + col = split.column() + col.itemL(text="Attributes:") + sub = col.column() + sub.itemR(game, "mass") + sub.itemR(game, "radius") + sub.itemR(game, "form_factor") + + col = split.column() + sub = col.column() + sub.active = (game.physics_type == 'RIGID_BODY') + sub.itemR(game, "anisotropic_friction") + subsub = sub.column() + subsub.active = game.anisotropic_friction + subsub.itemR(game, "friction_coefficients", text="", slider=True) + + split = layout.split() + + col = split.column() + col.itemL(text="Velocity:") + sub = col.column(align=True) + sub.itemR(game, "minimum_velocity", text="Minimum") + sub.itemR(game, "maximum_velocity", text="Maximum") + + col = split.column() + col.itemL(text="Damping:") + sub = col.column(align=True) + sub.itemR(game, "damping", text="Translation", slider=True) + sub.itemR(game, "rotation_damping", text="Rotation", slider=True) + + layout.itemS() + + split = layout.split() + + col = split.column() + col.itemL(text="Lock Translation:") + col.itemR(game, "lock_x_axis", text="X") + col.itemR(game, "lock_y_axis", text="Y") + col.itemR(game, "lock_z_axis", text="Z") + + col = split.column() + col.itemL(text="Lock Rotation:") + col.itemR(game, "lock_x_rot_axis", text="X") + col.itemR(game, "lock_y_rot_axis", text="Y") + col.itemR(game, "lock_z_rot_axis", text="Z") + + elif game.physics_type == 'SOFT_BODY': + + col = layout.column() + col.itemR(game, "actor") + col.itemR(game, "ghost") + col.itemR(ob, "restrict_render", text="Invisible") + + layout.itemS() + + split = layout.split() + + col = split.column() + col.itemL(text="Attributes:") + col.itemR(game, "mass") + col.itemR(soft, "welding") + col.itemR(soft, "position_iterations") + col.itemR(soft, "linstiff", slider=True) + col.itemR(soft, "dynamic_friction", slider=True) + col.itemR(soft, "margin", slider=True) + col.itemR(soft, "bending_const", text="Bending Constraints") + + + col = split.column() + col.itemR(soft, "shape_match") + sub = col.column() + sub.active = soft.shape_match + sub.itemR(soft, "threshold", slider=True) + + col.itemS() + + col.itemL(text="Cluster Collision:") + col.itemR(soft, "cluster_rigid_to_softbody") + col.itemR(soft, "cluster_soft_to_softbody") + sub = col.column() + sub.active = (soft.cluster_rigid_to_softbody or soft.cluster_soft_to_softbody) + sub.itemR(soft, "cluster_iterations", text="Iterations") + + elif game.physics_type == 'STATIC': + + col = layout.column() + col.itemR(game, "actor") + col.itemR(game, "ghost") + col.itemR(ob, "restrict_render", text="Invisible") + + elif game.physics_type in ('SENSOR', 'INVISIBLE', 'NO_COLLISION', 'OCCLUDE'): + + col = layout.column() + col.itemR(ob, "restrict_render", text="Invisible") + class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel): __label__ = "Collision Bounds" + def poll(self, context): + ob = context.active_object + game = ob.game + rd = context.scene.render_data + return (game.physics_type in ('DYNAMIC', 'RIGID_BODY', 'SENSOR', 'SOFT_BODY', 'STATIC')) and (rd.engine == 'BLENDER_GAME') + def draw_header(self, context): layout = self.layout @@ -110,7 +171,7 @@ bpy.types.register(PHYSICS_PT_game_physics) bpy.types.register(PHYSICS_PT_game_collision_bounds) class SceneButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "scene" @@ -131,7 +192,7 @@ class SCENE_PT_game(SceneButtonsPanel): row.itemL() class SCENE_PT_game_player(SceneButtonsPanel): - __label__ = "Player" + __label__ = "Standalone Player" def draw(self, context): layout = self.layout @@ -158,8 +219,8 @@ class SCENE_PT_game_player(SceneButtonsPanel): col = layout.column() col.itemL(text="Framing:") col.row().itemR(gs, "framing_type", expand=True) - sub = col.column() - sub.itemR(gs, "framing_color", text="") + if gs.framing_type == 'LETTERBOX': + col.itemR(gs, "framing_color", text="") class SCENE_PT_game_stereo(SceneButtonsPanel): __label__ = "Stereo" @@ -176,29 +237,92 @@ class SCENE_PT_game_stereo(SceneButtonsPanel): # stereo: if stereo_mode == 'STEREO': layout.itemR(gs, "stereo_mode") + layout.itemL(text="To do: Focal Length") + layout.itemL(text="To do: Eye Separation") # dome: - if stereo_mode == 'DOME': + elif stereo_mode == 'DOME': layout.itemR(gs, "dome_mode", text="Dome Type") + dome_type = gs.dome_mode + split=layout.split() - - col=split.column() - col.itemR(gs, "dome_angle", slider=True) - col.itemR(gs, "dome_tesselation", text="Tesselation") - - col=split.column() - col.itemR(gs, "dome_tilt") - col.itemR(gs, "dome_buffer_resolution", text="Resolution", slider=True) - + + if dome_type == 'FISHEYE' or \ + dome_type == 'TRUNCATED_REAR' or \ + dome_type == 'TRUNCATED_FRONT': + + col=split.column() + col.itemR(gs, "dome_angle", slider=True) + col.itemR(gs, "dome_tilt") + + col=split.column() + col.itemR(gs, "dome_tesselation", text="Tesselation") + col.itemR(gs, "dome_buffer_resolution", text="Resolution", slider=True) + + elif dome_type == 'PANORAM_SPH': + col=split.column() + col.itemR(gs, "dome_tesselation", text="Tesselation") + col.itemR(gs, "dome_buffer_resolution", text="Resolution", slider=True) + + else: # cube map + col=split.column() + col.itemR(gs, "dome_buffer_resolution", text="Resolution", slider=True) + layout.itemR(gs, "dome_text") +class SCENE_PT_game_shading(SceneButtonsPanel): + __label__ = "Shading" + + def draw(self, context): + layout = self.layout + + gs = context.scene.game_data + layout.itemR(gs, "material_mode", expand=True) + + if gs.material_mode == 'GLSL': + split = layout.split() + + col = split.column() + col.itemR(gs, "glsl_lights", text="Lights") + col.itemR(gs, "glsl_shaders", text="Shaders") + col.itemR(gs, "glsl_shadows", text="Shadows") + + col = split.column() + col.itemR(gs, "glsl_ramps", text="Ramps") + col.itemR(gs, "glsl_nodes", text="Nodes") + col.itemR(gs, "glsl_extra_textures", text="Extra Textures") + +class SCENE_PT_game_performance(SceneButtonsPanel): + __label__ = "Performance" + + def draw(self, context): + layout = self.layout + + gs = context.scene.game_data + + split = layout.split() + + col = split.column() + col.itemL(text="Show:") + col.itemR(gs, "show_debug_properties", text="Debug Properties") + col.itemR(gs, "show_framerate_profile", text="Framerate and Profile") + col.itemR(gs, "show_physics_visualization", text="Physics Visualization") + col.itemR(gs, "deprecation_warnings") + + col = split.column() + col.itemL(text="Render:") + col.itemR(gs, "all_frames") + col.itemR(gs, "display_lists") + bpy.types.register(SCENE_PT_game) bpy.types.register(SCENE_PT_game_player) bpy.types.register(SCENE_PT_game_stereo) +bpy.types.register(SCENE_PT_game_shading) +bpy.types.register(SCENE_PT_game_performance) class WorldButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "world" @@ -246,30 +370,6 @@ class WORLD_PT_game_world(WorldButtonsPanel): row.itemR(world.mist, "start") row.itemR(world.mist, "depth") - -""" -class WORLD_PT_game(WorldButtonsPanel): - __space_type__ = "LOGIC_EDITOR" - __region_type__ = "UI" - __label__ = "Game Settings" - - def draw(self, context): - layout = self.layout - world = context.world - - flow = layout.column_flow() - flow.itemR(world, "physics_engine") - flow.itemR(world, "physics_gravity") - - flow.itemR(world, "game_fps") - flow.itemR(world, "game_logic_step_max") - flow.itemR(world, "game_physics_substep") - flow.itemR(world, "game_physics_step_max") - - flow.itemR(world, "game_use_occlusion_culling", text="Enable Occlusion Culling") - flow.itemR(world, "game_occlusion_culling_resolution") -""" - class WORLD_PT_game_physics(WorldButtonsPanel): __label__ = "Physics" @@ -279,7 +379,7 @@ class WORLD_PT_game_physics(WorldButtonsPanel): gs = context.scene.game_data layout.itemR(gs, "physics_engine") - if gs.physics_engine != "NONE": + if gs.physics_engine != 'NONE': layout.itemR(gs, "physics_gravity", text="Gravity") split = layout.split() diff --git a/release/ui/buttons_material.py b/release/ui/buttons_material.py index b570deebfe2..b971a678926 100644 --- a/release/ui/buttons_material.py +++ b/release/ui/buttons_material.py @@ -1,14 +1,8 @@ import bpy -# If python version is less than 2.4, try to get set stuff from module -try: - set -except: - from sets import Set as set - class MaterialButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "material" # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here @@ -66,15 +60,16 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel): split.template_ID(ob, "active_material", new="material.new") row = split.row() if slot: - row.itemR(slot, "link", expand=True) + row.itemR(slot, "link", text="") else: row.itemL() elif mat: split.template_ID(space, "pin_id") split.itemS() + + layout.itemR(mat, "type", expand=True) -class MATERIAL_PT_material(MaterialButtonsPanel): - __idname__= "MATERIAL_PT_material" +class MATERIAL_PT_shading(MaterialButtonsPanel): __label__ = "Shading" COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME']) @@ -87,30 +82,34 @@ class MATERIAL_PT_material(MaterialButtonsPanel): space = context.space_data if mat: - layout.itemR(mat, "type", expand=True) if mat.type in ('SURFACE', 'WIRE', 'VOLUME'): split = layout.split() col = split.column() - col.itemR(mat, "alpha", slider=True) - col.itemR(mat, "ambient", slider=True) + col.active = not mat.shadeless + col.itemR(mat, "ambient") col.itemR(mat, "emit") - col.itemR(mat, "translucency", slider=True) + col.itemR(mat, "translucency") col = split.column() - col.itemR(mat, "z_transparency") col.itemR(mat, "shadeless") - col.itemR(mat, "tangent_shading") - col.itemR(mat, "cubic", slider=True) + sub = col.column() + sub.active = not mat.shadeless + sub.itemR(mat, "tangent_shading") + sub.itemR(mat, "cubic") elif mat.type == 'HALO': - layout.itemR(mat, "alpha", slider=True) + layout.itemR(mat, "alpha") class MATERIAL_PT_strand(MaterialButtonsPanel): __label__ = "Strand" __default_closed__ = True COMPAT_ENGINES = set(['BLENDER_RENDER']) + + def poll(self, context): + mat = context.material + return mat and (mat.type in ('SURFACE', 'WIRE')) and (context.scene.render_data.engine in self.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -127,7 +126,7 @@ class MATERIAL_PT_strand(MaterialButtonsPanel): col.itemR(tan, "min_size", text="Minimum") col.itemR(tan, "blender_units") sub = col.column() - sub.active = mat.shadeless == False + sub.active = (not mat.shadeless) sub.itemR(tan, "tangent_shading") col = split.column() @@ -135,12 +134,34 @@ class MATERIAL_PT_strand(MaterialButtonsPanel): col.itemR(tan, "width_fade") col.itemR(tan, "uv_layer") sub = col.column() - sub.active = mat.shadeless == False + sub.active = (not mat.shadeless) sub.itemR(tan, "surface_diffuse") sub = col.column() sub.active = tan.surface_diffuse sub.itemR(tan, "blend_distance", text="Distance") +class MATERIAL_PT_physics(MaterialButtonsPanel): + __label__ = "Physics" + COMPAT_ENGINES = set(['BLENDER_GAME']) + + def draw(self, context): + layout = self.layout + + mat = context.material + phys = mat.physics + + split = layout.split() + + col = split.column() + col.itemR(phys, "distance") + col.itemR(phys, "friction") + col.itemR(phys, "align_to_normal") + + col = split.column() + col.itemR(phys, "force", slider=True) + col.itemR(phys, "elasticity", slider=True) + col.itemR(phys, "damp", slider=True) + class MATERIAL_PT_options(MaterialButtonsPanel): __label__ = "Options" COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME']) @@ -175,8 +196,9 @@ class MATERIAL_PT_options(MaterialButtonsPanel): col.itemR(mat, "vertex_color_light") col.itemR(mat, "object_color") -class MATERIAL_PT_shadows(MaterialButtonsPanel): - __label__ = "Shadows" +class MATERIAL_PT_shadow(MaterialButtonsPanel): + __label__ = "Shadow" + __default_closed__ = True COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME']) def draw(self, context): @@ -191,23 +213,26 @@ class MATERIAL_PT_shadows(MaterialButtonsPanel): col.itemR(mat, "transparent_shadows", text="Receive Transparent") col.itemR(mat, "only_shadow", text="Shadows Only") col.itemR(mat, "cast_shadows_only", text="Cast Only") - col.itemR(mat, "shadow_casting_alpha", text="Casting Alpha", slider=True) + col.itemR(mat, "shadow_casting_alpha", text="Casting Alpha") col = split.column() + col.itemR(mat, "cast_buffer_shadows") + sub = col.column() + sub.active = mat.cast_buffer_shadows + sub.itemR(mat, "shadow_buffer_bias", text="Buffer Bias") col.itemR(mat, "ray_shadow_bias", text="Auto Ray Bias") sub = col.column() - subsub = sub.column() - subsub.active = not mat.ray_shadow_bias - subsub.itemR(mat, "shadow_ray_bias", text="Ray Shadow Bias") - sub.itemR(mat, "cast_buffer_shadows") - sub.itemR(mat, "shadow_buffer_bias", text="Buffer Bias") + sub.active = (not mat.ray_shadow_bias) + sub.itemR(mat, "shadow_ray_bias", text="Ray Bias") + class MATERIAL_PT_diffuse(MaterialButtonsPanel): __label__ = "Diffuse" COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME']) def poll(self, context): - return (context.material.type != 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES) + mat = context.material + return mat and (mat.type != 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -219,16 +244,16 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel): col = split.column() col.itemR(mat, "diffuse_color", text="") sub = col.column() - sub.active = mat.shadeless== False - sub.itemR(mat, "diffuse_reflection", text="Intensity", slider=True) + sub.active = (not mat.shadeless) + sub.itemR(mat, "diffuse_reflection", text="Intensity") col = split.column() - col.active = mat.shadeless== False + col.active = (not mat.shadeless) col.itemR(mat, "diffuse_shader", text="") col.itemR(mat, "use_diffuse_ramp", text="Ramp") col = layout.column() - col.active = mat.shadeless== False + col.active = (not mat.shadeless) if mat.diffuse_shader == 'OREN_NAYAR': col.itemR(mat, "roughness") elif mat.diffuse_shader == 'MINNAERT': @@ -236,7 +261,7 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel): elif mat.diffuse_shader == 'TOON': row = col.row() row.itemR(mat, "diffuse_toon_size", text="Size") - row.itemR(mat, "diffuse_toon_smooth", text="Smooth", slider=True) + row.itemR(mat, "diffuse_toon_smooth", text="Smooth") elif mat.diffuse_shader == 'FRESNEL': row = col.row() row.itemR(mat, "diffuse_fresnel", text="Fresnel") @@ -260,20 +285,21 @@ class MATERIAL_PT_specular(MaterialButtonsPanel): COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME']) def poll(self, context): - return (context.material.type != 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES) + mat = context.material + return mat and (mat.type != 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES) def draw(self, context): layout = self.layout mat = context.material - layout.active = mat.shadeless == False + layout.active = (not mat.shadeless) split = layout.split() col = split.column() col.itemR(mat, "specular_color", text="") - col.itemR(mat, "specular_reflection", text="Intensity", slider=True) + col.itemR(mat, "specular_reflection", text="Intensity") col = split.column() col.itemR(mat, "specular_shader", text="") @@ -291,7 +317,7 @@ class MATERIAL_PT_specular(MaterialButtonsPanel): elif mat.specular_shader == 'TOON': row = col.row() row.itemR(mat, "specular_toon_size", text="Size") - row.itemR(mat, "specular_toon_smooth", text="Smooth", slider=True) + row.itemR(mat, "specular_toon_smooth", text="Smooth") if mat.use_specular_ramp: layout.itemS() @@ -311,7 +337,8 @@ class MATERIAL_PT_sss(MaterialButtonsPanel): COMPAT_ENGINES = set(['BLENDER_RENDER']) def poll(self, context): - return (context.material.type in ('SURFACE', 'WIRE')) and (context.scene.render_data.engine in self.COMPAT_ENGINES) + mat = context.material + return mat and (mat.type in ('SURFACE', 'WIRE')) and (context.scene.render_data.engine in self.COMPAT_ENGINES) def draw_header(self, context): layout = self.layout @@ -328,13 +355,13 @@ class MATERIAL_PT_sss(MaterialButtonsPanel): layout.active = sss.enabled split = layout.split() - split.active = mat.shadeless== False + split.active = (not mat.shadeless) col = split.column(align=True) col.itemR(sss, "color", text="") col.itemL(text="Blend:") - col.itemR(sss, "color_factor", text="Color", slider=True) - col.itemR(sss, "texture_factor", text="Texture", slider=True) + col.itemR(sss, "color_factor", text="Color") + col.itemR(sss, "texture_factor", text="Texture") col.itemL(text="Scattering Weight:") col.itemR(sss, "front") col.itemR(sss, "back") @@ -346,13 +373,14 @@ class MATERIAL_PT_sss(MaterialButtonsPanel): col.itemR(sss, "radius", text="RGB Radius") col.itemR(sss, "error_tolerance") -class MATERIAL_PT_raymir(MaterialButtonsPanel): - __label__ = "Ray Mirror" +class MATERIAL_PT_mirror(MaterialButtonsPanel): + __label__ = "Mirror" __default_closed__ = True COMPAT_ENGINES = set(['BLENDER_RENDER']) def poll(self, context): - return (context.material.type in 'SURFACE', 'WIRE') and (context.scene.render_data.engine in self.COMPAT_ENGINES) + mat = context.material + return mat and (mat.type in ('SURFACE', 'WIRE')) and (context.scene.render_data.engine in self.COMPAT_ENGINES) def draw_header(self, context): layout = self.layout @@ -372,13 +400,13 @@ class MATERIAL_PT_raymir(MaterialButtonsPanel): split = layout.split() col = split.column() - col.itemR(raym, "reflect", text="Reflectivity", slider=True) + col.itemR(raym, "reflect", text="Reflectivity") col.itemR(mat, "mirror_color", text="") col.itemL(text="Fresnel:") col.itemR(raym, "fresnel", text="Amount") sub = col.column() sub.active = raym.fresnel > 0 - sub.itemR(raym, "fresnel_fac", text="Blend", slider=True) + sub.itemR(raym, "fresnel_factor", text="Blend") col.itemS() col.itemS() sub = col.split(percentage=0.4) @@ -389,28 +417,28 @@ class MATERIAL_PT_raymir(MaterialButtonsPanel): col.itemR(raym, "depth") col.itemR(raym, "distance", text="Max Dist") col.itemL(text="Gloss:") - col.itemR(raym, "gloss", text="Amount", slider=True) + col.itemR(raym, "gloss", text="Amount") sub = col.column() sub.active = raym.gloss < 1 - sub.itemR(raym, "gloss_threshold", slider=True, text="Threshold") + sub.itemR(raym, "gloss_threshold", text="Threshold") sub.itemR(raym, "gloss_samples", text="Samples") - sub.itemR(raym, "gloss_anisotropic", slider=True, text="Anisotropic") + sub.itemR(raym, "gloss_anisotropic", text="Anisotropic") -class MATERIAL_PT_raytransp(MaterialButtonsPanel): - __label__= "Ray Transparency" +class MATERIAL_PT_transp(MaterialButtonsPanel): + __label__= "Transparency" __default_closed__ = True COMPAT_ENGINES = set(['BLENDER_RENDER']) def poll(self, context): - return (context.material.type in 'SURFACE', 'WIRE') and (context.scene.render_data.engine in self.COMPAT_ENGINES) + mat = context.material + return mat and (mat.type in ('SURFACE', 'WIRE')) and (context.scene.render_data.engine in self.COMPAT_ENGINES) def draw_header(self, context): layout = self.layout - rayt = context.material.raytrace_transparency - - layout.itemR(rayt, "enabled", text="") + mat = context.material + layout.itemR(mat, "transparency", text="") def draw(self, context): layout = self.layout @@ -418,43 +446,55 @@ class MATERIAL_PT_raytransp(MaterialButtonsPanel): mat = context.material rayt = context.material.raytrace_transparency - layout.active = rayt.enabled and mat.shadeless == False + row= layout.row() + row.itemR(mat, "transparency_method", expand=True) + row.active = mat.transparency and (not mat.shadeless) split = layout.split() col = split.column() - col.itemR(rayt, "ior") - col.itemR(rayt, "falloff") - col.itemR(rayt, "limit") - - col = split.column() - col.itemR(rayt, "depth") - col.itemR(rayt, "filter", slider=True) - col.itemR(rayt, "specular_opacity", slider=True, text="Spec Opacity") - - split = layout.split() + col.itemL(text="Transparency:") + row = col.row() + row.itemR(mat, "alpha") + row.active = mat.transparency + row = col.row() + row.itemR(mat, "specular_alpha", text="Specular") + row.active = mat.transparency and (not mat.shadeless) col = split.column() + col.active = mat.transparency and (not mat.shadeless) col.itemL(text="Fresnel:") col.itemR(rayt, "fresnel", text="Amount") sub = col.column() sub.active = rayt.fresnel > 0 - sub.itemR(rayt, "fresnel_fac", text="Blend", slider=True) - - col = split.column() - col.itemL(text="Gloss:") - col.itemR(rayt, "gloss", text="Amount", slider=True) - sub = col.column() - sub.active = rayt.gloss < 1 - sub.itemR(rayt, "gloss_threshold", slider=True, text="Threshold") - sub.itemR(rayt, "gloss_samples", text="Samples") + sub.itemR(rayt, "fresnel_factor", text="Blend") + + if mat.transparency_method == 'RAYTRACE': + split = layout.split() + split.active = mat.transparency and (not mat.shadeless) + + col = split.column() + col.itemR(rayt, "ior") + col.itemR(rayt, "filter") + col.itemR(rayt, "falloff") + col.itemR(rayt, "limit") + col.itemR(rayt, "depth") + + col = split.column() + col.itemL(text="Gloss:") + col.itemR(rayt, "gloss", text="Amount") + sub = col.column() + sub.active = rayt.gloss < 1 + sub.itemR(rayt, "gloss_threshold", text="Threshold") + sub.itemR(rayt, "gloss_samples", text="Samples") class MATERIAL_PT_halo(MaterialButtonsPanel): __label__= "Halo" COMPAT_ENGINES = set(['BLENDER_RENDER']) def poll(self, context): - return (context.material.type == 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES) + mat = context.material + return mat and (mat.type == 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -468,7 +508,7 @@ class MATERIAL_PT_halo(MaterialButtonsPanel): col.itemR(mat, "diffuse_color", text="") col.itemR(halo, "size") col.itemR(halo, "hardness") - col.itemR(halo, "add", slider=True) + col.itemR(halo, "add") col.itemL(text="Options:") col.itemR(halo, "use_texture", text="Texture") col.itemR(halo, "use_vertex_normal", text="Vertex Normal") @@ -502,13 +542,15 @@ class MATERIAL_PT_halo(MaterialButtonsPanel): bpy.types.register(MATERIAL_PT_context_material) bpy.types.register(MATERIAL_PT_preview) -bpy.types.register(MATERIAL_PT_material) bpy.types.register(MATERIAL_PT_diffuse) bpy.types.register(MATERIAL_PT_specular) -bpy.types.register(MATERIAL_PT_raymir) -bpy.types.register(MATERIAL_PT_raytransp) +bpy.types.register(MATERIAL_PT_shading) +bpy.types.register(MATERIAL_PT_transp) +bpy.types.register(MATERIAL_PT_mirror) bpy.types.register(MATERIAL_PT_sss) bpy.types.register(MATERIAL_PT_halo) +bpy.types.register(MATERIAL_PT_physics) bpy.types.register(MATERIAL_PT_strand) bpy.types.register(MATERIAL_PT_options) -bpy.types.register(MATERIAL_PT_shadows) +bpy.types.register(MATERIAL_PT_shadow) + diff --git a/release/ui/buttons_object.py b/release/ui/buttons_object.py index d59ed604c55..6b6d583e2ca 100644 --- a/release/ui/buttons_object.py +++ b/release/ui/buttons_object.py @@ -2,7 +2,7 @@ import bpy class ObjectButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "object" @@ -51,7 +51,9 @@ class OBJECT_PT_relations(ObjectButtonsPanel): col.itemR(ob, "parent", text="") sub = col.column() - sub.itemR(ob, "parent_type", text="Type") + split = sub.split(percentage=0.3) + split.itemL(text="Type:") + split.itemR(ob, "parent_type", text="") parent = ob.parent if parent and ob.parent_type == 'BONE' and parent.type == 'ARMATURE': sub.item_pointerR(ob, "parent_bone", parent.data, "bones", text="") diff --git a/release/ui/buttons_object_constraint.py b/release/ui/buttons_object_constraint.py index 3804ef5d409..c67d6e40cfb 100644 --- a/release/ui/buttons_object_constraint.py +++ b/release/ui/buttons_object_constraint.py @@ -2,7 +2,7 @@ import bpy class ConstraintButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "constraint" @@ -12,50 +12,12 @@ class ConstraintButtonsPanel(bpy.types.Panel): box = layout.template_constraint(con) if box: - if con.type == "CHILD_OF": - self.child_of(box, con) - elif con.type == "TRACK_TO": - self.track_to(box, con) - elif con.type == "IK": - self.ik(box, con) - elif con.type == "FOLLOW_PATH": - self.follow_path(box, con) - elif con.type == "LIMIT_ROTATION": - self.limit_rotation(box, con) - elif con.type == "LIMIT_LOCATION": - self.limit_location(box, con) - elif con.type == "LIMIT_SCALE": - self.limit_scale(box, con) - elif con.type == "COPY_ROTATION": - self.copy_rotation(box, con) - elif con.type == "COPY_LOCATION": - self.copy_location(box, con) - elif con.type == "COPY_SCALE": - self.copy_scale(box, con) - #elif con.type == "SCRIPT": - # self.script(box, con) - elif con.type == "ACTION": - self.action(box, con) - elif con.type == "LOCKED_TRACK": - self.locked_track(box, con) - elif con.type == "LIMIT_DISTANCE": - self.limit_distance(box, con) - elif con.type == "STRETCH_TO": - self.stretch_to(box, con) - elif con.type == "FLOOR": - self.floor(box, con) - elif con.type == "RIGID_BODY_JOINT": - self.rigid_body(box, con) - elif con.type == "CLAMP_TO": - self.clamp_to(box, con) - elif con.type == "TRANSFORM": - self.transform(box, con) - elif con.type == "SHRINKWRAP": - self.shrinkwrap(box, con) - + # match enum type to our functions, avoids a lookup table. + getattr(self, con.type)(box, con) + # show/key buttons here are most likely obsolete now, with # keyframing functionality being part of every button - if con.type not in ("RIGID_BODY_JOINT", "NULL"): + if con.type not in ('RIGID_BODY_JOINT', 'NULL'): box.itemR(con, "influence") def space_template(self, layout, con, target=True, owner=True): @@ -68,7 +30,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.itemR(con, "target_space", text="") if target and owner: - row.itemL(icon="ICON_ARROW_LEFTRIGHT") + row.itemL(icon='ICON_ARROW_LEFTRIGHT') if owner: row.itemR(con, "owner_space", text="") @@ -84,10 +46,10 @@ class ConstraintButtonsPanel(bpy.types.Panel): row = layout.row() row.itemL(text="Head/Tail:") row.itemR(con, "head_tail", text="") - elif con.target.type in ("MESH", "LATTICE"): + elif con.target.type in ('MESH', 'LATTICE'): layout.item_pointerR(con, "subtarget", con.target, "vertex_groups", text="Vertex Group") - def child_of(self, layout, con): + def CHILD_OF(self, layout, con): self.target_template(layout, con) split = layout.split() @@ -114,7 +76,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.itemO("constraint.childof_set_inverse") row.itemO("constraint.childof_clear_inverse") - def track_to(self, layout, con): + def TRACK_TO(self, layout, con): self.target_template(layout, con) row = layout.row() @@ -128,27 +90,35 @@ class ConstraintButtonsPanel(bpy.types.Panel): self.space_template(layout, con) - def ik(self, layout, con): + def IK(self, layout, con): self.target_template(layout, con) layout.itemR(con, "pole_target") - if con.pole_target and con.pole_target.type == "ARMATURE": + + if con.pole_target and con.pole_target.type == 'ARMATURE': layout.item_pointerR(con, "pole_subtarget", con.pole_target.data, "bones", text="Bone") - flow = layout.column_flow() - flow.itemR(con, "iterations") - flow.itemR(con, "pole_angle") - flow.itemR(con, "weight") - flow.itemR(con, "orient_weight") - flow.itemR(con, "chain_length") + split = layout.split() + + col = split.column() + col.itemR(con, "iterations") + col.itemR(con, "chain_length") + sub = col.column() + sub.active = con.pole_target + sub.itemR(con, "pole_angle") + col.itemL(text="Weight:") + col.itemR(con, "weight", text="Position", slider=True) + sub = col.column() + sub.active = con.rotation + sub.itemR(con, "orient_weight", text="Rotation", slider=True) - flow = layout.column_flow() - flow.itemR(con, "tail") - flow.itemR(con, "rotation") - flow.itemR(con, "targetless") - flow.itemR(con, "stretch") + col = split.column() + col.itemR(con, "tail") + col.itemR(con, "rotation") + col.itemR(con, "targetless") + col.itemR(con, "stretch") - def follow_path(self, layout, con): + def FOLLOW_PATH(self, layout, con): self.target_template(layout, con) row = layout.row() @@ -163,7 +133,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.itemR(con, "up", text="Up") row.itemL() - def limit_rotation(self, layout, con): + def LIMIT_ROTATION(self, layout, con): split = layout.split() @@ -196,7 +166,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.itemL(text="Convert:") row.itemR(con, "owner_space", text="") - def limit_location(self, layout, con): + def LIMIT_LOCATION(self, layout, con): split = layout.split() col = split.column() @@ -237,7 +207,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.itemL(text="Convert:") row.itemR(con, "owner_space", text="") - def limit_scale(self, layout, con): + def LIMIT_SCALE(self, layout, con): split = layout.split() col = split.column() @@ -278,7 +248,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.itemL(text="Convert:") row.itemR(con, "owner_space", text="") - def copy_rotation(self, layout, con): + def COPY_ROTATION(self, layout, con): self.target_template(layout, con) split = layout.split() @@ -305,7 +275,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): self.space_template(layout, con) - def copy_location(self, layout, con): + def COPY_LOCATION(self, layout, con): self.target_template(layout, con) split = layout.split() @@ -332,7 +302,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): self.space_template(layout, con) - def copy_scale(self, layout, con): + def COPY_SCALE(self, layout, con): self.target_template(layout, con) row = layout.row(align=True) @@ -344,9 +314,9 @@ class ConstraintButtonsPanel(bpy.types.Panel): self.space_template(layout, con) - #def script(self, layout, con): + #def SCRIPT(self, layout, con): - def action(self, layout, con): + def ACTION(self, layout, con): self.target_template(layout, con) layout.itemR(con, "action") @@ -366,7 +336,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.itemL(text="Convert:") row.itemR(con, "owner_space", text="") - def locked_track(self, layout, con): + def LOCKED_TRACK(self, layout, con): self.target_template(layout, con) row = layout.row() @@ -377,7 +347,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.itemL(text="Lock:") row.itemR(con, "locked", expand=True) - def limit_distance(self, layout, con): + def LIMIT_DISTANCE(self, layout, con): self.target_template(layout, con) col = layout.column(align=True); @@ -388,12 +358,12 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.itemL(text="Clamp Region:") row.itemR(con, "limit_mode", text="") - def stretch_to(self, layout, con): + def STRETCH_TO(self, layout, con): self.target_template(layout, con) - col = layout.column(align=True) - col.itemR(con, "original_length", text="Rest Length") - col.itemO("constraint.stretchto_reset") + row = layout.row() + row.itemR(con, "original_length", text="Rest Length") + row.itemO("constraint.stretchto_reset", text="Reset") col = layout.column() col.itemR(con, "bulge", text="Volume Variation") @@ -404,7 +374,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.itemL(text="Plane:") row.itemR(con, "keep_axis", expand=True) - def floor(self, layout, con): + def FLOOR(self, layout, con): self.target_template(layout, con) row = layout.row() @@ -417,7 +387,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.itemL(text="Min/Max:") row.itemR(con, "floor_location", expand=True) - def rigid_body(self, layout, con): + def RIGID_BODY_JOINT(self, layout, con): self.target_template(layout, con) layout.itemR(con, "pivot_type") @@ -425,23 +395,25 @@ class ConstraintButtonsPanel(bpy.types.Panel): row = layout.row() row.itemR(con, "disable_linked_collision", text="No Collision") - row.itemR(con, "draw_pivot") + row.itemR(con, "draw_pivot", text="Display Pivot") split = layout.split() - col = split.column() - col.itemR(con, "pivot_x") - col.itemR(con, "pivot_y") - col.itemR(con, "pivot_z") + col = split.column(align=True) + col.itemL(text="Pivot:") + col.itemR(con, "pivot_x", text="X") + col.itemR(con, "pivot_y", text="Y") + col.itemR(con, "pivot_z", text="Z") - col = split.column() - col.itemR(con, "axis_x") - col.itemR(con, "axis_y") - col.itemR(con, "axis_z") + col = split.column(align=True) + col.itemL(text="Axis:") + col.itemR(con, "axis_x", text="X") + col.itemR(con, "axis_y", text="Y") + col.itemR(con, "axis_z", text="Z") #Missing: Limit arrays (not wrapped in RNA yet) - def clamp_to(self, layout, con): + def CLAMP_TO(self, layout, con): self.target_template(layout, con) row = layout.row() @@ -451,7 +423,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): row = layout.row() row.itemR(con, "cyclic") - def transform(self, layout, con): + def TRANSFORM(self, layout, con): self.target_template(layout, con) layout.itemR(con, "extrapolate_motion", text="Extrapolate") @@ -500,7 +472,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): self.space_template(layout, con) - def shrinkwrap (self, layout, con): + def SHRINKWRAP (self, layout, con): self.target_template(layout, con) layout.itemR(con, "distance") @@ -536,7 +508,7 @@ class BONE_PT_constraints(ConstraintButtonsPanel): def poll(self, context): ob = context.object - return (ob and ob.type == "ARMATURE" and context.bone) + return (ob and ob.type == 'ARMATURE' and context.bone) def draw(self, context): layout = self.layout diff --git a/release/ui/buttons_physics_cloth.py b/release/ui/buttons_physics_cloth.py index 372dc32d063..f34077c758a 100644 --- a/release/ui/buttons_physics_cloth.py +++ b/release/ui/buttons_physics_cloth.py @@ -2,7 +2,7 @@ import bpy class PhysicButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "physics" @@ -16,11 +16,12 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel): def draw(self, context): layout = self.layout + md = context.cloth ob = context.object split = layout.split() - split.operator_context = "EXEC_DEFAULT" + split.operator_context = 'EXEC_DEFAULT' if md: # remove modifier + settings @@ -32,7 +33,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel): row.itemR(md, "realtime", text="") else: # add modifier - split.item_enumO("object.modifier_add", "type", "CLOTH", text="Add") + split.item_enumO("object.modifier_add", "type", 'CLOTH', text="Add") split.itemL() if md: @@ -41,27 +42,29 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel): split = layout.split() col = split.column() - col.itemR(cloth, "quality", slider=True) + col.itemL(text="Quality:") + col.itemR(cloth, "quality", text="Steps",slider=True) col.itemL(text="Gravity:") col.itemR(cloth, "gravity", text="") col.itemR(cloth, "pin_cloth", text="Pin") - colsub = col.column(align=True) - colsub.active = cloth.pin_cloth - colsub.itemR(cloth, "pin_stiffness", text="Stiffness") - colsub.item_pointerR(cloth, "mass_vertex_group", ob, "vertex_groups", text="") + sub = col.column(align=True) + sub.active = cloth.pin_cloth + sub.itemR(cloth, "pin_stiffness", text="Stiffness") + sub.item_pointerR(cloth, "mass_vertex_group", ob, "vertex_groups", text="") col = split.column() col.itemL(text="Presets...") + col.itemL(text="TODO!") col.itemL(text="Material:") - colsub = col.column(align=True) - colsub.itemR(cloth, "mass") - colsub.itemR(cloth, "structural_stiffness", text="Structural") - colsub.itemR(cloth, "bending_stiffness", text="Bending") + sub = col.column(align=True) + sub.itemR(cloth, "mass") + sub.itemR(cloth, "structural_stiffness", text="Structural") + sub.itemR(cloth, "bending_stiffness", text="Bending") col.itemL(text="Damping:") - colsub = col.column(align=True) - colsub.itemR(cloth, "spring_damping", text="Spring") - colsub.itemR(cloth, "air_damping", text="Air") + sub = col.column(align=True) + sub.itemR(cloth, "spring_damping", text="Spring") + sub.itemR(cloth, "air_damping", text="Air") # Disabled for now """ @@ -85,6 +88,13 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel): layout = self.layout cache = context.cloth.point_cache + layout.set_context_pointer("PointCache", cache) + + row = layout.row() + row.template_list(cache, "point_cache_list", cache, "active_point_cache_index") + col = row.column(align=True) + col.itemO("ptcache.add_new", icon="ICON_ZOOMIN", text="") + col.itemO("ptcache.remove", icon="ICON_ZOOMOUT", text="") row = layout.row() row.itemR(cache, "name") @@ -96,17 +106,17 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel): row = layout.row() if cache.baked == True: - row.itemO("ptcache.free_bake_cloth", text="Free Bake") + row.itemO("ptcache.free_bake", text="Free Bake") else: - row.item_booleanO("ptcache.cache_cloth", "bake", True, text="Bake") + row.item_booleanO("ptcache.bake", "bake", True, text="Bake") subrow = row.row() subrow.enabled = cache.frames_skipped or cache.outdated - subrow.itemO("ptcache.cache_cloth", text="Calculate to Current Frame") + subrow.itemO("ptcache.bake", "bake", False, text="Calculate to Current Frame") row = layout.row() #row.enabled = particle_panel_enabled(psys) - row.itemO("ptcache.bake_from_cloth_cache", text="Current Cache to Bake") + row.itemO("ptcache.bake_from_cache", text="Current Cache to Bake") row.itemR(cache, "step"); row = layout.row() @@ -121,7 +131,7 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel): row = layout.row() row.itemO("ptcache.bake_all", "bake", True, text="Bake All Dynamics") row.itemO("ptcache.free_bake_all", text="Free All Bakes") - layout.itemO("ptcache.bake_all", text="Update All Dynamics to current frame") + layout.itemO("ptcache.bake_all", "bake", False, text="Update All Dynamics to current frame") class PHYSICS_PT_cloth_collision(PhysicButtonsPanel): __label__ = "Cloth Collision" @@ -143,14 +153,14 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel): layout.active = cloth.enable_collision - col = split.column(align=True) + col = split.column() col.itemR(cloth, "collision_quality", slider=True, text="Quality") col.itemR(cloth, "min_distance", slider=True, text="Distance") col.itemR(cloth, "friction") - col = split.column(align=True) + col = split.column() col.itemR(cloth, "enable_self_collision", text="Self Collision") - col = col.column(align=True) + col = col.column() col.active = cloth.enable_self_collision col.itemR(cloth, "self_collision_quality", slider=True, text="Quality") col.itemR(cloth, "self_min_distance", slider=True, text="Distance") @@ -179,15 +189,15 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel): col = split.column() col.itemL(text="Structural Stiffness:") - colsub = col.column(align=True) - colsub.itemR(cloth, "structural_stiffness_max", text="Max") - colsub.item_pointerR(cloth, "structural_stiffness_vertex_group", ob, "vertex_groups", text="") + sub = col.column(align=True) + sub.itemR(cloth, "structural_stiffness_max", text="Max") + sub.item_pointerR(cloth, "structural_stiffness_vertex_group", ob, "vertex_groups", text="") col = split.column() col.itemL(text="Bending Stiffness:") - colsub = col.column(align=True) - colsub.itemR(cloth, "bending_stiffness_max", text="Max") - colsub.item_pointerR(cloth, "bending_vertex_group", ob, "vertex_groups", text="") + sub = col.column(align=True) + sub.itemR(cloth, "bending_stiffness_max", text="Max") + sub.item_pointerR(cloth, "bending_vertex_group", ob, "vertex_groups", text="") bpy.types.register(PHYSICS_PT_cloth) bpy.types.register(PHYSICS_PT_cloth_cache) diff --git a/release/ui/buttons_physics_field.py b/release/ui/buttons_physics_field.py index 3b054f7d557..fb29dd92833 100644 --- a/release/ui/buttons_physics_field.py +++ b/release/ui/buttons_physics_field.py @@ -2,7 +2,7 @@ import bpy class PhysicButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "physics" @@ -165,46 +165,66 @@ class PHYSICS_PT_collision(PhysicButtonsPanel): ob = context.object rd = context.scene.render_data return (ob and ob.type == 'MESH') and (not rd.use_game_engine) - - def draw_header(self, context): - settings = context.object.collision - self.layout.itemR(settings, "enabled", text="") - + def draw(self, context): layout = self.layout md = context.collision - settings = context.object.collision - layout.active = settings.enabled - split = layout.split() + split.operator_context = 'EXEC_DEFAULT' + + if md: + # remove modifier + settings + split.set_context_pointer("modifier", md) + split.itemO("object.modifier_remove", text="Remove") + col = split.column() + + #row = split.row(align=True) + #row.itemR(md, "render", text="") + #row.itemR(md, "realtime", text="") + + coll = md.settings + + else: + # add modifier + split.item_enumO("object.modifier_add", "type", 'COLLISION', text="Add") + split.itemL() + + coll = None - col = split.column() - col.itemL(text="Particle:") - col.itemR(settings, "permeability", slider=True) - col.itemL(text="Particle Damping:") - sub = col.column(align=True) - sub.itemR(settings, "damping_factor", text="Factor", slider=True) - sub.itemR(settings, "random_damping", text="Random", slider=True) + if coll: + settings = context.object.collision + + layout.active = settings.enabled - col.itemL(text="Soft Body and Cloth:") - sub = col.column(align=True) - sub.itemR(settings, "outer_thickness", text="Outer", slider=True) - sub.itemR(settings, "inner_thickness", text="Inner", slider=True) + split = layout.split() - layout.itemL(text="Force Fields:") - layout.itemR(md, "absorption", text="Absorption") + col = split.column() + col.itemL(text="Particle:") + col.itemR(settings, "permeability", slider=True) + col.itemL(text="Particle Damping:") + sub = col.column(align=True) + sub.itemR(settings, "damping_factor", text="Factor", slider=True) + sub.itemR(settings, "random_damping", text="Random", slider=True) - col = split.column() - col.itemL(text="") - col.itemR(settings, "kill_particles") - col.itemL(text="Particle Friction:") - sub = col.column(align=True) - sub.itemR(settings, "friction_factor", text="Factor", slider=True) - sub.itemR(settings, "random_friction", text="Random", slider=True) - col.itemL(text="Soft Body Damping:") - col.itemR(settings, "damping", text="Factor", slider=True) + col.itemL(text="Soft Body and Cloth:") + sub = col.column(align=True) + sub.itemR(settings, "outer_thickness", text="Outer", slider=True) + sub.itemR(settings, "inner_thickness", text="Inner", slider=True) + + layout.itemL(text="Force Fields:") + layout.itemR(md, "absorption", text="Absorption") + + col = split.column() + col.itemL(text="") + col.itemR(settings, "kill_particles") + col.itemL(text="Particle Friction:") + sub = col.column(align=True) + sub.itemR(settings, "friction_factor", text="Factor", slider=True) + sub.itemR(settings, "random_friction", text="Random", slider=True) + col.itemL(text="Soft Body Damping:") + col.itemR(settings, "damping", text="Factor", slider=True) bpy.types.register(PHYSICS_PT_field) bpy.types.register(PHYSICS_PT_collision) diff --git a/release/ui/buttons_physics_fluid.py b/release/ui/buttons_physics_fluid.py index 17813beecaa..304d419b388 100644 --- a/release/ui/buttons_physics_fluid.py +++ b/release/ui/buttons_physics_fluid.py @@ -2,7 +2,7 @@ import bpy class PhysicButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "physics" @@ -21,7 +21,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): ob = context.object split = layout.split() - split.operator_context = "EXEC_DEFAULT" + split.operator_context = 'EXEC_DEFAULT' if md: # remove modifier + settings @@ -36,7 +36,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): else: # add modifier - split.item_enumO("object.modifier_add", "type", "FLUID_SIMULATION", text="Add") + split.item_enumO("object.modifier_add", "type", 'FLUID_SIMULATION', text="Add") split.itemL() fluid = None @@ -51,10 +51,9 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): col = split.column() col.itemL(text="Resolution:") - sub = col.column() - sub.itemR(fluid, "resolution", text="Final") - sub.itemL(text="Render Display:") - sub.itemR(fluid, "render_display_mode", text="") + col.itemR(fluid, "resolution", text="Final") + col.itemL(text="Render Display:") + col.itemR(fluid, "render_display_mode", text="") col.itemL(text="Time:") sub = col.column(align=True) sub.itemR(fluid, "start_time", text="Start") @@ -66,8 +65,8 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): col.itemL(text="Viewport Display:") col.itemR(fluid, "viewport_display_mode", text="") col.itemL() - col.itemR(fluid, "reverse_frames") col.itemR(fluid, "generate_speed_vectors") + col.itemR(fluid, "reverse_frames") layout.itemR(fluid, "path", text="") @@ -93,12 +92,12 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): col = split.column() col.itemL(text="Slip Type:") - sub = col.column(align=True) - sub.itemR(fluid, "slip_type", text="") + col.itemR(fluid, "slip_type", text="") if fluid.slip_type == 'PARTIALSLIP': - sub.itemR(fluid, "partial_slip_amount", slider=True, text="Amount") + col.itemR(fluid, "partial_slip_amount", slider=True, text="Amount") - col.itemR(fluid, "impact_factor") + col.itemL(text="Impact:") + col.itemR(fluid, "impact_factor", text="Factor") elif fluid.type == 'INFLOW': split = layout.split() @@ -124,22 +123,23 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel): split.column() elif fluid.type == 'PARTICLE': - split = layout.split() + split = layout.split(percentage=0.5) col = split.column() col.itemL(text="Influence:") - sub = col.column(align=True) - sub.itemR(fluid, "particle_influence", text="Size") - sub.itemR(fluid, "alpha_influence", text="Alpha") - - layout.itemR(fluid, "path", text="") + col.itemR(fluid, "particle_influence", text="Size") + col.itemR(fluid, "alpha_influence", text="Alpha") col = split.column() col.itemL(text="Type:") col.itemR(fluid, "drops") col.itemR(fluid, "floats") + col = split.column() + col.itemL() col.itemR(fluid, "tracer") + layout.itemR(fluid, "path", text="") + elif fluid.type == 'CONTROL': split = layout.split() diff --git a/release/ui/buttons_physics_smoke.py b/release/ui/buttons_physics_smoke.py new file mode 100644 index 00000000000..7e2395216c0 --- /dev/null +++ b/release/ui/buttons_physics_smoke.py @@ -0,0 +1,159 @@ + +import bpy + +class PhysicButtonsPanel(bpy.types.Panel): + __space_type__ = "PROPERTIES" + __region_type__ = "WINDOW" + __context__ = "physics" + + def poll(self, context): + ob = context.object + rd = context.scene.render_data + return (ob and ob.type == 'MESH') and (not rd.use_game_engine) + +class PHYSICS_PT_smoke(PhysicButtonsPanel): + __label__ = "Smoke" + + def draw(self, context): + layout = self.layout + + md = context.smoke + ob = context.object + + split = layout.split() + split.operator_context = 'EXEC_DEFAULT' + + if md: + # remove modifier + settings + split.set_context_pointer("modifier", md) + split.itemO("object.modifier_remove", text="Remove") + + row = split.row(align=True) + row.itemR(md, "render", text="") + row.itemR(md, "realtime", text="") + + else: + # add modifier + split.item_enumO("object.modifier_add", "type", 'SMOKE', text="Add") + split.itemL() + + if md: + layout.itemR(md, "smoke_type", expand=True) + + if md.smoke_type == 'TYPE_DOMAIN': + + domain = md.domain_settings + + split = layout.split() + + col = split.column() + col.itemL(text="Resolution:") + col.itemR(domain, "maxres", text="Divisions") + + col.itemL(text="Display:") + col.itemR(domain, "visibility", text="Resolution") + col.itemR(domain, "color", slider=True) + sub = col.column() + sub.active = domain.highres + sub.itemR(domain, "viewhighres") + + col = split.column() + col.itemL(text="Behavior:") + col.itemR(domain, "alpha") + col.itemR(domain, "beta") + col.itemR(domain, "dissolve_smoke", text="Dissolve") + sub = col.column() + sub.active = domain.dissolve_smoke + sub.itemR(domain, "dissolve_speed", text="Speed") + sub.itemR(domain, "dissolve_smoke_log", text="Slow") + + elif md.smoke_type == 'TYPE_FLOW': + + flow = md.flow_settings + + split = layout.split() + + col = split.column() + col.itemR(flow, "outflow") + col.itemL(text="Particle System:") + col.item_pointerR(flow, "psys", ob, "particle_systems", text="") + + if md.flow_settings.outflow: + col = split.column() + else: + col = split.column() + col.itemL(text="Behavior:") + col.itemR(flow, "temperature") + col.itemR(flow, "density") + + #elif md.smoke_type == 'TYPE_COLL': + # layout.itemS() + +class PHYSICS_PT_smoke_highres(PhysicButtonsPanel): + __label__ = "Smoke High Resolution" + __default_closed__ = True + + def poll(self, context): + md = context.smoke + if md: + return (md.smoke_type == 'TYPE_DOMAIN') + + return False + + def draw_header(self, context): + layout = self.layout + + high = context.smoke.domain_settings + + layout.itemR(high, "highres", text="") + + def draw(self, context): + layout = self.layout + + high = context.smoke.domain_settings + + layout.active = high.highres + + split = layout.split() + + col = split.column() + col.itemL(text="Resolution:") + col.itemR(high, "amplify", text="Divisions") + + sub = split.column() + sub.itemL(text="Noise Method:") + sub.row().itemR(high, "noise_type", text="") + sub.itemR(high, "strength") + +class PHYSICS_PT_smoke_groups(PhysicButtonsPanel): + __label__ = "Smoke Groups" + __default_closed__ = True + + def poll(self, context): + md = context.smoke + if md: + return (md.smoke_type == 'TYPE_DOMAIN') + + return False + + def draw(self, context): + layout = self.layout + + group = context.smoke.domain_settings + + split = layout.split() + + col = split.column() + col.itemL(text="Flow Group:") + col.itemR(group, "fluid_group", text="") + + #col.itemL(text="Effector Group:") + #col.itemR(group, "eff_group", text="") + + col = split.column() + col.itemL(text="Collision Group:") + col.itemR(group, "coll_group", text="") + +bpy.types.register(PHYSICS_PT_smoke) +bpy.types.register(PHYSICS_PT_smoke_highres) +bpy.types.register(PHYSICS_PT_smoke_groups) diff --git a/release/ui/buttons_physics_softbody.py b/release/ui/buttons_physics_softbody.py index bff9b13f464..2613f9e8032 100644 --- a/release/ui/buttons_physics_softbody.py +++ b/release/ui/buttons_physics_softbody.py @@ -2,7 +2,7 @@ import bpy class PhysicButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "physics" @@ -33,7 +33,7 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel): row.itemR(md, "realtime", text="") else: # add modifier - split.item_enumO("object.modifier_add", "type", "SOFTBODY", text="Add") + split.item_enumO("object.modifier_add", "type", 'SOFT_BODY', text="Add") split.itemL("") if md: @@ -63,6 +63,13 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel): layout = self.layout cache = context.soft_body.point_cache + layout.set_context_pointer("PointCache", cache) + + row = layout.row() + row.template_list(cache, "point_cache_list", cache, "active_point_cache_index") + col = row.column(align=True) + col.itemO("ptcache.add_new", icon="ICON_ZOOMIN", text="") + col.itemO("ptcache.remove", icon="ICON_ZOOMOUT", text="") row = layout.row() row.itemR(cache, "name") @@ -74,16 +81,16 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel): row = layout.row() if cache.baked == True: - row.itemO("ptcache.free_bake_softbody", text="Free Bake") + row.itemO("ptcache.free_bake", text="Free Bake") else: - row.item_booleanO("ptcache.cache_softbody", "bake", True, text="Bake") + row.item_booleanO("ptcache.bake", "bake", True, text="Bake") sub = row.row() sub.enabled = cache.frames_skipped or cache.outdated - sub.itemO("ptcache.cache_softbody", text="Calculate to Current Frame") + sub.itemO("ptcache.bake", "bake", False, text="Calculate to Current Frame") row = layout.row() - row.itemO("ptcache.bake_from_softbody_cache", text="Current Cache to Bake") + row.itemO("ptcache.bake_from_cache", text="Current Cache to Bake") row.itemR(cache, "step"); row = layout.row() @@ -97,7 +104,7 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel): row = layout.row() row.itemO("ptcache.bake_all", "bake", True, text="Bake All Dynamics") row.itemO("ptcache.free_bake_all", text="Free All Bakes") - layout.itemO("ptcache.bake_all", text="Update All Dynamics to current frame") + layout.itemO("ptcache.bake_all", "bake", False, text="Update All Dynamics to current frame") class PHYSICS_PT_softbody_goal(PhysicButtonsPanel): __label__ = "Soft Body Goal" diff --git a/release/ui/buttons_scene.py b/release/ui/buttons_scene.py index 2d8dc0eab33..e9ee97468e8 100644 --- a/release/ui/buttons_scene.py +++ b/release/ui/buttons_scene.py @@ -1,14 +1,8 @@ import bpy -# If python version is less than 2.4, try to get set stuff from module -try: - set -except: - from sets import Set as set - class RenderButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "scene" # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here @@ -434,6 +428,25 @@ class SCENE_PT_stamp(RenderButtonsPanel): sub.active = rd.stamp_note sub.itemR(rd, "stamp_note_text", text="") +class SCENE_PT_unit(RenderButtonsPanel): + __label__ = "Units" + __default_closed__ = True + COMPAT_ENGINES = set(['BLENDER_RENDER']) + + def draw(self, context): + layout = self.layout + + unit = context.scene.unit_settings + + col = layout.column() + col.row().itemR(unit, "system", expand=True) + + row = layout.row() + row.active = (unit.system != 'NONE') + row.itemR(unit, "scale_length", text="Scale") + row.itemR(unit, "use_separate") + + bpy.types.register(SCENE_PT_render) bpy.types.register(SCENE_PT_layers) bpy.types.register(SCENE_PT_dimensions) @@ -444,3 +457,4 @@ bpy.types.register(SCENE_PT_encoding) bpy.types.register(SCENE_PT_performance) bpy.types.register(SCENE_PT_post_processing) bpy.types.register(SCENE_PT_stamp) +bpy.types.register(SCENE_PT_unit) diff --git a/release/ui/buttons_texture.py b/release/ui/buttons_texture.py index 5b1269c982c..29e43981fd2 100644 --- a/release/ui/buttons_texture.py +++ b/release/ui/buttons_texture.py @@ -2,38 +2,39 @@ import bpy class TextureButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "texture" def poll(self, context): - return (context.texture != None and context.texture.type != 'NONE') + tex = context.texture + return (tex and (tex.type != 'NONE' or tex.use_nodes)) class TEXTURE_PT_preview(TextureButtonsPanel): - __idname__= "TEXTURE_PT_preview" __label__ = "Preview" def draw(self, context): layout = self.layout + tex = context.texture + slot = context.texture_slot ma = context.material la = context.lamp wo = context.world br = context.brush if ma: - layout.template_preview(tex, parent=ma) + layout.template_preview(tex, parent=ma, slot=slot) elif la: - layout.template_preview(tex, parent=la) + layout.template_preview(tex, parent=la, slot=slot) elif wo: - layout.template_preview(tex, parent=wo) + layout.template_preview(tex, parent=wo, slot=slot) elif br: - layout.template_preview(tex, parent=br) + layout.template_preview(tex, parent=br, slot=slot) else: - layout.template_preview(tex) - + layout.template_preview(tex, slot=slot) + class TEXTURE_PT_context_texture(TextureButtonsPanel): - __idname__= "TEXTURE_PT_context_texture" __show_header__ = False def poll(self, context): @@ -43,23 +44,14 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel): layout = self.layout tex = context.texture - ma = context.material - la = context.lamp - wo = context.world - br = context.brush + + id = context.material + if not id: id = context.lamp + if not id: id = context.world + if not id: id = context.brush + space = context.space_data - if ma: - id = ma - elif la: - id = la - elif wo: - id = wo - elif br: - id = br - else: - id = None - if id: row = layout.row() row.template_list(id, "textures", id, "active_texture_index", rows=2) @@ -71,30 +63,65 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel): elif tex: split.template_ID(space, "pin_id") - if not space.pin_id and \ - (context.sculpt_object or context.vertex_paint_object or \ - context.weight_paint_object or context.texture_paint_object): + if (not space.pin_id) and ( + context.sculpt_object or + context.vertex_paint_object or + context.weight_paint_object or + context.texture_paint_object + ): split.itemR(space, "brush_texture", text="Brush", toggle=True) - - layout.itemS() if tex: + layout.itemR(tex, "use_nodes") + split = layout.split(percentage=0.2) - - col = split.column() - col.itemL(text="Type:") - col = split.column() - col.itemR(tex, "type", text="") + + if tex.use_nodes: + slot = context.texture_slot + split.itemL(text="Output:") + split.itemR(slot, "output_node", text="") -class TEXTURE_PT_mapping(TextureButtonsPanel): - __idname__= "TEXTURE_PT_mapping" - __label__ = "Mapping" - - def poll(self, context): - return (context.texture_slot and context.texture and context.texture.type != 'NONE') + else: + split.itemL(text="Type:") + split.itemR(tex, "type", text="") + +class TEXTURE_PT_colors(TextureButtonsPanel): + __label__ = "Colors" + __default_closed__ = True def draw(self, context): layout = self.layout + + tex = context.texture + + layout.itemR(tex, "use_color_ramp", text="Ramp") + if tex.use_color_ramp: + layout.template_color_ramp(tex.color_ramp, expand=True) + + split = layout.split() + + split.itemR(tex, "rgb_factor", text="Multiply RGB") + + col = split.column() + col.itemL(text="Adjust:") + col.itemR(tex, "brightness") + col.itemR(tex, "contrast") + +# Texture Slot Panels # + +class TextureSlotPanel(TextureButtonsPanel): + def poll(self, context): + return ( + context.texture_slot and + TextureButtonsPanel.poll(self, context) + ) + +class TEXTURE_PT_mapping(TextureSlotPanel): + __label__ = "Mapping" + + def draw(self, context): + layout = self.layout + ma = context.material la = context.lamp wo = context.world @@ -128,10 +155,8 @@ class TEXTURE_PT_mapping(TextureButtonsPanel): if ma: split = layout.split(percentage=0.3) - col = split.column() - col.itemL(text="Projection:") - col = split.column() - col.itemR(tex, "mapping", text="") + split.itemL(text="Projection:") + split.itemR(tex, "mapping", text="") split = layout.split() @@ -149,17 +174,24 @@ class TEXTURE_PT_mapping(TextureButtonsPanel): row.itemR(tex, "y_mapping", text="") row.itemR(tex, "z_mapping", text="") - row = layout.row() - row.column().itemR(tex, "offset") - row.column().itemR(tex, "size") + if br: + layout.itemR(tex, "brush_map_mode", expand=True) + + row = layout.row() + row.active = tex.brush_map_mode in ('FIXED', 'TILED') + row.itemR(tex, "angle") -class TEXTURE_PT_influence(TextureButtonsPanel): - __idname__= "TEXTURE_PT_influence" + row = layout.row() + row.active = tex.brush_map_mode in ('TILED', '3D') + row.column().itemR(tex, "size") + else: + row = layout.row() + row.column().itemR(tex, "offset") + row.column().itemR(tex, "size") + +class TEXTURE_PT_influence(TextureSlotPanel): __label__ = "Influence" - def poll(self, context): - return (context.texture_slot and context.texture and context.texture.type != 'NONE' and (not context.brush)) - def draw(self, context): layout = self.layout @@ -181,7 +213,6 @@ class TEXTURE_PT_influence(TextureButtonsPanel): split = layout.split() col = split.column() - col.itemL(text="Diffuse:") factor_but(col, tex.map_diffuse, "map_diffuse", "diffuse_factor", "Intensity") factor_but(col, tex.map_colordiff, "map_colordiff", "colordiff_factor", "Color") @@ -205,15 +236,16 @@ class TEXTURE_PT_influence(TextureButtonsPanel): factor_but(col, tex.map_warp, "map_warp", "warp_factor", "Warp") factor_but(col, tex.map_displacement, "map_displacement", "displacement_factor", "Displace") - #colsub = col.column() - #colsub.active = tex.map_translucency or tex.map_emit or tex.map_alpha or tex.map_raymir or tex.map_hardness or tex.map_ambient or tex.map_specularity or tex.map_reflection or tex.map_mirror - #colsub.itemR(tex, "default_value", text="Amount", slider=True) + #sub = col.column() + #sub.active = tex.map_translucency or tex.map_emit or tex.map_alpha or tex.map_raymir or tex.map_hardness or tex.map_ambient or tex.map_specularity or tex.map_reflection or tex.map_mirror + #sub.itemR(tex, "default_value", text="Amount", slider=True) elif la: row = layout.row() factor_but(row, tex.map_color, "map_color", "color_factor", "Color") factor_but(row, tex.map_shadow, "map_shadow", "shadow_factor", "Shadow") elif wo: split = layout.split() + col = split.column() factor_but(col, tex.map_blend, "map_blend", "blend_factor", "Blend") factor_but(col, tex.map_horizon, "map_horizon", "horizon_factor", "Horizon") @@ -223,15 +255,15 @@ class TEXTURE_PT_influence(TextureButtonsPanel): factor_but(col, tex.map_zenith_down, "map_zenith_down", "zenith_down_factor", "Zenith Down") layout.itemS() + split = layout.split() col = split.column() - col.itemR(tex, "blend_type", text="Blend") col.itemR(tex, "rgb_to_intensity") - colsub = col.column() - colsub.active = tex.rgb_to_intensity - colsub.itemR(tex, "color", text="") + sub = col.column() + sub.active = tex.rgb_to_intensity + sub.itemR(tex, "color", text="") col = split.column() col.itemR(tex, "negate", text="Negative") @@ -239,38 +271,20 @@ class TEXTURE_PT_influence(TextureButtonsPanel): if ma or wo: col.itemR(tex, "default_value", text="DVar", slider=True) -class TEXTURE_PT_colors(TextureButtonsPanel): - __idname__= "TEXTURE_PT_colors" - __label__ = "Colors" - __default_closed__ = True +# Texture Type Panels # - def draw(self, context): - layout = self.layout - tex = context.texture - - layout.itemR(tex, "use_color_ramp", text="Ramp") - if tex.use_color_ramp: - layout.template_color_ramp(tex.color_ramp, expand=True) - - split = layout.split() - col = split.column() - col.itemR(tex, "rgb_factor", text="Multiply RGB") - - col = split.column() - col.itemL(text="Adjust:") - col.itemR(tex, "brightness") - col.itemR(tex, "contrast") - -class TEXTURE_PT_clouds(TextureButtonsPanel): - __idname__= "TEXTURE_PT_clouds" - __label__ = "Clouds" - +class TextureTypePanel(TextureButtonsPanel): def poll(self, context): tex = context.texture - return (tex and tex.type == 'CLOUDS') + return (tex and tex.type == self.tex_type and not tex.use_nodes) + +class TEXTURE_PT_clouds(TextureTypePanel): + __label__ = "Clouds" + tex_type = 'CLOUDS' def draw(self, context): layout = self.layout + tex = context.texture layout.itemR(tex, "stype", expand=True) @@ -278,21 +292,18 @@ class TEXTURE_PT_clouds(TextureButtonsPanel): layout.itemR(tex, "noise_type", text="Type", expand=True) layout.itemR(tex, "noise_basis", text="Basis") - col = layout.column_flow() - col.itemR(tex, "noise_size", text="Size") - col.itemR(tex, "noise_depth", text="Depth") - col.itemR(tex, "nabla", text="Nabla") + flow = layout.column_flow() + flow.itemR(tex, "noise_size", text="Size") + flow.itemR(tex, "noise_depth", text="Depth") + flow.itemR(tex, "nabla", text="Nabla") -class TEXTURE_PT_wood(TextureButtonsPanel): - __idname__= "TEXTURE_PT_wood" +class TEXTURE_PT_wood(TextureTypePanel): __label__ = "Wood" - - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'WOOD') + tex_type = 'WOOD' def draw(self, context): layout = self.layout + tex = context.texture layout.itemR(tex, "noisebasis2", expand=True) @@ -304,22 +315,19 @@ class TEXTURE_PT_wood(TextureButtonsPanel): col.row().itemR(tex, "noise_type", text="Type", expand=True) col.itemR(tex, "noise_basis", text="Basis") - col = layout.column_flow() - col.active = tex.stype in ('RINGNOISE', 'BANDNOISE') - col.itemR(tex, "noise_size", text="Size") - col.itemR(tex, "turbulence") - col.itemR(tex, "nabla") + flow = layout.column_flow() + flow.active = tex.stype in ('RINGNOISE', 'BANDNOISE') + flow.itemR(tex, "noise_size", text="Size") + flow.itemR(tex, "turbulence") + flow.itemR(tex, "nabla") -class TEXTURE_PT_marble(TextureButtonsPanel): - __idname__= "TEXTURE_PT_marble" +class TEXTURE_PT_marble(TextureTypePanel): __label__ = "Marble" + tex_type = 'MARBLE' - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'MARBLE') - def draw(self, context): layout = self.layout + tex = context.texture layout.itemR(tex, "stype", expand=True) @@ -328,53 +336,44 @@ class TEXTURE_PT_marble(TextureButtonsPanel): layout.itemR(tex, "noise_type", text="Type", expand=True) layout.itemR(tex, "noise_basis", text="Basis") - col = layout.column_flow() - col.itemR(tex, "noise_size", text="Size") - col.itemR(tex, "noise_depth", text="Depth") - col.itemR(tex, "turbulence") - col.itemR(tex, "nabla") + flow = layout.column_flow() + flow.itemR(tex, "noise_size", text="Size") + flow.itemR(tex, "noise_depth", text="Depth") + flow.itemR(tex, "turbulence") + flow.itemR(tex, "nabla") -class TEXTURE_PT_magic(TextureButtonsPanel): - __idname__= "TEXTURE_PT_magic" +class TEXTURE_PT_magic(TextureTypePanel): __label__ = "Magic" + tex_type = 'MAGIC' - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'MAGIC') - def draw(self, context): layout = self.layout + tex = context.texture row = layout.row() row.itemR(tex, "noise_depth", text="Depth") row.itemR(tex, "turbulence") -class TEXTURE_PT_blend(TextureButtonsPanel): - __idname__= "TEXTURE_PT_blend" +class TEXTURE_PT_blend(TextureTypePanel): __label__ = "Blend" + tex_type = 'BLEND' - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'BLEND') - def draw(self, context): layout = self.layout + tex = context.texture layout.itemR(tex, "progression") layout.itemR(tex, "flip_axis") -class TEXTURE_PT_stucci(TextureButtonsPanel): - __idname__= "TEXTURE_PT_stucci" +class TEXTURE_PT_stucci(TextureTypePanel): __label__ = "Stucci" + tex_type = 'STUCCI' - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'STUCCI') - def draw(self, context): layout = self.layout + tex = context.texture layout.itemR(tex, "stype", expand=True) @@ -386,81 +385,73 @@ class TEXTURE_PT_stucci(TextureButtonsPanel): row.itemR(tex, "noise_size", text="Size") row.itemR(tex, "turbulence") -class TEXTURE_PT_image(TextureButtonsPanel): - __idname__= "TEXTURE_PT_image" +class TEXTURE_PT_image(TextureTypePanel): __label__ = "Image" + tex_type = 'IMAGE' - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'IMAGE') - def draw(self, context): layout = self.layout + tex = context.texture layout.template_texture_image(tex) -class TEXTURE_PT_image_sampling(TextureButtonsPanel): - __idname__= "TEXTURE_PT_image_sampling" +class TEXTURE_PT_image_sampling(TextureTypePanel): __label__ = "Image Sampling" __default_closed__ = True + tex_type = 'IMAGE' - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'IMAGE') - def draw(self, context): layout = self.layout + tex = context.texture slot = context.texture_slot split = layout.split() """ - sub = split.column() - sub.itemR(tex, "flip_axis") - sub.itemR(tex, "normal_map") + col = split.column() + col.itemR(tex, "flip_axis") + col.itemR(tex, "normal_map") if slot: - row = sub.row() + row = col.row() row.active = tex.normal_map row.itemR(slot, "normal_map_space", text="") """ - sub = split.column() + col = split.column() + col.itemL(text="Alpha:") + col.itemR(tex, "use_alpha", text="Use") + col.itemR(tex, "calculate_alpha", text="Calculate") + col.itemR(tex, "invert_alpha", text="Invert") - sub.itemL(text="Alpha:") - sub.itemR(tex, "use_alpha", text="Use") - sub.itemR(tex, "calculate_alpha", text="Calculate") - sub.itemR(tex, "invert_alpha", text="Invert") + col.itemL(text="Flip:") + col.itemR(tex, "flip_axis", text="X/Y Axis") - sub.itemL(text="Flip:") - sub.itemR(tex, "flip_axis", text="X/Y Axis") - - sub = split.column() - sub.itemL(text="Filter:") - sub.itemR(tex, "filter", text="") - sub.itemR(tex, "mipmap") - row = sub.row() - row.itemR(tex, "mipmap_gauss", text="Gauss") + col = split.column() + col.itemL(text="Filter:") + col.itemR(tex, "filter", text="") + col.itemR(tex, "mipmap") + + row = col.row() row.active = tex.mipmap - sub.itemR(tex, "interpolation") + row.itemR(tex, "mipmap_gauss", text="Gauss") + + col.itemR(tex, "interpolation") if tex.mipmap and tex.filter != 'DEFAULT': if tex.filter == 'FELINE': - sub.itemR(tex, "filter_probes", text="Probes") + col.itemR(tex, "filter_probes", text="Probes") else: - sub.itemR(tex, "filter_eccentricity", text="Eccentricity") + col.itemR(tex, "filter_eccentricity", text="Eccentricity") -class TEXTURE_PT_image_mapping(TextureButtonsPanel): - __idname__= "TEXTURE_PT_image_mapping" +class TEXTURE_PT_image_mapping(TextureTypePanel): __label__ = "Image Mapping" __default_closed__ = True + tex_type = 'IMAGE' - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'IMAGE') - def draw(self, context): layout = self.layout + tex = context.texture layout.itemR(tex, "extension") @@ -468,90 +459,84 @@ class TEXTURE_PT_image_mapping(TextureButtonsPanel): split = layout.split() if tex.extension == 'REPEAT': - sub = split.column(align=True) - sub.itemL(text="Repeat:") - sub.itemR(tex, "repeat_x", text="X") - sub.itemR(tex, "repeat_y", text="Y") - sub = split.column(align=True) - sub.itemL(text="Mirror:") - sub.itemR(tex, "mirror_x", text="X") - sub.itemR(tex, "mirror_y", text="Y") + col = split.column(align=True) + col.itemL(text="Repeat:") + col.itemR(tex, "repeat_x", text="X") + col.itemR(tex, "repeat_y", text="Y") + + col = split.column(align=True) + col.itemL(text="Mirror:") + col.itemR(tex, "mirror_x", text="X") + col.itemR(tex, "mirror_y", text="Y") elif tex.extension == 'CHECKER': - sub = split.column(align=True) - row = sub.row() + col = split.column(align=True) + row = col.row() row.itemR(tex, "checker_even", text="Even") row.itemR(tex, "checker_odd", text="Odd") - sub = split.column() - sub.itemR(tex, "checker_distance", text="Distance") + + split.itemR(tex, "checker_distance", text="Distance") layout.itemS() split = layout.split() - sub = split.column(align=True) - #sub.itemR(tex, "crop_rectangle") - sub.itemL(text="Crop Minimum:") - sub.itemR(tex, "crop_min_x", text="X") - sub.itemR(tex, "crop_min_y", text="Y") - sub = split.column(align=True) - sub.itemL(text="Crop Maximum:") - sub.itemR(tex, "crop_max_x", text="X") - sub.itemR(tex, "crop_max_y", text="Y") + col = split.column(align=True) + #col.itemR(tex, "crop_rectangle") + col.itemL(text="Crop Minimum:") + col.itemR(tex, "crop_min_x", text="X") + col.itemR(tex, "crop_min_y", text="Y") + + col = split.column(align=True) + col.itemL(text="Crop Maximum:") + col.itemR(tex, "crop_max_x", text="X") + col.itemR(tex, "crop_max_y", text="Y") -class TEXTURE_PT_plugin(TextureButtonsPanel): - __idname__= "TEXTURE_PT_plugin" +class TEXTURE_PT_plugin(TextureTypePanel): __label__ = "Plugin" + tex_type = 'PLUGIN' - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'PLUGIN') - def draw(self, context): layout = self.layout + tex = context.texture layout.itemL(text="Nothing yet") -class TEXTURE_PT_envmap(TextureButtonsPanel): - __idname__= "TEXTURE_PT_envmap" +class TEXTURE_PT_envmap(TextureTypePanel): __label__ = "Environment Map" + tex_type = 'ENVIRONMENT_MAP' - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'ENVIRONMENT_MAP') - def draw(self, context): layout = self.layout + tex = context.texture layout.itemL(text="Nothing yet") -class TEXTURE_PT_musgrave(TextureButtonsPanel): - __idname__= "TEXTURE_PT_musgrave" +class TEXTURE_PT_musgrave(TextureTypePanel): __label__ = "Musgrave" + tex_type = 'MUSGRAVE' - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'MUSGRAVE') - def draw(self, context): layout = self.layout + tex = context.texture layout.itemR(tex, "musgrave_type") split = layout.split() - sub = split.column() - sub.itemR(tex, "highest_dimension", text="Dimension") - sub.itemR(tex, "lacunarity") - sub.itemR(tex, "octaves") - sub = split.column() + col = split.column() + col.itemR(tex, "highest_dimension", text="Dimension") + col.itemR(tex, "lacunarity") + col.itemR(tex, "octaves") + + col = split.column() if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')): - sub.itemR(tex, "offset") + col.itemR(tex, "offset") if (tex.musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')): - sub.itemR(tex, "gain") - sub.itemR(tex, "noise_intensity", text="Intensity") + col.itemR(tex, "gain") + col.itemR(tex, "noise_intensity", text="Intensity") layout.itemL(text="Noise:") @@ -561,30 +546,33 @@ class TEXTURE_PT_musgrave(TextureButtonsPanel): row.itemR(tex, "noise_size", text="Size") row.itemR(tex, "nabla") -class TEXTURE_PT_voronoi(TextureButtonsPanel): - __idname__= "TEXTURE_PT_voronoi" +class TEXTURE_PT_voronoi(TextureTypePanel): __label__ = "Voronoi" - - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'VORONOI') + tex_type = 'VORONOI' def draw(self, context): layout = self.layout + tex = context.texture - - layout.itemR(tex, "distance_metric") - layout.itemR(tex, "coloring") split = layout.split() - sub = split.column() + col = split.column() + col.itemL(text="Distance Metric:") + col.itemR(tex, "distance_metric", text="") + sub = col.column() + sub.active = tex.distance_metric == 'MINKOVSKY' + sub.itemR(tex, "minkovsky_exponent", text="Exponent") + col.itemL(text="Coloring:") + col.itemR(tex, "coloring", text="") + col.itemR(tex, "noise_intensity", text="Intensity") - sub.itemR(tex, "noise_intensity", text="Intensity") - if tex.distance_metric == 'MINKOVSKY': - sub.itemR(tex, "minkovsky_exponent", text="Exponent") - sub = split.column() - sub.itemR(tex, "feature_weights", slider=True) + col = split.column(align=True) + col.itemL(text="Feature Weights:") + col.itemR(tex, "weight_1", text="1", slider=True) + col.itemR(tex, "weight_2", text="2", slider=True) + col.itemR(tex, "weight_3", text="3", slider=True) + col.itemR(tex, "weight_4", text="4", slider=True) layout.itemL(text="Noise:") @@ -592,29 +580,22 @@ class TEXTURE_PT_voronoi(TextureButtonsPanel): row.itemR(tex, "noise_size", text="Size") row.itemR(tex, "nabla") -class TEXTURE_PT_distortednoise(TextureButtonsPanel): - __idname__= "TEXTURE_PT_distortednoise" +class TEXTURE_PT_distortednoise(TextureTypePanel): __label__ = "Distorted Noise" + tex_type = 'DISTORTED_NOISE' - def poll(self, context): - tex = context.texture - return (tex and tex.type == 'DISTORTED_NOISE') - def draw(self, context): layout = self.layout + tex = context.texture layout.itemR(tex, "noise_distortion") layout.itemR(tex, "noise_basis", text="Basis") - split = layout.split() - - sub = split.column() - sub.itemR(tex, "distortion_amount", text="Distortion") - sub.itemR(tex, "noise_size", text="Size") - - sub = split.column() - sub.itemR(tex, "nabla") + flow = layout.column_flow() + flow.itemR(tex, "distortion_amount", text="Distortion") + flow.itemR(tex, "noise_size", text="Size") + flow.itemR(tex, "nabla") bpy.types.register(TEXTURE_PT_context_texture) bpy.types.register(TEXTURE_PT_preview) @@ -635,4 +616,3 @@ bpy.types.register(TEXTURE_PT_distortednoise) bpy.types.register(TEXTURE_PT_colors) bpy.types.register(TEXTURE_PT_mapping) bpy.types.register(TEXTURE_PT_influence) - diff --git a/release/ui/buttons_world.py b/release/ui/buttons_world.py index e44d7102511..599f45d160b 100644 --- a/release/ui/buttons_world.py +++ b/release/ui/buttons_world.py @@ -1,14 +1,8 @@ import bpy -# If python version is less than 2.4, try to get set stuff from module -try: - set -except: - from sets import Set as set - class WorldButtonsPanel(bpy.types.Panel): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __region_type__ = "WINDOW" __context__ = "world" # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here @@ -61,8 +55,8 @@ class WORLD_PT_world(WorldButtonsPanel): if world: row = layout.row() - row.itemR(world, "blend_sky") row.itemR(world, "paper_sky") + row.itemR(world, "blend_sky") row.itemR(world, "real_sky") row = layout.row() @@ -89,10 +83,11 @@ class WORLD_PT_mist(WorldButtonsPanel): layout.active = world.mist.enabled flow = layout.column_flow() + flow.itemR(world.mist, "intensity", slider=True) flow.itemR(world.mist, "start") flow.itemR(world.mist, "depth") flow.itemR(world.mist, "height") - flow.itemR(world.mist, "intensity", slider=True) + layout.itemR(world.mist, "falloff") @@ -152,12 +147,12 @@ class WORLD_PT_ambient_occlusion(WorldButtonsPanel): col.itemL(text="Sampling:") col.itemR(ao, "sample_method", text="") - sub = col.column(align=True) + sub = col.column() sub.itemR(ao, "samples") if ao.sample_method == 'ADAPTIVE_QMC': sub.itemR(ao, "threshold") - sub.itemR(ao, "adapt_to_speed") + sub.itemR(ao, "adapt_to_speed", slider=True) elif ao.sample_method == 'CONSTANT_JITTERED': sub.itemR(ao, "bias") diff --git a/release/ui/space_buttons.py b/release/ui/space_buttons.py index b444913809d..3cf782e615f 100644 --- a/release/ui/space_buttons.py +++ b/release/ui/space_buttons.py @@ -2,7 +2,7 @@ import bpy class Buttons_HT_header(bpy.types.Header): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" def draw(self, context): layout = self.layout @@ -10,18 +10,19 @@ class Buttons_HT_header(bpy.types.Header): so = context.space_data scene = context.scene - layout.template_header() + row= layout.row(align=True) + row.template_header() if context.area.show_menus: - row = layout.row(align=True) - row.itemM("Buttons_MT_view", text="View") + sub = row.row(align=True) + sub.itemM("Buttons_MT_view", text="View") row = layout.row() row.itemR(so, "buttons_context", expand=True, text="") row.itemR(scene, "current_frame") class Buttons_MT_view(bpy.types.Menu): - __space_type__ = "BUTTONS_WINDOW" + __space_type__ = "PROPERTIES" __label__ = "View" def draw(self, context): diff --git a/release/ui/space_console.py b/release/ui/space_console.py index 8814553e55f..45cb2a856e1 100644 --- a/release/ui/space_console.py +++ b/release/ui/space_console.py @@ -12,17 +12,22 @@ class CONSOLE_HT_header(bpy.types.Header): # text = sc.text layout = self.layout - layout.template_header() + row= layout.row(align=True) + row.template_header() - row = layout.row() - row.itemR(sc, "console_type", expand=True) + if context.area.show_menus: + sub = row.row(align=True) + + if sc.console_type == 'REPORT': + sub.itemM("CONSOLE_MT_report") + else: + sub.itemM("CONSOLE_MT_console") + + layout.itemS() + layout.itemR(sc, "console_type", expand=True) if sc.console_type == 'REPORT': - - if context.area.show_menus: - row = layout.row() - row.itemM("CONSOLE_MT_report") - + row = layout.row(align=True) row.itemR(sc, "show_report_debug", text="Debug") row.itemR(sc, "show_report_info", text="Info") row.itemR(sc, "show_report_operator", text="Operators") @@ -32,12 +37,6 @@ class CONSOLE_HT_header(bpy.types.Header): row = layout.row() row.enabled = sc.show_report_operator row.itemO("console.report_replay") - - else: - if context.area.show_menus: - row = layout.row() - row.itemM("CONSOLE_MT_console") - class CONSOLE_MT_console(bpy.types.Menu): __space_type__ = "CONSOLE" @@ -99,19 +98,9 @@ def get_console(console_id): console = code.InteractiveConsole(namespace) - if sys.version.startswith('3'): - import io - stdout = io.StringIO() - stderr = io.StringIO() - elif sys.version.startswith('2.6'): - import io - stdout = io.BytesIO() # Py2x support - stderr = io.BytesIO() - else: - import cStringIO - stdout = cStringIO.StringIO() - stderr = cStringIO.StringIO() - + import io + stdout = io.StringIO() + stderr = io.StringIO() consoles[console_id]= namespace, console, stdout, stderr diff --git a/release/ui/space_filebrowser.py b/release/ui/space_filebrowser.py index 0fecbdbfbba..51a8f3f78e8 100644 --- a/release/ui/space_filebrowser.py +++ b/release/ui/space_filebrowser.py @@ -10,7 +10,7 @@ class FILEBROWSER_HT_header(bpy.types.Header): layout = self.layout params = st.params - layout.template_header() + layout.template_header(menus=False) row = layout.row(align=True) row.itemO("file.parent", text="", icon='ICON_FILE_PARENT') diff --git a/release/ui/space_image.py b/release/ui/space_image.py index eeac19c04e0..090067120b1 100644 --- a/release/ui/space_image.py +++ b/release/ui/space_image.py @@ -124,9 +124,9 @@ class IMAGE_MT_uvs_transform(bpy.types.Menu): def draw(self, context): layout = self.layout - layout.item_enumO("tfm.transform", "mode", "TRANSLATION") - layout.item_enumO("tfm.transform", "mode", "ROTATION") - layout.item_enumO("tfm.transform", "mode", "RESIZE") + layout.item_enumO("tfm.transform", "mode", 'TRANSLATION') + layout.item_enumO("tfm.transform", "mode", 'ROTATION') + layout.item_enumO("tfm.transform", "mode", 'RESIZE') class IMAGE_MT_uvs_mirror(bpy.types.Menu): __space_type__ = "IMAGE_EDITOR" @@ -135,8 +135,8 @@ class IMAGE_MT_uvs_mirror(bpy.types.Menu): def draw(self, context): layout = self.layout - layout.item_enumO("uv.mirror", "axis", "MIRROR_X") # "X Axis", M, - layout.item_enumO("uv.mirror", "axis", "MIRROR_Y") # "Y Axis", M, + layout.item_enumO("uv.mirror", "axis", 'MIRROR_X') # "X Axis", M, + layout.item_enumO("uv.mirror", "axis", 'MIRROR_Y') # "Y Axis", M, class IMAGE_MT_uvs_weldalign(bpy.types.Menu): __space_type__ = "IMAGE_EDITOR" @@ -205,23 +205,24 @@ class IMAGE_HT_header(bpy.types.Header): show_paint = sima.show_paint show_uvedit = sima.show_uvedit - layout.template_header() + row = layout.row(align=True) + row.template_header() # menus if context.area.show_menus: - row = layout.row() - row.itemM("IMAGE_MT_view") + sub = row.row(align=True) + sub.itemM("IMAGE_MT_view") if show_uvedit: - row.itemM("IMAGE_MT_select") + sub.itemM("IMAGE_MT_select") if ima and ima.dirty: - row.itemM("IMAGE_MT_image", text="Image*") + sub.itemM("IMAGE_MT_image", text="Image*") else: - row.itemM("IMAGE_MT_image", text="Image") + sub.itemM("IMAGE_MT_image", text="Image") if show_uvedit: - row.itemM("IMAGE_MT_uvs") + sub.itemM("IMAGE_MT_uvs") layout.template_ID(sima, "image", new="image.new") diff --git a/release/ui/space_info.py b/release/ui/space_info.py index 79346f6268a..bfe051b8df2 100644 --- a/release/ui/space_info.py +++ b/release/ui/space_info.py @@ -2,27 +2,29 @@ import bpy class INFO_HT_header(bpy.types.Header): - __space_type__ = "USER_PREFERENCES" + __space_type__ = "INFO" def draw(self, context): - st = context.space_data - rd = context.scene.render_data layout = self.layout - layout.template_header() + st = context.space_data + rd = context.scene.render_data + + row = layout.row(align=True) + row.template_header() if context.area.show_menus: - row = layout.row() - row.itemM("INFO_MT_file") - row.itemM("INFO_MT_add") + sub = row.row(align=True) + sub.itemM("INFO_MT_file") + sub.itemM("INFO_MT_add") if rd.use_game_engine: - row.itemM("INFO_MT_game") + sub.itemM("INFO_MT_game") else: - row.itemM("INFO_MT_render") - row.itemM("INFO_MT_help") + sub.itemM("INFO_MT_render") + sub.itemM("INFO_MT_help") - layout.template_ID(context.window, "screen") #, new="screen.new", open="scene.unlink") - layout.template_ID(context.screen, "scene") #, new="screen.new", unlink="scene.unlink") + layout.template_ID(context.window, "screen", new="screen.new", unlink="screen.delete") + layout.template_ID(context.screen, "scene", new="scene.new", unlink="scene.delete") if rd.multiple_engines: layout.itemR(rd, "engine", text="") @@ -33,7 +35,7 @@ class INFO_HT_header(bpy.types.Header): layout.template_running_jobs() class INFO_MT_file(bpy.types.Menu): - __space_type__ = "USER_PREFERENCES" + __space_type__ = "INFO" __label__ = "File" def draw(self, context): @@ -69,7 +71,7 @@ class INFO_MT_file(bpy.types.Menu): layout.itemO("wm.exit_blender", text="Quit") class INFO_MT_file_import(bpy.types.Menu): - __space_type__ = "USER_PREFERENCES" + __space_type__ = "INFO" __label__ = "Import" def draw(self, context): @@ -78,7 +80,7 @@ class INFO_MT_file_import(bpy.types.Menu): layout.itemO("import.obj", text="OBJ") class INFO_MT_file_export(bpy.types.Menu): - __space_type__ = "USER_PREFERENCES" + __space_type__ = "INFO" __label__ = "Export" def draw(self, context): @@ -91,7 +93,7 @@ class INFO_MT_file_export(bpy.types.Menu): layout.itemO("export.x3d", text="X3D") class INFO_MT_file_external_data(bpy.types.Menu): - __space_type__ = "USER_PREFERENCES" + __space_type__ = "INFO" __label__ = "External Data" def draw(self, context): @@ -108,7 +110,7 @@ class INFO_MT_file_external_data(bpy.types.Menu): layout.itemO("file.find_missing_files") class INFO_MT_add(bpy.types.Menu): - __space_type__ = "USER_PREFERENCES" + __space_type__ = "INFO" __label__ = "Add" def draw(self, context): @@ -116,38 +118,48 @@ class INFO_MT_add(bpy.types.Menu): layout.operator_context = "EXEC_SCREEN" - layout.item_menu_enumO( "OBJECT_OT_mesh_add", "type", text="Mesh", icon="ICON_OUTLINER_OB_MESH") - layout.item_menu_enumO( "OBJECT_OT_curve_add", "type", text="Curve", icon="ICON_OUTLINER_OB_CURVE") - layout.item_menu_enumO( "OBJECT_OT_surface_add", "type", text="Surface", icon="ICON_OUTLINER_OB_SURFACE") - layout.item_menu_enumO( "OBJECT_OT_metaball_add", "type", "META", icon="ICON_OUTLINER_OB_META") - layout.itemO("OBJECT_OT_text_add", text="Text", icon="ICON_OUTLINER_OB_FONT") + layout.item_menu_enumO( "OBJECT_OT_mesh_add", "type", text="Mesh", icon='ICON_OUTLINER_OB_MESH') + layout.item_menu_enumO( "OBJECT_OT_curve_add", "type", text="Curve", icon='ICON_OUTLINER_OB_CURVE') + layout.item_menu_enumO( "OBJECT_OT_surface_add", "type", text="Surface", icon='ICON_OUTLINER_OB_SURFACE') + layout.item_menu_enumO( "OBJECT_OT_metaball_add", "type", 'META', icon='ICON_OUTLINER_OB_META') + layout.itemO("OBJECT_OT_text_add", text="Text", icon='ICON_OUTLINER_OB_FONT') layout.itemS() - layout.itemO("OBJECT_OT_armature_add", text="Armature", icon="ICON_OUTLINER_OB_ARMATURE") - layout.item_enumO("OBJECT_OT_object_add", "type", "LATTICE", icon="ICON_OUTLINER_OB_LATTICE") - layout.item_enumO("OBJECT_OT_object_add", "type", "EMPTY", icon="ICON_OUTLINER_OB_EMPTY") + layout.itemO("OBJECT_OT_armature_add", text="Armature", icon='ICON_OUTLINER_OB_ARMATURE') + layout.item_enumO("OBJECT_OT_object_add", "type", 'LATTICE', icon='ICON_OUTLINER_OB_LATTICE') + layout.item_enumO("OBJECT_OT_object_add", "type", 'EMPTY', icon='ICON_OUTLINER_OB_EMPTY') layout.itemS() - layout.item_enumO("OBJECT_OT_object_add", "type", "CAMERA", icon="ICON_OUTLINER_OB_CAMERA") - layout.item_enumO("OBJECT_OT_object_add", "type", "LAMP", icon="ICON_OUTLINER_OB_LAMP") + layout.item_enumO("OBJECT_OT_object_add", "type", 'CAMERA', icon='ICON_OUTLINER_OB_CAMERA') + layout.item_enumO("OBJECT_OT_object_add", "type", 'LAMP', icon='ICON_OUTLINER_OB_LAMP') class INFO_MT_game(bpy.types.Menu): - __space_type__ = "USER_PREFERENCES" + __space_type__ = "INFO" __label__ = "Game" def draw(self, context): layout = self.layout + gs = context.scene.game_data + layout.itemO("view3d.game_start") + layout.itemS() + + layout.itemR(gs, "show_debug_properties") + layout.itemR(gs, "show_framerate_profile") + layout.itemR(gs, "show_physics_visualization") + layout.itemR(gs, "deprecation_warnings") + class INFO_MT_render(bpy.types.Menu): - __space_type__ = "USER_PREFERENCES" + __space_type__ = "INFO" __label__ = "Render" def draw(self, context): layout = self.layout + rd = context.scene.render_data layout.itemO("screen.render", text="Render Image") @@ -158,7 +170,7 @@ class INFO_MT_render(bpy.types.Menu): layout.itemO("screen.render_view_show") class INFO_MT_help(bpy.types.Menu): - __space_type__ = "USER_PREFERENCES" + __space_type__ = "INFO" __label__ = "Help" def draw(self, context): @@ -174,382 +186,6 @@ class INFO_MT_help(bpy.types.Menu): layout.itemO("help.developer_community") layout.itemO("help.user_community") -class INFO_PT_tabs(bpy.types.Panel): - __space_type__ = "USER_PREFERENCES" - __show_header__ = False - - def draw(self, context): - layout = self.layout - userpref = context.user_preferences - - layout.itemR(userpref, "active_section", expand=True) - -class INFO_PT_view(bpy.types.Panel): - __space_type__ = "USER_PREFERENCES" - __label__ = "View" - __show_header__ = False - - def poll(self, context): - userpref = context.user_preferences - return (userpref.active_section == 'VIEW_CONTROLS') - - def draw(self, context): - layout = self.layout - userpref = context.user_preferences - view = userpref.view - - split = layout.split() - col = split.column() - colsplit = col.split(percentage=0.85) - colsplitcol = colsplit.column() - colsplitcol.itemL(text="Display:") - colsplitcol.itemR(view, "tooltips") - colsplitcol.itemR(view, "display_object_info", text="Object Info") - colsplitcol.itemR(view, "use_large_cursors") - colsplitcol.itemR(view, "show_view_name", text="View Name") - colsplitcol.itemR(view, "show_playback_fps", text="Playback FPS") - colsplitcol.itemR(view, "global_scene") - colsplitcol.itemR(view, "pin_floating_panels") - colsplitcol.itemR(view, "object_center_size") - colsplitcol.itemS() - colsplitcol.itemS() - colsplitcol.itemS() - - colsplitcol.itemR(view, "show_mini_axis") - colsub = colsplitcol.column() - colsub.enabled = view.show_mini_axis - colsub.itemR(view, "mini_axis_size") - colsub.itemR(view, "mini_axis_brightness") - - - - - col = split.column() - colsplit = col.split(percentage=0.85) - colsplitcol = colsplit.column() - colsplitcol.itemL(text="View Manipulation:") - colsplitcol.itemR(view, "auto_depth") - colsplitcol.itemR(view, "global_pivot") - colsplitcol.itemR(view, "zoom_to_mouse") - colsplitcol.itemR(view, "rotate_around_selection") - colsplitcol.itemL(text="Zoom Style:") - row = colsplitcol.row() - row.itemR(view, "viewport_zoom_style", expand=True) - colsplitcol.itemL(text="Orbit Style:") - row = colsplitcol.row() - row.itemR(view, "view_rotation", expand=True) - colsplitcol.itemR(view, "perspective_orthographic_switch") - colsplitcol.itemR(view, "smooth_view") - colsplitcol.itemR(view, "rotation_angle") - colsplitcol.itemL(text="NDOF Device:") - colsplitcol.itemR(view, "ndof_pan_speed", text="Pan Speed") - colsplitcol.itemR(view, "ndof_rotate_speed", text="Orbit Speed") - - col = split.column() - colsplit = col.split(percentage=0.85) - colsplitcol = colsplit.column() - colsplitcol.itemL(text="Mouse Buttons:") - colsplitcol.itemR(view, "left_mouse_button_select") - colsplitcol.itemR(view, "right_mouse_button_select") - colsplitcol.itemR(view, "emulate_3_button_mouse") - colsplitcol.itemR(view, "use_middle_mouse_paste") - colsplitcol.itemR(view, "middle_mouse_rotate") - colsplitcol.itemR(view, "middle_mouse_pan") - colsplitcol.itemR(view, "wheel_invert_zoom") - colsplitcol.itemR(view, "wheel_scroll_lines") - colsplitcol.itemS() - colsplitcol.itemS() - colsplitcol.itemS() - - colsplitcol.itemL(text="Menus:") - colsplitcol.itemR(view, "open_mouse_over") - colsplitcol.itemL(text="Menu Open Delay:") - colsplitcol.itemR(view, "open_toplevel_delay", text="Top Level") - colsplitcol.itemR(view, "open_sublevel_delay", text="Sub Level") - - - col = split.column() - colsplit = col.split(percentage=0.85) - colsplitcol = colsplit.column() - #manipulator - colsplitcol.itemR(view, "use_manipulator") - colsub = colsplitcol.column() - colsub.enabled = view.use_manipulator - colsub.itemR(view, "manipulator_size", text="Size") - colsub.itemR(view, "manipulator_handle_size", text="Handle Size") - colsub.itemR(view, "manipulator_hotspot", text="Hotspot") - colsplitcol.itemS() - colsplitcol.itemS() - colsplitcol.itemS() - - colsplitcol.itemL(text="Toolbox:") - colsplitcol.itemR(view, "use_column_layout") - colsplitcol.itemL(text="Open Toolbox Delay:") - colsplitcol.itemR(view, "open_left_mouse_delay", text="Hold LMB") - colsplitcol.itemR(view, "open_right_mouse_delay", text="Hold RMB") - - -class INFO_PT_edit(bpy.types.Panel): - __space_type__ = "USER_PREFERENCES" - __label__ = "Edit" - __show_header__ = False - - def poll(self, context): - userpref = context.user_preferences - return (userpref.active_section == 'EDIT_METHODS') - - def draw(self, context): - layout = self.layout - userpref = context.user_preferences - edit = userpref.edit - view = userpref.view - - split = layout.split() - col = split.column() - colsplit = col.split(percentage=0.85) - colsplitcol = colsplit.column() - - colsplitcol.itemL(text="Materials:") - colsplitcol.itemR(edit, "material_linked_object", text="Linked to Object") - colsplitcol.itemR(edit, "material_linked_obdata", text="Linked to ObData") - colsplitcol.itemS() - colsplitcol.itemS() - colsplitcol.itemS() - - colsplitcol.itemL(text="New Objects:") - colsplitcol.itemR(edit, "enter_edit_mode") - colsplitcol.itemR(edit, "align_to_view") - colsplitcol.itemS() - colsplitcol.itemS() - colsplitcol.itemS() - - colsplitcol.itemL(text="Transform:") - colsplitcol.itemR(edit, "drag_immediately") - - col = split.column() - colsplit = col.split(percentage=0.85) - colsplitcol = colsplit.column() - colsplitcol.itemL(text="Snap:") - colsplitcol.itemR(edit, "snap_translate", text="Translate") - colsplitcol.itemR(edit, "snap_rotate", text="Rotate") - colsplitcol.itemR(edit, "snap_scale", text="Scale") - colsplitcol.itemS() - colsplitcol.itemS() - colsplitcol.itemS() - - colsplitcol.itemL(text="Grease Pencil:") - colsplitcol.itemR(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance") - colsplitcol.itemR(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance") - colsplitcol.itemR(edit, "grease_pencil_smooth_stroke", text="Smooth Stroke") - colsplitcol.itemR(edit, "grease_pencil_simplify_stroke", text="Simplify Stroke") - colsplitcol.itemR(edit, "grease_pencil_eraser_radius", text="Eraser Radius") - - - col = split.column() - colsplit = col.split(percentage=0.85) - colsplitcol = colsplit.column() - - colsplitcol.itemL(text="Keyframing:") - colsplitcol.itemR(edit, "use_visual_keying") - colsplitcol.itemR(edit, "new_interpolation_type") - colsplitcol.itemR(edit, "auto_keying_enable", text="Auto Keyframing") - colsub = colsplitcol.column() - colsub.enabled = edit.auto_keying_enable - row = colsub.row() - row.itemR(edit, "auto_keying_mode", expand=True) - colsub.itemR(edit, "auto_keyframe_insert_available", text="Only Insert Available") - colsub.itemR(edit, "auto_keyframe_insert_needed", text="Only Insert Needed") - colsplitcol.itemS() - colsplitcol.itemS() - colsplitcol.itemS() - - colsplitcol.itemL(text="Undo:") - colsplitcol.itemR(edit, "global_undo") - colsplitcol.itemR(edit, "undo_steps", text="Steps") - colsplitcol.itemR(edit, "undo_memory_limit", text="Memory Limit") - colsplitcol.itemS() - colsplitcol.itemS() - colsplitcol.itemS() - - col = split.column() - colsplit = col.split(percentage=0.85) - colsplitcol = colsplit.column() - colsplitcol.itemL(text="Duplicate:") - colsplitcol.itemR(edit, "duplicate_mesh", text="Mesh") - colsplitcol.itemR(edit, "duplicate_surface", text="Surface") - colsplitcol.itemR(edit, "duplicate_curve", text="Curve") - colsplitcol.itemR(edit, "duplicate_text", text="Text") - colsplitcol.itemR(edit, "duplicate_metaball", text="Metaball") - colsplitcol.itemR(edit, "duplicate_armature", text="Armature") - colsplitcol.itemR(edit, "duplicate_lamp", text="Lamp") - colsplitcol.itemR(edit, "duplicate_material", text="Material") - colsplitcol.itemR(edit, "duplicate_texture", text="Texture") - colsplitcol.itemR(edit, "duplicate_ipo", text="F-Curve") - colsplitcol.itemR(edit, "duplicate_action", text="Action") - -class INFO_PT_system(bpy.types.Panel): - __space_type__ = "USER_PREFERENCES" - __label__ = "System" - __show_header__ = False - - def poll(self, context): - userpref = context.user_preferences - return (userpref.active_section == 'SYSTEM_OPENGL') - - def draw(self, context): - layout = self.layout - userpref = context.user_preferences - system = userpref.system - lan = userpref.language - - split = layout.split() - col = split.column() - colsplit = col.split(percentage=0.85) - colsplitcol = colsplit.column() - colsplitcol.itemR(system, "emulate_numpad") - colsplitcol.itemS() - colsplitcol.itemS() - #Weight Colors - colsplitcol.itemL(text="Weight Colors:") - colsplitcol.itemR(system, "use_weight_color_range", text="Use Custom Range") - - colsub = colsplitcol.column() - colsub.active = system.use_weight_color_range - colsub.template_color_ramp(system.weight_color_range, expand=True) - colsplitcol.itemS() - colsplitcol.itemS() - - #sequencer - colsplitcol.itemL(text="Sequencer:") - colsplitcol.itemR(system, "prefetch_frames") - colsplitcol.itemR(system, "memory_cache_limit") - - col = split.column() - colsplit = col.split(percentage=0.85) - colsplitcol = colsplit.column() - #System - colsplitcol.itemL(text="System:") - colsplitcol.itemR(lan, "dpi") - colsplitcol.itemR(system, "enable_all_codecs") - colsplitcol.itemR(system, "auto_run_python_scripts") - colsplitcol.itemR(system, "frame_server_port") - colsplitcol.itemR(system, "game_sound") - colsplitcol.itemR(system, "filter_file_extensions") - colsplitcol.itemR(system, "hide_dot_files_datablocks") - colsplitcol.itemR(system, "audio_mixing_buffer") - colsplitcol.itemR(lan, "scrollback", text="Console Scrollback") - - col = split.column() - colsplit = col.split(percentage=0.85) - colsplitcol = colsplit.column() - #OpenGL - colsplitcol.itemL(text="OpenGL:") - colsplitcol.itemR(system, "clip_alpha", slider=True) - colsplitcol.itemR(system, "use_mipmaps") - colsplitcol.itemL(text="Window Draw Method:") - row = colsplitcol.row() - row.itemR(system, "window_draw_method", expand=True) - colsplitcol.itemL(text="Textures:") - colsplitcol.itemR(system, "gl_texture_limit", text="Limit Size") - colsplitcol.itemR(system, "texture_time_out", text="Time Out") - colsplitcol.itemR(system, "texture_collection_rate", text="Collection Rate") - -class INFO_PT_filepaths(bpy.types.Panel): - __space_type__ = "USER_PREFERENCES" - __label__ = "File Paths" - __show_header__ = False - - def poll(self, context): - userpref = context.user_preferences - return (userpref.active_section == 'FILE_PATHS') - - def draw(self, context): - layout = self.layout - userpref = context.user_preferences - paths = userpref.filepaths - - split = layout.split() - col = split.column() - col.itemL(text="File Paths:") - splitcol = col.split(percentage=0.3) - - splitcol.itemL(text="Fonts:") - splitcol.itemR(paths, "fonts_directory", text="") - splitcol = col.split(percentage=0.3) - splitcol.itemL(text="Textures:") - splitcol.itemR(paths, "textures_directory", text="") - splitcol = col.split(percentage=0.3) - splitcol.itemL(text="Texture Plugins:") - splitcol.itemR(paths, "texture_plugin_directory", text="") - splitcol = col.split(percentage=0.3) - splitcol.itemL(text="Sequence Plugins:") - splitcol.itemR(paths, "sequence_plugin_directory", text="") - splitcol = col.split(percentage=0.3) - splitcol.itemL(text="Render Output:") - splitcol.itemR(paths, "render_output_directory", text="") - splitcol = col.split(percentage=0.3) - splitcol.itemL(text="Scripts:") - splitcol.itemR(paths, "python_scripts_directory", text="") - splitcol = col.split(percentage=0.3) - splitcol.itemL(text="Sounds:") - splitcol.itemR(paths, "sounds_directory", text="") - splitcol = col.split(percentage=0.3) - splitcol.itemL(text="Temp:") - splitcol.itemR(paths, "temporary_directory", text="") - - col = split.column() - colsplit = col.split(percentage=0.2) - colsplitcol = colsplit.column() - colsplitcol = colsplit.column() - colsplitcol.itemL(text="Save & Load:") - colsplitcol.itemR(paths, "use_relative_paths") - colsplitcol.itemR(paths, "compress_file") - colsplitcol.itemL(text="Auto Save:") - colsplitcol.itemR(paths, "save_version") - colsplitcol.itemR(paths, "recent_files") - colsplitcol.itemR(paths, "save_preview_images") - colsplitcol.itemR(paths, "auto_save_temporary_files") - colsub = colsplitcol.column() - colsub.enabled = paths.auto_save_temporary_files - colsub.itemR(paths, "auto_save_time") - -class INFO_PT_language(bpy.types.Panel): - __space_type__ = "USER_PREFERENCES" - __label__ = "Language" - __show_header__ = False - - def poll(self, context): - userpref = context.user_preferences - return (userpref.active_section == 'LANGUAGE_COLORS') - - def draw(self, context): - layout = self.layout - userpref = context.user_preferences - lan = userpref.language - - split = layout.split() - col = split.column() - - col.itemR(lan, "language") - col.itemR(lan, "translate_tooltips") - col.itemR(lan, "translate_buttons") - col.itemR(lan, "translate_toolbox") - col.itemR(lan, "use_textured_fonts") - -class INFO_PT_bottombar(bpy.types.Panel): - __space_type__ = "USER_PREFERENCES" - __label__ = " " - __show_header__ = False - - def draw(self, context): - layout = self.layout - userpref = context.user_preferences - - split = layout.split(percentage=0.8) - split.itemL(text="") - layout.operator_context = "EXEC_AREA" - split.itemO("wm.save_homefile", text="Save As Default") - bpy.types.register(INFO_HT_header) bpy.types.register(INFO_MT_file) bpy.types.register(INFO_MT_file_import) @@ -559,13 +195,6 @@ bpy.types.register(INFO_MT_add) bpy.types.register(INFO_MT_game) bpy.types.register(INFO_MT_render) bpy.types.register(INFO_MT_help) -bpy.types.register(INFO_PT_tabs) -bpy.types.register(INFO_PT_view) -bpy.types.register(INFO_PT_edit) -bpy.types.register(INFO_PT_system) -bpy.types.register(INFO_PT_filepaths) -bpy.types.register(INFO_PT_language) -bpy.types.register(INFO_PT_bottombar) # Help operators diff --git a/release/ui/space_node.py b/release/ui/space_node.py new file mode 100644 index 00000000000..2e28cfc2eed --- /dev/null +++ b/release/ui/space_node.py @@ -0,0 +1,121 @@ + +import bpy + +class NODE_HT_header(bpy.types.Header): + __space_type__ = "NODE_EDITOR" + + def draw(self, context): + layout = self.layout + snode = context.space_data + + row = layout.row(align=True) + row.template_header() + + if context.area.show_menus: + sub = row.row(align=True) + sub.itemM("NODE_MT_view") + sub.itemM("NODE_MT_select") + sub.itemM("NODE_MT_add") + sub.itemM("NODE_MT_node") + + row = layout.row() + row.itemR(snode, "tree_type", text="", expand=True) + + if snode.tree_type == 'MATERIAL': + ob = snode.id_from + id = snode.id + if ob: + layout.template_ID(ob, "active_material", new="material.new") + if id: + layout.itemR(id, "use_nodes", toggle=True) + + elif snode.tree_type == 'TEXTURE': + row.itemR(snode, "texture_type", text="", expand=True) + + id = snode.id + id_from = snode.id_from + if id_from: + layout.template_ID(id_from, "active_texture", new="texture.new") + if id: + layout.itemR(id, "use_nodes", toggle=True) + + elif snode.tree_type == 'COMPOSITING': + id = snode.id + + layout.itemR(id, "use_nodes", toggle=True) + layout.itemR(id.render_data, "free_unused_nodes", text="Free Unused", toggle=True) + layout.itemR(snode, "backdrop", toggle=True) + +class NODE_MT_view(bpy.types.Menu): + __space_type__ = "NODE_EDITOR" + __label__ = "View" + + def draw(self, context): + layout = self.layout + + # layout.itemO("grease_pencil..") + # layout.itemS() + + layout.itemO("view2d.zoom_in") + layout.itemO("view2d.zoom_out") + + layout.itemS() + + layout.itemO("node.view_all") + layout.itemO("screen.screen_full_area") + +class NODE_MT_select(bpy.types.Menu): + __space_type__ = "NODE_EDITOR" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("node.select_border") + + # XXX + # layout.itemS() + # layout.itemO("node.select_all") + # layout.itemO("node.select_linked_from") + # layout.itemO("node.select_linked_to") + +class NODE_MT_node(bpy.types.Menu): + __space_type__ = "NODE_EDITOR" + __label__ = "Node" + + def draw(self, context): + layout = self.layout + + layout.itemO("tfm.translate") + layout.itemO("tfm.resize") + layout.itemO("tfm.rotate") + + layout.itemS() + + layout.itemO("node.duplicate") + layout.itemO("node.delete") + + # XXX + # layout.itemS() + # layout.itemO("node.make_link") + # layout.itemS() + # layout.itemO("node.edit_group") + # layout.itemO("node.ungroup") + # layout.itemO("node.group") + # layout.itemO("node.make_link") + + layout.itemS() + + layout.itemO("node.visibility_toggle") + + # XXX + # layout.itemO("node.rename") + # layout.itemS() + # layout.itemO("node.show_cyclic_dependencies") + + +bpy.types.register(NODE_HT_header) +bpy.types.register(NODE_MT_view) +bpy.types.register(NODE_MT_select) +bpy.types.register(NODE_MT_node) + diff --git a/release/ui/space_outliner.py b/release/ui/space_outliner.py index 5815acc7e12..f55f4633a7b 100644 --- a/release/ui/space_outliner.py +++ b/release/ui/space_outliner.py @@ -9,11 +9,12 @@ class OUTLINER_HT_header(bpy.types.Header): sce = context.scene layout = self.layout - layout.template_header() + row = layout.row(align=True) + row.template_header() if context.area.show_menus: - row = layout.row(align=True) - row.itemM("OUTLINER_MT_view") + sub = row.row(align=True) + sub.itemM("OUTLINER_MT_view") row = layout.row() row.itemR(so, "display_mode", text="") diff --git a/release/ui/space_sequencer.py b/release/ui/space_sequencer.py index 4cba4d0af3a..1edcf32d3b5 100644 --- a/release/ui/space_sequencer.py +++ b/release/ui/space_sequencer.py @@ -10,36 +10,40 @@ class SEQUENCER_HT_header(bpy.types.Header): __space_type__ = "SEQUENCE_EDITOR" def draw(self, context): + layout = self.layout st = context.space_data - layout = self.layout - layout.template_header() + row = layout.row(align=True) + row.template_header() if context.area.show_menus: - row = layout.row() - row.itemM("SEQUENCER_MT_view") + sub = row.row(align=True) + sub.itemM("SEQUENCER_MT_view") - row.itemR(st, "display_mode") - - layout.itemS() + row.itemS() if st.display_mode == 'SEQUENCER': - row.itemM("SEQUENCER_MT_select") - row.itemM("SEQUENCER_MT_marker") - row.itemM("SEQUENCER_MT_add") - row.itemM("SEQUENCER_MT_strip") - layout.itemS() - row.itemO("sequencer.reload") - else: - row.itemR(st, "display_channel") # text="Chan" + sub.itemM("SEQUENCER_MT_select") + sub.itemM("SEQUENCER_MT_marker") + sub.itemM("SEQUENCER_MT_add") + sub.itemM("SEQUENCER_MT_strip") + + layout.itemR(st, "display_mode", text="") + + if st.display_mode == 'SEQUENCER': + layout.itemS() + layout.itemO("sequencer.reload") + else: + layout.itemR(st, "display_channel", text="Channel") class SEQUENCER_MT_view(bpy.types.Menu): __space_type__ = "SEQUENCE_EDITOR" - __label__ = "View (TODO)" + __label__ = "View" def draw(self, context): layout = self.layout + st = context.space_data layout.column() @@ -76,6 +80,7 @@ class SEQUENCER_MT_view(bpy.types.Menu): layout.itemO("sequencer.view_all") layout.itemO("sequencer.view_selected") layout.itemS() + layout.itemO("screen.screen_full_area", text="Toggle Full Screen") """ @@ -106,6 +111,7 @@ class SEQUENCER_MT_select(bpy.types.Menu): def draw(self, context): layout = self.layout + st = context.space_data layout.column() @@ -126,17 +132,18 @@ class SEQUENCER_MT_marker(bpy.types.Menu): def draw(self, context): layout = self.layout + st = context.space_data layout.column() - layout.itemO("sequencer.sound_strip_add", text="Add Marker|Ctrl Alt M") - layout.itemO("sequencer.sound_strip_add", text="Duplicate Marker|Ctrl Shift D") - layout.itemO("sequencer.sound_strip_add", text="Delete Marker|Shift X") + layout.itemO("marker.add", text="Add Marker") + layout.itemO("marker.duplicate", text="Duplicate Marker") + layout.itemO("marker.move", text="Grab/Move Marker") + layout.itemO("marker.delete", text="Delete Marker") layout.itemS() - layout.itemO("sequencer.sound_strip_add", text="(Re)Name Marker|Ctrl M") - layout.itemO("sequencer.sound_strip_add", text="Grab/Move Marker|Ctrl G") - layout.itemS() - layout.itemO("sequencer.sound_strip_add", text="Transform Markers") # toggle, will be rna - (sseq->flag & SEQ_MARKER_TRANS) + layout.itemL(text="ToDo: Name Marker") + + #layout.itemO("sequencer.sound_strip_add", text="Transform Markers") # toggle, will be rna - (sseq->flag & SEQ_MARKER_TRANS) class SEQUENCER_MT_add(bpy.types.Menu): __space_type__ = "SEQUENCE_EDITOR" @@ -144,6 +151,7 @@ class SEQUENCER_MT_add(bpy.types.Menu): def draw(self, context): layout = self.layout + st = context.space_data layout.column() @@ -154,29 +162,29 @@ class SEQUENCER_MT_add(bpy.types.Menu): layout.itemM("SEQUENCER_MT_add_effect") - class SEQUENCER_MT_add_effect(bpy.types.Menu): __space_type__ = "SEQUENCE_EDITOR" __label__ = "Effect Strip..." def draw(self, context): layout = self.layout + st = context.space_data - self.layout.column() - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'ADD') - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'SUBTRACT') - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'ALPHA_OVER') - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'ALPHA_UNDER') - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'GAMMA_CROSS') - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'MULTIPLY') - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'OVER_DROP') - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'PLUGIN') - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'WIPE') - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'GLOW') - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'TRANSFORM') - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'COLOR') - self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'SPEED') + layout.column() + layout.item_enumO("sequencer.effect_strip_add", 'type', 'ADD') + layout.item_enumO("sequencer.effect_strip_add", 'type', 'SUBTRACT') + layout.item_enumO("sequencer.effect_strip_add", 'type', 'ALPHA_OVER') + layout.item_enumO("sequencer.effect_strip_add", 'type', 'ALPHA_UNDER') + layout.item_enumO("sequencer.effect_strip_add", 'type', 'GAMMA_CROSS') + layout.item_enumO("sequencer.effect_strip_add", 'type', 'MULTIPLY') + layout.item_enumO("sequencer.effect_strip_add", 'type', 'OVER_DROP') + layout.item_enumO("sequencer.effect_strip_add", 'type', 'PLUGIN') + layout.item_enumO("sequencer.effect_strip_add", 'type', 'WIPE') + layout.item_enumO("sequencer.effect_strip_add", 'type', 'GLOW') + layout.item_enumO("sequencer.effect_strip_add", 'type', 'TRANSFORM') + layout.item_enumO("sequencer.effect_strip_add", 'type', 'COLOR') + layout.item_enumO("sequencer.effect_strip_add", 'type', 'SPEED') class SEQUENCER_MT_strip(bpy.types.Menu): __space_type__ = "SEQUENCE_EDITOR" @@ -184,6 +192,7 @@ class SEQUENCER_MT_strip(bpy.types.Menu): def draw(self, context): layout = self.layout + st = context.space_data layout.operator_context = 'INVOKE_REGION_WIN' @@ -266,35 +275,47 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel): strip = act_strip(context) - layout.itemR(strip, "name") + split = layout.split(percentage=0.3) + split.itemL(text="Name:") + split.itemR(strip, "name", text="") - layout.itemR(strip, "type") + split = layout.split(percentage=0.3) + split.itemL(text="Type:") + split.itemR(strip, "type", text="") - layout.itemR(strip, "blend_mode") + split = layout.split(percentage=0.3) + split.itemL(text="Blend:") + split.itemR(strip, "blend_mode", text="") - layout.itemR(strip, "blend_opacity", text="Opacity", slider=True) + row = layout.row() + if strip.mute == True: + row.itemR(strip, "mute", toggle=True, icon='ICON_RESTRICT_VIEW_ON', text="") + elif strip.mute == False: + row.itemR(strip, "mute", toggle=True, icon='ICON_RESTRICT_VIEW_OFF', text="") - split = layout.split() + sub = row.row() + sub.active = (not strip.mute) - col = split.column() - col.itemR(strip, "mute") - col.itemR(strip, "lock") - col.itemR(strip, "frame_locked") + sub.itemR(strip, "blend_opacity", text="Opacity", slider=True) - col = split.column() + row = layout.row() + row.itemR(strip, "lock") + row.itemR(strip, "frame_locked", text="Frame Lock") + + col = layout.column() col.itemR(strip, "channel") col.itemR(strip, "start_frame") col.itemR(strip, "length") - split = layout.split() + col = layout.column(align=True) + col.itemL(text="Offset:") + col.itemR(strip, "start_offset", text="Start") + col.itemR(strip, "end_offset", text="End") - col = split.column() - col.itemR(strip, "start_offset") - col.itemR(strip, "start_still") - - col = split.column() - col.itemR(strip, "end_offset") - col.itemR(strip, "end_still") + col = layout.column(align=True) + col.itemL(text="Still:") + col.itemR(strip, "start_still", text="Start") + col.itemR(strip, "end_still", text="End") class SEQUENCER_PT_effect(SequencerButtonsPanel): __label__ = "Effect Strip" @@ -318,23 +339,21 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel): layout.itemR(strip, "color") elif strip.type == 'WIPE': - row = layout.row() - row.itemL(text="Transition Type:") - row.itemL(text="Direction:") - row = layout.row() - row.itemR(strip, "transition_type", text="") - row.itemR(strip, "direction", text="") + col = layout.column() + col.itemR(strip, "transition_type") + col.itemL(text="Direction:") + col.row().itemR(strip, "direction", expand=True) - row = layout.row() - row.itemR(strip, "blur_width") + col = layout.column() + col.itemR(strip, "blur_width", slider=True) if strip.transition_type in ('SINGLE', 'DOUBLE'): - row.itemR(strip, "angle") + col.itemR(strip, "angle") elif strip.type == 'GLOW': flow = layout.column_flow() - flow.itemR(strip, "threshold") - flow.itemR(strip, "clamp") + flow.itemR(strip, "threshold", slider=True) + flow.itemR(strip, "clamp", slider=True) flow.itemR(strip, "boost_factor") flow.itemR(strip, "blur_distance") @@ -351,42 +370,39 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel): flow.itemR(strip, "frame_blending") elif strip.type == 'TRANSFORM': - row = layout.row() - row.itemL(text="Interpolation:") - row.itemL(text="Translation Unit:") - row = layout.row() - row.itemR(strip, "interpolation", text="") - row.itemR(strip, "translation_unit", text="") + col = layout.column() + col.itemR(strip, "interpolation") + col.itemR(strip, "translation_unit") - split = layout.split() + col = layout.column(align=True) + col.itemL(text="Position X:") + col.itemR(strip, "translate_start_x", text="Start") + col.itemR(strip, "translate_end_x", text="End") - col = split.column() - sub = col.column(align=True) - sub.itemL(text="Position X:") - sub.itemR(strip, "translate_start_x", text="Start") - sub.itemR(strip, "translate_end_x", text="End") + col = layout.column(align=True) + col.itemL(text="Position Y:") + col.itemR(strip, "translate_start_y", text="Start") + col.itemR(strip, "translate_end_y", text="End") - sub = col.column(align=True) - sub.itemL(text="Scale X:") - sub.itemR(strip, "scale_start_x", text="Start") - sub.itemR(strip, "scale_end_x", text="End") + layout.itemS() - sub = col.column(align=True) - sub.itemL(text="Rotation:") - sub.itemR(strip, "rotation_start", text="Start") - sub.itemR(strip, "rotation_end", text="End") + col = layout.column(align=True) + col.itemL(text="Scale X:") + col.itemR(strip, "scale_start_x", text="Start") + col.itemR(strip, "scale_end_x", text="End") - col = split.column() - sub = col.column(align=True) - sub.itemL(text="Position Y:") - sub.itemR(strip, "translate_start_y", text="Start") - sub.itemR(strip, "translate_end_y", text="End") + col = layout.column(align=True) + col.itemL(text="Scale Y:") + col.itemR(strip, "scale_start_y", text="Start") + col.itemR(strip, "scale_end_y", text="End") - sub = col.column(align=True) - sub.itemL(text="Scale Y:") - sub.itemR(strip, "scale_start_y", text="Start") - sub.itemR(strip, "scale_end_y", text="End") + layout.itemS() + + col = layout.column(align=True) + col.itemL(text="Rotation:") + col.itemR(strip, "rotation_start", text="Start") + col.itemR(strip, "rotation_end", text="End") class SEQUENCER_PT_input(SequencerButtonsPanel): __label__ = "Strip Input" @@ -406,42 +422,38 @@ class SEQUENCER_PT_input(SequencerButtonsPanel): strip = act_strip(context) - split = layout.split(percentage=0.3) - sub = split.column() - sub.itemL(text="Directory:") - sub = split.column() - sub.itemR(strip, "directory", text="") + layout.itemR(strip, "directory", text="") # Current element for the filename split = layout.split(percentage=0.3) - sub = split.column() - sub.itemL(text="File Name:") - sub = split.column() + col = split.column() + col.itemL(text="File Name:") + col = split.column() elem = strip.getStripElem(context.scene.current_frame) if elem: - sub.itemR(elem, "filename", text="") # strip.elements[0] could be a fallback + col.itemR(elem, "filename", text="") # strip.elements[0] could be a fallback - layout.itemR(strip, "use_translation") + layout.itemR(strip, "use_translation", text="Image Offset:") if strip.transform: - flow = layout.column_flow() - flow.active = strip.use_translation - flow.itemR(strip.transform, "offset_x") - flow.itemR(strip.transform, "offset_y") - - - layout.itemR(strip, "use_crop") + col = layout.column(align=True) + col.active = strip.use_translation + col.itemR(strip.transform, "offset_x", text="X") + col.itemR(strip.transform, "offset_y", text="Y") + + layout.itemR(strip, "use_crop", text="Image Crop:") if strip.crop: - flow = layout.column_flow() - flow.active = strip.use_crop - flow.itemR(strip.crop, "top") - flow.itemR(strip.crop, "left") - flow.itemR(strip.crop, "bottom") - flow.itemR(strip.crop, "right") - - layout.itemR(strip, "animation_start_offset") - layout.itemR(strip, "animation_end_offset") + col = layout.column(align=True) + col.active = strip.use_crop + col.itemR(strip.crop, "top") + col.itemR(strip.crop, "left") + col.itemR(strip.crop, "bottom") + col.itemR(strip.crop, "right") + col = layout.column(align=True) + col.itemL(text="Trim Duration:") + col.itemR(strip, "animation_start_offset", text="Start") + col.itemR(strip, "animation_end_offset", text="End") class SEQUENCER_PT_filter(SequencerButtonsPanel): __label__ = "Filter" @@ -460,17 +472,19 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel): layout = self.layout strip = act_strip(context) + + col = layout.column() + col.itemL(text="Video:") + col.itemR(strip, "strobe") + col.itemR(strip, "de_interlace") - split = layout.split() - - col = split.column() + col = layout.column() + col.itemL(text="Colors:") + col.itemR(strip, "multiply_colors", text="Multiply") col.itemR(strip, "premultiply") col.itemR(strip, "convert_float") - col.itemR(strip, "de_interlace") - col.itemR(strip, "multiply_colors") - col.itemR(strip, "strobe") - - col = split.column() + + col = layout.column() col.itemL(text="Flip:") col.itemR(strip, "flip_x", text="X") col.itemR(strip, "flip_y", text="Y") @@ -482,14 +496,13 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel): row.active = strip.use_color_balance col = row.column() col.itemR(strip.color_balance, "lift") - col.itemR(strip.color_balance, "inverse_lift") + col.itemR(strip.color_balance, "inverse_lift", text="Inverse") col = row.column() col.itemR(strip.color_balance, "gamma") - col.itemR(strip.color_balance, "inverse_gamma") + col.itemR(strip.color_balance, "inverse_gamma", text="Inverse") col = row.column() col.itemR(strip.color_balance, "gain") - col.itemR(strip.color_balance, "inverse_gain") - + col.itemR(strip.color_balance, "inverse_gain", text="Inverse") class SEQUENCER_PT_proxy(SequencerButtonsPanel): __label__ = "Proxy" @@ -505,36 +518,34 @@ class SEQUENCER_PT_proxy(SequencerButtonsPanel): return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META') def draw_header(self, context): - strip = act_strip(context) - layout = self.layout + strip = act_strip(context) + layout.itemR(strip, "use_proxy", text="") def draw(self, context): - strip = act_strip(context) - layout = self.layout + strip = act_strip(context) + flow = layout.column_flow() flow.itemR(strip, "proxy_custom_directory") if strip.proxy: # TODO - need to add this somehow flow.itemR(strip.proxy, "directory") flow.itemR(strip.proxy, "file") - class SEQUENCER_PT_view(SequencerButtonsPanel_Output): __label__ = "View Settings" def draw(self, context): + layout = self.layout + st = context.space_data - layout = self.layout - - flow = layout.column_flow() - flow.itemR(st, "draw_overexposed") # text="Zebra" - flow.itemR(st, "draw_safe_margin") - + col = layout.column() + col.itemR(st, "draw_overexposed") # text="Zebra" + col.itemR(st, "draw_safe_margin") bpy.types.register(SEQUENCER_HT_header) # header/menu classes bpy.types.register(SEQUENCER_MT_view) diff --git a/release/ui/space_text.py b/release/ui/space_text.py index 1b4fcea24b6..61e8d3489a5 100644 --- a/release/ui/space_text.py +++ b/release/ui/space_text.py @@ -9,34 +9,35 @@ class TEXT_HT_header(bpy.types.Header): text = st.text layout = self.layout - layout.template_header() + row = layout.row(align=True) + row.template_header() if context.area.show_menus: - row = layout.row() - row.itemM("TEXT_MT_text") + sub = row.row(align=True) + sub.itemM("TEXT_MT_text") if text: - row.itemM("TEXT_MT_edit") - row.itemM("TEXT_MT_format") + sub.itemM("TEXT_MT_edit") + sub.itemM("TEXT_MT_format") if text and text.modified: row = layout.row() # row.color(redalert) row.itemO("text.resolve_conflict", text="", icon='ICON_HELP') + layout.template_ID(st, "text", new="text.new", unlink="text.unlink") + row = layout.row(align=True) row.itemR(st, "line_numbers", text="") row.itemR(st, "word_wrap", text="") row.itemR(st, "syntax_highlight", text="") - layout.template_ID(st, "text", new="text.new", unlink="text.unlink") - if text: row = layout.row() if text.filename != "": if text.dirty: - row.itemL(text="File: *" + text.filename + " (unsaved)") + row.itemL(text="File: *%s (unsaved)" % text.filename) else: - row.itemL(text="File: " + text.filename) + row.itemL(text="File: %s" % text.filename ) else: if text.library: row.itemL(text="Text: External") @@ -123,6 +124,10 @@ class TEXT_MT_text(bpy.types.Menu): # XXX if(BPY_is_pyconstraint(text)) # XXX uiMenuItemO(head, 0, "text.refresh_pyconstraints"); #endif + + layout.itemS() + + layout.itemO("text.properties", icon="ICON_MENU_PANEL") #ifndef DISABLE_PYTHON # XXX layout.column() @@ -137,8 +142,8 @@ class TEXT_MT_edit_view(bpy.types.Menu): def draw(self, context): layout = self.layout - layout.item_enumO("text.move", "type", "FILE_TOP", text="Top of File") - layout.item_enumO("text.move", "type", "FILE_BOTTOM", text="Bottom of File") + layout.item_enumO("text.move", "type", 'FILE_TOP', text="Top of File") + layout.item_enumO("text.move", "type", 'FILE_BOTTOM', text="Bottom of File") class TEXT_MT_edit_select(bpy.types.Menu): __space_type__ = "TEXT_EDITOR" @@ -219,7 +224,7 @@ class TEXT_MT_edit(bpy.types.Menu): layout.itemS() layout.itemO("text.jump") - layout.itemO("text.properties") + layout.itemO("text.properties", text="Find...") layout.itemS() diff --git a/release/ui/space_time.py b/release/ui/space_time.py new file mode 100644 index 00000000000..d1c9f9806f3 --- /dev/null +++ b/release/ui/space_time.py @@ -0,0 +1,124 @@ + +import bpy + +class TIME_HT_header(bpy.types.Header): + __space_type__ = "TIMELINE" + + def draw(self, context): + layout = self.layout + + st = context.space_data + scene = context.scene + rd = context.scene.render_data + tools = context.tool_settings + screen = context.screen + + row = layout.row(align=True) + row.template_header() + + if context.area.show_menus: + sub = row.row(align=True) + sub.itemM("TIME_MT_view") + sub.itemM("TIME_MT_frame") + sub.itemM("TIME_MT_playback") + + layout.itemR(scene, "use_preview_range", text="PR", toggle=True) + + row = layout.row(align=True) + if not scene.use_preview_range: + row.itemR(scene, "start_frame", text="Start") + row.itemR(scene, "end_frame", text="End") + else: + row.itemR(scene, "preview_range_start_frame", text="Start") + row.itemR(scene, "preview_range_end_frame", text="End") + + layout.itemR(scene, "current_frame", text="") + + row = layout.row(align=True) + row.item_booleanO("screen.frame_jump", "end", False, text="", icon='ICON_REW') + row.item_booleanO("screen.keyframe_jump", "next", False, text="", icon='ICON_PREV_KEYFRAME') + if not screen.animation_playing: + row.item_booleanO("screen.animation_play", "reverse", True, text="", icon='ICON_PLAY_REVERSE') + row.itemO("screen.animation_play", text="", icon='ICON_PLAY') + else: + sub = row.row() + sub.scale_x = 2.0 + sub.itemO("screen.animation_play", text="", icon='ICON_PAUSE') + row.item_booleanO("screen.keyframe_jump", "next", True, text="", icon='ICON_NEXT_KEYFRAME') + row.item_booleanO("screen.frame_jump", "end", True, text="", icon='ICON_FF') + + layout.itemR(rd, "sync_audio", text="", toggle=True, icon='ICON_SPEAKER') + + layout.itemS() + + row = layout.row(align=True) + row.itemR(tools, "enable_auto_key", text="", toggle=True, icon='ICON_REC') + sub = row.row() + sub.active = tools.enable_auto_key + sub.itemR(tools, "autokey_mode", text="") + if screen.animation_playing and tools.enable_auto_key: + subsub = row.row() + subsub.itemR(tools, "record_with_nla", toggle=True) + + layout.itemS() + + row = layout.row(align=True) + row.itemR(scene, "active_keying_set", text="") + row.itemO("anim.insert_keyframe", text="", icon="ICON_KEY_HLT") + row.itemO("anim.delete_keyframe", text="", icon="ICON_KEY_DEHLT") + +class TIME_MT_view(bpy.types.Menu): + __space_type__ = "TIMELINE" + __label__ = "View" + + def draw(self, context): + layout = self.layout + + st = context.space_data + + layout.itemO("anim.time_toggle") + + layout.itemS() + + layout.itemR(st, "only_selected") + +class TIME_MT_frame(bpy.types.Menu): + __space_type__ = "TIMELINE" + __label__ = "Frame" + + def draw(self, context): + layout = self.layout + + layout.itemO("marker.add", text="Add Marker") + layout.itemO("marker.duplicate", text="Duplicate Marker") + layout.itemO("marker.move", text="Grab/Move Marker") + layout.itemO("marker.delete", text="Delete Marker") + layout.itemL(text="ToDo: Name Marker") + + layout.itemS() + + layout.itemO("time.start_frame_set") + layout.itemO("time.end_frame_set") + +class TIME_MT_playback(bpy.types.Menu): + __space_type__ = "TIMELINE" + __label__ = "Playback" + + def draw(self, context): + layout = self.layout + + st = context.space_data + + layout.itemR(st, "play_top_left") + layout.itemR(st, "play_all_3d") + layout.itemR(st, "play_anim") + layout.itemR(st, "play_buttons") + layout.itemR(st, "play_image") + layout.itemR(st, "play_sequencer") + layout.itemS() + layout.itemR(st, "continue_physics") + +bpy.types.register(TIME_HT_header) +bpy.types.register(TIME_MT_view) +bpy.types.register(TIME_MT_frame) +bpy.types.register(TIME_MT_playback) diff --git a/release/ui/space_userpref.py b/release/ui/space_userpref.py new file mode 100644 index 00000000000..95054efcb25 --- /dev/null +++ b/release/ui/space_userpref.py @@ -0,0 +1,418 @@ + +import bpy + +class USERPREF_HT_header(bpy.types.Header): + __space_type__ = "USER_PREFERENCES" + + def draw(self, context): + layout = self.layout + layout.template_header(menus=False) + +class USERPREF_MT_view(bpy.types.Menu): + __space_type__ = "USER_PREFERENCES" + __label__ = "View" + + def draw(self, context): + layout = self.layout + +class USERPREF_PT_tabs(bpy.types.Panel): + __space_type__ = "USER_PREFERENCES" + __show_header__ = False + + def draw(self, context): + layout = self.layout + + userpref = context.user_preferences + + layout.itemR(userpref, "active_section", expand=True) + +class USERPREF_PT_view(bpy.types.Panel): + __space_type__ = "USER_PREFERENCES" + __label__ = "View" + __show_header__ = False + + def poll(self, context): + userpref = context.user_preferences + return (userpref.active_section == 'VIEW_CONTROLS') + + def draw(self, context): + layout = self.layout + + userpref = context.user_preferences + view = userpref.view + + split = layout.split() + + col = split.column() + sub = col.split(percentage=0.85) + + sub1 = sub.column() + sub1.itemL(text="Display:") + sub1.itemR(view, "tooltips") + sub1.itemR(view, "display_object_info", text="Object Info") + sub1.itemR(view, "use_large_cursors") + sub1.itemR(view, "show_view_name", text="View Name") + sub1.itemR(view, "show_playback_fps", text="Playback FPS") + sub1.itemR(view, "global_scene") + sub1.itemR(view, "pin_floating_panels") + sub1.itemR(view, "object_center_size") + sub1.itemS() + sub1.itemS() + sub1.itemS() + sub1.itemR(view, "show_mini_axis") + sub2 = sub1.column() + sub2.enabled = view.show_mini_axis + sub2.itemR(view, "mini_axis_size") + sub2.itemR(view, "mini_axis_brightness") + + col = split.column() + sub = col.split(percentage=0.85) + + sub1 = sub.column() + sub1.itemL(text="View Manipulation:") + sub1.itemR(view, "auto_depth") + sub1.itemR(view, "global_pivot") + sub1.itemR(view, "zoom_to_mouse") + sub1.itemR(view, "rotate_around_selection") + sub1.itemS() + sub1.itemL(text="Zoom Style:") + sub1.row().itemR(view, "viewport_zoom_style", expand=True) + sub1.itemL(text="Orbit Style:") + sub1.row().itemR(view, "view_rotation", expand=True) + sub1.itemR(view, "perspective_orthographic_switch") + sub1.itemR(view, "smooth_view") + sub1.itemR(view, "rotation_angle") + sub1.itemS() + sub1.itemL(text="NDOF Device:") + sub1.itemR(view, "ndof_pan_speed", text="Pan Speed") + sub1.itemR(view, "ndof_rotate_speed", text="Orbit Speed") + + col = split.column() + sub = col.split(percentage=0.85) + + sub1 = sub.column() + sub1.itemL(text="Mouse Buttons:") + sub1.itemR(view, "left_mouse_button_select") + sub1.itemR(view, "right_mouse_button_select") + sub1.itemR(view, "emulate_3_button_mouse") + sub1.itemR(view, "use_middle_mouse_paste") + sub1.itemR(view, "middle_mouse_rotate") + sub1.itemR(view, "middle_mouse_pan") + sub1.itemR(view, "wheel_invert_zoom") + sub1.itemR(view, "wheel_scroll_lines") + sub1.itemS() + sub1.itemS() + sub1.itemS() + sub1.itemL(text="Menus:") + sub1.itemR(view, "open_mouse_over") + sub1.itemL(text="Menu Open Delay:") + sub1.itemR(view, "open_toplevel_delay", text="Top Level") + sub1.itemR(view, "open_sublevel_delay", text="Sub Level") + + col = split.column() + sub = col.split(percentage=0.85) + + sub1 = sub.column() + #manipulator + sub1.itemR(view, "use_manipulator") + sub2 = sub1.column() + sub2.enabled = view.use_manipulator + sub2.itemR(view, "manipulator_size", text="Size") + sub2.itemR(view, "manipulator_handle_size", text="Handle Size") + sub2.itemR(view, "manipulator_hotspot", text="Hotspot") + sub1.itemS() + sub1.itemS() + sub1.itemS() + sub1.itemL(text="Toolbox:") + sub1.itemR(view, "use_column_layout") + sub1.itemL(text="Open Toolbox Delay:") + sub1.itemR(view, "open_left_mouse_delay", text="Hold LMB") + sub1.itemR(view, "open_right_mouse_delay", text="Hold RMB") + +class USERPREF_PT_edit(bpy.types.Panel): + __space_type__ = "USER_PREFERENCES" + __label__ = "Edit" + __show_header__ = False + + def poll(self, context): + userpref = context.user_preferences + return (userpref.active_section == 'EDIT_METHODS') + + def draw(self, context): + layout = self.layout + + userpref = context.user_preferences + edit = userpref.edit + view = userpref.view + + split = layout.split() + + col = split.column() + sub = col.split(percentage=0.85) + + sub1 = sub.column() + sub1.itemL(text="Materials:") + sub1.itemR(edit, "material_linked_object", text="Linked to Object") + sub1.itemR(edit, "material_linked_obdata", text="Linked to ObData") + sub1.itemS() + sub1.itemS() + sub1.itemS() + sub1.itemL(text="New Objects:") + sub1.itemR(edit, "enter_edit_mode") + sub1.itemR(edit, "align_to_view") + sub1.itemS() + sub1.itemS() + sub1.itemS() + sub1.itemL(text="Transform:") + sub1.itemR(edit, "drag_immediately") + + col = split.column() + sub = col.split(percentage=0.85) + + sub1 = sub.column() + sub1.itemL(text="Snap:") + sub1.itemR(edit, "snap_translate", text="Translate") + sub1.itemR(edit, "snap_rotate", text="Rotate") + sub1.itemR(edit, "snap_scale", text="Scale") + sub1.itemS() + sub1.itemS() + sub1.itemS() + sub1.itemL(text="Grease Pencil:") + sub1.itemR(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance") + sub1.itemR(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance") + sub1.itemR(edit, "grease_pencil_smooth_stroke", text="Smooth Stroke") + # sub1.itemR(edit, "grease_pencil_simplify_stroke", text="Simplify Stroke") + sub1.itemR(edit, "grease_pencil_eraser_radius", text="Eraser Radius") + + col = split.column() + sub = col.split(percentage=0.85) + + sub1 = sub.column() + sub1.itemL(text="Keyframing:") + sub1.itemR(edit, "use_visual_keying") + sub1.itemR(edit, "new_interpolation_type") + sub1.itemS() + sub1.itemR(edit, "auto_keying_enable", text="Auto Keyframing") + sub2 = sub1.column() + sub2.enabled = edit.auto_keying_enable + sub2.row().itemR(edit, "auto_keying_mode", expand=True) + sub2.itemR(edit, "auto_keyframe_insert_available", text="Only Insert Available") + sub2.itemR(edit, "auto_keyframe_insert_needed", text="Only Insert Needed") + sub1.itemS() + sub1.itemS() + sub1.itemS() + sub1.itemL(text="Undo:") + sub1.itemR(edit, "global_undo") + sub1.itemR(edit, "undo_steps", text="Steps") + sub1.itemR(edit, "undo_memory_limit", text="Memory Limit") + sub1.itemS() + sub1.itemS() + sub1.itemS() + + col = split.column() + sub = col.split(percentage=0.85) + + sub1 = sub.column() + sub1.itemL(text="Duplicate:") + sub1.itemR(edit, "duplicate_mesh", text="Mesh") + sub1.itemR(edit, "duplicate_surface", text="Surface") + sub1.itemR(edit, "duplicate_curve", text="Curve") + sub1.itemR(edit, "duplicate_text", text="Text") + sub1.itemR(edit, "duplicate_metaball", text="Metaball") + sub1.itemR(edit, "duplicate_armature", text="Armature") + sub1.itemR(edit, "duplicate_lamp", text="Lamp") + sub1.itemR(edit, "duplicate_material", text="Material") + sub1.itemR(edit, "duplicate_texture", text="Texture") + sub1.itemR(edit, "duplicate_ipo", text="F-Curve") + sub1.itemR(edit, "duplicate_action", text="Action") + +class USERPREF_PT_system(bpy.types.Panel): + __space_type__ = "USER_PREFERENCES" + __label__ = "System" + __show_header__ = False + + def poll(self, context): + userpref = context.user_preferences + return (userpref.active_section == 'SYSTEM_OPENGL') + + def draw(self, context): + layout = self.layout + + userpref = context.user_preferences + system = userpref.system + lan = userpref.language + + split = layout.split() + + col = split.column() + sub = col.split(percentage=0.85) + + sub1 = sub.column() + sub1.itemR(system, "emulate_numpad") + sub1.itemS() + sub1.itemS() + + #Weight Colors + sub1.itemL(text="Weight Colors:") + sub1.itemR(system, "use_weight_color_range", text="Use Custom Range") + + sub2 = sub1.column() + sub2.active = system.use_weight_color_range + sub2.template_color_ramp(system.weight_color_range, expand=True) + sub1.itemS() + sub1.itemS() + + #sequencer + sub1.itemL(text="Sequencer:") + sub1.itemR(system, "prefetch_frames") + sub1.itemR(system, "memory_cache_limit") + + col = split.column() + sub = col.split(percentage=0.85) + + sub1 = sub .column() + #System + sub1.itemL(text="System:") + sub1.itemR(lan, "dpi") + sub1.itemR(system, "auto_run_python_scripts") + sub1.itemR(system, "frame_server_port") + sub1.itemR(system, "filter_file_extensions") + sub1.itemR(system, "hide_dot_files_datablocks") + sub1.itemR(lan, "scrollback", text="Console Scrollback") + sub1.itemS() + sub1.itemS() + sub1.itemL(text="Sound:") + sub1.itemR(system, "audio_device") + sub2 = sub1.column() + sub2.active = system.audio_device != 'AUDIO_DEVICE_NULL' + sub2.itemR(system, "enable_all_codecs") + sub2.itemR(system, "game_sound") + sub2.itemR(system, "audio_channels") + sub2.itemR(system, "audio_mixing_buffer") + sub2.itemR(system, "audio_sample_rate") + sub2.itemR(system, "audio_sample_format") + + col = split.column() + sub = col.split(percentage=0.85) + + sub1 = sub.column() + #OpenGL + sub1.itemL(text="OpenGL:") + sub1.itemR(system, "clip_alpha", slider=True) + sub1.itemR(system, "use_mipmaps") + sub1.itemL(text="Window Draw Method:") + sub1.row().itemR(system, "window_draw_method", expand=True) + sub1.itemL(text="Textures:") + sub1.itemR(system, "gl_texture_limit", text="Limit Size") + sub1.itemR(system, "texture_time_out", text="Time Out") + sub1.itemR(system, "texture_collection_rate", text="Collection Rate") + +class USERPREF_PT_filepaths(bpy.types.Panel): + __space_type__ = "USER_PREFERENCES" + __label__ = "File Paths" + __show_header__ = False + + def poll(self, context): + userpref = context.user_preferences + return (userpref.active_section == 'FILE_PATHS') + + def draw(self, context): + layout = self.layout + + userpref = context.user_preferences + paths = userpref.filepaths + + split = layout.split() + + col = split.column() + col.itemL(text="File Paths:") + sub = col.split(percentage=0.3) + + sub.itemL(text="Fonts:") + sub.itemR(paths, "fonts_directory", text="") + sub = col.split(percentage=0.3) + sub.itemL(text="Textures:") + sub.itemR(paths, "textures_directory", text="") + sub = col.split(percentage=0.3) + sub.itemL(text="Texture Plugins:") + sub.itemR(paths, "texture_plugin_directory", text="") + sub = col.split(percentage=0.3) + sub.itemL(text="Sequence Plugins:") + sub.itemR(paths, "sequence_plugin_directory", text="") + sub = col.split(percentage=0.3) + sub.itemL(text="Render Output:") + sub.itemR(paths, "render_output_directory", text="") + sub = col.split(percentage=0.3) + sub.itemL(text="Scripts:") + sub.itemR(paths, "python_scripts_directory", text="") + sub = col.split(percentage=0.3) + sub.itemL(text="Sounds:") + sub.itemR(paths, "sounds_directory", text="") + sub = col.split(percentage=0.3) + sub.itemL(text="Temp:") + sub.itemR(paths, "temporary_directory", text="") + + col = split.column() + sub = col.split(percentage=0.2) + sub1 = sub.column() + sub2 = sub.column() + sub2.itemL(text="Save & Load:") + sub2.itemR(paths, "use_relative_paths") + sub2.itemR(paths, "compress_file") + sub2.itemL(text="Auto Save:") + sub2.itemR(paths, "save_version") + sub2.itemR(paths, "recent_files") + sub2.itemR(paths, "save_preview_images") + sub2.itemR(paths, "auto_save_temporary_files") + sub3 = sub2.column() + sub3.enabled = paths.auto_save_temporary_files + sub3.itemR(paths, "auto_save_time") + +class USERPREF_PT_language(bpy.types.Panel): + __space_type__ = "USER_PREFERENCES" + __label__ = "Language" + __show_header__ = False + + def poll(self, context): + userpref = context.user_preferences + return (userpref.active_section == 'LANGUAGE_COLORS') + + def draw(self, context): + layout = self.layout + + userpref = context.user_preferences + lan = userpref.language + + split = layout.split() + col = split.column() + + col.itemR(lan, "language") + col.itemR(lan, "translate_tooltips") + col.itemR(lan, "translate_buttons") + col.itemR(lan, "translate_toolbox") + col.itemR(lan, "use_textured_fonts") + +class USERPREF_PT_bottombar(bpy.types.Panel): + __space_type__ = "USER_PREFERENCES" + __label__ = " " + __show_header__ = False + + def draw(self, context): + layout = self.layout + userpref = context.user_preferences + + split = layout.split(percentage=0.8) + split.itemL(text="") + layout.operator_context = "EXEC_AREA" + split.itemO("wm.save_homefile", text="Save As Default") + +bpy.types.register(USERPREF_HT_header) +bpy.types.register(USERPREF_MT_view) +bpy.types.register(USERPREF_PT_tabs) +bpy.types.register(USERPREF_PT_view) +bpy.types.register(USERPREF_PT_edit) +bpy.types.register(USERPREF_PT_system) +bpy.types.register(USERPREF_PT_filepaths) +bpy.types.register(USERPREF_PT_language) +bpy.types.register(USERPREF_PT_bottombar) + diff --git a/release/ui/space_view3d.py b/release/ui/space_view3d.py index fc550982afa..44b1c82ff46 100644 --- a/release/ui/space_view3d.py +++ b/release/ui/space_view3d.py @@ -1,45 +1,44 @@ import bpy -# ********** Header **************** +# ********** Header ********** class VIEW3D_HT_header(bpy.types.Header): __space_type__ = "VIEW_3D" def draw(self, context): layout = self.layout + + view = context.space_data + mode_string = context.mode + edit_object = context.edit_object + + row = layout.row(align=True) + row.template_header() - layout.template_header() - - # menus + # Menus if context.area.show_menus: - row = layout.row() - row.itemM("VIEW3D_MT_view") + sub = row.row(align=True) + + sub.itemM("VIEW3D_MT_view") + + # Select Menu + if mode_string not in ('EDIT_TEXT', 'SCULPT', 'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE', 'PARTICLE'): + # XXX: Particle Mode has Select Menu. + sub.itemM("VIEW3D_MT_select_%s" % mode_string) + + if mode_string == 'OBJECT': + sub.itemM("VIEW3D_MT_object") + elif mode_string == 'SCULPT': + sub.itemM("VIEW3D_MT_sculpt") + elif edit_object: + sub.itemM("VIEW3D_MT_edit_%s" % edit_object.type) layout.template_header_3D() -# ********** Menu **************** +# ********** Menu ********** -class VIEW3D_MT_view_navigation(bpy.types.Menu): - __space_type__ = "VIEW_3D" - __label__ = "Navigation" - - def draw(self, context): - layout = self.layout - - # layout.itemO("view3d.view_fly_mode") - # layout.itemS() - - layout.items_enumO("view3d.view_orbit", "type") - - layout.itemS() - - layout.items_enumO("view3d.view_pan", "type") - - layout.itemS() - - layout.item_floatO("view3d.zoom", "delta", 1.0, text="Zoom In") - layout.item_floatO("view3d.zoom", "delta", -1.0, text="Zoom Out") +# ********** View menus ********** class VIEW3D_MT_view(bpy.types.Menu): __space_type__ = "VIEW_3D" @@ -53,10 +52,10 @@ class VIEW3D_MT_view(bpy.types.Menu): layout.itemS() - layout.item_enumO("view3d.viewnumpad", "type", "CAMERA") - layout.item_enumO("view3d.viewnumpad", "type", "TOP") - layout.item_enumO("view3d.viewnumpad", "type", "FRONT") - layout.item_enumO("view3d.viewnumpad", "type", "RIGHT") + layout.item_enumO("view3d.viewnumpad", "type", 'CAMERA') + layout.item_enumO("view3d.viewnumpad", "type", 'TOP') + layout.item_enumO("view3d.viewnumpad", "type", 'FRONT') + layout.item_enumO("view3d.viewnumpad", "type", 'RIGHT') # layout.itemM("VIEW3D_MT_view_cameras", text="Cameras") @@ -94,8 +93,848 @@ class VIEW3D_MT_view(bpy.types.Menu): layout.itemO("screen.region_foursplit", text="Toggle Quad View") layout.itemO("screen.screen_full_area", text="Toggle Full Screen") + +class VIEW3D_MT_view_navigation(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Navigation" -# ********** Panel **************** + def draw(self, context): + layout = self.layout + + # layout.itemO("view3d.view_fly_mode") + # layout.itemS() + + layout.items_enumO("view3d.view_orbit", "type") + + layout.itemS() + + layout.items_enumO("view3d.view_pan", "type") + + layout.itemS() + + layout.item_floatO("view3d.zoom", "delta", 1.0, text="Zoom In") + layout.item_floatO("view3d.zoom", "delta", -1.0, text="Zoom Out") + +# ********** Select menus, suffix from context.mode ********** + +class VIEW3D_MT_select_OBJECT(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("view3d.select_border") + + layout.itemS() + + layout.itemO("object.select_all_toggle", text="Select/Deselect All") + layout.itemO("object.select_inverse", text="Inverse") + layout.itemO("object.select_random", text="Random") + layout.itemO("object.select_by_layer", text="Select All by Layer") + layout.item_enumO("object.select_by_type", "type", "", text="Select All by Type") + layout.itemO("object.select_grouped", text="Select Grouped") + +class VIEW3D_MT_select_POSE(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("view3d.select_border") + + layout.itemS() + + layout.itemO("pose.select_all_toggle", text="Select/Deselect All") + layout.itemO("pose.select_inverse", text="Inverse") + layout.itemO("pose.select_constraint_target", text="Constraint Target") + + layout.itemS() + + layout.item_enumO("pose.select_hierarchy", "direction", 'PARENT') + layout.item_enumO("pose.select_hierarchy", "direction", 'CHILD') + + layout.itemS() + + layout.view3d_select_posemenu() + +class VIEW3D_MT_select_PARTICLE(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("view3d.select_border") + + layout.itemS() + + layout.itemO("particle.select_all_toggle", text="Select/Deselect All") + layout.itemO("particle.select_linked") + + layout.itemS() + + #layout.itemO("particle.select_last") + #layout.itemO("particle.select_first") + + layout.itemO("particle.select_more") + layout.itemO("particle.select_less") + +class VIEW3D_MT_select_EDIT_MESH(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("view3d.select_border") + + layout.itemS() + + layout.itemO("mesh.select_all_toggle", text="Select/Deselect All") + layout.itemO("mesh.select_inverse", text="Inverse") + + layout.itemS() + + layout.itemO("mesh.select_random", text="Random...") + layout.itemO("mesh.edges_select_sharp", text="Sharp Edges") + layout.itemO("mesh.faces_select_linked_flat", text="Linked Flat Faces") + + layout.itemS() + + layout.item_enumO("mesh.select_by_number_vertices", "type", 'TRIANGLES', text="Triangles") + layout.item_enumO("mesh.select_by_number_vertices", "type", 'QUADS', text="Quads") + layout.item_enumO("mesh.select_by_number_vertices", "type", 'OTHER', text="Loose Verts/Edges") + layout.itemO("mesh.select_similar", text="Similar...") + + layout.itemS() + + layout.itemO("mesh.select_less", text="Less") + layout.itemO("mesh.select_more", text="More") + + layout.itemS() + + layout.itemO("mesh.select_linked", text="Linked") + layout.itemO("mesh.select_vertex_path", text="Vertex Path") + layout.itemO("mesh.loop_multi_select", text="Edge Loop") + layout.item_booleanO("mesh.loop_multi_select", "ring", True, text="Edge Ring") + + layout.itemS() + + layout.itemO("mesh.loop_to_region") + layout.itemO("mesh.region_to_loop") + +class VIEW3D_MT_select_EDIT_CURVE(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("view3d.select_border") + layout.itemO("view3d.select_circle") + + layout.itemS() + + layout.itemO("curve.select_all_toggle", text="Select/Deselect All") + layout.itemO("curve.select_inverse") + layout.itemO("curve.select_random") + layout.itemO("curve.select_every_nth") + + layout.itemS() + + layout.itemO("curve.de_select_first") + layout.itemO("curve.de_select_last") + layout.itemO("curve.select_next") + layout.itemO("curve.select_previous") + + layout.itemS() + + layout.itemO("curve.select_more") + layout.itemO("curve.select_less") + +class VIEW3D_MT_select_EDIT_SURFACE(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("view3d.select_border") + layout.itemO("view3d.select_circle") + + layout.itemS() + + layout.itemO("curve.select_all_toggle", text="Select/Deselect All") + layout.itemO("curve.select_inverse") + layout.itemO("curve.select_random") + layout.itemO("curve.select_every_nth") + + layout.itemS() + + layout.itemO("curve.select_row") + + layout.itemS() + + layout.itemO("curve.select_more") + layout.itemO("curve.select_less") + +class VIEW3D_MT_select_EDIT_METABALL(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("view3d.select_border") + + layout.itemS() + + layout.itemL(text="Select/Deselect All") + layout.itemL(text="Inverse") + + layout.itemS() + + layout.itemL(text="Random") + +class VIEW3D_MT_select_EDIT_LATTICE(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("view3d.select_border") + + layout.itemS() + + layout.itemO("lattice.select_all_toggle", text="Select/Deselect All") + +class VIEW3D_MT_select_EDIT_ARMATURE(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("view3d.select_border") + + layout.itemS() + + layout.itemO("armature.select_all_toggle", text="Select/Deselect All") + layout.itemO("armature.select_inverse", text="Inverse") + + layout.itemS() + + layout.item_enumO("armature.select_hierarchy", "direction", 'PARENT') + layout.item_enumO("armature.select_hierarchy", "direction", 'CHILD') + + layout.itemS() + + layout.view3d_select_armaturemenu() + +class VIEW3D_MT_select_FACE(bpy.types.Menu):# XXX no matching enum + __space_type__ = "VIEW_3D" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.view3d_select_faceselmenu() + +# ********** Object menu ********** + +class VIEW3D_MT_object(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __context__ = "objectmode" + __label__ = "Object" + + def draw(self, context): + layout = self.layout + + layout.itemM("VIEW3D_MT_object_clear") + layout.itemM("VIEW3D_MT_object_snap") + + layout.itemS() + + layout.itemO("anim.insert_keyframe_menu") + layout.itemO("anim.delete_keyframe_v3d") + + layout.itemS() + + layout.itemO("object.duplicate") + layout.item_booleanO("object.duplicate", "linked", True, text="Duplicate Linked") + layout.itemO("object.delete") + layout.itemO("object.proxy_make") + + layout.itemS() + + layout.itemM("VIEW3D_MT_object_parent") + layout.itemM("VIEW3D_MT_object_track") + layout.itemM("VIEW3D_MT_object_group") + layout.itemM("VIEW3D_MT_object_constraints") + + layout.itemS() + + layout.itemO("object.join") + + layout.itemS() + + layout.itemM("VIEW3D_MT_object_show") + +class VIEW3D_MT_object_clear(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Clear" + + def draw(self, context): + layout = self.layout + + layout.itemO("object.location_clear") + layout.itemO("object.rotation_clear") + layout.itemO("object.scale_clear") + layout.itemO("object.origin_clear") + +class VIEW3D_MT_object_snap(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Snap" + + def draw(self, context): + layout = self.layout + + layout.itemO("view3d.snap_selected_to_grid") + layout.itemO("view3d.snap_selected_to_cursor") + layout.itemO("view3d.snap_selected_to_center") + + layout.itemS() + + layout.itemO("view3d.snap_cursor_to_selected") + layout.itemO("view3d.snap_cursor_to_grid") + layout.itemO("view3d.snap_cursor_to_active") + +class VIEW3D_MT_object_parent(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Parent" + + def draw(self, context): + layout = self.layout + + layout.itemO("object.parent_set") + layout.itemO("object.parent_clear") + +class VIEW3D_MT_object_track(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Track" + + def draw(self, context): + layout = self.layout + + layout.itemO("object.track_set") + layout.itemO("object.track_clear") + +class VIEW3D_MT_object_group(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Group" + + def draw(self, context): + layout = self.layout + + layout.itemO("group.group_create") + layout.itemO("group.objects_remove") + + layout.itemS() + + layout.itemO("group.objects_add_active") + layout.itemO("group.objects_remove_active") + +class VIEW3D_MT_object_constraints(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Constraints" + + def draw(self, context): + layout = self.layout + + layout.itemO("object.constraint_add_with_targets") + layout.itemO("object.constraints_clear") + +class VIEW3D_MT_object_show(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Show/Hide" + + def draw(self, context): + layout = self.layout + + layout.itemO("object.restrictview_clear") + layout.itemO("object.restrictview_set") + layout.item_booleanO("object.restrictview_set", "unselected", True, text="Hide Unselected") + +# ********** Sculpt menu ********** + +class VIEW3D_MT_sculpt(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Sculpt" + + def draw(self, context): + layout = self.layout + + sculpt = context.tool_settings.sculpt + brush = context.tool_settings.sculpt.brush + + layout.itemR(sculpt, "symmetry_x") + layout.itemR(sculpt, "symmetry_y") + layout.itemR(sculpt, "symmetry_z") + layout.itemS() + layout.itemR(sculpt, "lock_x") + layout.itemR(sculpt, "lock_y") + layout.itemR(sculpt, "lock_z") + layout.itemS() + layout.item_menu_enumO("brush.curve_preset", property="shape") + layout.itemS() + + if brush.sculpt_tool != 'GRAB': + layout.itemR(brush, "airbrush") + + if brush.sculpt_tool != 'LAYER': + layout.itemR(brush, "anchored") + + if brush.sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'): + layout.itemR(brush, "flip_direction") + + if brush.sculpt_tool == 'LAYER': + layout.itemR(brush, "persistent") + layout.itemO("sculpt.set_persistent_base") + +# ********** Edit Menus, suffix from ob.type ********** + +class VIEW3D_MT_edit_snap(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Snap" + + def draw(self, context): + layout = self.layout + + layout.itemO("view3d.snap_selected_to_grid") + layout.itemO("view3d.snap_selected_to_cursor") + layout.itemO("view3d.snap_selected_to_center") + + layout.itemS() + + layout.itemO("view3d.snap_cursor_to_selected") + layout.itemO("view3d.snap_cursor_to_grid") + layout.itemO("view3d.snap_cursor_to_active") + +# Edit MESH +class VIEW3D_MT_edit_MESH(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Mesh" + + def draw(self, context): + layout = self.layout + + settings = context.tool_settings + + layout.itemO("ed.undo") + layout.itemO("ed.redo") + + layout.itemS() + + layout.itemM("VIEW3D_MT_edit_snap") + + layout.itemS() + + layout.itemO("uv.mapping_menu") + + layout.itemS() + + layout.itemO("mesh.extrude") + layout.itemO("mesh.duplicate") + layout.itemO("mesh.delete") + + layout.itemS() + + layout.itemM("VIEW3D_MT_edit_MESH_vertices") + layout.itemM("VIEW3D_MT_edit_MESH_edges") + layout.itemM("VIEW3D_MT_edit_MESH_faces") + layout.itemM("VIEW3D_MT_edit_MESH_normals") + + layout.itemS() + + layout.itemR(settings, "automerge_editing") + layout.itemR(settings, "proportional_editing") + layout.item_menu_enumR(settings, "proportional_editing_falloff") + + layout.itemS() + + layout.itemM("VIEW3D_MT_edit_MESH_showhide") + +class VIEW3D_MT_edit_MESH_vertices(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Vertices" + + def draw(self, context): + layout = self.layout + + layout.itemO("mesh.merge") + layout.itemO("mesh.rip") + layout.itemO("mesh.split") + layout.itemO("mesh.separate") + + layout.itemS() + + layout.itemO("mesh.vertices_smooth") + layout.itemO("mesh.remove_doubles") + +class VIEW3D_MT_edit_MESH_edges(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Edges" + + def draw(self, context): + layout = self.layout + + layout.itemO("mesh.edge_face_add") + layout.itemO("mesh.subdivide") + layout.item_floatO("mesh.subdivide", "smoothness", 1.0, text="Subdivide Smooth") + + layout.itemS() + + layout.itemO("mesh.mark_seam") + layout.item_booleanO("mesh.mark_seam", "clear", True, text="Clear Seam") + + layout.itemS() + + layout.itemO("mesh.mark_sharp") + layout.item_booleanO("mesh.mark_sharp", "clear", True, text="Clear Sharp") + + layout.itemS() + + layout.item_enumO("mesh.edge_rotate", "direction", 'CW', text="Rotate Edge CW") + layout.item_enumO("mesh.edge_rotate", "direction", 'CCW', text="Rotate Edge CCW") + +class VIEW3D_MT_edit_MESH_faces(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Faces" + + def draw(self, context): + layout = self.layout + + layout.itemO("mesh.edge_face_add") + layout.itemO("mesh.fill") + layout.itemO("mesh.beauty_fill") + + layout.itemS() + + layout.itemO("mesh.quads_convert_to_tris") + layout.itemO("mesh.tris_convert_to_quads") + layout.itemO("mesh.edge_flip") + + layout.itemS() + + layout.itemO("mesh.faces_shade_smooth") + layout.itemO("mesh.faces_shade_flat") + +class VIEW3D_MT_edit_MESH_normals(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Normals" + + def draw(self, context): + layout = self.layout + + layout.itemO("mesh.normals_make_consistent", text="Recalculate Outside") + layout.item_booleanO("mesh.normals_make_consistent", "inside", True, text="Recalculate Inside") + + layout.itemS() + + layout.itemO("mesh.flip_normals") + +class VIEW3D_MT_edit_MESH_showhide(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Show/Hide" + + def draw(self, context): + layout = self.layout + + layout.itemO("mesh.reveal") + layout.itemO("mesh.hide") + layout.item_booleanO("mesh.hide", "unselected", True, text="Hide Unselected") + +# Edit CURVE + +# draw_CURVE is used by VIEW3D_MT_edit_CURVE and VIEW3D_MT_edit_SURFACE +def draw_CURVE(self, context): + layout = self.layout + + settings = context.tool_settings + + layout.itemM("VIEW3D_MT_edit_snap") + + layout.itemS() + + layout.itemO("curve.extrude") + layout.itemO("curve.duplicate") + layout.itemO("curve.separate") + layout.itemO("curve.make_segment") + layout.itemO("curve.cyclic_toggle") + layout.itemO("curve.delete") + + layout.itemS() + + layout.itemM("VIEW3D_MT_edit_CURVE_ctrlpoints") + layout.itemM("VIEW3D_MT_edit_CURVE_segments") + + layout.itemS() + + layout.itemR(settings, "proportional_editing") + layout.item_menu_enumR(settings, "proportional_editing_falloff") + + layout.itemS() + + layout.itemM("VIEW3D_MT_edit_CURVE_showhide") + +class VIEW3D_MT_edit_CURVE(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Curve" + + draw = draw_CURVE + +class VIEW3D_MT_edit_CURVE_ctrlpoints(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Control Points" + + def draw(self, context): + layout = self.layout + + edit_object = context.edit_object + + if edit_object.type == 'CURVE': + layout.item_enumO("tfm.transform", "mode", 'TILT') + layout.itemO("curve.tilt_clear") + layout.itemO("curve.separate") + + layout.itemS() + + layout.item_menu_enumO("curve.handle_type_set", "type") + +class VIEW3D_MT_edit_CURVE_segments(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Segments" + + def draw(self, context): + layout = self.layout + + layout.itemO("curve.subdivide") + layout.itemO("curve.switch_direction") + +class VIEW3D_MT_edit_CURVE_showhide(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Show/Hide" + + def draw(self, context): + layout = self.layout + + layout.itemO("curve.reveal") + layout.itemO("curve.hide") + layout.item_booleanO("curve.hide", "unselected", True, text="Hide Unselected") + +# Edit SURFACE +class VIEW3D_MT_edit_SURFACE(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Surface" + + draw = draw_CURVE + +# Edit TEXT +class VIEW3D_MT_edit_TEXT(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Text" + + def draw(self, context): + layout = self.layout + + layout.itemO("font.file_paste") + + layout.itemS() + + layout.itemM("VIEW3D_MT_edit_TEXT_chars") + +class VIEW3D_MT_edit_TEXT_chars(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Special Characters" + + def draw(self, context): + layout = self.layout + + layout.item_stringO("font.text_insert", "text", b'\xC2\xA9'.decode(), text="Copyright|Alt C") + layout.item_stringO("font.text_insert", "text", b'\xC2\xAE'.decode(), text="Registered Trademark|Alt R") + + layout.itemS() + + layout.item_stringO("font.text_insert", "text", b'\xC2\xB0'.decode(), text="Degree Sign|Alt G") + layout.item_stringO("font.text_insert", "text", b'\xC3\x97'.decode(), text="Multiplication Sign|Alt x") + layout.item_stringO("font.text_insert", "text", b'\xC2\x8A'.decode(), text="Circle|Alt .") + layout.item_stringO("font.text_insert", "text", b'\xC2\xB9'.decode(), text="Superscript 1|Alt 1") + layout.item_stringO("font.text_insert", "text", b'\xC2\xB2'.decode(), text="Superscript 2|Alt 2") + layout.item_stringO("font.text_insert", "text", b'\xC2\xB3'.decode(), text="Superscript 3|Alt 3") + layout.item_stringO("font.text_insert", "text", b'\xC2\xBB'.decode(), text="Double >>|Alt >") + layout.item_stringO("font.text_insert", "text", b'\xC2\xAB'.decode(), text="Double <<|Alt <") + layout.item_stringO("font.text_insert", "text", b'\xE2\x80\xB0'.decode(), text="Promillage|Alt %") + + layout.itemS() + + layout.item_stringO("font.text_insert", "text", b'\xC2\xA4'.decode(), text="Dutch Florin|Alt F") + layout.item_stringO("font.text_insert", "text", b'\xC2\xA3'.decode(), text="British Pound|Alt L") + layout.item_stringO("font.text_insert", "text", b'\xC2\xA5'.decode(), text="Japanese Yen|Alt Y") + + layout.itemS() + + layout.item_stringO("font.text_insert", "text", b'\xC3\x9F'.decode(), text="German S|Alt S") + layout.item_stringO("font.text_insert", "text", b'\xC2\xBF'.decode(), text="Spanish Question Mark|Alt ?") + layout.item_stringO("font.text_insert", "text", b'\xC2\xA1'.decode(), text="Spanish Exclamation Mark|Alt !") + +# Edit META +class VIEW3D_MT_edit_META(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Metaball" + + def draw(self, context): + layout = self.layout + + settings = context.tool_settings + + layout.itemO("ed.undo") + layout.itemO("ed.redo") + + layout.itemS() + + layout.itemM("VIEW3D_MT_edit_snap") + + layout.itemS() + + layout.itemO("mball.delete_metaelems") + layout.itemO("mball.duplicate_metaelems") + + layout.itemS() + + layout.itemR(settings, "proportional_editing") + layout.item_menu_enumR(settings, "proportional_editing_falloff") + + layout.itemS() + + layout.itemM("VIEW3D_MT_edit_META_showhide") + +class VIEW3D_MT_edit_META_showhide(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Show/Hide" + + def draw(self, context): + layout = self.layout + + layout.itemO("mball.reveal_metaelems") + layout.itemO("mball.hide_metaelems") + layout.item_booleanO("mball.hide_metaelems", "unselected", True, text="Hide Unselected") + +# Edit LATTICE +class VIEW3D_MT_edit_LATTICE(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Lattice" + + def draw(self, context): + layout = self.layout + + settings = context.tool_settings + + layout.itemM("VIEW3D_MT_edit_snap") + + layout.itemS() + + layout.itemO("lattice.make_regular") + + layout.itemS() + + layout.itemR(settings, "proportional_editing") + layout.item_menu_enumR(settings, "proportional_editing_falloff") + +# Edit ARMATURE +class VIEW3D_MT_edit_ARMATURE(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Armature" + + def draw(self, context): + layout = self.layout + + edit_object = context.edit_object + arm = edit_object.data + + layout.itemM("VIEW3D_MT_edit_snap") + layout.itemM("VIEW3D_MT_edit_ARMATURE_roll") + + if arm.drawtype == 'ENVELOPE': + layout.item_enumO("tfm.transform", "mode", 'BONESIZE', text="Scale Envelope Distance") + else: + layout.item_enumO("tfm.transform", "mode", 'BONESIZE', text="Scale B-Bone Width") + + layout.itemS() + + layout.itemO("armature.extrude") + + if arm.x_axis_mirror: + layout.item_booleanO("armature.extrude", "forked", True, text="Extrude Forked") + + layout.itemO("armature.duplicate") + layout.itemO("armature.merge") + layout.itemO("armature.fill") + layout.itemO("armature.delete") + layout.itemO("armature.separate") + + layout.itemS() + + layout.itemO("armature.subdivide_simple") + layout.itemO("armature.subdivide_multi") + + layout.itemS() + + layout.item_enumO("armature.autoside_names", "axis", 'XAXIS', text="AutoName Left/Right") + layout.item_enumO("armature.autoside_names", "axis", 'YAXIS', text="AutoName Front/Back") + layout.item_enumO("armature.autoside_names", "axis", 'ZAXIS', text="AutoName Top/Bottom") + layout.itemO("armature.flip_names") + + layout.itemS() + + layout.itemO("armature.armature_layers") + layout.itemO("armature.bone_layers") + + layout.itemS() + + layout.itemM("VIEW3D_MT_edit_ARMATURE_parent") + + layout.itemS() + + layout.item_menu_enumO("armature.flags_set", "mode", text="Bone Settings") + +class VIEW3D_MT_edit_ARMATURE_parent(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Parent" + + def draw(self, context): + layout = self.layout + + layout.itemO("armature.parent_set") + layout.itemO("armature.parent_clear") + +class VIEW3D_MT_edit_ARMATURE_roll(bpy.types.Menu): + __space_type__ = "VIEW_3D" + __label__ = "Bone Roll" + + def draw(self, context): + layout = self.layout + + layout.item_enumO("armature.calculate_roll", "type", 'GLOBALUP', text="Clear Roll (Z-Axis Up)") + layout.item_enumO("armature.calculate_roll", "type", 'CURSOR', text="Roll to Cursor") + + layout.itemS() + + layout.item_enumO("tfm.transform", "mode", 'BONE_ROLL', text="Set Roll") + +# ********** Panel ********** class VIEW3D_PT_3dview_properties(bpy.types.Panel): __space_type__ = "VIEW_3D" @@ -198,9 +1037,61 @@ class VIEW3D_PT_background_image(bpy.types.Panel): col.itemR(bg, "x_offset", text="X") col.itemR(bg, "y_offset", text="Y") +bpy.types.register(VIEW3D_HT_header) # Header + +bpy.types.register(VIEW3D_MT_view) #View Menus bpy.types.register(VIEW3D_MT_view_navigation) -bpy.types.register(VIEW3D_MT_view) -bpy.types.register(VIEW3D_HT_header) -bpy.types.register(VIEW3D_PT_3dview_properties) + +bpy.types.register(VIEW3D_MT_select_OBJECT) # Select Menus +bpy.types.register(VIEW3D_MT_select_POSE) +bpy.types.register(VIEW3D_MT_select_PARTICLE) +bpy.types.register(VIEW3D_MT_select_EDIT_MESH) +bpy.types.register(VIEW3D_MT_select_EDIT_CURVE) +bpy.types.register(VIEW3D_MT_select_EDIT_SURFACE) +bpy.types.register(VIEW3D_MT_select_EDIT_METABALL) +bpy.types.register(VIEW3D_MT_select_EDIT_LATTICE) +bpy.types.register(VIEW3D_MT_select_EDIT_ARMATURE) +bpy.types.register(VIEW3D_MT_select_FACE) # XXX todo + +bpy.types.register(VIEW3D_MT_object) # Object Menu +bpy.types.register(VIEW3D_MT_object_clear) +bpy.types.register(VIEW3D_MT_object_snap) +bpy.types.register(VIEW3D_MT_object_parent) +bpy.types.register(VIEW3D_MT_object_track) +bpy.types.register(VIEW3D_MT_object_group) +bpy.types.register(VIEW3D_MT_object_constraints) +bpy.types.register(VIEW3D_MT_object_show) + +bpy.types.register(VIEW3D_MT_sculpt) # Sculpt Menu + +bpy.types.register(VIEW3D_MT_edit_snap) # Edit Menus + +bpy.types.register(VIEW3D_MT_edit_MESH) +bpy.types.register(VIEW3D_MT_edit_MESH_vertices) +bpy.types.register(VIEW3D_MT_edit_MESH_edges) +bpy.types.register(VIEW3D_MT_edit_MESH_faces) +bpy.types.register(VIEW3D_MT_edit_MESH_normals) +bpy.types.register(VIEW3D_MT_edit_MESH_showhide) + +bpy.types.register(VIEW3D_MT_edit_CURVE) +bpy.types.register(VIEW3D_MT_edit_CURVE_ctrlpoints) +bpy.types.register(VIEW3D_MT_edit_CURVE_segments) +bpy.types.register(VIEW3D_MT_edit_CURVE_showhide) + +bpy.types.register(VIEW3D_MT_edit_SURFACE) + +bpy.types.register(VIEW3D_MT_edit_TEXT) +bpy.types.register(VIEW3D_MT_edit_TEXT_chars) + +bpy.types.register(VIEW3D_MT_edit_META) +bpy.types.register(VIEW3D_MT_edit_META_showhide) + +bpy.types.register(VIEW3D_MT_edit_LATTICE) + +bpy.types.register(VIEW3D_MT_edit_ARMATURE) +bpy.types.register(VIEW3D_MT_edit_ARMATURE_parent) +bpy.types.register(VIEW3D_MT_edit_ARMATURE_roll) + +bpy.types.register(VIEW3D_PT_3dview_properties) # Panels bpy.types.register(VIEW3D_PT_3dview_display) bpy.types.register(VIEW3D_PT_background_image) diff --git a/release/ui/space_view3d_toolbar.py b/release/ui/space_view3d_toolbar.py index be57497a0b4..1b4c1e25c34 100644 --- a/release/ui/space_view3d_toolbar.py +++ b/release/ui/space_view3d_toolbar.py @@ -1,14 +1,14 @@ import bpy -# ********** default tools for objectmode **************** - class View3DPanel(bpy.types.Panel): __space_type__ = "VIEW_3D" __region_type__ = "TOOLS" - __context__ = "objectmode" + +# ********** default tools for objectmode **************** class VIEW3D_PT_tools_objectmode(View3DPanel): + __context__ = "objectmode" __label__ = "Object Tools" def draw(self, context): @@ -43,12 +43,8 @@ class VIEW3D_PT_tools_objectmode(View3DPanel): # ********** default tools for editmode_mesh **************** -class View3DPanel(bpy.types.Panel): - __space_type__ = "VIEW_3D" - __region_type__ = "TOOLS" - __context__ = "editmode_mesh" - -class VIEW3D_PT_tools_editmode_mesh(View3DPanel): +class VIEW3D_PT_tools_meshedit(View3DPanel): + __context__ = "mesh_edit" __label__ = "Mesh Tools" def draw(self, context): @@ -90,12 +86,8 @@ class VIEW3D_PT_tools_editmode_mesh(View3DPanel): # ********** default tools for editmode_curve **************** -class View3DPanel(bpy.types.Panel): - __space_type__ = "VIEW_3D" - __region_type__ = "TOOLS" - __context__ = "editmode_curve" - -class VIEW3D_PT_tools_editmode_curve(View3DPanel): +class VIEW3D_PT_tools_curveedit(View3DPanel): + __context__ = "curve_edit" __label__ = "Curve Tools" def draw(self, context): @@ -124,12 +116,8 @@ class VIEW3D_PT_tools_editmode_curve(View3DPanel): # ********** default tools for editmode_surface **************** -class View3DPanel(bpy.types.Panel): - __space_type__ = "VIEW_3D" - __region_type__ = "TOOLS" - __context__ = "editmode_surface" - -class VIEW3D_PT_tools_editmode_surface(View3DPanel): +class VIEW3D_PT_tools_surfaceedit(View3DPanel): + __context__ = "surface_edit" __label__ = "Surface Tools" def draw(self, context): @@ -158,12 +146,8 @@ class VIEW3D_PT_tools_editmode_surface(View3DPanel): # ********** default tools for editmode_text **************** -class View3DPanel(bpy.types.Panel): - __space_type__ = "VIEW_3D" - __region_type__ = "TOOLS" - __context__ = "editmode_text" - -class VIEW3D_PT_tools_editmode_text(View3DPanel): +class VIEW3D_PT_tools_textedit(View3DPanel): + __context__ = "text_edit" __label__ = "Text Tools" def draw(self, context): @@ -179,12 +163,8 @@ class VIEW3D_PT_tools_editmode_text(View3DPanel): # ********** default tools for editmode_armature **************** -class View3DPanel(bpy.types.Panel): - __space_type__ = "VIEW_3D" - __region_type__ = "TOOLS" - __context__ = "editmode_armature" - -class VIEW3D_PT_tools_editmode_armature(View3DPanel): +class VIEW3D_PT_tools_armatureedit(View3DPanel): + __context__ = "armature_edit" __label__ = "Armature Tools" def draw(self, context): @@ -209,12 +189,8 @@ class VIEW3D_PT_tools_editmode_armature(View3DPanel): # ********** default tools for editmode_mball **************** -class View3DPanel(bpy.types.Panel): - __space_type__ = "VIEW_3D" - __region_type__ = "TOOLS" - __context__ = "editmode_mball" - -class VIEW3D_PT_tools_editmode_mball(View3DPanel): +class VIEW3D_PT_tools_mballedit(View3DPanel): + __context__ = "mball_edit" __label__ = "Meta Tools" def draw(self, context): @@ -229,12 +205,8 @@ class VIEW3D_PT_tools_editmode_mball(View3DPanel): # ********** default tools for editmode_lattice **************** -class View3DPanel(bpy.types.Panel): - __space_type__ = "VIEW_3D" - __region_type__ = "TOOLS" - __context__ = "editmode_lattice" - -class VIEW3D_PT_tools_editmode_lattice(View3DPanel): +class VIEW3D_PT_tools_latticeedit(View3DPanel): + __context__ = "lattice_edit" __label__ = "Lattice Tools" def draw(self, context): @@ -249,12 +221,8 @@ class VIEW3D_PT_tools_editmode_lattice(View3DPanel): # ********** default tools for posemode **************** -class View3DPanel(bpy.types.Panel): - __space_type__ = "VIEW_3D" - __region_type__ = "TOOLS" - __context__ = "pose_mode" - class VIEW3D_PT_tools_posemode(View3DPanel): + __context__ = "posemode" __label__ = "Pose Tools" def draw(self, context): @@ -325,58 +293,94 @@ class VIEW3D_PT_tools_brush(PaintPanel): settings = self.paint_settings(context) brush = settings.brush + if not context.particle_edit_object: + col = layout.split().column() + row = col.row() + row.template_list(settings, "brushes", settings, "active_brush_index", rows=2) + + col.template_ID(settings, "brush", new="brush.add") + + # Particle Mode # + # XXX This needs a check if psys is editable. if context.particle_edit_object: + # XXX Select Particle System layout.column().itemR(settings, "tool", expand=True) + if settings.tool != 'NONE': - col = layout.column(align=True) + col = layout.column() col.itemR(brush, "size", slider=True) col.itemR(brush, "strength", slider=True) if settings.tool == 'ADD': - layout.itemR(settings, "add_interpolate") col = layout.column() - col.itemR(brush, "steps", slider=True) - col.itemR(settings, "add_keys", slider=True) + col.itemR(settings, "add_interpolate") + sub = col.column(align=True) + sub.active = settings.add_interpolate + sub.itemR(brush, "steps", slider=True) + sub.itemR(settings, "add_keys", slider=True) elif settings.tool == 'LENGTH': layout.itemR(brush, "length_mode", expand=True) elif settings.tool == 'PUFF': layout.itemR(brush, "puff_mode", expand=True) - - else: - layout.split().row().template_ID(settings, "brush") - if brush and not context.particle_edit_object: - if context.sculpt_object: - layout.column().itemR(brush, "sculpt_tool", expand=True) + # Sculpt Mode # - elif context.texture_paint_object: - col = layout.column(align=True) - col.item_enumR(settings, "tool", "DRAW") - col.item_enumR(settings, "tool", "SOFTEN") - if settings.use_projection: - col.item_enumR(settings, "tool", "CLONE") - else: - col.item_enumR(settings, "tool", "SMEAR") - + elif context.sculpt_object and settings.brush: col = layout.column() + col.itemS() + row = col.row(align=True) row.itemR(brush, "size", slider=True) row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="") - if context.weight_paint_object: - col.itemR(context.tool_settings, "vertex_group_weight", text="Weight", slider=True) + + if brush.sculpt_tool != 'GRAB': + row = col.row(align=True) + row.itemR(brush, "strength", slider=True) + row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="") + + col = layout.column() + + if brush.sculpt_tool != 'LAYER': + col.itemR(brush, "anchored") + + if brush.sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'): + col.itemR(brush, "flip_direction") + + if brush.sculpt_tool == 'LAYER': + col.itemR(brush, "persistent") + col.itemO("sculpt.set_persistent_base") + + col.itemR(brush, "rake") + + col.itemR(brush, "sculpt_tool") - col.itemR(brush, "strength", slider=True) + # Texture Paint Mode # + + elif context.texture_paint_object: + col = layout.column(align=True) + col.item_enumR(settings, "tool", 'DRAW') + col.item_enumR(settings, "tool", 'SOFTEN') + if settings.use_projection: + col.item_enumR(settings, "tool", 'CLONE') + else: + col.item_enumR(settings, "tool", 'SMEAR') + + col = layout.column() + col.itemR(brush, "color", text="") + + row = col.row(align=True) + row.itemR(brush, "size", slider=True) + row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="") + + row = col.row(align=True) + row.itemR(brush, "strength", slider=True) + row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="") + row = col.row(align=True) row.itemR(brush, "falloff", slider=True) row.itemR(brush, "falloff_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="") - if context.vertex_paint_object or context.texture_paint_object: - col.itemR(brush, "color", text="") - if context.texture_paint_object: - row = col.row(align=True) - row.itemR(brush, "clone_opacity", slider=True, text="Opacity") - row.itemR(brush, "opacity_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="") row = col.row(align=True) row.itemR(brush, "space", text="") @@ -384,14 +388,69 @@ class VIEW3D_PT_tools_brush(PaintPanel): rowsub.active = brush.space rowsub.itemR(brush, "spacing", text="Spacing", slider=True) rowsub.itemR(brush, "spacing_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="") - + col = layout.column() col.itemR(brush, "airbrush") - col.itemR(brush, "anchored") - col.itemR(brush, "rake") + sub = col.column() + sub.active = brush.airbrush + sub.itemR(brush, "rate") + + # Weight Paint Mode # + + elif context.weight_paint_object: + layout.itemR(context.tool_settings, "vertex_group_weight", text="Weight", slider=True) + + col = layout.column() + row = col.row(align=True) + row.itemR(brush, "size", slider=True) + row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="") + + row = col.row(align=True) + row.itemR(brush, "strength", slider=True) + row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="") + + # Vertex Paint Mode # + + elif context.vertex_paint_object: + col = layout.column() + col.itemR(brush, "color", text="") + + row = col.row(align=True) + row.itemR(brush, "size", slider=True) + row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="") + + row = col.row(align=True) + row.itemR(brush, "strength", slider=True) + row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="") + +class VIEW3D_PT_tools_brush_stroke(PaintPanel): + __label__ = "Stroke" + __default_closed__ = True + + def poll(self, context): + settings = self.paint_settings(context) + return (settings and settings.brush and context.sculpt_object) + + def draw(self, context): + settings = self.paint_settings(context) + brush = settings.brush + layout = self.layout + + layout.itemR(brush, "smooth_stroke") + col = layout.column() + col.active = brush.smooth_stroke + col.itemR(brush, "smooth_stroke_radius", text="Radius", slider=True) + col.itemR(brush, "smooth_stroke_factor", text="Factor", slider=True) + + layout.itemR(brush, "space") + col = layout.column() + col.active = brush.space + col.itemR(brush, "spacing", text="Distance", slider=True) + class VIEW3D_PT_tools_brush_curve(PaintPanel): __label__ = "Curve" + __default_closed__ = True def poll(self, context): settings = self.paint_settings(context) @@ -403,6 +462,7 @@ class VIEW3D_PT_tools_brush_curve(PaintPanel): layout = self.layout layout.template_curve_mapping(brush.curve) + layout.item_menu_enumO("brush.curve_preset", property="shape") class VIEW3D_PT_sculpt_options(PaintPanel): __label__ = "Options" @@ -434,12 +494,8 @@ class VIEW3D_PT_sculpt_options(PaintPanel): # ********** default tools for weightpaint **************** -class View3DPanel(bpy.types.Panel): - __space_type__ = "VIEW_3D" - __region_type__ = "TOOLS" - __context__ = "weight_paint" - -class VIEW3D_PT_weight_paint_options(View3DPanel): +class VIEW3D_PT_tools_weightpaint(View3DPanel): + __context__ = "weightpaint" __label__ = "Options" def draw(self, context): @@ -465,12 +521,8 @@ class VIEW3D_PT_weight_paint_options(View3DPanel): # ********** default tools for vertexpaint **************** -class View3DPanel(bpy.types.Panel): - __space_type__ = "VIEW_3D" - __region_type__ = "TOOLS" - -class VIEW3D_PT_vertex_paint_options(View3DPanel): - __context__ = "vertex_paint" +class VIEW3D_PT_tools_vertexpaint(View3DPanel): + __context__ = "vertexpaint" __label__ = "Options" def draw(self, context): @@ -493,38 +545,58 @@ class VIEW3D_PT_vertex_paint_options(View3DPanel): # ********** default tools for texturepaint **************** -class View3DPanel(bpy.types.Panel): - __space_type__ = "VIEW_3D" - __region_type__ = "TOOLS" - __context__ = "texture_paint" - -class VIEW3D_PT_tools_texture_paint(View3DPanel): +class VIEW3D_PT_tools_texturepaint(View3DPanel): + __context__ = "texturepaint" __label__ = "Options" def draw(self, context): layout = self.layout + ipaint = context.tool_settings.image_paint + settings = context.tool_settings.image_paint + use_projection= ipaint.use_projection col = layout.column() col.itemR(ipaint, "use_projection") - col.itemR(ipaint, "use_occlude") - col.itemR(ipaint, "use_backface_cull") + sub = col.column() + sub.active = use_projection + sub.itemR(ipaint, "use_occlude") + sub.itemR(ipaint, "use_backface_cull") + + split = layout.split() + + col = split.column() + col.active = (use_projection) col.itemR(ipaint, "use_normal_falloff") - col.itemR(ipaint, "invert_stencil") - col.itemR(ipaint, "use_clone_layer") + + col = split.column() + col.active = (ipaint.use_normal_falloff and use_projection) + col.itemR(ipaint, "normal_angle", text="") + + + split = layout.split(percentage=0.7) + + col = split.column(align=False) + col.active = (use_projection) col.itemR(ipaint, "use_stencil_layer") - col.itemR(ipaint, "seam_bleed") - col.itemR(ipaint, "normal_angle") + col = split.column(align=False) + col.active = (use_projection and ipaint.use_stencil_layer) + col.itemR(ipaint, "invert_stencil", text="Inv") + + + col = layout.column() + sub = col.column() + sub.active = (settings.tool == 'CLONE') + sub.itemR(ipaint, "use_clone_layer") + + sub = col.column() + sub.itemR(ipaint, "seam_bleed") # ********** default tools for particle mode **************** -class View3DPanel(bpy.types.Panel): - __space_type__ = "VIEW_3D" - __region_type__ = "TOOLS" - __context__ = "particle_mode" - -class VIEW3D_PT_tools_particle_edit(View3DPanel): +class VIEW3D_PT_tools_particlemode(View3DPanel): + __context__ = "particlemode" __label__ = "Options" def draw(self, context): @@ -543,23 +615,24 @@ class VIEW3D_PT_tools_particle_edit(View3DPanel): col.itemR(pe, "keep_root", text="Root") col = layout.column(align=True) - col.itemL(text="Draw:") + col.itemL(text="Display:") col.itemR(pe, "show_time", text="Time") col.itemR(pe, "show_children", text="Children") bpy.types.register(VIEW3D_PT_tools_objectmode) -bpy.types.register(VIEW3D_PT_tools_editmode_mesh) -bpy.types.register(VIEW3D_PT_tools_editmode_curve) -bpy.types.register(VIEW3D_PT_tools_editmode_surface) -bpy.types.register(VIEW3D_PT_tools_editmode_text) -bpy.types.register(VIEW3D_PT_tools_editmode_armature) -bpy.types.register(VIEW3D_PT_tools_editmode_mball) -bpy.types.register(VIEW3D_PT_tools_editmode_lattice) +bpy.types.register(VIEW3D_PT_tools_meshedit) +bpy.types.register(VIEW3D_PT_tools_curveedit) +bpy.types.register(VIEW3D_PT_tools_surfaceedit) +bpy.types.register(VIEW3D_PT_tools_textedit) +bpy.types.register(VIEW3D_PT_tools_armatureedit) +bpy.types.register(VIEW3D_PT_tools_mballedit) +bpy.types.register(VIEW3D_PT_tools_latticeedit) bpy.types.register(VIEW3D_PT_tools_posemode) bpy.types.register(VIEW3D_PT_tools_brush) +bpy.types.register(VIEW3D_PT_tools_brush_stroke) bpy.types.register(VIEW3D_PT_tools_brush_curve) bpy.types.register(VIEW3D_PT_sculpt_options) -bpy.types.register(VIEW3D_PT_vertex_paint_options) -bpy.types.register(VIEW3D_PT_weight_paint_options) -bpy.types.register(VIEW3D_PT_tools_texture_paint) -bpy.types.register(VIEW3D_PT_tools_particle_edit) +bpy.types.register(VIEW3D_PT_tools_vertexpaint) +bpy.types.register(VIEW3D_PT_tools_weightpaint) +bpy.types.register(VIEW3D_PT_tools_texturepaint) +bpy.types.register(VIEW3D_PT_tools_particlemode) diff --git a/source/Makefile b/source/Makefile index 49036fddb8f..cd2e7cf75ba 100644 --- a/source/Makefile +++ b/source/Makefile @@ -75,11 +75,11 @@ endif # PLUGAPPLIB libs that form the application to be plugged in # Note: the order is important here + GRPLIB = $(OCGDIR)/creator/$(DEBUG_DIR)libcreator.a GRPLIB += $(OCGDIR)/blender/windowmanager/$(DEBUG_DIR)libwindowmanager.a GRPLIB += $(NAN_BSP)/lib/$(DEBUG_DIR)libbsp.a GRPLIB += $(NAN_BOOLOP)/lib/$(DEBUG_DIR)libboolop.a -GRPLIB += $(NAN_SOUNDSYSTEM)/lib/$(DEBUG_DIR)libSoundSystem.a GRPLIB += $(NAN_GHOST)/lib/$(DEBUG_DIR)libghost.a GRPLIB += $(NAN_STRING)/lib/$(DEBUG_DIR)libstring.a GRPLIB += $(OCGDIR)/blender/render/$(DEBUG_DIR)librender.a @@ -106,6 +106,10 @@ COMLIB += $(NAN_JPEG)/lib/libjpeg.a COMLIB += $(OCGDIR)/blender/gpu/$(DEBUG_DIR)libgpu.a COMLIB += $(NAN_GLEW)/lib/$(DEBUG_DIR)libglew.a COMLIB += $(OCGDIR)/blender/blenfont/$(DEBUG_DIR)libblenfont.a +COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaudaspace.a +COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_src.a +COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_fx.a +COMLIB += $(NAN_SAMPLERATE)/lib/$(DEBUG_DIR)libsamplerate.a ifneq ($(NAN_NO_KETSJI),true) COMLIB += $(OCGDIR)/gameengine/bloutines/$(DEBUG_DIR)libbloutines.a @@ -114,8 +118,6 @@ ifneq ($(NAN_NO_KETSJI),true) COMLIB += $(OCGDIR)/gameengine/ketsji/$(DEBUG_DIR)libketsji.a COMLIB += $(OCGDIR)/gameengine/blconverter/$(DEBUG_DIR)libblconverter.a COMLIB += $(OCGDIR)/gameengine/blconverter/$(DEBUG_DIR)libblconverter.a - COMLIB += $(OCGDIR)/gameengine/blphys/fuzzics/$(DEBUG_DIR)libfuzzics.a - COMLIB += $(NAN_QHULL)/lib/libqhull.a COMLIB += $(OCGDIR)/gameengine/blphys/dummy/$(DEBUG_DIR)libdummy.a COMLIB += $(OCGDIR)/gameengine/blphys/common/$(DEBUG_DIR)libcommon.a COMLIB += $(OCGDIR)/gameengine/blphys/dummy/$(DEBUG_DIR)libdummy.a @@ -242,6 +244,7 @@ PULIB += $(OCGDIR)/blender/ed_image/$(DEBUG_DIR)libed_image.a PULIB += $(OCGDIR)/blender/ed_uvedit/$(DEBUG_DIR)libed_uvedit.a PULIB += $(OCGDIR)/blender/ed_screen/$(DEBUG_DIR)libed_screen.a PULIB += $(OCGDIR)/blender/ed_console/$(DEBUG_DIR)libed_console.a +PULIB += $(OCGDIR)/blender/ed_userpref/$(DEBUG_DIR)libed_userpref.a PULIB += $(OCGDIR)/blender/windowmanager/$(DEBUG_DIR)libwindowmanager.a PULIB += $(OCGDIR)/blender/python/$(DEBUG_DIR)libpython.a PULIB += $(OCGDIR)/blender/makesrna/$(DEBUG_DIR)librna.a @@ -352,67 +355,24 @@ endif # OpenAL libs are already compiled as shared code! -# Some vars to keep the rest of this section mostly readable -# in an 80 char term -SOUNDSYSTEM = $(OCGDIR)/intern/SoundSystem/$(DEBUG_DIR)libSoundSystem.a -DUMMYSOUND = $(OCGDIR)/intern/DummySoundSystem/$(DEBUG_DIR)libDummySoundSystem.a -OPENALSOUND = $(OCGDIR)/intern/OpenALSoundSystem/$(DEBUG_DIR)libOpenALSoundSystem.a -SDLSOUND = $(OCGDIR)/intern/SDLSoundSystem/$(DEBUG_DIR)libSDLSoundSystem.a - # Some kooky logic going on here ... ifeq ($(NAN_NO_OPENAL), true) - NAN_SND_LIBS = $(SOUNDSYSTEM) - NAN_SND_LIBS += $(DUMMYSOUND) - NAN_SND_LIBS += $(SOUNDSYSTEM) +# NAN_SND_LIBS = else ifeq ($(OS),$(findstring $(OS), "freebsd linux windows")) ifeq ($(CPU),$(findstring $(CPU), "i386 powerpc x86_64 parisc64")) - NAN_SND_LIBS = $(SOUNDSYSTEM) - NAN_SND_LIBS += $(DUMMYSOUND) - NAN_SND_LIBS += $(OPENALSOUND) - NAN_SND_LIBS += $(SDLSOUND) NAN_SND_LIBS += $(NAN_OPENAL)/lib/libopenal.a - NAN_SND_LIBS += $(SOUNDSYSTEM) else ifeq ($(OS),windows) - NAN_SND_LIBS = $(SOUNDSYSTEM) - NAN_SND_LIBS += $(DUMMYSOUND) - NAN_SND_LIBS += $(OPENALSOUND) - NAN_SND_LIBS += $(SDLSOUND) NAN_SND_LIBS += $(NAN_OPENAL)/lib/openal_static.lib - NAN_SND_LIBS += $(SOUNDSYSTEM) - else - NAN_SND_LIBS = $(SOUNDSYSTEM) - NAN_SND_LIBS += $(DUMMYSOUND) - NAN_SND_LIBS += $(SOUNDSYSTEM) endif endif else ifeq ($(OS),darwin) - NAN_SND_LIBS = $(SOUNDSYSTEM) - NAN_SND_LIBS += $(DUMMYSOUND) - NAN_SND_LIBS += $(OPENALSOUND) NAN_SND_LIBS += $(NAN_OPENAL)/lib/libopenal.a - NAN_SND_LIBS += $(SOUNDSYSTEM) else ifeq ($(OS), solaris) - NAN_SND_LIBS = $(SOUNDSYSTEM) - NAN_SND_LIBS += $(DUMMYSOUND) - NAN_SND_LIBS += $(OPENALSOUND) - NAN_SND_LIBS += $(SDLSOUND) NAN_SND_LIBS += $(NAN_OPENAL)/lib/libopenal.a - NAN_SND_LIBS += $(SOUNDSYSTEM) - else - ifeq ($(OS), irix) - NAN_SND_LIBS = $(SOUNDSYSTEM) - NAN_SND_LIBS += $(DUMMYSOUND) - NAN_SND_LIBS += $(SDLSOUND) - NAN_SND_LIBS += $(SOUNDSYSTEM) - else - NAN_SND_LIBS = $(SOUNDSYSTEM) - NAN_SND_LIBS += $(DUMMYSOUND) - NAN_SND_LIBS += $(SOUNDSYSTEM) - endif endif endif endif diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index c1b14a14f8c..760b7059bc7 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -70,6 +70,11 @@ void BLF_boundbox(char *str, struct rctf *box); float BLF_width(char *str); float BLF_height(char *str); +/* + * The following function return the width and height of the string, but + * just in one call, so avoid extra freetype2 stuff. + */ +void BLF_width_and_height(char *str, float *width, float *height); /* * For fixed width fonts only, returns the width of a @@ -116,6 +121,28 @@ void BLF_shadow(int level, float r, float g, float b, float a); */ void BLF_shadow_offset(int x, int y); +/* + * Set the buffer, size and number of channels to draw, one thing to take care is call + * this function with NULL pointer when we finish, for example: + * BLF_buffer(my_fbuf, my_cbuf, 100, 100, 4); + * + * ... set color, position and draw ... + * + * BLF_buffer(NULL, NULL, 0, 0, 0); + */ +void BLF_buffer(float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch); + +/* + * Set the color to be used for text. + */ +void BLF_buffer_col(float r, float g, float b, float a); + +/* + * Draw the string into the buffer, this function draw in both buffer, float and unsigned char _BUT_ + * it's not necessary set both buffer, NULL is valid here. + */ +void BLF_draw_buffer(char *str); + /* * Search the path directory to the locale files, this try all * the case for Linux, Win and Mac. @@ -140,17 +167,10 @@ char **BLF_dir_get(int *ndir); /* Free the data return by BLF_dir_get. */ void BLF_dir_free(char **dirs, int count); -/* Set the current draw mode. */ -void BLF_mode(int mode); - /* font->flags. */ #define BLF_ROTATION (1<<0) #define BLF_CLIPPING (1<<1) #define BLF_SHADOW (1<<2) #define BLF_KERNING_DEFAULT (1<<3) -/* font->mode. */ -#define BLF_MODE_TEXTURE 0 -#define BLF_MODE_BITMAP 1 - #endif /* BLF_API_H */ diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt index aef655ca0d1..bc03e69eb88 100644 --- a/source/blender/blenfont/CMakeLists.txt +++ b/source/blender/blenfont/CMakeLists.txt @@ -27,11 +27,13 @@ FILE(GLOB SRC intern/*.c) SET(INC ../../../intern/guardedalloc ../blenlib ../makesdna ../editors/include ../blenkernel ../../../extern/glew/include . - ${FTGL_INC} - ${FREETYPE_INC} - ${GETTEXT_INC} + ${FREETYPE_INCLUDE_DIRS} ) +IF(WITH_INTERNATIONAL) + SET(INC ${INC} ${GETTEXT_INC}) +ENDIF(WITH_INTERNATIONAL) + IF(WIN32) ADD_DEFINITIONS(-D_WIN32 -DUSE_GETTEXT_DLL) ENDIF(WIN32) diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index af57f822c40..8cb237a19ac 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -333,7 +333,6 @@ void BLF_default_rotation(float angle) } } - void BLF_draw(char *str) { FontBLF *font; @@ -342,40 +341,24 @@ void BLF_draw(char *str) * The pixmap alignment hack is handle * in BLF_position (old ui_rasterpos_safe). */ - font= global_font[global_font_cur]; if (font) { - if (font->mode == BLF_MODE_BITMAP) { - glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); - glPushAttrib(GL_ENABLE_BIT); - glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glDisable(GL_BLEND); - glRasterPos3f(font->pos[0], font->pos[1], font->pos[2]); + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - blf_font_draw(font, str); + glPushMatrix(); + glTranslatef(font->pos[0], font->pos[1], font->pos[2]); + glScalef(font->aspect, font->aspect, 1.0); - glPopAttrib(); - glPopClientAttrib(); - } - else { - glEnable(GL_BLEND); - glEnable(GL_TEXTURE_2D); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + if (font->flags & BLF_ROTATION) + glRotatef(font->angle, 0.0f, 0.0f, 1.0f); - glPushMatrix(); - glTranslatef(font->pos[0], font->pos[1], font->pos[2]); - glScalef(font->aspect, font->aspect, 1.0); + blf_font_draw(font, str); - if (font->flags & BLF_ROTATION) - glRotatef(font->angle, 0.0f, 0.0f, 1.0f); - - blf_font_draw(font, str); - - glPopMatrix(); - glDisable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - } + glPopMatrix(); + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); } } @@ -388,6 +371,15 @@ void BLF_boundbox(char *str, rctf *box) blf_font_boundbox(font, str, box); } +void BLF_width_and_height(char *str, float *width, float *height) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) + blf_font_width_and_height(font, str, width, height); +} + float BLF_width(char *str) { FontBLF *font; @@ -506,15 +498,6 @@ void BLF_clipping(float xmin, float ymin, float xmax, float ymax) } } -void BLF_mode(int mode) -{ - FontBLF *font; - - font= global_font[global_font_cur]; - if (font) - font->mode= mode; -} - void BLF_shadow(int level, float r, float g, float b, float a) { FontBLF *font; @@ -539,3 +522,39 @@ void BLF_shadow_offset(int x, int y) font->shadow_y= y; } } + +void BLF_buffer(float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) { + font->b_fbuf= fbuf; + font->b_cbuf= cbuf; + font->bw= w; + font->bh= h; + font->bch= nch; + } +} + +void BLF_buffer_col(float r, float g, float b, float a) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) { + font->b_col[0]= r; + font->b_col[1]= g; + font->b_col[2]= b; + font->b_col[3]= a; + } +} + +void BLF_draw_buffer(char *str) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) + blf_font_buffer(font, str); +} diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c index 92dfe8457b0..b4d902ff428 100644 --- a/source/blender/blenfont/intern/blf_dir.c +++ b/source/blender/blenfont/intern/blf_dir.c @@ -153,7 +153,8 @@ char *blf_dir_search(char *file) int blf_dir_split(const char *str, char *file, int *size) { - char *s, i, len; + int i, len; + char *s; /* Window, Linux or Mac, this is always / */ s= strrchr(str, '/'); diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 6fc35a96e1e..432c3b5f854 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -100,7 +100,7 @@ void blf_font_draw(FontBLF *font, char *str) unsigned int c; GlyphBLF *g, *g_prev; FT_Vector delta; - FT_UInt glyph_index, g_prev_index; + FT_UInt glyph_index; int pen_x, pen_y; int i, has_kerning, st; @@ -112,41 +112,30 @@ void blf_font_draw(FontBLF *font, char *str) pen_y= 0; has_kerning= FT_HAS_KERNING(font->face); g_prev= NULL; - g_prev_index= 0; while (str[i]) { c= blf_utf8_next((unsigned char *)str, &i); if (c == 0) break; - glyph_index= FT_Get_Char_Index(font->face, c); g= blf_glyph_search(font->glyph_cache, c); - if (!g) + if (!g) { + glyph_index= FT_Get_Char_Index(font->face, c); g= blf_glyph_add(font, glyph_index, c); + } /* if we don't found a glyph, skip it. */ if (!g) continue; - /* - * This happen if we change the mode of the - * font, we don't drop the glyph cache, so it's - * possible that some glyph don't have the - * bitmap or texture information. - */ - if (font->mode == BLF_MODE_BITMAP && (!g->bitmap_data)) - g= blf_glyph_add(font, glyph_index, c); - else if (font->mode == BLF_MODE_TEXTURE && (!g->tex_data)) - g= blf_glyph_add(font, glyph_index, c); - if (has_kerning && g_prev) { delta.x= 0; delta.y= 0; if (font->flags & BLF_KERNING_DEFAULT) - st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, ft_kerning_default, &delta); + st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta); else - st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta); + st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta); if (st == 0) pen_x += delta.x >> 6; @@ -157,7 +146,129 @@ void blf_font_draw(FontBLF *font, char *str) pen_x += g->advance; g_prev= g; - g_prev_index= glyph_index; + } +} + +void blf_font_buffer(FontBLF *font, char *str) +{ + unsigned char *data; + unsigned int c; + GlyphBLF *g, *g_prev; + FT_Vector delta; + FT_UInt glyph_index; + float a, *fbuf; + int pen_x, pen_y, y, x, yb, diff; + int i, has_kerning, st, chx, chy; + + if (!font->glyph_cache) + return; + + i= 0; + pen_x= (int)font->pos[0]; + pen_y= (int)font->pos[1]; + has_kerning= FT_HAS_KERNING(font->face); + g_prev= NULL; + + while (str[i]) { + c= blf_utf8_next((unsigned char *)str, &i); + if (c == 0) + break; + + g= blf_glyph_search(font->glyph_cache, c); + if (!g) { + glyph_index= FT_Get_Char_Index(font->face, c); + g= blf_glyph_add(font, glyph_index, c); + } + + /* if we don't found a glyph, skip it. */ + if (!g) + continue; + + if (has_kerning && g_prev) { + delta.x= 0; + delta.y= 0; + + if (font->flags & BLF_KERNING_DEFAULT) + st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta); + else + st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta); + + if (st == 0) + pen_x += delta.x >> 6; + } + + if (font->b_fbuf) { + chx= pen_x + ((int)g->pos_x); + + diff= g->height - ((int)g->pos_y); + + if (diff > 0) { + if (g->pitch < 0) + pen_y += diff; + else + pen_y -= diff; + } + else if (diff < 0) { + if (g->pitch < 0) + pen_y -= diff; + else + pen_y += diff; + } + + + if (g->pitch < 0) + chy= pen_y - ((int)g->pos_y); + else + chy= pen_y + ((int)g->pos_y); + + if (chx >= 0 && chx < font->bw && pen_y >= 0 && pen_y < font->bh) { + if (g->pitch < 0) + yb= 0; + else + yb= g->height-1; + + for (y= 0; y < g->height; y++) { + for (x= 0; x < g->width; x++) { + fbuf= font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); + data= g->bitmap + x + (yb * g->pitch); + a= data[0]/255.0f; + + if (a == 1.0) { + fbuf[0]= font->b_col[0]; + fbuf[1]= font->b_col[1]; + fbuf[2]= font->b_col[2]; + } + else { + fbuf[0]= (font->b_col[0]*a) + (fbuf[0] * (1-a)); + fbuf[1]= (font->b_col[1]*a) + (fbuf[1] * (1-a)); + fbuf[2]= (font->b_col[2]*a) + (fbuf[2] * (1-a)); + } + } + + if (g->pitch < 0) + yb++; + else + yb--; + } + } + + if (diff > 0) { + if (g->pitch < 0) + pen_x -= diff; + else + pen_y += diff; + } + else if (diff < 0) { + if (g->pitch < 0) + pen_x += diff; + else + pen_y -= diff; + } + + } + + pen_x += g->advance; + g_prev= g; } } @@ -166,7 +277,7 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) unsigned int c; GlyphBLF *g, *g_prev; FT_Vector delta; - FT_UInt glyph_index, g_prev_index; + FT_UInt glyph_index; rctf gbox; int pen_x, pen_y; int i, has_kerning, st; @@ -184,41 +295,30 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) pen_y= 0; has_kerning= FT_HAS_KERNING(font->face); g_prev= NULL; - g_prev_index= 0; while (str[i]) { c= blf_utf8_next((unsigned char *)str, &i); if (c == 0) break; - glyph_index= FT_Get_Char_Index(font->face, c); g= blf_glyph_search(font->glyph_cache, c); - if (!g) + if (!g) { + glyph_index= FT_Get_Char_Index(font->face, c); g= blf_glyph_add(font, glyph_index, c); + } /* if we don't found a glyph, skip it. */ if (!g) continue; - /* - * This happen if we change the mode of the - * font, we don't drop the glyph cache, so it's - * possible that some glyph don't have the - * bitmap or texture information. - */ - if (font->mode == BLF_MODE_BITMAP && (!g->bitmap_data)) - g= blf_glyph_add(font, glyph_index, c); - else if (font->mode == BLF_MODE_TEXTURE && (!g->tex_data)) - g= blf_glyph_add(font, glyph_index, c); - if (has_kerning && g_prev) { delta.x= 0; delta.y= 0; if (font->flags & BLF_KERNING_DEFAULT) - st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, ft_kerning_default, &delta); + st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta); else - st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta); + st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta); if (st == 0) pen_x += delta.x >> 6; @@ -241,7 +341,6 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) pen_x += g->advance; g_prev= g; - g_prev_index= glyph_index; } if (box->xmin > box->xmax) { @@ -252,6 +351,17 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) } } +void blf_font_width_and_height(FontBLF *font, char *str, float *width, float *height) +{ + rctf box; + + if (font->glyph_cache) { + blf_font_boundbox(font, str, &box); + *width= ((box.xmax - box.xmin) * font->aspect); + *height= ((box.ymax - box.ymin) * font->aspect); + } +} + float blf_font_width(FontBLF *font, char *str) { rctf box; @@ -316,7 +426,6 @@ void blf_font_free(FontBLF *font) void blf_font_fill(FontBLF *font) { - font->mode= BLF_MODE_TEXTURE; font->aspect= 1.0f; font->pos[0]= 0.0f; font->pos[1]= 0.0f; @@ -333,7 +442,16 @@ void blf_font_fill(FontBLF *font) font->cache.last= NULL; font->glyph_cache= NULL; font->blur= 0; - glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size); + font->max_tex_size= -1; + font->b_fbuf= NULL; + font->b_cbuf= NULL; + font->bw= 0; + font->bh= 0; + font->bch= 0; + font->b_col[0]= 0; + font->b_col[1]= 0; + font->b_col[2]= 0; + font->b_col[3]= 0; } FontBLF *blf_font_new(char *name, char *filename) diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 805da02ba36..f3db3ddc9a5 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -189,29 +189,18 @@ GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c) return(NULL); } -GlyphBLF *blf_glyph_texture_add(FontBLF *font, FT_UInt index, unsigned int c) +GlyphBLF *blf_glyph_add(FontBLF *font, FT_UInt index, unsigned int c) { FT_GlyphSlot slot; - GlyphCacheBLF *gc; GlyphBLF *g; - GlyphTextureBLF *gt; FT_Error err; FT_Bitmap bitmap; FT_BBox bbox; unsigned int key; - int do_new; g= blf_glyph_search(font->glyph_cache, c); - - /* The glyph can be add on Bitmap mode, so we have the - * glyph, but not the texture data. - */ - if (g && g->tex_data) + if (g) return(g); - else if (g) - do_new= 0; - else - do_new= 1; err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); if (err) @@ -224,56 +213,33 @@ GlyphBLF *blf_glyph_texture_add(FontBLF *font, FT_UInt index, unsigned int c) if (err || slot->format != FT_GLYPH_FORMAT_BITMAP) return(NULL); - if (do_new) { - g= (GlyphBLF *)MEM_mallocN(sizeof(GlyphBLF), "blf_glyph_add"); - g->next= NULL; - g->prev= NULL; - g->tex_data= NULL; - g->bitmap_data= NULL; - g->c= c; - } - - gt= (GlyphTextureBLF *)MEM_mallocN(sizeof(GlyphTextureBLF), "blf_glyph_texture_add"); - gc= font->glyph_cache; - - if (gc->cur_tex == -1) { - blf_glyph_cache_texture(font, gc); - gc->x_offs= gc->pad; - gc->y_offs= gc->pad; - } - - if (gc->x_offs > (gc->p2_width - gc->max_glyph_width)) { - gc->x_offs= gc->pad; - gc->y_offs += gc->max_glyph_height; - - if (gc->y_offs > (gc->p2_height - gc->max_glyph_height)) { - gc->y_offs= gc->pad; - blf_glyph_cache_texture(font, gc); - } - } - + g= (GlyphBLF *)MEM_mallocN(sizeof(GlyphBLF), "blf_glyph_add"); + g->next= NULL; + g->prev= NULL; + g->c= c; + g->idx= index; + g->tex= 0; + g->build_tex= 0; + g->bitmap= NULL; + g->xoff= -1; + g->yoff= -1; + g->uv[0][0]= 0.0f; + g->uv[0][1]= 0.0f; + g->uv[1][0]= 0.0f; + g->uv[1][1]= 0.0f; bitmap= slot->bitmap; - gt->tex= gc->textures[gc->cur_tex]; + g->width= bitmap.width; + g->height= bitmap.rows; - gt->xoff= gc->x_offs; - gt->yoff= gc->y_offs; - gt->width= bitmap.width; - gt->height= bitmap.rows; - - if (gt->width && gt->height) { - glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); - glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glBindTexture(GL_TEXTURE_2D, gt->tex); - glTexSubImage2D(GL_TEXTURE_2D, 0, gt->xoff, gt->yoff, gt->width, gt->height, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap.buffer); - glPopClientAttrib(); + if (g->width && g->height) { + g->bitmap= (unsigned char *)MEM_mallocN(g->width * g->height, "glyph bitmap"); + memcpy((void *)g->bitmap, (void *)bitmap.buffer, g->width * g->height); } g->advance= ((float)slot->advance.x) / 64.0f; - gt->pos_x= slot->bitmap_left; - gt->pos_y= slot->bitmap_top; + g->pos_x= slot->bitmap_left; + g->pos_y= slot->bitmap_top; + g->pitch= slot->bitmap.pitch; FT_Outline_Get_CBox(&(slot->outline), &bbox); g->box.xmin= ((float)bbox.xMin) / 64.0f; @@ -281,143 +247,18 @@ GlyphBLF *blf_glyph_texture_add(FontBLF *font, FT_UInt index, unsigned int c) g->box.ymin= ((float)bbox.yMin) / 64.0f; g->box.ymax= ((float)bbox.yMax) / 64.0f; - gt->uv[0][0]= ((float)gt->xoff) / ((float)gc->p2_width); - gt->uv[0][1]= ((float)gt->yoff) / ((float)gc->p2_height); - gt->uv[1][0]= ((float)(gt->xoff + gt->width)) / ((float)gc->p2_width); - gt->uv[1][1]= ((float)(gt->yoff + gt->height)) / ((float)gc->p2_height); - - /* update the x offset for the next glyph. */ - gc->x_offs += (int)(g->box.xmax - g->box.xmin + gc->pad); - - if (do_new) { - key= blf_hash(g->c); - BLI_addhead(&(gc->bucket[key]), g); - gc->rem_glyphs--; - } - - /* and attach the texture information. */ - g->tex_data= gt; - + key= blf_hash(g->c); + BLI_addhead(&(font->glyph_cache->bucket[key]), g); return(g); } -GlyphBLF *blf_glyph_bitmap_add(FontBLF *font, FT_UInt index, unsigned int c) -{ - FT_GlyphSlot slot; - GlyphCacheBLF *gc; - GlyphBLF *g; - GlyphBitmapBLF *gt; - FT_Error err; - FT_Bitmap bitmap; - FT_BBox bbox; - unsigned char *dest, *src; - unsigned int key, y; - unsigned int src_width, src_height, src_pitch; - int do_new; - - g= blf_glyph_search(font->glyph_cache, c); - - /* - * The glyph can be add on Texture mode, so we have the - * glyph, but not the bitmap data. - */ - if (g && g->bitmap_data) - return(g); - else if (g) - do_new= 0; - else - do_new= 1; - - err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); - if (err) - return(NULL); - - /* get the glyph. */ - slot= font->face->glyph; - - err= FT_Render_Glyph(slot, FT_RENDER_MODE_MONO); - if (err || slot->format != FT_GLYPH_FORMAT_BITMAP) - return(NULL); - - if (do_new) { - g= (GlyphBLF *)MEM_mallocN(sizeof(GlyphBLF), "blf_glyph_add"); - g->next= NULL; - g->prev= NULL; - g->tex_data= NULL; - g->bitmap_data= NULL; - g->c= c; - } - - gt= (GlyphBitmapBLF *)MEM_mallocN(sizeof(GlyphBitmapBLF), "blf_glyph_bitmap_add"); - gc= font->glyph_cache; - - bitmap= slot->bitmap; - - src_width= bitmap.width; - src_height= bitmap.rows; - src_pitch= bitmap.pitch; - - gt->width= src_width; - gt->height= src_height; - gt->pitch= src_pitch; - gt->image= NULL; - - if (gt->width && gt->height) { - gt->image= (unsigned char *)malloc(gt->pitch * gt->height); - - dest= gt->image + ((gt->height - 1) * gt->pitch); - src= bitmap.buffer; - - for (y= 0; y < src_height; ++y) { - memcpy((void *)dest, (void *)src, src_pitch); - dest -= gt->pitch; - src += src_pitch; - } - } - - g->advance= ((float)slot->advance.x) / 64.0f; - gt->pos_x= slot->bitmap_left; - gt->pos_y= ((int)src_height) - slot->bitmap_top; - - FT_Outline_Get_CBox(&(slot->outline), &bbox); - g->box.xmin= ((float)bbox.xMin) / 64.0f; - g->box.xmax= ((float)bbox.xMax) / 64.0f; - g->box.ymin= ((float)bbox.yMin) / 64.0f; - g->box.ymax= ((float)bbox.yMax) / 64.0f; - - if (do_new) { - key= blf_hash(g->c); - BLI_addhead(&(gc->bucket[key]), g); - gc->rem_glyphs--; - } - - /* and attach the bitmap information. */ - g->bitmap_data= gt; - - return(g); -} - -GlyphBLF *blf_glyph_add(FontBLF *font, FT_UInt index, unsigned int c) -{ - if (font->mode == BLF_MODE_BITMAP) - return(blf_glyph_bitmap_add(font, index, c)); - return(blf_glyph_texture_add(font, index, c)); -} - void blf_glyph_free(GlyphBLF *g) { - if (g->tex_data) - MEM_freeN(g->tex_data); - - if (g->bitmap_data) { - if (g->bitmap_data->image) - free((void *)g->bitmap_data->image); - MEM_freeN(g->bitmap_data); - } - /* don't need free the texture, the GlyphCache already * have a list of all the texture and free it. */ + if (g->bitmap) + MEM_freeN(g->bitmap); MEM_freeN(g); } @@ -482,16 +323,65 @@ static void blf_texture3_draw(float uv[2][2], float x1, float y1, float x2, floa glColor4fv(color); } -int blf_glyph_texture_render(FontBLF *font, GlyphBLF *g, float x, float y) +int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) { - GlyphTextureBLF *gt; + GlyphCacheBLF *gc; GLint cur_tex; float dx, dx1; float y1, y2; float xo, yo; float color[4]; - gt= g->tex_data; + if ((!g->width) || (!g->height)) + return(1); + + if (g->build_tex == 0) { + gc= font->glyph_cache; + + if (font->max_tex_size == -1) + glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size); + + if (gc->cur_tex == -1) { + blf_glyph_cache_texture(font, gc); + gc->x_offs= gc->pad; + gc->y_offs= gc->pad; + } + + if (gc->x_offs > (gc->p2_width - gc->max_glyph_width)) { + gc->x_offs= gc->pad; + gc->y_offs += gc->max_glyph_height; + + if (gc->y_offs > (gc->p2_height - gc->max_glyph_height)) { + gc->y_offs= gc->pad; + blf_glyph_cache_texture(font, gc); + } + } + + g->tex= gc->textures[gc->cur_tex]; + g->xoff= gc->x_offs; + g->yoff= gc->y_offs; + + glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); + glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glBindTexture(GL_TEXTURE_2D, g->tex); + glTexSubImage2D(GL_TEXTURE_2D, 0, g->xoff, g->yoff, g->width, g->height, GL_ALPHA, GL_UNSIGNED_BYTE, g->bitmap); + glPopClientAttrib(); + + g->uv[0][0]= ((float)g->xoff) / ((float)gc->p2_width); + g->uv[0][1]= ((float)g->yoff) / ((float)gc->p2_height); + g->uv[1][0]= ((float)(g->xoff + g->width)) / ((float)gc->p2_width); + g->uv[1][1]= ((float)(g->yoff + g->height)) / ((float)gc->p2_height); + + /* update the x offset for the next glyph. */ + gc->x_offs += (int)(g->box.xmax - g->box.xmin + gc->pad); + + gc->rem_glyphs--; + g->build_tex= 1; + } + xo= 0.0f; yo= 0.0f; @@ -502,10 +392,10 @@ int blf_glyph_texture_render(FontBLF *font, GlyphBLF *g, float x, float y) y += font->shadow_y; } - dx= floor(x + gt->pos_x); - dx1= dx + gt->width; - y1= y + gt->pos_y; - y2= y + gt->pos_y - gt->height; + dx= floor(x + g->pos_x); + dx1= dx + g->width; + y1= y + g->pos_y; + y2= y + g->pos_y - g->height; if (font->flags & BLF_CLIPPING) { if (!BLI_in_rctf(&font->clip_rec, dx + font->pos[0], y1 + font->pos[1])) @@ -519,70 +409,36 @@ int blf_glyph_texture_render(FontBLF *font, GlyphBLF *g, float x, float y) } glGetIntegerv(GL_TEXTURE_2D_BINDING_EXT, &cur_tex); - if (cur_tex != gt->tex) - glBindTexture(GL_TEXTURE_2D, gt->tex); + if (cur_tex != g->tex) + glBindTexture(GL_TEXTURE_2D, g->tex); if (font->flags & BLF_SHADOW) { glGetFloatv(GL_CURRENT_COLOR, color); glColor4fv(font->shadow_col); if (font->shadow == 3) - blf_texture3_draw(gt->uv, dx, y1, dx1, y2); + blf_texture3_draw(g->uv, dx, y1, dx1, y2); else if (font->shadow == 5) - blf_texture5_draw(gt->uv, dx, y1, dx1, y2); + blf_texture5_draw(g->uv, dx, y1, dx1, y2); else - blf_texture_draw(gt->uv, dx, y1, dx1, y2); + blf_texture_draw(g->uv, dx, y1, dx1, y2); glColor4fv(color); x= xo; y= yo; - dx= floor(x + gt->pos_x); - dx1= dx + gt->width; - y1= y + gt->pos_y; - y2= y + gt->pos_y - gt->height; + dx= floor(x + g->pos_x); + dx1= dx + g->width; + y1= y + g->pos_y; + y2= y + g->pos_y - g->height; } if (font->blur==3) - blf_texture3_draw(gt->uv, dx, y1, dx1, y2); + blf_texture3_draw(g->uv, dx, y1, dx1, y2); else if (font->blur==5) - blf_texture5_draw(gt->uv, dx, y1, dx1, y2); + blf_texture5_draw(g->uv, dx, y1, dx1, y2); else - blf_texture_draw(gt->uv, dx, y1, dx1, y2); - + blf_texture_draw(g->uv, dx, y1, dx1, y2); + return(1); } - -int blf_glyph_bitmap_render(FontBLF *font, GlyphBLF *g, float x, float y) -{ - GlyphBitmapBLF *gt; - GLubyte null_bitmap= 0; - - gt= g->bitmap_data; - if (!gt->image) - return(1); - - if (font->flags & BLF_CLIPPING) { - if (!BLI_in_rctf(&font->clip_rec, x + font->pos[0], y + font->pos[1])) - return(0); - if (!BLI_in_rctf(&font->clip_rec, x + font->pos[0], y + gt->height + font->pos[1])) - return(0); - if (!BLI_in_rctf(&font->clip_rec, x + gt->width + font->pos[0], y + gt->height + font->pos[1])) - return(0); - if (!BLI_in_rctf(&font->clip_rec, x + gt->width + font->pos[0], y + font->pos[1])) - return(0); - } - - glBitmap(0, 0, 0.0, 0.0, x + gt->pos_x, y, (const GLubyte *)&null_bitmap); - glPixelStorei(GL_UNPACK_ROW_LENGTH, gt->pitch * 8); - glBitmap(gt->width, gt->height, 0.0, gt->pos_y, 0.0, 0.0, (const GLubyte *)gt->image); - glBitmap(0, 0, 0.0, 0.0, -x - gt->pos_x, -y, (const GLubyte *)&null_bitmap); - return(1); -} - -int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) -{ - if (font->mode == BLF_MODE_BITMAP) - return(blf_glyph_bitmap_render(font, g, x, y)); - return(blf_glyph_texture_render(font, g, x, y)); -} diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index 30d5c8ede65..2a69b8652ea 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -45,7 +45,9 @@ void blf_font_attach_from_mem(FontBLF *font, const unsigned char *mem, int mem_s void blf_font_size(FontBLF *font, int size, int dpi); void blf_font_draw(FontBLF *font, char *str); +void blf_font_buffer(FontBLF *font, char *str); void blf_font_boundbox(FontBLF *font, char *str, rctf *box); +void blf_font_width_and_height(FontBLF *font, char *str, float *width, float *height); float blf_font_width(FontBLF *font, char *str); float blf_font_height(FontBLF *font, char *str); float blf_font_fixed_width(FontBLF *font); diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 64d95986867..fb4a2e6a9e5 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -78,7 +78,22 @@ typedef struct GlyphCacheBLF { float descender; } GlyphCacheBLF; -typedef struct GlyphTextureBLF { +typedef struct GlyphBLF { + struct GlyphBLF *next; + struct GlyphBLF *prev; + + /* and the character, as UTF8 */ + unsigned int c; + + /* freetype2 index, to speed-up the search. */ + FT_UInt idx; + + /* glyph box. */ + rctf box; + + /* advance size. */ + float advance; + /* texture id where this glyph is store. */ GLuint tex; @@ -86,9 +101,15 @@ typedef struct GlyphTextureBLF { int xoff; int yoff; + /* Bitmap data, from freetype. Take care that this + * can be NULL. + */ + unsigned char *bitmap; + /* glyph width and height. */ int width; int height; + int pitch; /* uv coords. */ float uv[2][2]; @@ -99,38 +120,9 @@ typedef struct GlyphTextureBLF { */ float pos_x; float pos_y; -} GlyphTextureBLF; -typedef struct GlyphBitmapBLF { - /* image data. */ - unsigned char *image; - - int width; - int height; - int pitch; - - float pos_x; - float pos_y; -} GlyphBitmapBLF; - -typedef struct GlyphBLF { - struct GlyphBLF *next; - struct GlyphBLF *prev; - - /* and the character, as UTF8 */ - unsigned int c; - - /* glyph box. */ - rctf box; - - /* advance size. */ - float advance; - - /* texture information. */ - GlyphTextureBLF *tex_data; - - /* bitmap information. */ - GlyphBitmapBLF *bitmap_data; + /* with value of zero mean that we need build the texture. */ + short build_tex; } GlyphBLF; typedef struct FontBLF { @@ -140,9 +132,6 @@ typedef struct FontBLF { /* filename or NULL. */ char *filename; - /* draw mode, texture or bitmap. */ - int mode; - /* aspect ratio or scale. */ float aspect; @@ -191,6 +180,22 @@ typedef struct FontBLF { /* freetype2 face. */ FT_Face face; + + /* for draw to buffer, always set this to NULL after finish! */ + float *b_fbuf; + + /* the same but unsigned char */ + unsigned char *b_cbuf; + + /* buffer size. */ + unsigned int bw; + unsigned int bh; + + /* number of channels. */ + int bch; + + /* and the color, the alphas is get from the glyph! */ + float b_col[4]; } FontBLF; typedef struct DirBLF { diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index 2447d1823af..cabbaa7aa0f 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -66,6 +66,9 @@ void BKE_keyingset_add_destination(struct KeyingSet *ks, struct ID *id, const ch struct KS_Path *BKE_keyingset_find_destination(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode); +/* Copy all KeyingSets in the given list */ +void BKE_keyingsets_copy(struct ListBase *newlist, struct ListBase *list); + /* Free data for KeyingSet but not set itself */ void BKE_keyingset_free(struct KeyingSet *ks); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 19b9c315939..42ee11587a7 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -43,7 +43,7 @@ struct bContext; struct ReportList; #define BLENDER_VERSION 250 -#define BLENDER_SUBVERSION 0 +#define BLENDER_SUBVERSION 2 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 9eb0b15aed4..6ec988e111e 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -38,16 +38,15 @@ struct Scene; struct wmOperator; /* datablock functions */ -struct Brush *add_brush(char *name); +struct Brush *add_brush(const char *name); struct Brush *copy_brush(struct Brush *brush); void make_local_brush(struct Brush *brush); void free_brush(struct Brush *brush); /* brush library operations used by different paint panels */ -struct Brush **current_brush_source(struct Scene *sce); -int brush_set_nr(struct Brush **current_brush, int nr); +int brush_set_nr(struct Brush **current_brush, int nr, const char *name); int brush_delete(struct Brush **current_brush); -void brush_check_exists(struct Brush **brush); +void brush_check_exists(struct Brush **brush, const char *name); void brush_toggled_fake_user(struct Brush *brush); int brush_texture_set_nr(struct Brush *brush, int nr); int brush_texture_delete(struct Brush *brush); diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index f3165c959bf..bc4585106e6 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -244,10 +244,6 @@ void cloth_update_normals ( ClothVertex *verts, int nVerts, MFace *face, int tot void bvhtree_update_from_cloth ( ClothModifierData *clmd, int moving ); void bvhselftree_update_from_cloth ( ClothModifierData *clmd, int moving ); -// needed for editmesh.c -void cloth_write_cache( Object *ob, ClothModifierData *clmd, int framenr ); -int cloth_read_cache( Scene *scene, Object *ob, ClothModifierData *clmd, float framenr, int *old_framenr ); - // needed for button_object.c void cloth_clear_cache ( Object *ob, ClothModifierData *clmd, float framenr ); diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index e47ad969b91..09e13c2930e 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -86,6 +86,25 @@ typedef struct bContextStore { int used; } bContextStore; +/* for the conrtext's rna mode enum + * keep aligned with data_mode_strings in context.c */ +enum { + CTX_MODE_EDIT_MESH = 0, + CTX_MODE_EDIT_CURVE, + CTX_MODE_EDIT_SURFACE, + CTX_MODE_EDIT_TEXT, + CTX_MODE_EDIT_ARMATURE, + CTX_MODE_EDIT_METABALL, + CTX_MODE_EDIT_LATTICE, + CTX_MODE_POSE, + CTX_MODE_SCULPT, + CTX_MODE_PAINT_WEIGHT, + CTX_MODE_PAINT_VERTEX, + CTX_MODE_PAINT_TEXTURE, + CTX_MODE_PARTICLE, + CTX_MODE_OBJECT +}; + /* Context */ bContext *CTX_create(void); @@ -133,6 +152,7 @@ struct SpaceLogic *CTX_wm_space_logic(const bContext *C); struct SpaceIpo *CTX_wm_space_graph(const bContext *C); struct SpaceAction *CTX_wm_space_action(const bContext *C); struct SpaceInfo *CTX_wm_space_info(const bContext *C); +struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C); void CTX_wm_manager_set(bContext *C, struct wmWindowManager *wm); void CTX_wm_window_set(bContext *C, struct wmWindow *win); @@ -191,6 +211,9 @@ struct Main *CTX_data_main(const bContext *C); struct Scene *CTX_data_scene(const bContext *C); struct ToolSettings *CTX_data_tool_settings(const bContext *C); +char *CTX_data_mode_string(const bContext *C); +int CTX_data_mode_enum(const bContext *C); + void CTX_data_main_set(bContext *C, struct Main *bmain); void CTX_data_scene_set(bContext *C, struct Scene *bmain); diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 4b7ddf43647..6323258ff43 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -44,7 +44,6 @@ extern "C" { /* forwards */ struct Main; struct Object; -struct bSoundListener; struct BME_Glob; typedef struct Global { @@ -93,9 +92,6 @@ typedef struct Global { /* save the allowed windowstate of blender when using -W or -w */ int windowstate; - /* Janco's playing ground */ - struct bSoundListener* listener; - /* ndof device found ? */ int ndofdevice; @@ -116,52 +112,40 @@ typedef struct Global { #define G_FACESELECT (1 << 8) -#define G_VERTEXPAINT (1 << 10) - #define G_DEBUG (1 << 12) #define G_DOSCRIPTLINKS (1 << 13) -#define G_WEIGHTPAINT (1 << 15) -#define G_TEXTUREPAINT (1 << 16) /* #define G_NOFROZEN (1 << 17) also removed */ #define G_GREASEPENCIL (1 << 17) -#define G_SCULPTMODE (1 << 29) -#define G_PARTICLEEDIT (1 << 30) - /* #define G_AUTOMATKEYS (1 << 30) also removed */ #define G_HIDDENHANDLES (1 << 31) /* used for curves only */ -/* macro for testing face select mode - * Texture paint could be removed since selected faces are not used - * however hiding faces is useful */ -#define FACESEL_PAINT_TEST ((G.f&G_FACESELECT) && (G.f & (G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT))) - /* G.fileflags */ #define G_AUTOPACK (1 << 0) #define G_FILE_COMPRESS (1 << 1) #define G_FILE_AUTOPLAY (1 << 2) -#define G_FILE_ENABLE_ALL_FRAMES (1 << 3) -#define G_FILE_SHOW_DEBUG_PROPS (1 << 4) -#define G_FILE_SHOW_FRAMERATE (1 << 5) -#define G_FILE_SHOW_PROFILE (1 << 6) +#define G_FILE_ENABLE_ALL_FRAMES (1 << 3) /* deprecated */ +#define G_FILE_SHOW_DEBUG_PROPS (1 << 4) /* deprecated */ +#define G_FILE_SHOW_FRAMERATE (1 << 5) /* deprecated */ +#define G_FILE_SHOW_PROFILE (1 << 6) /* deprecated */ #define G_FILE_LOCK (1 << 7) #define G_FILE_SIGN (1 << 8) #define G_FIle_PUBLISH (1 << 9) #define G_FILE_NO_UI (1 << 10) -#define G_FILE_GAME_TO_IPO (1 << 11) -#define G_FILE_GAME_MAT (1 << 12) -#define G_FILE_DISPLAY_LISTS (1 << 13) -#define G_FILE_SHOW_PHYSICS (1 << 14) -#define G_FILE_GAME_MAT_GLSL (1 << 15) -#define G_FILE_GLSL_NO_LIGHTS (1 << 16) -#define G_FILE_GLSL_NO_SHADERS (1 << 17) -#define G_FILE_GLSL_NO_SHADOWS (1 << 18) -#define G_FILE_GLSL_NO_RAMPS (1 << 19) -#define G_FILE_GLSL_NO_NODES (1 << 20) -#define G_FILE_GLSL_NO_EXTRA_TEX (1 << 21) -#define G_FILE_IGNORE_DEPRECATION_WARNINGS (1 << 22) +#define G_FILE_GAME_TO_IPO (1 << 11) /* deprecated */ +#define G_FILE_GAME_MAT (1 << 12) /* deprecated */ +#define G_FILE_DISPLAY_LISTS (1 << 13) /* deprecated */ +#define G_FILE_SHOW_PHYSICS (1 << 14) /* deprecated */ +#define G_FILE_GAME_MAT_GLSL (1 << 15) /* deprecated */ +#define G_FILE_GLSL_NO_LIGHTS (1 << 16) /* deprecated */ +#define G_FILE_GLSL_NO_SHADERS (1 << 17) /* deprecated */ +#define G_FILE_GLSL_NO_SHADOWS (1 << 18) /* deprecated */ +#define G_FILE_GLSL_NO_RAMPS (1 << 19) /* deprecated */ +#define G_FILE_GLSL_NO_NODES (1 << 20) /* deprecated */ +#define G_FILE_GLSL_NO_EXTRA_TEX (1 << 21) /* deprecated */ +#define G_FILE_IGNORE_DEPRECATION_WARNINGS (1 << 22) /* deprecated */ /* G.windowstate */ #define G_WINDOWSTATE_USERDEF 0 diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index ce182267b93..4e7db115168 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -58,6 +58,7 @@ int set_listbasepointers(struct Main *main, struct ListBase **lb); void free_libblock(struct ListBase *lb, void *idv); void free_libblock_us(struct ListBase *lb, void *idv); void free_main(struct Main *mainvar); +void tag_main(struct Main *mainvar, int tag); void splitIDname(char *name, char *left, int *nr); void rename_id(struct ID *id, char *name); diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index ba78aa0682d..ff9ac693ba8 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -164,6 +164,7 @@ struct MetaBall *copy_mball(struct MetaBall *mb); void make_local_mball(struct MetaBall *mb); void tex_space_mball(struct Object *ob); float *make_orco_mball(struct Object *ob); +void copy_mball_properties(struct Scene *scene, struct Object *active_object); struct Object *find_basis_mball(struct Scene *scene, struct Object *ob); int is_basis_mball(struct Object *ob); void metaball_polygonize(struct Scene *scene, struct Object *ob); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 87ee8f9cab3..4ac95b61a5e 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -47,6 +47,7 @@ struct rctf; struct ListBase; struct RenderData; struct Scene; +struct Main; struct Tex; struct GPUMaterial; struct GPUNode; @@ -421,7 +422,7 @@ extern struct ListBase node_all_textures; /* API */ int ntreeTexTagAnimated(struct bNodeTree *ntree); void ntreeTexUpdatePreviews( struct bNodeTree* nodetree ); -void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, char do_preview, short thread, struct Tex *tex, short which_output, int cfra); +void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, float *dxt, float *dyt, char do_preview, short thread, struct Tex *tex, short which_output, int cfra); void ntreeTexCheckCyclics(struct bNodeTree *ntree); void ntreeTexAssignIndex(struct bNodeTree *ntree, struct bNode *node); char* ntreeTexOutputMenu(struct bNodeTree *ntree); @@ -432,4 +433,8 @@ char* ntreeTexOutputMenu(struct bNodeTree *ntree); void init_nodesystem(void); void free_nodesystem(void); +/**/ + +void clear_scene_in_nodes(struct Main *bmain, struct Scene *sce); + #endif diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h index efd930d375a..b6513bede99 100644 --- a/source/blender/blenkernel/BKE_packedFile.h +++ b/source/blender/blenkernel/BKE_packedFile.h @@ -34,7 +34,6 @@ #define RET_OK 0 #define RET_ERROR 1 -struct bSample; struct bSound; struct Image; struct Main; @@ -51,7 +50,7 @@ void packAll(struct Main *bmain, struct ReportList *reports); /* unpack */ char *unpackFile(struct ReportList *reports, char *abs_name, char *local_name, struct PackedFile *pf, int how); int unpackVFont(struct ReportList *reports, struct VFont *vfont, int how); -int unpackSample(struct ReportList *reports, struct bSample *sample, int how); +int unpackSound(struct ReportList *reports, struct bSound *sound, int how); int unpackImage(struct ReportList *reports, struct Image *ima, int how); void unpackAll(struct Main *bmain, struct ReportList *reports, int how); diff --git a/intern/SoundSystem/dummy/SND_DummyDevice.cpp b/source/blender/blenkernel/BKE_paint.h similarity index 50% rename from intern/SoundSystem/dummy/SND_DummyDevice.cpp rename to source/blender/blenkernel/BKE_paint.h index 672c73e9c52..67b260b2348 100644 --- a/intern/SoundSystem/dummy/SND_DummyDevice.cpp +++ b/source/blender/blenkernel/BKE_paint.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -14,10 +12,10 @@ * 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, + * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * The Original Code is Copyright (C) 2009 by Nicholas Bishop * All rights reserved. * * The Original Code is: all of this file. @@ -25,28 +23,29 @@ * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** - * SND_DummyDevice derived from SND_IAudioDevice - */ + */ + +#ifndef BKE_PAINT_H +#define BKE_PAINT_H + +struct Brush; +struct Object; +struct Paint; +struct Scene; + +void paint_init(struct Paint *p, const char *brush_name); +void free_paint(struct Paint *p); +void copy_paint(struct Paint *orig, struct Paint *new); + +struct Paint *paint_get_active(struct Scene *sce); +struct Brush *paint_brush(struct Paint *paint); +void paint_brush_set(struct Paint *paint, struct Brush *br); +void paint_brush_slot_add(struct Paint *p); +void paint_brush_slot_remove(struct Paint *p); + +/* testing face select mode + * Texture paint could be removed since selected faces are not used + * however hiding faces is useful */ +int paint_facesel_test(struct Object *ob); -#ifdef HAVE_CONFIG_H -#include #endif - -#ifdef WIN32 -#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning -#endif //WIN32 - -#include "SND_DummyDevice.h" - -SND_DummyDevice::SND_DummyDevice() -{ -} - -SND_DummyDevice::~SND_DummyDevice() -{ -#ifdef ONTKEVER - printf("SND_DummyDevice destructor"); -#endif -} - - diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 8062f807055..5d9dddfe30d 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -30,6 +30,8 @@ #define BKE_POINTCACHE_H #include "DNA_ID.h" +#include "DNA_object_force.h" +#include "DNA_boid_types.h" #include "MEM_guardedalloc.h" @@ -55,9 +57,11 @@ #define PTCACHE_FILE_WRITE 1 /* PTCacheID types */ -#define PTCACHE_TYPE_SOFTBODY 0 -#define PTCACHE_TYPE_PARTICLES 1 -#define PTCACHE_TYPE_CLOTH 2 +#define PTCACHE_TYPE_SOFTBODY 0 +#define PTCACHE_TYPE_PARTICLES 1 +#define PTCACHE_TYPE_CLOTH 2 +#define PTCACHE_TYPE_SMOKE_DOMAIN_LOW 3 +#define PTCACHE_TYPE_SMOKE_DOMAIN_HIGH 4 /* PTCache read return code */ #define PTCACHE_READ_EXACT 1 @@ -69,47 +73,71 @@ struct Object; struct Scene; struct SoftBody; struct ParticleSystem; +struct ParticleKey; struct ClothModifierData; +struct SmokeModifierData; struct PointCache; struct ListBase; +/* temp structure for read/write */ +typedef struct PTCacheData { + int index; + float loc[3]; + float vel[3]; + float rot[4]; + float ave[3]; + float size; + float times[3]; + struct BoidData boids; +} PTCacheData; + typedef struct PTCacheFile { FILE *fp; + + int totpoint, type; + unsigned int data_types; + + struct PTCacheData data; + void *cur[BPHYS_TOT_DATA]; } PTCacheFile; typedef struct PTCacheID { struct PTCacheID *next, *prev; + struct Scene *scene; struct Object *ob; - void *data; + void *calldata; int type; int stack_index; + /* flags defined in DNA_object_force.h */ + unsigned int data_types, info_types; + + /* copies point data to cache data */ + int (*write_elem)(int index, void *calldata, void **data); + /* copies point data to cache data */ + int (*write_stream)(PTCacheFile *pf, void *calldata); + /* copies cache cata to point data */ + void (*read_elem)(int index, void *calldata, void **data, float frs_sec, float cfra, float *old_data); + /* copies cache cata to point data */ + void (*read_stream)(PTCacheFile *pf, void *calldata); + /* interpolated between previously read point data and cache data */ + void (*interpolate_elem)(int index, void *calldata, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data); + + /* total number of simulated points */ + int (*totpoint)(void *calldata); + /* number of points written for current cache frame (currently not used) */ + int (*totwrite)(void *calldata); + + int (*write_header)(PTCacheFile *pf); + int (*read_header)(PTCacheFile *pf); + struct PointCache *cache; + /* used for setting the current cache from ptcaches list */ + struct PointCache **cache_ptr; + struct ListBase *ptcaches; } PTCacheID; -typedef struct PTCacheWriter { - struct PTCacheID *pid; - int cfra; - int totelem; - - void (*set_elem)(int index, void *calldata, float *data); - void *calldata; -} PTCacheWriter; - -typedef struct PTCacheReader { - struct Scene *scene; - struct PTCacheID *pid; - float cfra; - int totelem; - - void (*set_elem)(int elem_index, void *calldata, float *data); - void (*interpolate_elem)(int index, void *calldata, float frs_sec, float cfra, float cfra1, float cfra2, float *data1, float *data2); - void *calldata; - - int *old_frame; -} PTCacheReader; - typedef struct PTCacheBaker { struct Scene *scene; int bake; @@ -123,49 +151,75 @@ typedef struct PTCacheBaker { void *progresscontext; } PTCacheBaker; -/* Creating ID's */ +/* Particle functions */ +void BKE_ptcache_make_particle_key(struct ParticleKey *key, int index, void **data, float time); + +/**************** Creating ID's ****************************/ void BKE_ptcache_id_from_softbody(PTCacheID *pid, struct Object *ob, struct SoftBody *sb); void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys); void BKE_ptcache_id_from_cloth(PTCacheID *pid, struct Object *ob, struct ClothModifierData *clmd); +void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd, int num); void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob); -/* Global funcs */ +/***************** Global funcs ****************************/ void BKE_ptcache_remove(void); -/* ID specific functions */ +/************ ID specific functions ************************/ void BKE_ptcache_id_clear(PTCacheID *id, int mode, int cfra); int BKE_ptcache_id_exist(PTCacheID *id, int cfra); int BKE_ptcache_id_reset(struct Scene *scene, PTCacheID *id, int mode); void BKE_ptcache_id_time(PTCacheID *pid, struct Scene *scene, float cfra, int *startframe, int *endframe, float *timescale); int BKE_ptcache_object_reset(struct Scene *scene, struct Object *ob, int mode); -/* File reading/writing */ -PTCacheFile *BKE_ptcache_file_open(PTCacheID *id, int mode, int cfra); -void BKE_ptcache_file_close(PTCacheFile *pf); -int BKE_ptcache_file_read_floats(PTCacheFile *pf, float *f, int tot); -int BKE_ptcache_file_write_floats(PTCacheFile *pf, float *f, int tot); - void BKE_ptcache_update_info(PTCacheID *pid); -/* General cache reading/writing */ -int BKE_ptcache_read_cache(PTCacheReader *reader); -int BKE_ptcache_write_cache(PTCacheWriter *writer); +/*********** General cache reading/writing ******************/ -/* Continue physics */ +/* Size of cache data type. */ +int BKE_ptcache_data_size(int data_type); + +/* Copy a specific data type from cache data to point data. */ +void BKE_ptcache_data_get(void **data, int type, int index, void *to); + +/* Copy a specific data type from point data to cache data. */ +void BKE_ptcache_data_set(void **data, int type, void *from); + +/* Main cache reading call. */ +int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec); + +/* Main cache writing call. */ +int BKE_ptcache_write_cache(PTCacheID *pid, int cfra); + +/****************** Continue physics ***************/ void BKE_ptcache_set_continue_physics(struct Scene *scene, int enable); int BKE_ptcache_get_continue_physics(void); -/* Point Cache */ -struct PointCache *BKE_ptcache_add(void); +/******************* Allocate & free ***************/ +struct PointCache *BKE_ptcache_add(struct ListBase *ptcaches); +void BKE_ptache_free_mem(struct PointCache *cache); void BKE_ptcache_free(struct PointCache *cache); -struct PointCache *BKE_ptcache_copy(struct PointCache *cache); +void BKE_ptcache_free_list(struct ListBase *ptcaches); +struct PointCache *BKE_ptcache_copy_list(struct ListBase *ptcaches_new, struct ListBase *ptcaches_old); -/* Baking */ +/********************** Baking *********************/ + +/* Bakes cache with cache_step sized jumps in time, not accurate but very fast. */ void BKE_ptcache_quick_cache_all(struct Scene *scene); + +/* Bake cache or simulate to current frame with settings defined in the baker. */ void BKE_ptcache_make_cache(struct PTCacheBaker* baker); + +/* Convert disk cache to memory cache. */ +void BKE_ptcache_disk_to_mem(struct PTCacheID *pid); + +/* Convert memory cache to disk cache. */ +void BKE_ptcache_mem_to_disk(struct PTCacheID *pid); + +/* Convert disk cache to memory cache and vice versa. Clears the cache that was converted. */ void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid); +/* Loads simulation from external (disk) cache files. */ void BKE_ptcache_load_external(struct PTCacheID *pid); #endif diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 9bb246f88cc..12a13a2b50c 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -40,6 +40,12 @@ struct AviCodecData; struct QuicktimeCodecData; struct RenderData; struct Text; +struct Main; + +#define SCE_COPY_EMPTY 0 +#define SCE_COPY_LINK_OB 1 +#define SCE_COPY_LINK_DATA 2 +#define SCE_COPY_FULL 3 /* note; doesn't work when scene is empty */ #define SETLOOPER(s, b) sce= s, b= (Base*)sce->base.first; b; b= (Base*)(b->next?b->next:sce->set?(sce=sce->set)->base.first:NULL) @@ -48,13 +54,16 @@ struct Text; void free_avicodecdata(struct AviCodecData *acd); void free_qtcodecdata(struct QuicktimeCodecData *acd); -void free_scene(struct Scene *me); +void free_scene(struct Scene *sce); struct Scene *add_scene(char *name); struct Base *object_in_scene(struct Object *ob, struct Scene *sce); void set_scene_bg(struct Scene *sce); void set_scene_name(char *name); +struct Scene *copy_scene(struct Main *bmain, struct Scene *sce, int type); +void unlink_scene(struct Main *bmain, struct Scene *sce, struct Scene *newsce); + int next_object(struct Scene *scene, int val, struct Base **base, struct Object **ob); struct Object *scene_find_camera(struct Scene *sc); diff --git a/source/blender/blenkernel/BKE_sculpt.h b/source/blender/blenkernel/BKE_sculpt.h index 08db1ac632e..9e5647a8775 100644 --- a/source/blender/blenkernel/BKE_sculpt.h +++ b/source/blender/blenkernel/BKE_sculpt.h @@ -33,7 +33,7 @@ struct MFace; struct MultireModifierData; struct MVert; -struct Sculpt; +struct Object; struct StrokeCache; typedef struct SculptSession { @@ -59,13 +59,14 @@ typedef struct SculptSession { /* Used to cache the render of the active texture */ unsigned int texcache_side, *texcache, texcache_actual; - void *cursor; /* wm handle */ + /* Layer brush persistence between strokes */ + float (*mesh_co_orig)[3]; /* Copy of the mesh vertices' locations */ + float *layer_disps; /* Displacements for each vertex */ struct SculptStroke *stroke; - struct StrokeCache *cache; } SculptSession; -void sculptsession_free(struct Sculpt *sculpt); +void free_sculptsession(SculptSession **); #endif diff --git a/source/blender/blenkernel/BKE_sequence.h b/source/blender/blenkernel/BKE_sequence.h index 7162fa7b9dd..f72617c8312 100644 --- a/source/blender/blenkernel/BKE_sequence.h +++ b/source/blender/blenkernel/BKE_sequence.h @@ -37,6 +37,7 @@ struct Strip; struct StripElem; struct ImBuf; struct Scene; +struct bContext; #define MAXSEQ 32 @@ -44,7 +45,6 @@ struct Scene; #define BUILD_SEQAR_COUNT_CURRENT 1 #define BUILD_SEQAR_COUNT_CHILDREN 2 - /* sequence iterator */ typedef struct SeqIterator { @@ -137,9 +137,9 @@ struct SeqEffectHandle { /* sequence.c */ // extern -void seq_free_sequence(struct Editing *ed, struct Sequence *seq); +void seq_free_sequence(struct Scene *scene, struct Sequence *seq); void seq_free_strip(struct Strip *strip); -void seq_free_editing(struct Editing *ed); +void seq_free_editing(struct Scene *scene); struct Editing *seq_give_editing(struct Scene *scene, int alloc); char *give_seqname(struct Sequence *seq); struct ImBuf *give_ibuf_seq(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size); @@ -183,3 +183,8 @@ int seq_test_overlap(struct ListBase * seqbasep, struct Sequence *test); int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test); void free_imbuf_seq(struct ListBase * seqbasep, int check_mem_usage); +void seq_update_sound(struct Sequence *seq); + +void clear_scene_in_allseqs(struct Scene *sce); + + diff --git a/source/blender/blenkernel/BKE_smoke.h b/source/blender/blenkernel/BKE_smoke.h index b37e1d08fcc..8dc38640e9a 100644 --- a/source/blender/blenkernel/BKE_smoke.h +++ b/source/blender/blenkernel/BKE_smoke.h @@ -1,5 +1,5 @@ /** - * BKE_cloth.h + * BKE_smoke.h * * $Id$ * @@ -32,7 +32,7 @@ #ifndef BKE_SMOKE_H_ #define BKE_SMOKE_H_ -void smokeModifier_do(struct SmokeModifierData *smd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm); +void smokeModifier_do(struct SmokeModifierData *smd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, int useRenderParams, int isFinalCalc); void smokeModifier_free (struct SmokeModifierData *smd); void smokeModifier_reset(struct SmokeModifierData *smd); diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h index 0d9682cf842..d8053281ceb 100644 --- a/source/blender/blenkernel/BKE_softbody.h +++ b/source/blender/blenkernel/BKE_softbody.h @@ -68,8 +68,5 @@ extern void sbObjectToSoftbody(struct Object *ob); /* pass NULL to unlink again */ extern void sbSetInterruptCallBack(int (*f)(void)); -/* writing to cache for bake editing */ -extern void softbody_write_cache(struct Object *ob, struct SoftBody *soft, int cfra); - #endif diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index f3bed467c3a..1dd90b4dbda 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -1,7 +1,7 @@ /** * sound.h (mar-2001 nzc) - * - * $Id$ + * + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -33,20 +33,45 @@ struct PackedFile; struct bSound; -struct bSample; +struct bContext; struct ListBase; +struct Main; -/* bad bad global... */ -extern struct ListBase *samples; +void sound_init(); -void sound_free_all_samples(void); +void sound_exit(); -/* void *sound_get_listener(void); implemented in src!also declared there now */ +struct bSound* sound_new_file(struct Main *main, char* filename); -void sound_set_packedfile(struct bSample* sample, struct PackedFile* pf); -struct PackedFile* sound_find_packedfile(struct bSound* sound); -void sound_free_sample(struct bSample* sample); -void sound_free_sound(struct bSound* sound); +// XXX unused currently +#if 0 +struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source); +struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, float start, float end); #endif +void sound_delete(struct bContext *C, struct bSound* sound); + +void sound_cache(struct bSound* sound, int ignore); + +void sound_load(struct bSound* sound); + +void sound_free(struct bSound* sound); + +void sound_unlink(struct bContext *C, struct bSound* sound); + +struct SoundHandle* sound_new_handle(struct Scene *scene, struct bSound* sound, int startframe, int endframe, int frameskip); + +void sound_delete_handle(struct Scene *scene, struct SoundHandle *handle); + +void sound_update_playing(struct bContext *C); + +void sound_scrub(struct bContext *C); + +#ifdef AUD_CAPI +AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int end); +#endif + +void sound_stop_all(struct bContext *C); + +#endif diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h new file mode 100644 index 00000000000..5d5f8cddf47 --- /dev/null +++ b/source/blender/blenkernel/BKE_unit.h @@ -0,0 +1,68 @@ +/** + * + * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BKE_UNIT_H +#define BKE_UNIT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* in all cases the value is assumed to be scaled by the user preference */ + +/* humanly readable representation of a value in units (used for button drawing) */ +void bUnit_AsString(char *str, int len_max, double value, int prec, int system, int type, int split, int pad); + +/* replace units with values, used before python button evaluation */ +int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pref, int system, int type); + +/* the size of the unit used for this value (used for calculating the ckickstep) */ +double bUnit_ClosestScalar(double value, int system, int type); + +/* base scale for these units */ +double bUnit_BaseScalar(int system, int type); + +/* loop over scales, coudl add names later */ +//double bUnit_Iter(void **unit, char **name, int system, int type); + +void bUnit_GetSystem(void **usys_pt, int *len, int system, int type); +char* bUnit_GetName(void *usys_pt, int index); +char* bUnit_GetNameDisplay(void *usys_pt, int index); +double bUnit_GetScaler(void *usys_pt, int index); + +/* aligned with PropertyUnit */ +#define B_UNIT_NONE 0 +#define B_UNIT_LENGTH 1 +#define B_UNIT_AREA 2 +#define B_UNIT_VOLUME 3 +#define B_UNIT_MASS 4 +#define B_UNIT_ROTATION 5 +#define B_UNIT_TIME 6 +#define B_UNIT_VELOCITY 7 +#define B_UNIT_ACCELERATION 8 + +#ifdef __cplusplus +} +#endif + +#endif /* BKE_UNIT_H */ diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index f6c305b202d..76e0da98f69 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -62,11 +62,6 @@ #define SHIFT3(type, a, b, c) { type tmp; tmp = a; a = c; c = b; b = tmp; } #define SHIFT4(type, a, b, c, d) { type tmp; tmp = a; a = d; d = c; c = b; b = tmp; } -/* string compare */ -#define STREQ(str, a) ( strcmp((str), (a))==0 ) -#define STREQ2(str, a, b) ( STREQ(str, a) || STREQ(str, b) ) -#define STREQ3(str, a, b, c) ( STREQ2(str, a, b) || STREQ(str, c) ) - /* min/max */ #define MIN2(x,y) ( (x)<(y) ? (x) : (y) ) #define MIN3(x,y,z) MIN2( MIN2((x),(y)) , (z) ) @@ -92,8 +87,6 @@ if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \ if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; } -#define MINSIZE(val, size) ( ((val)>=0.0) ? (((val)<(size)) ? (size): (val)) : ( ((val)>(-size)) ? (-size) : (val))) - /* some math and copy defines */ #define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; } diff --git a/source/blender/blenkernel/BKE_writeavi.h b/source/blender/blenkernel/BKE_writeavi.h index cae1f25d0d8..4ef63b069c2 100644 --- a/source/blender/blenkernel/BKE_writeavi.h +++ b/source/blender/blenkernel/BKE_writeavi.h @@ -37,13 +37,14 @@ extern "C" { /* generic blender movie support, could move to own module */ struct RenderData; -void start_avi(struct RenderData *rd, int rectx, int recty); +struct Scene; +void start_avi(struct Scene *scene, struct RenderData *rd, int rectx, int recty); void end_avi(void); void append_avi(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); void makeavistring (struct RenderData *rd, char *string); typedef struct bMovieHandle { - void (*start_movie)(struct RenderData *rd, int rectx, int recty); + void (*start_movie)(struct Scene *scene, struct RenderData *rd, int rectx, int recty); void (*append_movie)(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); void (*end_movie)(void); int (*get_next_frame)(struct RenderData *rd); /* optional */ diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index be136bd9d6d..07e0e01ef7e 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -57,8 +57,9 @@ extern "C" { struct IDProperty; struct RenderData; +struct Scene; -extern void start_ffmpeg(struct RenderData *rd, int rectx, int recty); +extern void start_ffmpeg(struct Scene *scene, struct RenderData *rd, int rectx, int recty); extern void end_ffmpeg(void); extern void append_ffmpeg(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); diff --git a/source/blender/blenkernel/BKE_writeframeserver.h b/source/blender/blenkernel/BKE_writeframeserver.h index e870cbb865d..6a38abe977f 100644 --- a/source/blender/blenkernel/BKE_writeframeserver.h +++ b/source/blender/blenkernel/BKE_writeframeserver.h @@ -33,8 +33,9 @@ extern "C" { #endif struct RenderData; +struct Scene; -extern void start_frameserver(struct RenderData *rd, int rectx, int recty); +extern void start_frameserver(struct Scene *scene, struct RenderData *rd, int rectx, int recty); extern void end_frameserver(void); extern void append_frameserver(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); extern int frameserver_loop(struct RenderData *rd); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index a2a7457545d..8d1df98c5b4 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -30,13 +30,18 @@ SET(INC . ../../../intern/guardedalloc ../../../intern/memutil ../editors/include ../blenlib ../makesdna ../render/extern/include ../../../intern/decimation/extern ../imbuf ../avi ../../../intern/elbeem/extern ../../../intern/opennl/extern - ../../../intern/iksolver/extern ../blenloader ../quicktime - ../../../extern/bullet2/src + ../../../intern/iksolver/extern ../blenloader ../nodes ../../../extern/glew/include ../gpu ../makesrna ../../../intern/smoke/extern - ../../../intern/bsp/extern + ../../../intern/bsp/extern ../blenfont + ../../../intern/audaspace/intern ${ZLIB_INC} ) +IF(WITH_BULLET) + SET(INC ${INC} ../../../extern/bullet2/src) + ADD_DEFINITIONS(-DUSE_BULLET) +ENDIF(WITH_BULLET) + IF(WITH_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) @@ -50,16 +55,10 @@ IF(WITH_DDS) ENDIF(WITH_DDS) IF(WITH_QUICKTIME) - SET(INC ${INC} ${QUICKTIME_INC}) + SET(INC ${INC} ../quicktime ${QUICKTIME_INC}) ADD_DEFINITIONS(-DWITH_QUICKTIME) ENDIF(WITH_QUICKTIME) -IF(WITH_SDL) - SET(INC ${INC} ${SDL_INC}) -ELSE(WITH_SDL) - ADD_DEFINITIONS(-DDISABLE_SDL) -ENDIF(WITH_SDL) - IF(WITH_FFMPEG) SET(INC ${INC} ${FFMPEG_INC}) ADD_DEFINITIONS(-DWITH_FFMPEG) diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 1392fd75f30..accaaef1e2f 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('intern/*.c') -incs = '. #/intern/guardedalloc #/intern/memutil ../editors/include ../blenlib ../makesdna' +incs = '. #/intern/guardedalloc #/intern/memutil ../editors/include ../blenlib ../blenfont ../makesdna' incs += ' ../render/extern/include #/intern/decimation/extern ../makesrna' incs += ' ../imbuf ../avi #/intern/elbeem/extern ../nodes' incs += ' #/intern/iksolver/extern ../blenloader' @@ -11,6 +11,7 @@ incs += ' #/extern/bullet2/src' incs += ' #/intern/opennl/extern #/intern/bsp/extern' incs += ' ../gpu #/extern/glew/include' incs += ' #/intern/smoke/extern' +incs += ' #/intern/audaspace/intern' incs += ' ' + env['BF_OPENGL_INC'] incs += ' ' + env['BF_ZLIB_INC'] @@ -51,7 +52,7 @@ if env['WITH_BF_QUICKTIME']: incs += ' ' + env['BF_QUICKTIME_INC'] if env['WITH_BF_BULLET']: - defs.append('WITH_BULLET') + defs.append('USE_BULLET') if env['BF_NO_ELBEEM']: defs.append('DISABLE_ELBEEM') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 090f256ab9f..84cccd8b939 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -72,6 +72,7 @@ #include "BKE_modifier.h" #include "BKE_mesh.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_subsurf.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -2076,7 +2077,7 @@ static void clear_mesh_caches(Object *ob) static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) { Object *obact = scene->basact?scene->basact->object:NULL; - int editing = (FACESEL_PAINT_TEST)|(G.f & G_PARTICLEEDIT); + int editing = paint_facesel_test(ob)|(ob && ob->mode & OB_MODE_PARTICLE_EDIT); int needMapping = editing && (ob==obact); float min[3], max[3]; diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile index f60bdffa282..d6d41d6579e 100644 --- a/source/blender/blenkernel/intern/Makefile +++ b/source/blender/blenkernel/intern/Makefile @@ -42,6 +42,7 @@ CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include CPPFLAGS += -I../../../../intern/memutil +CPPFLAGS += -I$(NAN_AUDASPACE)/include # Reference to the types in makesdna and imbuf CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../makesrna @@ -50,6 +51,7 @@ CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../blenlib CPPFLAGS += -I../../blenloader CPPFLAGS += -I../../python +CPPFLAGS += -I../../blenfont # also avi is used CPPFLAGS += -I../../avi CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 7278fee5ab8..5eaf2133515 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -71,7 +71,7 @@ static short id_has_animdata (ID *id) switch (GS(id->name)) { /* has AnimData */ case ID_OB: - case ID_CU: + case ID_MB: case ID_CU: case ID_KE: case ID_PA: case ID_MA: case ID_TE: case ID_NT: @@ -276,7 +276,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho if (name) BLI_snprintf(ks->name, 64, name); else - strcpy(ks->name, "Keying Set"); + strcpy(ks->name, "KeyingSet"); ks->flag= flag; ks->keyingflag= keyingflag; @@ -285,7 +285,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho BLI_addtail(list, ks); /* make sure KeyingSet has a unique name (this helps with identification) */ - BLI_uniquename(list, ks, "Keying Set", ' ', offsetof(KeyingSet, name), 64); + BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, name), 64); /* return new KeyingSet for further editing */ return ks; @@ -342,6 +342,21 @@ void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name BLI_addtail(&ks->paths, ksp); } +/* Copy all KeyingSets in the given list */ +void BKE_keyingsets_copy(ListBase *newlist, ListBase *list) +{ + KeyingSet *ksn; + KS_Path *kspn; + + BLI_duplicatelist(newlist, list); + + for(ksn=newlist->first; ksn; ksn=ksn->next) { + BLI_duplicatelist(&ksn->paths, &ksn->paths); + + for(kspn=ksn->paths.first; kspn; kspn=kspn->next) + kspn->rna_path= MEM_dupallocN(kspn->rna_path); + } +} /* Freeing Tools --------------------------- */ @@ -1202,6 +1217,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) NlaTrack *nlt; short track_index=0; + short has_strips = 0; ListBase estrips= {NULL, NULL}; ListBase echannels= {NULL, NULL}; @@ -1223,6 +1239,12 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) if (nlt->flag & NLATRACK_MUTED) continue; + /* if this track has strips (but maybe they won't be suitable), set has_strips + * - used for mainly for still allowing normal action evaluation... + */ + if (nlt->strips.first) + has_strips= 1; + /* otherwise, get strip to evaluate for this channel */ nes= nlastrips_ctime_get_strip(&estrips, &nlt->strips, track_index, ctime); if (nes) nes->track= nlt; @@ -1232,23 +1254,33 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) * - only do this if we're not exclusively evaluating the 'solo' NLA-track */ if ((adt->action) && !(adt->flag & ADT_NLA_SOLO_TRACK)) { - /* make dummy NLA strip, and add that to the stack */ - memset(&dummy_strip, 0, sizeof(NlaStrip)); - dummy_trackslist.first= dummy_trackslist.last= &dummy_strip; - - dummy_strip.act= adt->action; - dummy_strip.remap= adt->remap; - - calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1); - dummy_strip.start = dummy_strip.actstart; - dummy_strip.end = (IS_EQ(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend); - - dummy_strip.blendmode= adt->act_blendmode; - dummy_strip.extendmode= adt->act_extendmode; - dummy_strip.influence= adt->act_influence; - - /* add this to our list of evaluation strips */ - nlastrips_ctime_get_strip(&estrips, &dummy_trackslist, -1, ctime); + /* if there are strips, evaluate action as per NLA rules */ + if (has_strips) { + /* make dummy NLA strip, and add that to the stack */ + memset(&dummy_strip, 0, sizeof(NlaStrip)); + dummy_trackslist.first= dummy_trackslist.last= &dummy_strip; + + dummy_strip.act= adt->action; + dummy_strip.remap= adt->remap; + + // FIXME: what happens when we want to included F-Modifier access? + calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1); + dummy_strip.start = dummy_strip.actstart; + dummy_strip.end = (IS_EQ(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend); + + dummy_strip.blendmode= adt->act_blendmode; + dummy_strip.extendmode= adt->act_extendmode; + dummy_strip.influence= adt->act_influence; + + /* add this to our list of evaluation strips */ + nlastrips_ctime_get_strip(&estrips, &dummy_trackslist, -1, ctime); + } + else { + /* special case - evaluate as if there isn't any NLA data */ + // TODO: this is really just a stop-gap measure... + animsys_evaluate_action(ptr, adt->action, adt->remap, ctime); + return; + } } /* only continue if there are strips to evaluate */ @@ -1442,6 +1474,9 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) // TODO: we probably need the same hack as for curves (ctime-hack) EVAL_ANIM_IDS(main->key.first, ADT_RECALC_ANIM); + /* metaballs */ + EVAL_ANIM_IDS(main->mball.first, ADT_RECALC_ANIM); + /* curves */ /* we need to perform a special hack here to ensure that the ctime * value of the curve gets set in case there's no animation for that diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 2728aa30e6e..746dc6c59cc 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -176,8 +176,6 @@ void pushpop_test() void free_blender(void) { /* samples are in a global list..., also sets G.main->sound->sample NULL */ - sound_free_all_samples(); - free_main(G.main); G.main= NULL; @@ -228,7 +226,7 @@ static void clear_global(void) G.main= NULL; - G.f &= ~(G_WEIGHTPAINT + G_VERTEXPAINT + G_FACESELECT + G_PARTICLEEDIT); + G.f &= ~(G_FACESELECT); } /* make sure path names are correct for OS */ @@ -330,9 +328,6 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) MEM_freeN(bfd->user); } - /* samples is a global list... */ - sound_free_all_samples(); - /* case G_FILE_NO_UI or no screens in file */ if(mode) { /* leave entire context further unaltered? */ diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 30a35cbe91c..a7b5a16d924 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -35,6 +35,7 @@ #include "DNA_brush_types.h" #include "DNA_color_types.h" #include "DNA_image_types.h" +#include "DNA_object_types.h" #include "DNA_texture_types.h" #include "DNA_scene_types.h" #include "DNA_windowmanager_types.h" @@ -50,6 +51,7 @@ #include "BKE_image.h" #include "BKE_library.h" #include "BKE_main.h" +#include "BKE_paint.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -61,7 +63,7 @@ /* Datablock add/copy/free/make_local */ -Brush *add_brush(char *name) +Brush *add_brush(const char *name) { Brush *brush; @@ -73,6 +75,8 @@ Brush *add_brush(char *name) brush->alpha= 0.2f; brush->size= 25; brush->spacing= 10.0f; + brush->smooth_stroke_radius= 75; + brush->smooth_stroke_factor= 0.9; brush->rate= 0.1f; brush->innerradius= 0.5f; brush->clone.alpha= 0.5; @@ -152,7 +156,7 @@ void make_local_brush(Brush *brush) } for(scene= G.main->scene.first; scene; scene=scene->id.next) - if(scene->toolsettings->imapaint.brush==brush) { + if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) { if(scene->id.lib) lib= 1; else local= 1; } @@ -174,9 +178,9 @@ void make_local_brush(Brush *brush) brushn->id.flag |= LIB_FAKEUSER; for(scene= G.main->scene.first; scene; scene=scene->id.next) - if(scene->toolsettings->imapaint.brush==brush) + if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) if(scene->id.lib==0) { - scene->toolsettings->imapaint.brush= brushn; + paint_brush_set(&scene->toolsettings->imapaint.paint, brushn); brushn->id.us++; brush->id.us--; } @@ -185,20 +189,7 @@ void make_local_brush(Brush *brush) /* Library Operations */ -Brush **current_brush_source(Scene *sce) -{ - if(G.f & G_SCULPTMODE) - return &sce->toolsettings->sculpt->brush; - else if(G.f & G_VERTEXPAINT) - return &sce->toolsettings->vpaint->brush; - else if(G.f & G_WEIGHTPAINT) - return &sce->toolsettings->wpaint->brush; - else if(G.f & G_TEXTUREPAINT) - return &sce->toolsettings->imapaint.brush; - return NULL; -} - -int brush_set_nr(Brush **current_brush, int nr) +int brush_set_nr(Brush **current_brush, int nr, const char *name) { ID *idtest, *id; @@ -207,7 +198,7 @@ int brush_set_nr(Brush **current_brush, int nr) if(idtest==0) { /* new brush */ if(id) idtest= (ID *)copy_brush((Brush *)id); - else idtest= (ID *)add_brush("Brush"); + else idtest= (ID *)add_brush(name); idtest->us--; } if(idtest!=id) { @@ -300,6 +291,13 @@ void brush_curve_preset(Brush *b, BrushCurvePreset preset) curvemapping_changed(b->curve, 0); } +static MTex *brush_active_texture(Brush *brush) +{ + if(brush && brush->texact >= 0) + return brush->mtex[brush->texact]; + return NULL; +} + int brush_texture_set_nr(Brush *brush, int nr) { ID *idtest, *id=NULL; @@ -374,10 +372,10 @@ int brush_clone_image_delete(Brush *brush) return 0; } -void brush_check_exists(Brush **brush) +void brush_check_exists(Brush **brush, const char *name) { if(*brush==NULL) - brush_set_nr(brush, 1); + brush_set_nr(brush, 1, name); } /* Brush Sampling */ @@ -1077,8 +1075,11 @@ void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight) original_value = br->size * size_weight; else if(mode == WM_RADIALCONTROL_STRENGTH) original_value = br->alpha; - else if(mode == WM_RADIALCONTROL_ANGLE) - original_value = br->rot; + else if(mode == WM_RADIALCONTROL_ANGLE) { + MTex *mtex = brush_active_texture(br); + if(mtex) + original_value = mtex->rot; + } RNA_float_set(op->ptr, "initial_value", original_value); op->customdata = brush_gen_radial_control_imbuf(br); @@ -1094,8 +1095,11 @@ int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight) br->size = new_value * size_weight; else if(mode == WM_RADIALCONTROL_STRENGTH) br->alpha = new_value; - else if(mode == WM_RADIALCONTROL_ANGLE) - br->rot = new_value * conv; + else if(mode == WM_RADIALCONTROL_ANGLE) { + MTex *mtex = brush_active_texture(br); + if(mtex) + mtex->rot = new_value * conv; + } return OPERATOR_FINISHED; } diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 089dafeb8c7..3acaaecb1e8 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -340,92 +340,6 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, int moving) } } -int modifiers_indexInObject(Object *ob, ModifierData *md_seek); -static void cloth_write_state(int index, void *cloth_v, float *data) -{ - Cloth *cloth= cloth_v; - ClothVertex *vert = cloth->verts + index; - - memcpy(data, vert->x, 3 * sizeof(float)); - memcpy(data + 3, vert->xconst, 3 * sizeof(float)); - memcpy(data + 6, vert->v, 3 * sizeof(float)); -} -static void cloth_read_state(int index, void *cloth_v, float *data) -{ - Cloth *cloth= cloth_v; - ClothVertex *vert = cloth->verts + index; - - memcpy(vert->x, data, 3 * sizeof(float)); - memcpy(vert->xconst, data + 3, 3 * sizeof(float)); - memcpy(vert->v, data + 6, 3 * sizeof(float)); -} -static void cloth_cache_interpolate(int index, void *cloth_v, float frs_sec, float cfra, float cfra1, float cfra2, float *data1, float *data2) -{ - Cloth *cloth= cloth_v; - ClothVertex *vert = cloth->verts + index; - ParticleKey keys[4]; - float dfra; - - if(cfra1 == cfra2) { - cloth_read_state(index, cloth, data1); - return; - } - - memcpy(keys[1].co, data1, 3 * sizeof(float)); - memcpy(keys[1].vel, data1 + 6, 3 * sizeof(float)); - - memcpy(keys[2].co, data2, 3 * sizeof(float)); - memcpy(keys[2].vel, data2 + 6, 3 * sizeof(float)); - - dfra = cfra2 - cfra1; - - VecMulf(keys[1].vel, dfra); - VecMulf(keys[2].vel, dfra); - - psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1); - - VecMulf(keys->vel, 1.0f / dfra); - - memcpy(vert->x, keys->co, 3 * sizeof(float)); - memcpy(vert->v, keys->vel, 3 * sizeof(float)); - - /* not sure what to do with this - jahka */ - memcpy(vert->xconst, data1 + 3, 3 * sizeof(float)); -} -void cloth_write_cache(Object *ob, ClothModifierData *clmd, int cfra) -{ - PTCacheWriter writer; - PTCacheID pid; - - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - - writer.calldata = clmd->clothObject; - writer.cfra = cfra; - writer.set_elem = cloth_write_state; - writer.pid = &pid; - writer.totelem = clmd->clothObject->numverts; - - BKE_ptcache_write_cache(&writer); -} - -int cloth_read_cache(Scene *scene, Object *ob, ClothModifierData *clmd, float cfra, int *old_framenr) -{ - PTCacheReader reader; - PTCacheID pid; - - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - - reader.calldata = clmd->clothObject; - reader.cfra = cfra; - reader.interpolate_elem = cloth_cache_interpolate; - reader.old_frame = old_framenr; - reader.pid = &pid; - reader.scene = scene; - reader.set_elem = cloth_read_state; - reader.totelem = clmd->clothObject->numverts; - - return BKE_ptcache_read_cache(&reader); -} void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr) { PTCacheID pid; @@ -512,7 +426,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, PTCacheID pid; float timescale; int framedelta, framenr, startframe, endframe; - int cache_result, old_framenr; + int cache_result; clmd->scene= scene; /* nice to pass on later :) */ framenr= (int)scene->r.cfra; @@ -583,7 +497,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, return result; /* try to read from cache */ - cache_result = cloth_read_cache(scene, ob, clmd, framenr, &old_framenr); + cache_result = BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec); if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { cache->flag |= PTCACHE_SIMULATION_VALID; @@ -600,7 +514,6 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, implicit_set_positions(clmd); cache->flag |= PTCACHE_SIMULATION_VALID; - cache->simframe= old_framenr; } else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) { /* if baked and nothing in cache, do nothing */ @@ -624,7 +537,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, else { /* if on second frame, write cache for first frame */ if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) - cloth_write_cache(ob, clmd, startframe); + BKE_ptcache_write_cache(&pid, startframe); clmd->sim_parms->timescale *= framenr - cache->simframe; @@ -638,7 +551,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, cache->last_exact= 0; } else - cloth_write_cache(ob, clmd, framenr); + BKE_ptcache_write_cache(&pid, framenr); cloth_to_object (ob, clmd, result); } diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index c122145c98f..37e9c93a108 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -591,7 +591,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap ClothModifierData *clmd = ( ClothModifierData * ) md1; CollisionModifierData *collmd = ( CollisionModifierData * ) md2; MFace *face1=NULL, *face2 = NULL; -#ifdef WITH_BULLET +#ifdef USE_BULLET ClothVertex *verts1 = clmd->clothObject->verts; #endif double distance = 0; @@ -669,7 +669,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap break; } -#ifdef WITH_BULLET +#ifdef USE_BULLET // calc distance + normal distance = plNearestPoints ( verts1[collpair->ap1].txold, verts1[collpair->ap2].txold, verts1[collpair->ap3].txold, collmd->current_x[collpair->bp1].co, collmd->current_x[collpair->bp2].co, collmd->current_x[collpair->bp3].co, collpair->pa,collpair->pb,collpair->vector ); diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 2280ec71f7a..26f9245abc7 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -68,33 +68,33 @@ void gamma_correct_rec709(float *c, float gamma) { /* Rec. 709 gamma correction. */ - float cc = 0.018f; + const float cc = 0.018f; if (*c < cc) - *c *= ((1.099f * (float)pow(cc, gamma)) - 0.099f) / cc; + *c *= ((1.099f * (float)powf(cc, gamma)) - 0.099f) * (1.0f/cc); else - *c = (1.099f * (float)pow(*c, gamma)) - 0.099f; + *c = (1.099f * (float)powf(*c, gamma)) - 0.099f; } void gamma_correct(float *c, float gamma) { - *c = pow((*c), gamma); + *c = powf((*c), gamma); } float srgb_to_linearrgb(float c) { if (c < 0.04045f) - return (c < 0.f)?0.f:c / 12.92; + return (c < 0.0f)? 0.0f: c*(1.0f/12.92f); else - return pow((c + 0.055)/1.055, 2.4); + return powf((c + 0.055f)*(1.0f/1.055f), 2.4f); } float linearrgb_to_srgb(float c) { - if (c < 0.0031308) - return (c < 0.f)?0.f:c * 12.92; + if (c < 0.0031308f) + return (c < 0.0f)? 0.0f: c * 12.92f; else - return 1.055 * pow(c, 1.0/2.4) - 0.055; + return 1.055f * powf(c, 1.0f/2.4f) - 0.055f; } /* utility function convert an RGB triplet from sRGB to linear RGB color space */ diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 78c29a96bff..bbfe077c15e 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -34,6 +34,7 @@ #include "DNA_space_types.h" #include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" +#include "DNA_object_types.h" #include "RNA_access.h" @@ -43,6 +44,7 @@ #include "BKE_context.h" #include "BKE_main.h" #include "BKE_screen.h" +#include "BKE_global.h" #include @@ -217,7 +219,10 @@ struct ARegion *CTX_wm_menu(const bContext *C) struct ReportList *CTX_wm_reports(const bContext *C) { - return &(C->wm.manager->reports); + if (C->wm.manager) + return &(C->wm.manager->reports); + + return NULL; } View3D *CTX_wm_view3d(const bContext *C) @@ -333,6 +338,13 @@ struct SpaceInfo *CTX_wm_space_info(const bContext *C) return NULL; } +struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C) +{ + if(C->wm.area && C->wm.area->spacetype==SPACE_USERPREF) + return C->wm.area->spacedata.first; + return NULL; +} + void CTX_wm_manager_set(bContext *C, wmWindowManager *wm) { C->wm.manager= wm; @@ -656,6 +668,69 @@ Scene *CTX_data_scene(const bContext *C) return C->data.scene; } +int CTX_data_mode_enum(const bContext *C) +{ + Object *obedit= CTX_data_edit_object(C); + + if(obedit) { + switch(obedit->type) { + case OB_MESH: + return CTX_MODE_EDIT_MESH; + case OB_CURVE: + return CTX_MODE_EDIT_CURVE; + case OB_SURF: + return CTX_MODE_EDIT_SURFACE; + case OB_FONT: + return CTX_MODE_EDIT_TEXT; + case OB_ARMATURE: + return CTX_MODE_EDIT_ARMATURE; + case OB_MBALL: + return CTX_MODE_EDIT_METABALL; + case OB_LATTICE: + return CTX_MODE_EDIT_LATTICE; + } + } + else { + Object *ob = CTX_data_active_object(C); + + if(ob) { + if(ob->mode & OB_MODE_POSE) return CTX_MODE_POSE; + else if(ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT; + else if(ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT; + else if(ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX; + else if(ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE; + else if(ob->mode & OB_MODE_PARTICLE_EDIT) return CTX_MODE_PARTICLE; + } + } + + return CTX_MODE_OBJECT; +} + + +/* would prefer if we can use the enum version below over this one - Campbell */ +/* must be aligned with above enum */ +static char *data_mode_strings[] = { + "mesh_edit", + "curve_edit", + "surface_edit", + "text_edit", + "armature_edit", + "mball_edit", + "lattice_edit", + "posemode", + "sculpt_mode", + "weightpaint", + "vertexpaint", + "texturepaint", + "particlemode", + "objectmode", + 0 +}; +char *CTX_data_mode_string(const bContext *C) +{ + return data_mode_strings[CTX_data_mode_enum(C)]; +} + void CTX_data_scene_set(bContext *C, Scene *scene) { C->data.scene= scene; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index cdf4b90cee1..069129c15da 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -315,6 +315,9 @@ static void init_fastshade_shadeinput(Render *re) static Render *fastshade_get_render(Scene *scene) { + // XXX 2.5: this crashes combined with previewrender + // due to global R so disabled for now +#if 0 /* XXX ugly global still, but we can't do preview while rendering */ if(G.rendering==0) { @@ -326,6 +329,7 @@ static Render *fastshade_get_render(Scene *scene) } return re; } +#endif return NULL; } diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 54366aadd92..3cff82f522a 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -167,7 +167,7 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen) for (i=newlen; ilen; i++) { IDP_FreeProperty(GETPROP(prop, i)); } - memcpy(newarr, prop->data.pointer, newlen*prop->len*sizeof(IDProperty)); + memcpy(newarr, prop->data.pointer, newlen*sizeof(IDProperty)); } if(prop->data.pointer) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 4a355640d8b..1af0d37d58f 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -73,6 +73,8 @@ //XXX #include "BIF_editseq.h" +#include "BLF_api.h" + #include "PIL_time.h" #include "RE_pipeline.h" @@ -978,7 +980,6 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) if (do_prefix) strcpy(stamp_data->file, "File "); else strcpy(stamp_data->file, ""); } - stamp_data->note[0] = '\0'; } else { stamp_data->file[0] = '\0'; } @@ -1046,8 +1047,8 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) if (scene->r.stamp & R_STAMP_FRAME) { char format[32]; - if (do_prefix) sprintf(format, "Frame %%0%di\n", 1 + (int) log10(scene->r.efra)); - else sprintf(format, "%%0%di\n", 1 + (int) log10(scene->r.efra)); + if (do_prefix) sprintf(format, "Frame %%0%di", 1 + (int) log10(scene->r.efra)); + else sprintf(format, "%%0%di", 1 + (int) log10(scene->r.efra)); sprintf (stamp_data->frame, format, scene->r.cfra); } else { stamp_data->frame[0] = '\0'; @@ -1083,131 +1084,172 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } } +// XXX - Bad level call. +extern int datatoc_bmonofont_ttf_size; +extern char datatoc_bmonofont_ttf[]; + +// XXX - copied from text_font_begin +static void stamp_font_begin(int size) +{ + static int mono= -1; + + if (mono == -1) + mono= BLF_load_mem("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); + + BLF_set(mono); + BLF_aspect(1.0); + BLF_size(size, 72); +} + void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels) { -#if 0 -// XXX -// This go back when BLF_draw_buffer is implemented - Diego struct StampData stamp_data; - - int x=1,y=1; - int font_height; - int text_width; - int text_pad; - struct BMF_Font *font; + float w, h, pad; + int x, y; if (!rect && !rectf) return; stampdata(scene, &stamp_data, 1); - - switch (scene->r.stamp_font_id) { - case 1: /* tiny */ - font = BMF_GetFont(BMF_kHelveticaBold8); - break; - case 2: /* small */ - font = BMF_GetFont(BMF_kHelveticaBold10); - break; - case 3: /* medium */ - font = BMF_GetFont(BMF_kScreen12); - break; - case 0: /* large - default */ - font = BMF_GetFont(BMF_kScreen15); - break; - case 4: /* huge */ - font = BMF_GetFont(BMF_kHelveticaBold14); - break; - default: - font = NULL; - break; - } - - font_height = BMF_GetFontHeight(font); - /* All texts get halfspace+1 pixel on each side and 1 pix - above and below as padding against their backing rectangles */ - text_pad = BMF_GetStringWidth(font, " "); - - x = 1; /* Inits for everyone, text position, so 1 for padding, not 0 */ - y = height - font_height - 1; /* Also inits for everyone, notice padding pixel */ - + stamp_font_begin(12); + + BLF_buffer(rectf, rect, width, height, channels); + BLF_buffer_col(scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); + pad= BLF_width("--"); + + x= 0; + y= height; + if (stamp_data.file[0]) { /* Top left corner */ - text_width = BMF_GetStringWidth(font, stamp_data.file); - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.file, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); - y -= font_height+2; /* Top and bottom 1 pix padding each */ + BLF_width_and_height(stamp_data.file, &w, &h); + y -= h; + + /* also a little of space to the background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, w+3, y+h+3); + + /* and draw the text. */ + BLF_position(x, y, 0.0); + BLF_draw_buffer(stamp_data.file); + + /* the extra pixel for background. */ + y -= 4; } /* Top left corner, below File */ if (stamp_data.note[0]) { - text_width = BMF_GetStringWidth(font, stamp_data.note); - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.note, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); - y -= font_height+2; /* Top and bottom 1 pix padding each */ + BLF_width_and_height(stamp_data.note, &w, &h); + y -= h; + + /* and space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-2, w+3, y+h+2); + + BLF_position(x, y+1, 0.0); + BLF_draw_buffer(stamp_data.note); + + /* the extra pixel for background. */ + y -= 4; } /* Top left corner, below File (or Note) */ if (stamp_data.date[0]) { - text_width = BMF_GetStringWidth(font, stamp_data.date); - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.date, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); + BLF_width_and_height(stamp_data.date, &w, &h); + y -= h; + + /* and space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+3); + + BLF_position(x, y, 0.0); + BLF_draw_buffer(stamp_data.date); } + x= 0; + y= 0; + /* Bottom left corner, leaving space for timing */ if (stamp_data.marker[0]) { - x = 1; - y = font_height+2+1; /* 2 for padding in TIME|FRAME fields below and 1 for padding in this one */ - text_width = BMF_GetStringWidth(font, stamp_data.marker); - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.marker, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); + BLF_width_and_height(stamp_data.marker, &w, &h); + + /* extra space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, w+2, y+h+3); + + /* and pad the text. */ + BLF_position(x, y+3, 0.0); + BLF_draw_buffer(stamp_data.marker); + + /* space width. */ + x += w + pad; } /* Left bottom corner */ if (stamp_data.time[0]) { - x = 1; - y = 1; - text_width = BMF_GetStringWidth(font, stamp_data.time); - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.time, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); - x += text_width+text_pad+2; /* Both sides have 1 pix additional padding each */ + BLF_width_and_height(stamp_data.time, &w, &h); + + /* extra space for background */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); + + /* and pad the text. */ + BLF_position(x, y+3, 0.0); + BLF_draw_buffer(stamp_data.time); + + /* space width. */ + x += w + pad; } if (stamp_data.frame[0]) { - text_width = BMF_GetStringWidth(font, stamp_data.frame); - /* Left bottom corner (after SMPTE if exists) */ - if (!stamp_data.time[0]) x = 1; - y = 1; - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.frame, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); + BLF_width_and_height(stamp_data.frame, &w, &h); + + /* extra space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); + + /* and pad the text. */ + BLF_position(x, y+3, 0.0); + + BLF_draw_buffer(stamp_data.frame); + + /* space width. */ + x += w + pad; } if (stamp_data.camera[0]) { - text_width = BMF_GetStringWidth(font, stamp_data.camera); - /* Center of bottom edge */ - x = (width/2) - (BMF_GetStringWidth(font, stamp_data.camera)/2); - y = 1; - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.camera, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); + BLF_width_and_height(stamp_data.camera, &w, &h); + + /* extra space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); + BLF_position(x, y+3, 0.0); + BLF_draw_buffer(stamp_data.camera); } if (stamp_data.scene[0]) { - text_width = BMF_GetStringWidth(font, stamp_data.scene); - /* Bottom right corner */ - x = width - (text_width+1+text_pad); - y = 1; - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.scene, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); + BLF_width_and_height(stamp_data.scene, &w, &h); + + /* Bottom right corner, with an extra space because blenfont is too strict! */ + x= width - w - 2; + + /* extra space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+3, y+h+3); + + /* and pad the text. */ + BLF_position(x, y+3, 0.0); + BLF_draw_buffer(stamp_data.scene); } if (stamp_data.strip[0]) { - text_width = BMF_GetStringWidth(font, stamp_data.strip); - /* Top right corner */ - x = width - (text_width+1+text_pad); - y = height - font_height - 1; - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1); - BMF_DrawStringBuf(font, stamp_data.strip, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels); + BLF_width_and_height(stamp_data.scene, &w, &h); + + /* Top right corner, with an extra space because blenfont is too strict! */ + x= width - w - pad; + y= height - h; + + /* extra space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, x+w+pad, y+h+3); + + BLF_position(x, y, 0.0); + BLF_draw_buffer(stamp_data.strip); } -#endif // 0 XXX + + /* cleanup the buffer. */ + BLF_buffer(NULL, NULL, 0, 0, 0); } void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index a72f26f6157..2f0e0931588 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -160,7 +160,7 @@ static AdrBit2Path ma_mode_bits[]= { // {MA_SHADOW, "shadow", 0}, // {MA_SHLESS, "shadeless", 0}, // ... - {MA_RAYTRANSP, "raytrace_transparency.enabled", 0}, + {MA_RAYTRANSP, "transparency", 0}, {MA_RAYMIRROR, "raytrace_mirror.enabled", 0}, // {MA_HALO, "type", MA_TYPE_HALO} }; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 90ab4e05d44..3c8bf9200f8 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -567,7 +567,7 @@ void free_libblock(ListBase *lb, void *idv) //XXX free_script((Script *)id); break; case ID_SO: - sound_free_sound((bSound *)id); + sound_free((bSound*)id); break; case ID_GR: free_group((Group *)id); @@ -1030,6 +1030,20 @@ static void lib_indirect_test_id(ID *id) } } +void tag_main(struct Main *mainvar, int tag) +{ + ListBase *lbarray[MAX_LIBARRAY]; + ID *id; + int a; + + a= set_listbasepointers(mainvar, lbarray); + while(a--) { + for(id= lbarray[a]->first; id; id= id->next) { + if(tag) id->flag |= LIB_DOIT; + else id->flag &= ~LIB_DOIT; + } + } +} /* if lib!=NULL, only all from lib local */ void all_local(Library *lib, int untagged_only) diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 08a19cada7d..50db2bfe706 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -170,7 +170,7 @@ void init_material(Material *ma) ma->sss_front= 1.0f; ma->sss_back= 1.0f; - ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RADIO|MA_RAYBIAS|MA_TANGENT_STR; + ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR; ma->preview = NULL; } @@ -678,9 +678,6 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) if(needtang) ma->mode |= MA_NORMAP_TANG; else ma->mode &= ~MA_NORMAP_TANG; - if(r_mode & R_RADIO) - if(ma->mode & MA_RADIO) needuv= 1; - if(ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) { needuv= 1; if(r_mode & R_OSA) ma->texco |= TEXCO_OSA; /* for texfaces */ @@ -689,7 +686,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) /* since the raytracer doesnt recalc O structs for each ray, we have to preset them all */ if(r_mode & R_RAYTRACE) { - if(ma->mode & (MA_RAYMIRROR|MA_RAYTRANSP|MA_SHADOW_TRA)) { + if((ma->mode & (MA_RAYMIRROR|MA_SHADOW_TRA)) || ((ma->mode && MA_TRANSP) && (ma->mode & MA_RAYTRANSP))) { ma->texco |= NEED_UV|TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM; if(r_mode & R_OSA) ma->texco |= TEXCO_OSA; } diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 74d56e81a87..3ca7dac4bc9 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -55,6 +55,7 @@ #include "BKE_main.h" /* #include "BKE_object.h" */ +#include "BKE_animsys.h" #include "BKE_scene.h" #include "BKE_blender.h" #include "BKE_library.h" @@ -68,10 +69,10 @@ /* Global variables */ -float thresh= 0.6f; -int totelem=0; -MetaElem **mainb; -octal_tree *metaball_tree = NULL; +static float thresh= 0.6f; +static int totelem=0; +static MetaElem **mainb; +static octal_tree *metaball_tree = NULL; /* Functions */ void unlink_mball(MetaBall *mb) @@ -90,6 +91,7 @@ void free_mball(MetaBall *mb) { unlink_mball(mb); + if(mb->adt) BKE_free_animdata((ID *)mb); if(mb->mat) MEM_freeN(mb->mat); if(mb->bb) MEM_freeN(mb->bb); BLI_freelistN(&mb->elems); @@ -278,6 +280,47 @@ int is_basis_mball(Object *ob) return 1; } +/* \brief copy some properties from object to other metaball object with same base name + * + * When some properties (wiresize, threshold, update flags) of metaball are changed, then this properties + * are copied to all metaballs in same "group" (metaballs with same base name: MBall, + * MBall.001, MBall.002, etc). The most important is to copy properties to the base metaball, + * because this metaball influence polygonisation of metaballs. */ +void copy_mball_properties(Scene *scene, Object *active_object) +{ + Base *base; + Object *ob; + MetaBall *active_mball = (MetaBall*)active_object->data; + int basisnr, obnr; + char basisname[32], obname[32]; + + splitIDname(active_object->id.name+2, basisname, &basisnr); + + /* XXX recursion check, see scene.c, just too simple code this next_object() */ + if(F_ERROR==next_object(scene, 0, 0, 0)) + return; + + while(next_object(scene, 1, &base, &ob)) { + if (ob->type==OB_MBALL) { + if(ob!=active_object){ + splitIDname(ob->id.name+2, obname, &obnr); + + /* Object ob has to be in same "group" ... it means, that it has to have + * same base of its name */ + if(strcmp(obname, basisname)==0){ + MetaBall *mb= ob->data; + + /* Copy properties from selected/edited metaball */ + mb->wiresize= active_mball->wiresize; + mb->rendersize= active_mball->rendersize; + mb->thresh= active_mball->thresh; + mb->flag= active_mball->flag; + } + } + } + } +} + /** \brief This function finds basic MetaBall. * * Basic MetaBall doesn't include any number at the end of diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index d86d563aaa2..53d1baa5c9c 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5844,7 +5844,7 @@ static void smokeModifier_deformVerts( CDDM_apply_vert_coords(dm, vertexCos); CDDM_calc_normals(dm); - smokeModifier_do(smd, md->scene, ob, dm); + smokeModifier_do(smd, md->scene, ob, dm, useRenderParams, isFinalCalc); if(dm != derivedData) dm->release(dm); } @@ -5858,8 +5858,7 @@ static void smokeModifier_updateDepgraph( ModifierData *md, DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) { - SmokeModifierData *smd = (SmokeModifierData *) md; - /* + /*SmokeModifierData *smd = (SmokeModifierData *) md; if(smd && (smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { if(smd->domain->fluid_group) @@ -5893,7 +5892,7 @@ static void clothModifier_initData(ModifierData *md) clmd->sim_parms = MEM_callocN(sizeof(ClothSimSettings), "cloth sim parms"); clmd->coll_parms = MEM_callocN(sizeof(ClothCollSettings), "cloth coll parms"); - clmd->point_cache = BKE_ptcache_add(); + clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches); /* check for alloc failing */ if(!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache) @@ -5972,12 +5971,13 @@ static void clothModifier_copyData(ModifierData *md, ModifierData *target) MEM_freeN(tclmd->sim_parms); if(tclmd->coll_parms) MEM_freeN(tclmd->coll_parms); - if(tclmd->point_cache) - BKE_ptcache_free(tclmd->point_cache); + + BKE_ptcache_free_list(&tclmd->ptcaches); + tclmd->point_cache = NULL; tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms); tclmd->coll_parms = MEM_dupallocN(clmd->coll_parms); - tclmd->point_cache = BKE_ptcache_copy(clmd->point_cache); + tclmd->point_cache = BKE_ptcache_copy_list(&tclmd->ptcaches, &clmd->ptcaches); tclmd->clothObject = NULL; } @@ -6001,8 +6001,9 @@ static void clothModifier_freeData(ModifierData *md) MEM_freeN(clmd->sim_parms); if(clmd->coll_parms) MEM_freeN(clmd->coll_parms); - if(clmd->point_cache) - BKE_ptcache_free(clmd->point_cache); + + BKE_ptcache_free_list(&clmd->ptcaches); + clmd->point_cache = NULL; } } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 22a471f6521..e91f318adad 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -220,6 +220,7 @@ static void multires_subdisp(DerivedMesh *orig, Mesh *me, DerivedMesh *final, in int skip = multires_side_tot[totlvl - lvl] - 1; int i, j, k; + memset(&mmd_sub, 0, sizeof(MultiresModifierData)); mmd_sub.lvl = mmd_sub.totlvl = totlvl; mrdm = multires_dm_create_from_derived(&mmd_sub, orig, me, 0, 0); @@ -465,6 +466,7 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int dista MultiresModifierData mmd_sub; orig = CDDM_from_mesh(me, NULL); + memset(&mmd_sub, 0, sizeof(MultiresModifierData)); mmd_sub.lvl = mmd_sub.totlvl = mmd->lvl; mrdm = multires_dm_create_from_derived(&mmd_sub, orig, me, 0, 0); totsubvert = mrdm->getNumVerts(mrdm); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 0f42ba0d2e2..bd6919dc115 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -950,9 +950,6 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id) if(ntype->initfunc!=NULL) ntype->initfunc(node); - if(type==TEX_NODE_OUTPUT) - ntreeTexAssignIndex(ntree, node); - nodeAddSockets(node, ntype); return node; @@ -1021,9 +1018,6 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal) nnode->new_node= NULL; nnode->preview= NULL; - if(node->type==TEX_NODE_OUTPUT) - ntreeTexAssignIndex(ntree, node); - return nnode; } @@ -3112,3 +3106,29 @@ void free_nodesystem(void) BLI_freelistN(&node_all_shaders); BLI_freelistN(&node_all_textures); } + +/* called from unlink_scene, when deleting a scene goes over all scenes + * other than the input, checks if they have render layer nodes referencing + * the to-be-deleted scene, and resets them to NULL. */ + +/* XXX needs to get current scene then! */ +void clear_scene_in_nodes(Main *bmain, Scene *sce) +{ + Scene *sce1; + bNode *node; + + for(sce1= bmain->scene.first; sce1; sce1=sce1->id.next) { + if(sce1!=sce) { + if(sce1->nodetree) { + for(node= sce1->nodetree->nodes.first; node; node= node->next) { + if(node->type==CMP_NODE_R_LAYERS) { + Scene *nodesce= (Scene *)node->id; + + if (nodesce==sce) node->id = NULL; + } + } + } + } + } +} + diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index e463d007a2d..0e45aedc3ed 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -91,6 +91,7 @@ #include "BKE_constraint.h" #include "BKE_curve.h" #include "BKE_displist.h" +#include "BKE_fcurve.h" #include "BKE_group.h" #include "BKE_icons.h" #include "BKE_key.h" @@ -106,6 +107,7 @@ #include "BKE_sca.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_sculpt.h" #include "BKE_softbody.h" #include "LBM_fluidsim.h" @@ -221,6 +223,34 @@ void object_free_display(Object *ob) freedisplist(&ob->disp); } +void free_sculptsession(SculptSession **ssp) +{ + if(ssp && *ssp) { + SculptSession *ss = *ssp; + if(ss->projverts) + MEM_freeN(ss->projverts); + + if(ss->fmap) + MEM_freeN(ss->fmap); + + if(ss->fmap_mem) + MEM_freeN(ss->fmap_mem); + + if(ss->texcache) + MEM_freeN(ss->texcache); + + if(ss->layer_disps) + MEM_freeN(ss->layer_disps); + + if(ss->mesh_co_orig) + MEM_freeN(ss->mesh_co_orig); + + MEM_freeN(ss); + + *ssp = NULL; + } +} + /* do not free object itself */ void free_object(Object *ob) { @@ -275,6 +305,8 @@ void free_object(Object *ob) if(ob->soft) sbFree(ob->soft); if(ob->bsoft) bsbFree(ob->bsoft); if(ob->gpulamp.first) GPU_lamp_free(ob); + + free_sculptsession(&ob->sculpt); } static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Object **obpoin) @@ -1025,7 +1057,7 @@ SoftBody *copy_softbody(SoftBody *sb) sbn->scratch= NULL; - sbn->pointcache= BKE_ptcache_copy(sb->pointcache); + sbn->pointcache= BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches); return sbn; } @@ -1084,7 +1116,7 @@ ParticleSystem *copy_particlesystem(ParticleSystem *psys) psysn->reactevents.first = psysn->reactevents.last = NULL; psysn->renderdata = NULL; - psysn->pointcache= BKE_ptcache_copy(psys->pointcache); + psysn->pointcache= BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches); id_us_plus((ID *)psysn->part); @@ -1210,6 +1242,9 @@ Object *copy_object(Object *ob) copy_defgroups(&obn->defbase, &ob->defbase); copy_constraints(&obn->constraints, &ob->constraints); + obn->mode = 0; + obn->sculpt = NULL; + /* increase user numbers */ id_us_plus((ID *)obn->data); id_us_plus((ID *)obn->dup_group); @@ -1402,11 +1437,32 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) ob->parent= target->parent; /* libdata */ Mat4CpyMat4(ob->parentinv, target->parentinv); -#if 0 // XXX old animation system - ob->ipo= target->ipo; /* libdata */ -#endif // XXX old animation system - /* skip constraints, constraintchannels, nla? */ + /* copy animdata stuff - drivers only for now... */ + if ((target->adt) && (target->adt->drivers.first)) { + FCurve *fcu; + + /* add new animdata block */ + ob->adt= BKE_id_add_animdata(&ob->id); + + /* make a copy of all the drivers (for now), then correct any links that need fixing */ + copy_fcurves(&ob->adt->drivers, &target->adt->drivers); + + for (fcu= ob->adt->drivers.first; fcu; fcu= fcu->next) { + ChannelDriver *driver= fcu->driver; + DriverTarget *dtar; + + for (dtar= driver->targets.first; dtar; dtar= dtar->next) { + if ((Object *)dtar->id == target) + dtar->id= (ID *)ob; + else + id_lib_extern((ID *)dtar->id); + } + } + } + + /* skip constraints? */ + // FIXME: this is considered by many as a bug /* set object type and link to data */ ob->type= target->type; @@ -1442,6 +1498,9 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) armature_set_id_extern(ob); } + + /* copy drawtype info */ + ob->dt= target->dt; } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 590189fbd5d..8c77ed92aa1 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -123,7 +123,7 @@ int countPackedFiles(Main *bmain) { Image *ima; VFont *vf; - bSample *sample; + bSound *sound; int count = 0; // let's check if there are packed files... @@ -135,10 +135,9 @@ int countPackedFiles(Main *bmain) if(vf->packedfile) count++; - if(samples) - for(sample=samples->first; sample; sample=sample->id.next) - if(sample->packedfile) - count++; + for(sound=bmain->sound.first; sound; sound=sound->id.next) + if(sound->packedfile) + count++; return count; } @@ -208,8 +207,8 @@ void packAll(Main *bmain, ReportList *reports) { Image *ima; VFont *vf; - bSample *sample; - + bSound *sound; + for(ima=bmain->image.first; ima; ima=ima->id.next) if(ima->packedfile == NULL) ima->packedfile = newPackedFile(reports, ima->name); @@ -218,10 +217,9 @@ void packAll(Main *bmain, ReportList *reports) if(vf->packedfile == NULL) vf->packedfile = newPackedFile(reports, vf->name); - if(samples) - for(sample=samples->first; sample; sample=sample->id.next) - if(sample->packedfile == NULL) - sound_set_packedfile(sample, newPackedFile(reports, sample->name)); + for(sound=bmain->sound.first; sound; sound=sound->id.next) + if(sound->packedfile == NULL) + sound->packedfile = newPackedFile(reports, sound->name); } @@ -456,28 +454,26 @@ int unpackVFont(ReportList *reports, VFont *vfont, int how) return (ret_value); } -int unpackSample(ReportList *reports, bSample *sample, int how) +int unpackSound(ReportList *reports, bSound *sound, int how) { char localname[FILE_MAXDIR + FILE_MAX], fi[FILE_MAX]; char *newname; int ret_value = RET_ERROR; - PackedFile *pf; - - if (sample != NULL) { - strcpy(localname, sample->name); + + if (sound != NULL) { + strcpy(localname, sound->name); BLI_splitdirstring(localname, fi); - sprintf(localname, "//samples/%s", fi); - - newname = unpackFile(reports, sample->name, localname, sample->packedfile, how); + sprintf(localname, "//sounds/%s", fi); + + newname = unpackFile(reports, sound->name, localname, sound->packedfile, how); if (newname != NULL) { - strcpy(sample->name, newname); + strcpy(sound->name, newname); MEM_freeN(newname); - pf = sample->packedfile; - // because samples and sounds can point to the - // same packedfile we have to check them all - sound_set_packedfile(sample, NULL); - freePackedFile(pf); + freePackedFile(sound->packedfile); + sound->packedfile = 0; + + sound_load(sound); ret_value = RET_OK; } @@ -515,7 +511,7 @@ void unpackAll(Main *bmain, ReportList *reports, int how) { Image *ima; VFont *vf; - bSample *sample; + bSound *sound; for(ima=bmain->image.first; ima; ima=ima->id.next) if(ima->packedfile) @@ -525,9 +521,8 @@ void unpackAll(Main *bmain, ReportList *reports, int how) if(vf->packedfile) unpackVFont(reports, vf, how); - if(samples) - for(sample=samples->first; sample; sample=sample->id.next) - if(sample->packedfile) - unpackSample(reports, sample, how); + for(sound=bmain->sound.first; sound; sound=sound->id.next) + if(sound->packedfile) + unpackSound(reports, sound, how); } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c new file mode 100644 index 00000000000..80016f23d7c --- /dev/null +++ b/source/blender/blenkernel/intern/paint.c @@ -0,0 +1,181 @@ +/* + * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 by Nicholas Bishop + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_brush_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_brush.h" +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_paint.h" + +#include +#include + +Paint *paint_get_active(Scene *sce) +{ + if(sce && sce->basact && sce->basact->object) { + ToolSettings *ts = sce->toolsettings; + + switch(sce->basact->object->mode) { + case OB_MODE_SCULPT: + return &ts->sculpt->paint; + case OB_MODE_VERTEX_PAINT: + return &ts->vpaint->paint; + case OB_MODE_WEIGHT_PAINT: + return &ts->wpaint->paint; + case OB_MODE_TEXTURE_PAINT: + return &ts->imapaint.paint; + } + } + + return NULL; +} + +Brush *paint_brush(Paint *p) +{ + return p && p->brushes ? p->brushes[p->active_brush_index] : NULL; +} + +void paint_brush_set(Paint *p, Brush *br) +{ + if(p && !br) { + /* Setting to NULL removes the current slot */ + paint_brush_slot_remove(p); + } + else if(p) { + int found = 0; + + if(p->brushes) { + int i; + + /* See if there's already a slot with the brush */ + for(i = 0; i < p->brush_count; ++i) { + if(p->brushes[i] == br) { + p->active_brush_index = i; + found = 1; + break; + } + } + + } + + if(!found) { + paint_brush_slot_add(p); + id_us_plus(&br->id); + } + + /* Make sure the current slot is the new brush */ + p->brushes[p->active_brush_index] = br; + } +} + +static void paint_brush_slots_alloc(Paint *p, const int count) +{ + p->brush_count = count; + if(count == 0) + p->brushes = NULL; + else + p->brushes = MEM_callocN(sizeof(Brush*) * count, "Brush slots"); +} + +void paint_brush_slot_add(Paint *p) +{ + if(p) { + Brush **orig = p->brushes; + int orig_count = p->brushes ? p->brush_count : 0; + + /* Increase size of brush slot array */ + paint_brush_slots_alloc(p, orig_count + 1); + if(orig) { + memcpy(p->brushes, orig, sizeof(Brush*) * orig_count); + MEM_freeN(orig); + } + + p->active_brush_index = orig_count; + } +} + +void paint_brush_slot_remove(Paint *p) +{ + if(p && p->brushes) { + Brush **orig = p->brushes; + int src, dst; + + /* Decrease size of brush slot array */ + paint_brush_slots_alloc(p, p->brush_count - 1); + if(p->brushes) { + for(src = 0, dst = 0; dst < p->brush_count; ++src) { + if(src != p->active_brush_index) { + p->brushes[dst] = orig[src]; + ++dst; + } + } + } + MEM_freeN(orig); + + if(p->active_brush_index >= p->brush_count) + p->active_brush_index = p->brush_count - 1; + if(p->active_brush_index < 0) + p->active_brush_index = 0; + } +} + +int paint_facesel_test(Object *ob) +{ + return (G.f&G_FACESELECT) && (ob && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))); + +} + +void paint_init(Paint *p, const char *name) +{ + Brush *brush; + + /* If there's no brush, create one */ + brush = paint_brush(p); + brush_check_exists(&brush, name); + paint_brush_set(p, brush); +} + +void free_paint(Paint *paint) +{ + if(paint->brushes) + MEM_freeN(paint->brushes); +} + +void copy_paint(Paint *orig, Paint *new) +{ + if(orig->brushes) { + int i; + new->brushes = MEM_dupallocN(orig->brushes); + for(i = 0; i < orig->brush_count; ++i) + id_us_plus((ID *)new->brushes[i]); + } +} diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index e4f8a484061..e1987d34a6c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -321,7 +321,7 @@ int psys_ob_has_hair(Object *ob) } int psys_in_edit_mode(Scene *scene, ParticleSystem *psys) { - return ((G.f & G_PARTICLEEDIT) && psys==psys_get_current((scene->basact)->object) && psys->edit); + return ((scene->basact->object->mode & OB_MODE_PARTICLE_EDIT) && psys==psys_get_current((scene->basact)->object) && psys->edit); } int psys_check_enabled(Object *ob, ParticleSystem *psys) { @@ -431,9 +431,6 @@ void psys_free(Object *ob, ParticleSystem * psys) int nr = 0; ParticleSystem * tpsys; - if(ob->particlesystem.first == NULL && G.f & G_PARTICLEEDIT) - G.f &= ~G_PARTICLEEDIT; - psys_free_path_cache(psys); free_hair(psys, 1); @@ -484,8 +481,8 @@ void psys_free(Object *ob, ParticleSystem * psys) if(psys->reactevents.first) BLI_freelistN(&psys->reactevents); - if(psys->pointcache) - BKE_ptcache_free(psys->pointcache); + BKE_ptcache_free_list(&psys->ptcaches); + psys->pointcache = NULL; if(psys->targets.first) BLI_freelistN(&psys->targets); @@ -980,13 +977,13 @@ static void get_pointcache_keys_for_time(Object *ob, ParticleSystem *psys, int i while(pm && pm->next && (float)pm->frame < t) pm = pm->next; - copy_particle_key(key2, ((ParticleKey *)pm->data) + index, 1); - copy_particle_key(key1, ((ParticleKey *)(pm->prev)->data) + index, 1); + BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] : index, pm->data, (float)pm->frame); + BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] : index, pm->prev->data, (float)pm->prev->frame); } else if(cache->mem_cache.first) { PTCacheMem *pm2 = cache->mem_cache.first; - copy_particle_key(key2, ((ParticleKey *)pm2->data) + index, 1); - copy_particle_key(key1, ((ParticleKey *)pm2->data) + index, 1); + BKE_ptcache_make_particle_key(key2, pm2->index_array ? pm2->index_array[index] : index, pm2->data, (float)pm2->frame); + copy_particle_key(key1, key2, 1); } } } @@ -3038,7 +3035,7 @@ void object_add_particle_system(Scene *scene, Object *ob) psys->flag &= ~PSYS_CURRENT; psys = MEM_callocN(sizeof(ParticleSystem), "particle_system"); - psys->pointcache = BKE_ptcache_add(); + psys->pointcache = BKE_ptcache_add(&psys->ptcaches); BLI_addtail(&ob->particlesystem, psys); psys->part = psys_new_settings("ParticleSettings", NULL); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index b5d58e9db8c..dcd3fcd2f89 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2260,56 +2260,21 @@ void psys_get_reactor_target(Object *ob, ParticleSystem *psys, Object **target_o void psys_make_temp_pointcache(Object *ob, ParticleSystem *psys) { PointCache *cache = psys->pointcache; - PTCacheFile *pf = NULL; - PTCacheMem *pm = NULL; PTCacheID pid; - int cfra, sfra = cache->startframe, efra = cache->endframe; - int totelem = psys->totpart; - int float_count = sizeof(ParticleKey) / sizeof(float); - int tot = totelem * float_count; if((cache->flag & PTCACHE_DISK_CACHE)==0 || cache->mem_cache.first) return; BKE_ptcache_id_from_particles(&pid, ob, psys); - for(cfra=sfra; cfra <= efra; cfra++) { - pf = BKE_ptcache_file_open(&pid, PTCACHE_FILE_READ, cfra); - - if(pf) { - pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache temp mem"); - pm->data = MEM_callocN(sizeof(float)*tot, "Pointcache temp mem data"); - - if(fread(pm->data, sizeof(float), tot, pf->fp)!= tot) { - printf("Error reading from disk cache\n"); - - MEM_freeN(pm->data); - MEM_freeN(pm); - BKE_ptcache_file_close(pf); - return; - } - - pm->frame = cfra; - pm->totpoint = totelem; - - BLI_addtail(&cache->mem_cache, pm); - - BKE_ptcache_file_close(pf); - } - } + BKE_ptcache_disk_to_mem(&pid); } void psys_clear_temp_pointcache(ParticleSystem *psys) { - PTCacheMem *pm = psys->pointcache->mem_cache.first; - if((psys->pointcache->flag & PTCACHE_DISK_CACHE)==0) return; - for(; pm; pm=pm->next) { - MEM_freeN(pm->data); - } - - BLI_freelistN(&psys->pointcache->mem_cache); + BKE_ptache_free_mem(psys->pointcache); } void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra, int *efra) { @@ -2318,88 +2283,6 @@ void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra *sfra = MAX2(1, (int)part->sta); *efra = MIN2((int)(part->end + part->lifetime + 1.0), scene->r.efra); } -static void particle_write_state(int index, void *psys_ptr, float *data) -{ - ParticleSystem *psys= psys_ptr; - - memcpy(data, (float *)(&(psys->particles+index)->state), sizeof(ParticleKey)); -} -static void particle_read_state(int index, void *psys_ptr, float *data) -{ - ParticleSystem *psys= psys_ptr; - ParticleData *pa = psys->particles + index; - ParticleKey *key = (ParticleKey *)data; - - if(key->time > pa->state.time) - copy_particle_key(&pa->prev_state, &pa->state, 1); - - copy_particle_key(&pa->state, key, 1); -} -static void particle_cache_interpolate(int index, void *psys_ptr, float frs_sec, float cfra, float cfra1, float cfra2, float *data1, float *data2) -{ - ParticleSystem *psys= psys_ptr; - ParticleData *pa = psys->particles + index; - ParticleKey keys[4]; - float dfra; - - cfra = MIN2(cfra, pa->dietime); - cfra1 = MIN2(cfra1, pa->dietime); - cfra2 = MIN2(cfra2, pa->dietime); - - keys[1] = *((ParticleKey*)data1); - keys[2] = *((ParticleKey*)data2); - - if(cfra1 == cfra2) { - copy_particle_key(&pa->state, &keys[1], 1); - return; - } - - dfra = cfra2 - cfra1; - - VecMulf(keys[1].vel, dfra / frs_sec); - VecMulf(keys[2].vel, dfra / frs_sec); - - psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1); - QuatInterpol(pa->state.rot, keys[1].rot,keys[2].rot, (cfra - cfra1) / dfra); - - VecMulf(pa->state.vel, frs_sec / dfra); - - pa->state.time = cfra; -} -static void write_particles_to_cache(Object *ob, ParticleSystem *psys, int cfra) -{ - PTCacheWriter writer; - PTCacheID pid; - - BKE_ptcache_id_from_particles(&pid, ob, psys); - - writer.calldata = psys; - writer.cfra = cfra; - writer.set_elem = particle_write_state; - writer.pid = &pid; - writer.totelem = psys->totpart; - - BKE_ptcache_write_cache(&writer); -} - -static int get_particles_from_cache(Scene *scene, Object *ob, ParticleSystem *psys, float cfra, int *old_frame) -{ - PTCacheReader reader; - PTCacheID pid; - - BKE_ptcache_id_from_particles(&pid, ob, psys); - - reader.calldata = psys; - reader.cfra = cfra; - reader.interpolate_elem = particle_cache_interpolate; - reader.old_frame = old_frame; - reader.pid = &pid; - reader.scene = scene; - reader.set_elem = particle_read_state; - reader.totelem = psys->totpart; - - return BKE_ptcache_read_cache(&reader); -} /************************************************/ /* Effectors */ @@ -3843,7 +3726,7 @@ static void psys_update_path_cache(Scene *scene, Object *ob, ParticleSystemModif if((psys->part->childtype && psys->totchild != get_psys_tot_child(scene, psys)) || psys->recalc&PSYS_RECALC_RESET) alloc=1; - if(alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (G.f & G_WEIGHTPAINT))) + if(alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))) distr=1; if(distr){ @@ -4237,7 +4120,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle int totpart, oldtotpart, totchild, oldtotchild, p; float disp, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0; int init= 0, distr= 0, alloc= 0, usecache= 0, only_children_changed= 0; - int framenr, framedelta, startframe, endframe, old_framenr; + int framenr, framedelta, startframe, endframe; part= psys->part; cache= psys->pointcache; @@ -4327,8 +4210,10 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle if(alloc) { realloc_particles(ob, psys, totpart); - if(usecache && !only_children_changed) + if(usecache && !only_children_changed) { BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0); + BKE_ptcache_id_from_particles(&pid, ob, psys); + } } if(!only_children_changed) @@ -4358,7 +4243,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle /* try to read from the cache */ if(usecache) { - int result = get_particles_from_cache(scene, ob, psys, (float)framenr, &old_framenr); + int result = BKE_ptcache_read_cache(&pid, cfra, scene->r.frs_sec); if(result == PTCACHE_READ_EXACT || result == PTCACHE_READ_INTERPOLATED) { cached_step(scene, ob, psmd, psys, cfra); @@ -4369,14 +4254,12 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle cache->flag |= PTCACHE_SIMULATION_VALID; if(result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) - write_particles_to_cache(ob, psys, cfra); + BKE_ptcache_write_cache(&pid, (int)cfra); return; } else if(result==PTCACHE_READ_OLD) { - /* set old cfra */ - psys->cfra = (float)old_framenr; - + psys->cfra = (float)cache->simframe; for(p=0, pa=psys->particles; ptime > psys->cfra) @@ -4402,7 +4285,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle /* if on second frame, write cache for first frame */ if(usecache && psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) - write_particles_to_cache(ob, psys, startframe); + BKE_ptcache_write_cache(&pid, startframe); if(part->phystype==PART_PHYS_KEYED) psys_count_keyed_targets(ob,psys); @@ -4448,7 +4331,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle /* only write cache starting from second frame */ if(usecache && framenr != startframe) - write_particles_to_cache(ob, psys, framenr); + BKE_ptcache_write_cache(&pid, (int)cfra); /* for keyed particles the path is allways known so it can be drawn */ if(part->phystype==PART_PHYS_KEYED) { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index beb72c2c13f..09170d92866 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -39,6 +39,7 @@ #include "DNA_object_force.h" #include "DNA_particle_types.h" #include "DNA_scene_types.h" +#include "DNA_smoke_types.h" #include "BLI_blenlib.h" @@ -52,11 +53,14 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_scene.h" +#include "BKE_smoke.h" #include "BKE_softbody.h" #include "BKE_utildefines.h" #include "BLI_blenlib.h" +#include "smoke_API.h" + /* needed for directory lookup */ #ifndef WIN32 #include @@ -77,8 +81,308 @@ #endif #endif -/* Creating ID's */ +static void ptcache_data_to(void **data, int type, int index, void *to); +static void ptcache_data_from(void **data, int type, void *from); +/* Common functions */ +static int ptcache_read_basic_header(PTCacheFile *pf) +{ + int error=0; + + /* Custom functions should read these basic elements too! */ + if(!error && !fread(&pf->totpoint, sizeof(int), 1, pf->fp)) + error = 1; + + if(!error && !fread(&pf->data_types, sizeof(int), 1, pf->fp)) + error = 1; + + return !error; +} +static int ptcache_write_basic_header(PTCacheFile *pf) +{ + /* Custom functions should write these basic elements too! */ + if(!fwrite(&pf->totpoint, sizeof(int), 1, pf->fp)) + return 0; + + if(!fwrite(&pf->data_types, sizeof(int), 1, pf->fp)) + return 0; + + return 1; +} +/* Softbody functions */ +static int ptcache_write_softbody(int index, void *soft_v, void **data) +{ + SoftBody *soft= soft_v; + BodyPoint *bp = soft->bpoint + index; + + ptcache_data_from(data, BPHYS_DATA_LOCATION, bp->pos); + ptcache_data_from(data, BPHYS_DATA_VELOCITY, bp->vec); + + return 1; +} +static void ptcache_read_softbody(int index, void *soft_v, void **data, float frs_sec, float cfra, float *old_data) +{ + SoftBody *soft= soft_v; + BodyPoint *bp = soft->bpoint + index; + + if(old_data) { + memcpy(bp->pos, data, 3 * sizeof(float)); + memcpy(bp->vec, data + 3, 3 * sizeof(float)); + } + else { + ptcache_data_to(data, BPHYS_DATA_LOCATION, 0, bp->pos); + ptcache_data_to(data, BPHYS_DATA_VELOCITY, 0, bp->vec); + } +} +static void ptcache_interpolate_softbody(int index, void *soft_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) +{ + SoftBody *soft= soft_v; + BodyPoint *bp = soft->bpoint + index; + ParticleKey keys[4]; + float dfra; + + if(cfra1 == cfra2) + return; + + VECCOPY(keys[1].co, bp->pos); + VECCOPY(keys[1].vel, bp->vec); + + if(old_data) { + memcpy(keys[2].co, old_data, 3 * sizeof(float)); + memcpy(keys[2].vel, old_data + 3, 3 * sizeof(float)); + } + else + BKE_ptcache_make_particle_key(keys+2, 0, data, cfra2); + + dfra = cfra2 - cfra1; + + VecMulf(keys[1].vel, dfra); + VecMulf(keys[2].vel, dfra); + + psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1); + + VecMulf(keys->vel, 1.0f / dfra); + + VECCOPY(bp->pos, keys->co); + VECCOPY(bp->vec, keys->vel); +} +static int ptcache_totpoint_softbody(void *soft_v) +{ + SoftBody *soft= soft_v; + return soft->totpoint; +} +/* Particle functions */ +static int ptcache_write_particle(int index, void *psys_v, void **data) +{ + ParticleSystem *psys= psys_v; + ParticleData *pa = psys->particles + index; + float times[3] = {pa->time, pa->dietime, pa->lifetime}; + + if(data[BPHYS_DATA_INDEX]) { + int step = psys->pointcache->step; + /* No need to store unborn or died particles */ + if(pa->time - step > pa->state.time || pa->dietime + step < pa->state.time) + return 0; + } + + ptcache_data_from(data, BPHYS_DATA_INDEX, &index); + ptcache_data_from(data, BPHYS_DATA_LOCATION, pa->state.co); + ptcache_data_from(data, BPHYS_DATA_VELOCITY, pa->state.vel); + ptcache_data_from(data, BPHYS_DATA_ROTATION, pa->state.rot); + ptcache_data_from(data, BPHYS_DATA_AVELOCITY, pa->state.ave); + ptcache_data_from(data, BPHYS_DATA_SIZE, &pa->size); + ptcache_data_from(data, BPHYS_DATA_TIMES, times); + + if(pa->boid) + ptcache_data_from(data, BPHYS_DATA_TIMES, &pa->boid); + + return 1; +} +void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, float time) +{ + ptcache_data_to(data, BPHYS_DATA_LOCATION, index, key->co); + ptcache_data_to(data, BPHYS_DATA_VELOCITY, index, key->vel); + ptcache_data_to(data, BPHYS_DATA_ROTATION, index, key->rot); + ptcache_data_to(data, BPHYS_DATA_AVELOCITY, index, key->ave); + key->time = time; +} +static void ptcache_read_particle(int index, void *psys_v, void **data, float frs_sec, float cfra, float *old_data) +{ + ParticleSystem *psys= psys_v; + ParticleData *pa = psys->particles + index; + + if(cfra > pa->state.time) + memcpy(&pa->prev_state, &pa->state, sizeof(ParticleKey)); + + if(old_data){ + /* old format cache */ + memcpy(&pa->state, old_data, sizeof(ParticleKey)); + return; + } + + BKE_ptcache_make_particle_key(&pa->state, 0, data, cfra); + + if(data[BPHYS_DATA_SIZE]) + ptcache_data_to(data, BPHYS_DATA_SIZE, 0, &pa->size); + + if(data[BPHYS_DATA_TIMES]) { + float times[3]; + ptcache_data_to(data, BPHYS_DATA_TIMES, 0, ×); + pa->time = times[0]; + pa->dietime = times[1]; + pa->lifetime = times[2]; + } + + if(pa->boid) + ptcache_data_to(data, BPHYS_DATA_BOIDS, 0, &pa->boid); + + /* determine velocity from previous location */ + if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) { + if(cfra > pa->prev_state.time) { + VecSubf(pa->state.vel, pa->state.co, pa->prev_state.co); + VecMulf(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec); + } + else { + VecSubf(pa->state.vel, pa->prev_state.co, pa->state.co); + VecMulf(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec); + } + } + + /* determine rotation from velocity */ + if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) { + vectoquat(pa->state.vel, OB_POSX, OB_POSZ, pa->state.rot); + } +} +static void ptcache_interpolate_particle(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) +{ + ParticleSystem *psys= psys_v; + ParticleData *pa = psys->particles + index; + ParticleKey keys[4]; + float dfra; + + cfra = MIN2(cfra, pa->dietime); + cfra1 = MIN2(cfra1, pa->dietime); + cfra2 = MIN2(cfra2, pa->dietime); + + if(cfra1 == cfra2) + return; + + memcpy(keys+1, &pa->state, sizeof(ParticleKey)); + if(old_data) + memcpy(keys+2, old_data, sizeof(ParticleKey)); + else + BKE_ptcache_make_particle_key(keys+2, 0, data, cfra2); + + dfra = cfra2 - cfra1; + + VecMulf(keys[1].vel, dfra / frs_sec); + VecMulf(keys[2].vel, dfra / frs_sec); + + psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1); + QuatInterpol(pa->state.rot, keys[1].rot,keys[2].rot, (cfra - cfra1) / dfra); + + VecMulf(pa->state.vel, frs_sec / dfra); + + pa->state.time = cfra; +} + +static int ptcache_totpoint_particle(void *psys_v) +{ + ParticleSystem *psys = psys_v; + return psys->totpart; +} +static int ptcache_totwrite_particle(void *psys_v) +{ + ParticleSystem *psys = psys_v; + int totwrite = 0; + + /* TODO for later */ + //if((psys->part->flag & (PART_UNBORN|PART_DIED))==0) { + // ParticleData *pa= psys->particles; + // int p, step = psys->pointcache->step; + + // for(p=0; ptotpart; p++,pa++) + // totwrite += (pa->time - step > pa->state.time || pa->dietime + step > pa->state.time); + //} + //else + totwrite= psys->totpart; + + return totwrite; +} + +/* Cloth functions */ +static int ptcache_write_cloth(int index, void *cloth_v, void **data) +{ + ClothModifierData *clmd= cloth_v; + Cloth *cloth= clmd->clothObject; + ClothVertex *vert = cloth->verts + index; + + ptcache_data_from(data, BPHYS_DATA_LOCATION, vert->x); + ptcache_data_from(data, BPHYS_DATA_VELOCITY, vert->v); + ptcache_data_from(data, BPHYS_DATA_XCONST, vert->xconst); + + return 1; +} +static void ptcache_read_cloth(int index, void *cloth_v, void **data, float frs_sec, float cfra, float *old_data) +{ + ClothModifierData *clmd= cloth_v; + Cloth *cloth= clmd->clothObject; + ClothVertex *vert = cloth->verts + index; + + if(old_data) { + memcpy(vert->x, data, 3 * sizeof(float)); + memcpy(vert->xconst, data + 3, 3 * sizeof(float)); + memcpy(vert->v, data + 6, 3 * sizeof(float)); + } + else { + ptcache_data_to(data, BPHYS_DATA_LOCATION, 0, vert->x); + ptcache_data_to(data, BPHYS_DATA_VELOCITY, 0, vert->v); + ptcache_data_to(data, BPHYS_DATA_XCONST, 0, vert->xconst); + } +} +static void ptcache_interpolate_cloth(int index, void *cloth_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) +{ + ClothModifierData *clmd= cloth_v; + Cloth *cloth= clmd->clothObject; + ClothVertex *vert = cloth->verts + index; + ParticleKey keys[4]; + float dfra; + + if(cfra1 == cfra2) + return; + + VECCOPY(keys[1].co, vert->x); + VECCOPY(keys[1].vel, vert->v); + + if(old_data) { + memcpy(keys[2].co, old_data, 3 * sizeof(float)); + memcpy(keys[2].vel, old_data + 6, 3 * sizeof(float)); + } + else + BKE_ptcache_make_particle_key(keys+2, 0, data, cfra2); + + dfra = cfra2 - cfra1; + + VecMulf(keys[1].vel, dfra); + VecMulf(keys[2].vel, dfra); + + psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1); + + VecMulf(keys->vel, 1.0f / dfra); + + VECCOPY(vert->x, keys->co); + VECCOPY(vert->v, keys->vel); + + /* should vert->xconst be interpolated somehow too? - jahka */ +} + +static int ptcache_totpoint_cloth(void *cloth_v) +{ + ClothModifierData *clmd= cloth_v; + return clmd->clothObject->numverts; +} + +/* Creating ID's */ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) { ParticleSystemModifierData *psmd; @@ -88,9 +392,24 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) memset(pid, 0, sizeof(PTCacheID)); pid->ob= ob; - pid->data= sb; + pid->calldata= sb; pid->type= PTCACHE_TYPE_SOFTBODY; pid->cache= sb->pointcache; + pid->cache_ptr= &sb->pointcache; + pid->ptcaches= &sb->ptcaches; + pid->totpoint= pid->totwrite= ptcache_totpoint_softbody; + + pid->write_elem= ptcache_write_softbody; + pid->write_stream = NULL; + pid->read_stream = NULL; + pid->read_elem= ptcache_read_softbody; + pid->interpolate_elem= ptcache_interpolate_softbody; + + pid->write_header= ptcache_write_basic_header; + pid->read_header= ptcache_read_basic_header; + + pid->data_types= (1<info_types= 0; if(sb->particles) { psmd= psys_get_modifier(ob, sb->particles); @@ -113,21 +432,173 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p memset(pid, 0, sizeof(PTCacheID)); pid->ob= ob; - pid->data= psys; + pid->calldata= psys; pid->type= PTCACHE_TYPE_PARTICLES; pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)psmd); pid->cache= psys->pointcache; + pid->cache_ptr= &psys->pointcache; + pid->ptcaches= &psys->ptcaches; + + pid->write_elem= ptcache_write_particle; + pid->write_stream = NULL; + pid->read_stream = NULL; + pid->read_elem= ptcache_read_particle; + pid->interpolate_elem= ptcache_interpolate_particle; + + pid->totpoint= ptcache_totpoint_particle; + pid->totwrite= ptcache_totwrite_particle; + + pid->write_header= ptcache_write_basic_header; + pid->read_header= ptcache_read_basic_header; + + pid->data_types= (1<part->flag & (PART_UNBORN|PART_DIED))==0) + // pid->data_types|= (1<part->phystype == PART_PHYS_BOIDS) + pid->data_types|= (1<part->rotmode || psys->part->avemode) + pid->data_types|= (1<part->flag & PART_ROT_DYN) + pid->data_types|= (1<info_types= (1<domain; + + if(sds->fluid) + { + return sds->res[0]*sds->res[1]*sds->res[2]; + } + else + return 0; +} + +// forward decleration +static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size); + +static int ptcache_write_smoke(PTCacheFile *pf, void *smoke_v) +{ + SmokeModifierData *smd= (SmokeModifierData *)smoke_v; + SmokeDomainSettings *sds = smd->domain; + + if(sds->fluid) + { + size_t res = sds->res[0]*sds->res[1]*sds->res[2]; + float *dens, *densold, *heat, *heatold, *vx, *vy, *vz; + + smoke_export(sds->fluid, &dens, &densold, &heat, &heatold, &vx, &vy, &vz); + + ptcache_file_write(pf, dens, res, sizeof(float)); + ptcache_file_write(pf, densold, res, sizeof(float)); + ptcache_file_write(pf, heat, res, sizeof(float)); + ptcache_file_write(pf, heatold, res, sizeof(float)); + ptcache_file_write(pf, vx, res, sizeof(float)); + ptcache_file_write(pf, vy, res, sizeof(float)); + ptcache_file_write(pf, vz, res, sizeof(float)); + + return 1; + } + + return 0; +} + +// forward decleration +static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size); + +static void ptcache_read_smoke(PTCacheFile *pf, void *smoke_v) +{ + SmokeModifierData *smd= (SmokeModifierData *)smoke_v; + SmokeDomainSettings *sds = smd->domain; + + if(sds->fluid) + { + size_t res = sds->res[0]*sds->res[1]*sds->res[2]; + float *dens, *densold, *heat, *heatold, *vx, *vy, *vz; + + smoke_export(sds->fluid, &dens, &densold, &heat, &heatold, &vx, &vy, &vz); + + ptcache_file_read(pf, dens, res, sizeof(float)); + ptcache_file_read(pf, densold, res, sizeof(float)); + ptcache_file_read(pf, heat, res, sizeof(float)); + ptcache_file_read(pf, heatold, res, sizeof(float)); + ptcache_file_read(pf, vx, res, sizeof(float)); + ptcache_file_read(pf, vy, res, sizeof(float)); + ptcache_file_read(pf, vz, res, sizeof(float)); + + } +} +void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd, int num) +{ + SmokeDomainSettings *sds = smd->domain; + + memset(pid, 0, sizeof(PTCacheID)); + + pid->ob= ob; + pid->calldata= smd; + + // if(num == 0) + pid->type= PTCACHE_TYPE_SMOKE_DOMAIN_LOW; + // else if(num == 1) + // pid->type= PTCACHE_TYPE_SMOKE_DOMAIN_HIGH; + + pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)smd); + + pid->cache= sds->point_cache; + pid->cache_ptr= &sds->point_cache; + pid->ptcaches= &sds->ptcaches; + + + pid->totpoint= pid->totwrite= ptcache_totpoint_smoke; + + pid->write_elem= NULL; + pid->read_elem= NULL; + pid->read_stream = ptcache_read_smoke; + pid->write_stream = ptcache_write_smoke; + pid->interpolate_elem= NULL; + + pid->write_header= ptcache_write_basic_header; + pid->read_header= ptcache_read_basic_header; + + pid->data_types= (1<info_types= 0; +} +#endif // XXX smoke poitcache stuff breaks compiling + void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *clmd) { memset(pid, 0, sizeof(PTCacheID)); pid->ob= ob; - pid->data= clmd; + pid->calldata= clmd; pid->type= PTCACHE_TYPE_CLOTH; pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)clmd); pid->cache= clmd->point_cache; + pid->cache_ptr= &clmd->point_cache; + pid->ptcaches= &clmd->ptcaches; + pid->totpoint= pid->totwrite= ptcache_totpoint_cloth; + + pid->write_elem= ptcache_write_cloth; + pid->write_stream = NULL; + pid->read_stream = NULL; + pid->read_elem= ptcache_read_cloth; + pid->interpolate_elem= ptcache_interpolate_cloth; + + pid->write_header= ptcache_write_basic_header; + pid->read_header= ptcache_read_basic_header; + + pid->data_types= (1<info_types= 0; } void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob) @@ -162,9 +633,24 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob) BKE_ptcache_id_from_cloth(pid, ob, (ClothModifierData*)md); BLI_addtail(lb, pid); } + /* + // enabled on next commit + if(md->type == eModifierType_Smoke) { + SmokeModifierData *smd = (SmokeModifierData *)md; + if(smd->type & MOD_SMOKE_TYPE_DOMAIN) + { + pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID"); + BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md, 0); + BLI_addtail(lb, pid); + } + } + */ } } + +/* File handling */ + /* Takes an Object ID and returns a unique name - id: object id - cfra: frame for the cache, can be negative @@ -177,7 +663,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob) static int ptcache_path(PTCacheID *pid, char *filename) { Library *lib; - int i; + size_t i; lib= (pid)? pid->ob->id.lib: NULL; @@ -235,7 +721,7 @@ static int BKE_ptcache_id_filename(PTCacheID *pid, char *filename, int cfra, sho } } else { - int temp = strlen(pid->cache->name); + int temp = (int)strlen(pid->cache->name); strcpy(newname, pid->cache->name); newname+=temp; len += temp; @@ -258,7 +744,7 @@ static int BKE_ptcache_id_filename(PTCacheID *pid, char *filename, int cfra, sho } /* youll need to close yourself after! */ -PTCacheFile *BKE_ptcache_file_open(PTCacheID *pid, int mode, int cfra) +static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) { PTCacheFile *pf; FILE *fp = NULL; @@ -291,23 +777,181 @@ PTCacheFile *BKE_ptcache_file_open(PTCacheID *pid, int mode, int cfra) return pf; } -void BKE_ptcache_file_close(PTCacheFile *pf) +static void ptcache_file_close(PTCacheFile *pf) { fclose(pf->fp); MEM_freeN(pf); } -int BKE_ptcache_file_read_floats(PTCacheFile *pf, float *f, int tot) +static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size) { - return (fread(f, sizeof(float), tot, pf->fp) == tot); + return (fread(f, size, tot, pf->fp) == tot); +} +static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size) +{ + return (fwrite(f, size, tot, pf->fp) == tot); +} +static int ptcache_file_read_data(PTCacheFile *pf) +{ + int i; + + for(i=0; idata_types & (1<cur[i], 1, BKE_ptcache_data_size(i))) + return 0; + } + + return 1; +} +static int ptcache_file_write_data(PTCacheFile *pf) +{ + int i; + + for(i=0; idata_types & (1<cur[i], 1, BKE_ptcache_data_size(i))) + return 0; + } + + return 1; +} +static int ptcache_file_read_header_begin(PTCacheFile *pf) +{ + int error=0; + char bphysics[8]; + + pf->data_types = 0; + + if(fread(bphysics, sizeof(char), 8, pf->fp) != 8) + error = 1; + + if(!error && strncmp(bphysics, "BPHYSICS", 8)) + error = 1; + + if(!error && !fread(&pf->type, sizeof(int), 1, pf->fp)) + error = 1; + + /* if there was an error set file as it was */ + if(error) + fseek(pf->fp, 0, SEEK_SET); + + return !error; } -int BKE_ptcache_file_write_floats(PTCacheFile *pf, float *f, int tot) + +static int ptcache_file_write_header_begin(PTCacheFile *pf) { - return (fwrite(f, sizeof(float), tot, pf->fp) == tot); + char *bphysics = "BPHYSICS"; + + if(fwrite(bphysics, sizeof(char), 8, pf->fp) != 8) + return 0; + + if(!fwrite(&pf->type, sizeof(int), 1, pf->fp)) + return 0; + + return 1; } -static int ptcache_pid_elemsize(PTCacheID *pid) + +/* Data pointer handling */ +int BKE_ptcache_data_size(int data_type) +{ + switch(data_type) { + case BPHYS_DATA_INDEX: + return sizeof(int); + case BPHYS_DATA_LOCATION: + case BPHYS_DATA_VELOCITY: + case BPHYS_DATA_AVELOCITY: /* also BPHYS_DATA_XCONST */ + case BPHYS_DATA_TIMES: + return 3 * sizeof(float); + case BPHYS_DATA_ROTATION: + return 4 * sizeof(float); + case BPHYS_DATA_SIZE: + return sizeof(float); + case BPHYS_DATA_BOIDS: + return sizeof(BoidData); + default: + return 0; + } +} +static void ptcache_data_to(void **data, int type, int index, void *to) +{ + if(data[type]) { + if(index) + memcpy(to, (char*)data[type] + index * BKE_ptcache_data_size(type), BKE_ptcache_data_size(type)); + else + memcpy(to, data[type], BKE_ptcache_data_size(type)); + } +} + +static void ptcache_data_from(void **data, int type, void *from) +{ + if(data[type]) + memcpy(data[type], from, BKE_ptcache_data_size(type)); +} + +static void ptcache_file_init_pointers(PTCacheFile *pf) +{ + int data_types = pf->data_types; + + pf->cur[BPHYS_DATA_INDEX] = data_types & (1<data.index : NULL; + pf->cur[BPHYS_DATA_LOCATION] = data_types & (1<data.loc : NULL; + pf->cur[BPHYS_DATA_VELOCITY] = data_types & (1<data.vel : NULL; + pf->cur[BPHYS_DATA_ROTATION] = data_types & (1<data.rot : NULL; + pf->cur[BPHYS_DATA_AVELOCITY] = data_types & (1<data.ave : NULL; + pf->cur[BPHYS_DATA_SIZE] = data_types & (1<data.size : NULL; + pf->cur[BPHYS_DATA_TIMES] = data_types & (1<data.times : NULL; + pf->cur[BPHYS_DATA_BOIDS] = data_types & (1<data.boids : NULL; +} + +static void ptcache_mem_init_pointers(PTCacheMem *pm) +{ + int data_types = pm->data_types; + int i; + + for(i=0; icur[i] = data_types & (1<data[i] : NULL; +} + +static void ptcache_mem_incr_pointers(PTCacheMem *pm) +{ + int i; + + for(i=0; icur[i]) + pm->cur[i] = (char*)pm->cur[i] + BKE_ptcache_data_size(i); + } +} +static void ptcache_alloc_data(PTCacheMem *pm) +{ + int data_types = pm->data_types; + int totpoint = pm->totpoint; + int i; + + for(i=0; idata[i] = MEM_callocN(totpoint * BKE_ptcache_data_size(i), "PTCache Data"); + } +} +static void ptcache_free_data(void *data[]) +{ + int i; + + for(i=0; itype==PTCACHE_TYPE_SOFTBODY) return 6 * sizeof(float); @@ -318,109 +962,39 @@ static int ptcache_pid_elemsize(PTCacheID *pid) return 0; } -static int ptcache_pid_totelem(PTCacheID *pid) -{ - if(pid->type==PTCACHE_TYPE_SOFTBODY) { - SoftBody *soft = pid->data; - return soft->totpoint; - } - else if(pid->type==PTCACHE_TYPE_PARTICLES) { - ParticleSystem *psys = pid->data; - return psys->totpart; - } - else if(pid->type==PTCACHE_TYPE_CLOTH) { - ClothModifierData *clmd = pid->data; - return clmd->clothObject->numverts; - } - return 0; -} - -void BKE_ptcache_update_info(PTCacheID *pid) -{ - PointCache *cache = pid->cache; - int totframes = 0; - char mem_info[64]; - - if(cache->flag & PTCACHE_EXTERNAL) { - int cfra = cache->startframe; - - for(; cfra<=cache->endframe; cfra++) { - if(BKE_ptcache_id_exist(pid, cfra)) - totframes++; - } - - if(totframes) - sprintf(cache->info, "%i points read for %i frames", cache->totpoint, totframes); - else - sprintf(cache->info, "No valid data to read!"); - return; - } - - if(cache->flag & PTCACHE_DISK_CACHE) { - int cfra = cache->startframe; - - for(; cfra<=cache->endframe; cfra++) { - if(BKE_ptcache_id_exist(pid, cfra)) - totframes++; - } - - sprintf(mem_info, "%i frames on disk", totframes); - } - else { - PTCacheMem *pm = cache->mem_cache.first; - float framesize = 0.0f, bytes = 0.0f; - int mb; - - if(pm) - framesize = (float)ptcache_pid_elemsize(pid) * (float)pm->totpoint; - - for(; pm; pm=pm->next) - totframes++; - - bytes = totframes * framesize; - - mb = (bytes > 1024.0f * 1024.0f); - - sprintf(mem_info, "%i frames in memory (%.1f %s)", - totframes, - bytes / (mb ? 1024.0f * 1024.0f : 1024.0f), - mb ? "Mb" : "kb"); - } - - if(cache->flag & PTCACHE_OUTDATED) { - sprintf(cache->info, "%s, cache is outdated!", mem_info); - } - else if(cache->flag & PTCACHE_FRAMES_SKIPPED) { - sprintf(cache->info, "%s, not exact since frame %i.", mem_info, cache->last_exact); - } - else - sprintf(cache->info, "%s.", mem_info); -} /* reads cache from disk or memory */ /* possible to get old or interpolated result */ -int BKE_ptcache_read_cache(PTCacheReader *reader) +int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) { - PTCacheID *pid = reader->pid; PTCacheFile *pf=NULL, *pf2=NULL; PTCacheMem *pm=NULL, *pm2=NULL; - int totelem = reader->totelem; - float cfra = reader->cfra; + float old_data1[14], old_data2[14]; int cfrai = (int)cfra; - int elemsize = ptcache_pid_elemsize(pid); - int i, incr = elemsize / sizeof(float); - float frs_sec = reader->scene->r.frs_sec; - int cfra1=0, cfra2; - int ret = 0; + int old_elemsize = ptcache_pid_old_elemsize(pid); + int i; - if(totelem == 0) + int cfra1 = 0, cfra2 = 0; + int totpoint = 0, totpoint2 = 0; + int *index = &i, *index2 = &i; + int use_old = 0, old_frame; + + int ret = 0, error = 0; + + /* nothing to read to */ + if(pid->totpoint(pid->calldata) == 0) return 0; + if(pid->cache->flag & PTCACHE_READ_INFO) { + pid->cache->flag &= ~PTCACHE_READ_INFO; + BKE_ptcache_read_cache(pid, 0, frs_sec); + } + /* first check if we have the actual frame cached */ if(cfra == (float)cfrai) { if(pid->cache->flag & PTCACHE_DISK_CACHE) { - pf= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); + pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); } else { pm = pid->cache->mem_cache.first; @@ -432,240 +1006,297 @@ int BKE_ptcache_read_cache(PTCacheReader *reader) } } - /* if found, use exact frame */ - if(pf || pm) { - float *data; - - if(pm) - data = pm->data; - else - data = MEM_callocN(elemsize, "pointcache read data"); - - for(i=0; iset_elem(i, reader->calldata, data); - } - else { - reader->set_elem(i, reader->calldata, data); - data += incr; - } - } - - if(pf) { - BKE_ptcache_file_close(pf); - pf = NULL; - MEM_freeN(data); - } - - ret = PTCACHE_READ_EXACT; - } - - if(ret) - ; /* no exact cache frame found so try to find cached frames around cfra */ - else if(pid->cache->flag & PTCACHE_DISK_CACHE) { - pf=NULL; - while(cfrai > pid->cache->startframe && !pf) { - cfrai--; - pf= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); - cfra1 = cfrai; + if(!pm && !pf) { + if(pid->cache->flag & PTCACHE_DISK_CACHE) { + pf=NULL; + while(cfrai > pid->cache->startframe && !pf) { + cfrai--; + pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); + cfra1 = cfrai; + } + + old_frame = cfrai; + + cfrai = (int)cfra; + while(cfrai < pid->cache->endframe && !pf2) { + cfrai++; + pf2= ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); + cfra2 = cfrai; + } + + if(pf && !pf2) { + pf2 = pf; + pf = NULL; + } } + else if(pid->cache->mem_cache.first){ + pm = pid->cache->mem_cache.first; - if(reader->old_frame) - *(reader->old_frame) = cfrai; + while(pm->next && pm->next->frame < cfra) + pm= pm->next; - cfrai = (int)cfra; - while(cfrai < pid->cache->endframe && !pf2) { - cfrai++; - pf2= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); - cfra2 = cfrai; - } - } - else if(pid->cache->mem_cache.first){ - pm = pid->cache->mem_cache.first; + if(pm) { + old_frame = pm->frame; + cfra1 = pm->frame; + } - while(pm->next && pm->next->frame < cfra) - pm= pm->next; + pm2 = pid->cache->mem_cache.last; - if(pm) { - if(reader->old_frame) - *(reader->old_frame) = pm->frame; - cfra1 = pm->frame; - } + if(pm2 && pm2->frame < cfra) + pm2 = NULL; + else { + while(pm2->prev && pm2->prev->frame > cfra) + pm2= pm2->prev; - pm2 = pid->cache->mem_cache.last; + if(pm2) + cfra2 = pm2->frame; + } - if(pm2 && pm2->frame < cfra) - pm2 = NULL; - else { - while(pm2->prev && pm2->prev->frame > cfra) - pm2= pm2->prev; - - if(pm2) - cfra2 = pm2->frame; + if(pm && !pm2) { + pm2 = pm; + pm = NULL; + } } } - if(ret) - ; - else if((pf && pf2) || (pm && pm2)) { - /* interpolate from nearest frames if cache isn't outdated */ - float *data1, *data2; + if(!pm && !pm2 && !pf && !pf2) + return 0; - if(pm) { - data1 = pm->data; - data2 = pm2->data; + if(pm) { + ptcache_mem_init_pointers(pm); + totpoint = pm->totpoint; + index = pm->data_types & (1<cur[BPHYS_DATA_INDEX] : &i; + } + if(pm2) { + ptcache_mem_init_pointers(pm2); + totpoint2 = pm2->totpoint; + index2 = pm2->data_types & (1<cur[BPHYS_DATA_INDEX] : &i; + } + if(pf) { + if(ptcache_file_read_header_begin(pf)) { + if(pf->type != pid->type) { + /* todo report error */ + ptcache_file_close(pf); + pf = NULL; + } + else if(pid->read_header(pf)) { + ptcache_file_init_pointers(pf); + totpoint = pf->totpoint; + index = pf->data_types & BPHYS_DATA_INDEX ? &pf->data.index : &i; + } } else { - data1 = MEM_callocN(elemsize, "pointcache read data1"); - data2 = MEM_callocN(elemsize, "pointcache read data2"); + /* fall back to old cache file format */ + use_old = 1; + totpoint = pid->totpoint(pid->calldata); } - - for(i=0; iinterpolate_elem(i, reader->calldata, frs_sec, cfra, (float)cfra1, (float)cfra2, data1, data2); - } - else { - reader->interpolate_elem(i, reader->calldata, frs_sec, cfra, (float)cfra1, (float)cfra2, data1, data2); - data1 += incr; - data2 += incr; - } - } - - if(pf) { - BKE_ptcache_file_close(pf); - pf = NULL; - BKE_ptcache_file_close(pf2); - pf2 = NULL; - MEM_freeN(data1); - MEM_freeN(data2); - } - - ret = PTCACHE_READ_INTERPOLATED; } - else if(pf || pm) { - /* use last valid cache frame */ - float *data; - - /* don't read cache if allready simulated past cached frame */ - if(cfra1 && cfra1 <= pid->cache->simframe) { - if(pf) - BKE_ptcache_file_close(pf); - if(pf2) - BKE_ptcache_file_close(pf2); - - return 0; + if(pf2) { + if(ptcache_file_read_header_begin(pf2)) { + if(pf2->type != pid->type) { + /* todo report error */ + ptcache_file_close(pf2); + pf2 = NULL; + } + else if(pid->read_header(pf2)) { + ptcache_file_init_pointers(pf2); + totpoint2 = pf2->totpoint; + index2 = pf->data_types & BPHYS_DATA_INDEX ? &pf2->data.index : &i; + } } + else { + /* fall back to old cache file format */ + use_old = 1; + totpoint2 = pid->totpoint(pid->calldata); + } + } - if(pm) - data = pm->data; - else - data = MEM_callocN(elemsize, "pointcache read data"); + /* don't read old cache if allready simulated past cached frame */ + if(!pm && !pf && cfra1 && cfra1 <= pid->cache->simframe) + error = 1; + if(cfra1 && cfra1==cfra2) + error = 1; - for(i=0; iset_elem(i, reader->calldata, data); + if(!error) + { + if(pf && pid->read_stream) { + if(totpoint != pid->totpoint(pid->calldata)) + error = 1; + else + { + // we have stream writing here + pid->read_stream(pf, pid->calldata); + } + } + } + + totpoint = MIN2(totpoint, pid->totpoint(pid->calldata)); + + if(!error) + { + for(i=0; iread_elem && ptcache_file_read(pf, (void*)old_data1, 1, old_elemsize)) + pid->read_elem(i, pid->calldata, NULL, frs_sec, cfra, old_data1); + else + { error = 1; break; } } else { - reader->set_elem(i, reader->calldata, data); - data += incr; + if(pid->read_elem && (pm || ptcache_file_read_data(pf))) + pid->read_elem(*index, pid->calldata, pm ? pm->cur : pf->cur, frs_sec, cfra1 ? (float)cfra1 : (float)cfrai, NULL); + else + { error = 1; break; } + } + + if(pm) { + ptcache_mem_incr_pointers(pm); + index = pm->data_types & (1<cur[BPHYS_DATA_INDEX] : &i; } } + } - if(pf) { - BKE_ptcache_file_close(pf); - pf = NULL; - MEM_freeN(data); - } - if(pf2) { - BKE_ptcache_file_close(pf2); - pf = NULL; + if(!error) + { + if(pf2 && pid->read_stream) { + if(totpoint2 != pid->totpoint(pid->calldata)) + error = 1; + else + { + // we have stream writing here + pid->read_stream(pf2, pid->calldata); + } } + } + totpoint2 = MIN2(totpoint2, pid->totpoint(pid->calldata)); + + if(!error) + { + for(i=0; iread_elem && ptcache_file_read(pf2, (void*)old_data2, 1, old_elemsize)) { + if(!pf && pf2) + pid->read_elem(i, pid->calldata, NULL, frs_sec, (float)cfra2, old_data2); + else if(pid->interpolate_elem) + pid->interpolate_elem(i, pid->calldata, NULL, frs_sec, cfra, (float)cfra1, (float)cfra2, old_data2); + else + { error = 1; break; } + } + else + { error = 1; break; } + } + else { + if(pid->read_elem && (pm2 || ptcache_file_read_data(pf2))) { + if((!pf && pf2) || (!pm && pm2)) + pid->read_elem(*index2, pid->calldata, pm2 ? pm2->cur : pf2->cur, frs_sec, (float)cfra2, NULL); + else if(pid->interpolate_elem) + pid->interpolate_elem(*index2, pid->calldata, pm2 ? pm2->cur : pf2->cur, frs_sec, cfra, (float)cfra1, (float)cfra2, NULL); + else + { error = 1; break; } + } + else + { error = 1; break; } + } + + if(pm2) { + ptcache_mem_incr_pointers(pm2); + index2 = pm2->data_types & (1<cur[BPHYS_DATA_INDEX] : &i; + } + } + } + + if(pm || pf) + ret = (pm2 || pf2) ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT; + else if(pm2 || pf2) { ret = PTCACHE_READ_OLD; + pid->cache->simframe = old_frame; } - if(pf) - BKE_ptcache_file_close(pf); - if(pf2) - BKE_ptcache_file_close(pf2); + if(pf) { + ptcache_file_close(pf); + pf = NULL; + } + + if(pf2) { + ptcache_file_close(pf2); + pf = NULL; + } if((pid->cache->flag & PTCACHE_QUICK_CACHE)==0) { + cfrai = (int)cfra; /* clear invalid cache frames so that better stuff can be simulated */ if(pid->cache->flag & PTCACHE_OUTDATED) { - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfra); + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfrai); } else if(pid->cache->flag & PTCACHE_FRAMES_SKIPPED) { if(cfra <= pid->cache->last_exact) pid->cache->flag &= ~PTCACHE_FRAMES_SKIPPED; - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfra,pid->cache->last_exact)); + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai,pid->cache->last_exact)); } } - return ret; + return (error ? 0 : ret); } +/* TODO for later */ +//static void ptcache_make_index_array(PTCacheMem *pm, int totpoint) +//{ +// int i, *index; +// +// if(pm->index_array) { +// MEM_freeN(pm->index_array); +// pm->index_array = NULL; +// } +// +// if(!pm->data[BPHYS_DATA_INDEX]) +// return; +// +// pm->index_array = MEM_callocN(totpoint * sizeof(int), "PTCacheMem index_array"); +// index = pm->data[BPHYS_DATA_INDEX]; +// +// for(i=0; itotpoint; i++, index++) +// pm->index_array[*index] = i; +//} /* writes cache to disk or memory */ -int BKE_ptcache_write_cache(PTCacheWriter *writer) +int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) { - PointCache *cache = writer->pid->cache; + PointCache *cache = pid->cache; PTCacheFile *pf= NULL; - int elemsize = ptcache_pid_elemsize(writer->pid); - int i, incr = elemsize / sizeof(float); + int i; + int totpoint = pid->totpoint(pid->calldata); int add = 0, overwrite = 0; - float temp[14]; - if(writer->totelem == 0 || writer->cfra <= 0) + if(totpoint == 0 || cfra < 0 + || (cfra ? pid->data_types == 0 : pid->info_types == 0)) return 0; if(cache->flag & PTCACHE_DISK_CACHE) { - int cfra = cache->endframe; + int efra = cache->endframe; + if(cfra==0) + add = 1; /* allways start from scratch on the first frame */ - if(writer->cfra == cache->startframe) { - BKE_ptcache_id_clear(writer->pid, PTCACHE_CLEAR_ALL, writer->cfra); + else if(cfra == cache->startframe) { + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, cfra); cache->flag &= ~PTCACHE_REDO_NEEDED; add = 1; } else { - int ocfra; + int ofra; /* find last cached frame */ - while(cfra > cache->startframe && !BKE_ptcache_id_exist(writer->pid, cfra)) - cfra--; + while(efra > cache->startframe && !BKE_ptcache_id_exist(pid, efra)) + efra--; /* find second last cached frame */ - ocfra = cfra-1; - while(ocfra > cache->startframe && !BKE_ptcache_id_exist(writer->pid, ocfra)) - ocfra--; + ofra = efra-1; + while(ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra)) + ofra--; - if(cfra >= cache->startframe && writer->cfra > cfra) { - if(ocfra >= cache->startframe && cfra - ocfra < cache->step) + if(efra >= cache->startframe && cfra > efra) { + if(ofra >= cache->startframe && efra - ofra < cache->step) overwrite = 1; else add = 1; @@ -674,74 +1305,92 @@ int BKE_ptcache_write_cache(PTCacheWriter *writer) if(add || overwrite) { if(overwrite) - BKE_ptcache_id_clear(writer->pid, PTCACHE_CLEAR_FRAME, cfra); + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, efra); - pf = BKE_ptcache_file_open(writer->pid, PTCACHE_FILE_WRITE, writer->cfra); + pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, cfra); if(!pf) return 0; - for(i=0; itotelem; i++) { - writer->set_elem(i, writer->calldata, temp); - BKE_ptcache_file_write_floats(pf, temp, incr); + pf->type = pid->type; + pf->totpoint = cfra ? totpoint : pid->totwrite(pid->calldata); + pf->data_types = cfra ? pid->data_types : pid->info_types; + + if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) { + ptcache_file_close(pf); + return 0; } + + ptcache_file_init_pointers(pf); + + if(pf && pid->write_stream) { + // we have stream writing here + pid->write_stream(pf, pid->calldata); + } + else + for(i=0; iwrite_elem && pid->write_elem(i, pid->calldata, pf->cur)) + if(!ptcache_file_write_data(pf)) { + ptcache_file_close(pf); + return 0; + } + } } } else { PTCacheMem *pm; PTCacheMem *pm2; - float *pmdata; pm2 = cache->mem_cache.first; + /* don't write info file in memory */ + if(cfra==0) + return 1; /* allways start from scratch on the first frame */ - if(writer->cfra == cache->startframe) { - BKE_ptcache_id_clear(writer->pid, PTCACHE_CLEAR_ALL, writer->cfra); + if(cfra == cache->startframe) { + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, cfra); cache->flag &= ~PTCACHE_REDO_NEEDED; add = 1; } - else { + else if (cache->mem_cache.last) { pm2 = cache->mem_cache.last; - if(pm2 && writer->cfra > pm2->frame) { + if(pm2 && cfra > pm2->frame) { if(pm2->prev && pm2->frame - pm2->prev->frame < cache->step) overwrite = 1; else add = 1; } } + else + add = 1; - if(overwrite) { - pm = cache->mem_cache.last; - pmdata = pm->data; + if(add || overwrite) { + if(overwrite) + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, pm2->frame); - for(i=0; itotelem; i++, pmdata+=incr) { - writer->set_elem(i, writer->calldata, temp); - memcpy(pmdata, temp, elemsize); - } - - pm->frame = writer->cfra; - } - else if(add) { pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); - pm->data = MEM_callocN(elemsize * writer->totelem, "Pointcache mem data"); - pmdata = pm->data; - for(i=0; itotelem; i++, pmdata+=incr) { - writer->set_elem(i, writer->calldata, temp); - memcpy(pmdata, temp, elemsize); + pm->totpoint = pid->totwrite(pid->calldata); + pm->data_types = cfra ? pid->data_types : pid->info_types; + + ptcache_alloc_data(pm); + ptcache_mem_init_pointers(pm); + + for(i=0; iwrite_elem && pid->write_elem(i, pid->calldata, pm->cur)) + ptcache_mem_incr_pointers(pm); } + //ptcache_make_index_array(pm, pid->totpoint(pid->calldata)); - pm->frame = writer->cfra; - pm->totpoint = writer->totelem; - + pm->frame = cfra; BLI_addtail(&cache->mem_cache, pm); } } if(add || overwrite) { - if(writer->cfra - cache->last_exact == 1 - || writer->cfra == cache->startframe) { - cache->last_exact = writer->cfra; + if(cfra - cache->last_exact == 1 + || cfra == cache->startframe) { + cache->last_exact = cfra; cache->flag &= ~PTCACHE_FRAMES_SKIPPED; } else @@ -749,9 +1398,9 @@ int BKE_ptcache_write_cache(PTCacheWriter *writer) } if(pf) - BKE_ptcache_file_close(pf); + ptcache_file_close(pf); - BKE_ptcache_update_info(writer->pid); + BKE_ptcache_update_info(pid); return 1; } @@ -759,7 +1408,7 @@ int BKE_ptcache_write_cache(PTCacheWriter *writer) * mode - PTCACHE_CLEAR_ALL, */ - +/* Clears & resets */ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) { int len; /* store the length of the string */ @@ -806,7 +1455,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) BLI_delete(path_full, 0, 0); } else { /* read the number of the file */ - int frame, len2 = strlen(de->d_name); + int frame, len2 = (int)strlen(de->d_name); char num[7]; if (len2 > 15) { /* could crash if trying to copy a string out of this range*/ @@ -833,7 +1482,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) if(mode == PTCACHE_CLEAR_ALL) { pid->cache->last_exact = 0; for(; pm; pm=pm->next) - MEM_freeN(pm->data); + ptcache_free_data(pm->data); BLI_freelistN(&pid->cache->mem_cache); } else { while(pm) { @@ -841,7 +1490,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) (mode==PTCACHE_CLEAR_AFTER && pm->frame > cfra) ) { link = pm; pm = pm->next; - MEM_freeN(link->data); + ptcache_free_data(link->data); BLI_freelinkN(&pid->cache->mem_cache, link); } else @@ -863,7 +1512,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) for(; pm; pm=pm->next) { if(pm->frame == cfra) { - MEM_freeN(pm->data); + ptcache_free_data(pm->data); BLI_freelinkN(&pid->cache->mem_cache, pm); break; } @@ -985,11 +1634,13 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) cache->last_exact= 0; if(pid->type == PTCACHE_TYPE_CLOTH) - cloth_free_modifier(pid->ob, pid->data); + cloth_free_modifier(pid->ob, pid->calldata); else if(pid->type == PTCACHE_TYPE_SOFTBODY) - sbFreeSimulation(pid->data); + sbFreeSimulation(pid->calldata); else if(pid->type == PTCACHE_TYPE_PARTICLES) - psys_reset(pid->data, PSYS_RESET_DEPSGRAPH); + psys_reset(pid->calldata, PSYS_RESET_DEPSGRAPH); + else if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN_LOW) + smokeModifier_reset(pid->calldata); } if(clear) BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); @@ -1038,6 +1689,17 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) BKE_ptcache_id_from_cloth(&pid, ob, (ClothModifierData*)md); reset |= BKE_ptcache_id_reset(scene, &pid, mode); } + /* + // enabled on next commit + if(md->type == eModifierType_Smoke) { + SmokeModifierData *smd = (SmokeModifierData *)md; + if(smd->type & MOD_SMOKE_TYPE_DOMAIN) + { + BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md, 0); + reset |= BKE_ptcache_id_reset(scene, &pid, mode); + } + } + */ } return reset; @@ -1107,9 +1769,9 @@ int BKE_ptcache_get_continue_physics() return CONTINUE_PHYSICS; } -/* Point Cache */ +/* Point Cache handling */ -PointCache *BKE_ptcache_add() +PointCache *BKE_ptcache_add(ListBase *ptcaches) { PointCache *cache; @@ -1118,23 +1780,41 @@ PointCache *BKE_ptcache_add() cache->endframe= 250; cache->step= 10; + BLI_addtail(ptcaches, cache); + return cache; } -void BKE_ptcache_free(PointCache *cache) +void BKE_ptache_free_mem(PointCache *cache) { PTCacheMem *pm = cache->mem_cache.first; + if(pm) { - for(; pm; pm=pm->next) - MEM_freeN(pm->data); + for(; pm; pm=pm->next) { + ptcache_free_data(pm->data); + if(pm->index_array) + MEM_freeN(pm->index_array); + } BLI_freelistN(&cache->mem_cache); } - +} +void BKE_ptcache_free(PointCache *cache) +{ + BKE_ptache_free_mem(cache); MEM_freeN(cache); } +void BKE_ptcache_free_list(ListBase *ptcaches) +{ + PointCache *cache = ptcaches->first; -PointCache *BKE_ptcache_copy(PointCache *cache) + for(; cache; cache=cache->next) + BKE_ptache_free_mem(cache); + + BLI_freelistN(ptcaches); +} + +static PointCache *ptcache_copy(PointCache *cache) { PointCache *ncache; @@ -1149,7 +1829,18 @@ PointCache *BKE_ptcache_copy(PointCache *cache) return ncache; } +/* returns first point cache */ +PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old) +{ + PointCache *cache = ptcaches_old->first; + ptcaches_new->first = ptcaches_new->last = NULL; + + for(; cache; cache=cache->next) + BLI_addtail(ptcaches_new, ptcache_copy(cache)); + + return ptcaches_new->first; +} /* Baking */ @@ -1227,7 +1918,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) cache = pid->cache; if((cache->flag & PTCACHE_BAKED)==0) { if(pid->type==PTCACHE_TYPE_PARTICLES) - psys_get_pointcache_start_end(scene, pid->data, &cache->startframe, &cache->endframe); + psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe); if(bake || cache->flag & PTCACHE_REDO_NEEDED) BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); @@ -1253,12 +1944,12 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) cache = pid->cache; if((cache->flag & PTCACHE_BAKED)==0) { if(pid->type==PTCACHE_TYPE_PARTICLES) { - ParticleSystem *psys = (ParticleSystem*)pid->data; + ParticleSystem *psys = (ParticleSystem*)pid->calldata; /* skip hair & keyed particles */ if(psys->part->type == PART_HAIR || psys->part->phystype == PART_PHYS_KEYED) continue; - psys_get_pointcache_start_end(scene, pid->data, &cache->startframe, &cache->endframe); + psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe); } if((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0) @@ -1285,10 +1976,10 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) scene->r.framelen = 1.0; for(; CFRA <= endframe; CFRA+=step) { - float prog; + int prog; if(bake) - prog = (int)(100.0 * (float)(CFRA - startframe)/(float)(endframe-startframe)); + prog = (int)(100.0f * (float)(CFRA - startframe)/(float)(endframe-startframe)); else prog = CFRA; @@ -1307,15 +1998,19 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) if(pid) { cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED); cache->flag |= PTCACHE_SIMULATION_VALID; - if(bake) + if(bake) { cache->flag |= PTCACHE_BAKED; + /* write info file */ + if(cache->flag & PTCACHE_DISK_CACHE) + BKE_ptcache_write_cache(pid, 0); + } } else for(base=scene->base.first; base; base= base->next) { BKE_ptcache_ids_from_object(&pidlist, base->object); for(pid=pidlist.first; pid; pid=pid->next) { /* skip hair particles */ - if(pid->type==PTCACHE_TYPE_PARTICLES && ((ParticleSystem*)pid->data)->part->type == PART_HAIR) + if(pid->type==PTCACHE_TYPE_PARTICLES && ((ParticleSystem*)pid->calldata)->part->type == PART_HAIR) continue; cache = pid->cache; @@ -1327,8 +2022,11 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) cache->flag |= PTCACHE_SIMULATION_VALID; - if(bake) + if(bake) { cache->flag |= PTCACHE_BAKED; + if(cache->flag & PTCACHE_DISK_CACHE) + BKE_ptcache_write_cache(pid, 0); + } } BLI_freelistN(&pidlist); } @@ -1341,14 +2039,125 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) /* TODO: call redraw all windows somehow */ } - -void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) { +/* Helpers */ +void BKE_ptcache_disk_to_mem(PTCacheID *pid) +{ PointCache *cache = pid->cache; PTCacheFile *pf; PTCacheMem *pm; - int totelem=0; - int float_count=0; - int tot; + + int cfra, sfra = cache->startframe, efra = cache->endframe; + int i; + + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); + + for(cfra=sfra; cfra <= efra; cfra++) { + pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra); + + if(pf) { + if(!ptcache_file_read_header_begin(pf)) { + printf("Can't yet convert old cache format\n"); + cache->flag |= PTCACHE_DISK_CACHE; + ptcache_file_close(pf); + return; + } + + if(pf->type != pid->type || !pid->read_header(pf)) { + cache->flag |= PTCACHE_DISK_CACHE; + ptcache_file_close(pf); + return; + } + + pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); + + pm->totpoint = pf->totpoint; + pm->data_types = pf->data_types; + pm->frame = cfra; + + ptcache_alloc_data(pm); + ptcache_mem_init_pointers(pm); + ptcache_file_init_pointers(pf); + + for(i=0; itotpoint; i++) { + if(!ptcache_file_read_data(pf)) { + printf("Error reading from disk cache\n"); + + cache->flag |= PTCACHE_DISK_CACHE; + + ptcache_free_data(pm->data); + MEM_freeN(pm); + ptcache_file_close(pf); + + return; + } + ptcache_copy_data(pf->cur, pm->cur); + ptcache_mem_incr_pointers(pm); + } + + //ptcache_make_index_array(pm, pid->totpoint(pid->calldata)); + + BLI_addtail(&pid->cache->mem_cache, pm); + + ptcache_file_close(pf); + } + } + +} +void BKE_ptcache_mem_to_disk(PTCacheID *pid) +{ + PointCache *cache = pid->cache; + PTCacheFile *pf; + PTCacheMem *pm; + int i; + + pm = cache->mem_cache.first; + + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); + + for(; pm; pm=pm->next) { + pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame); + + if(pf) { + pf->data_types = pm->data_types; + pf->totpoint = pm->totpoint; + pf->type = pid->type; + + ptcache_mem_init_pointers(pm); + ptcache_file_init_pointers(pf); + + if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) { + printf("Error writing to disk cache\n"); + cache->flag &= ~PTCACHE_DISK_CACHE; + + ptcache_file_close(pf); + return; + } + + for(i=0; itotpoint; i++) { + ptcache_copy_data(pm->cur, pf->cur); + if(!ptcache_file_write_data(pf)) { + printf("Error writing to disk cache\n"); + cache->flag &= ~PTCACHE_DISK_CACHE; + + ptcache_file_close(pf); + return; + } + ptcache_mem_incr_pointers(pm); + } + + ptcache_file_close(pf); + + /* write info file */ + if(cache->flag & PTCACHE_BAKED) + BKE_ptcache_write_cache(pid, 0); + } + else + printf("Error creating disk cache file\n"); + } +} +void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) +{ + PointCache *cache = pid->cache; int last_exact = cache->last_exact; if (!G.relbase_valid){ @@ -1357,81 +2166,14 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) { return; } - totelem = ptcache_pid_totelem(pid); - float_count = ptcache_pid_elemsize(pid) / sizeof(float); + if(cache->flag & PTCACHE_DISK_CACHE) + BKE_ptcache_mem_to_disk(pid); + else + BKE_ptcache_disk_to_mem(pid); - if(totelem==0 || float_count==0) - return; - - tot = totelem*float_count; - - /* MEM -> DISK */ - if(cache->flag & PTCACHE_DISK_CACHE) { - pm = cache->mem_cache.first; - - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); - - for(; pm; pm=pm->next) { - pf = BKE_ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame); - - if(pf) { - if(fwrite(pm->data, sizeof(float), tot, pf->fp) != tot) { - printf("Error writing to disk cache\n"); - - cache->flag &= ~PTCACHE_DISK_CACHE; - - BKE_ptcache_file_close(pf); - return; - } - BKE_ptcache_file_close(pf); - } - else - printf("Error creating disk cache file\n"); - } - - cache->flag &= ~PTCACHE_DISK_CACHE; - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); - cache->flag |= PTCACHE_DISK_CACHE; - } - /* DISK -> MEM */ - else { - int cfra; - int sfra = cache->startframe; - int efra = cache->endframe; - - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); - - for(cfra=sfra; cfra <= efra; cfra++) { - pf = BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfra); - - if(pf) { - pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); - pm->data = MEM_callocN(sizeof(float)*tot, "Pointcache mem data"); - - if(fread(pm->data, sizeof(float), tot, pf->fp)!= tot) { - printf("Error reading from disk cache\n"); - - cache->flag |= PTCACHE_DISK_CACHE; - - MEM_freeN(pm->data); - MEM_freeN(pm); - BKE_ptcache_file_close(pf); - return; - } - - pm->frame = cfra; - pm->totpoint = totelem; - - BLI_addtail(&pid->cache->mem_cache, pm); - - BKE_ptcache_file_close(pf); - } - } - - cache->flag |= PTCACHE_DISK_CACHE; - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); - cache->flag &= ~PTCACHE_DISK_CACHE; - } + cache->flag ^= PTCACHE_DISK_CACHE; + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); + cache->flag ^= PTCACHE_DISK_CACHE; cache->last_exact = last_exact; @@ -1440,15 +2182,16 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) { void BKE_ptcache_load_external(PTCacheID *pid) { + /*todo*/ PointCache *cache = pid->cache; int len; /* store the length of the string */ + int info = 0; /* mode is same as fopen's modes */ DIR *dir; struct dirent *de; char path[MAX_PTCACHE_PATH]; char filename[MAX_PTCACHE_FILE]; - char path_full[MAX_PTCACHE_FILE]; char ext[MAX_PTCACHE_PATH]; if(!cache) @@ -1475,15 +2218,19 @@ void BKE_ptcache_load_external(PTCacheID *pid) if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */ /* read the number of the file */ - int frame, len2 = strlen(de->d_name); + int frame, len2 = (int)strlen(de->d_name); char num[7]; if (len2 > 15) { /* could crash if trying to copy a string out of this range*/ BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num)); frame = atoi(num); - cache->startframe = MIN2(cache->startframe, frame); - cache->endframe = MAX2(cache->endframe, frame); + if(frame) { + cache->startframe = MIN2(cache->startframe, frame); + cache->endframe = MAX2(cache->endframe, frame); + } + else + info = 1; } } } @@ -1492,18 +2239,36 @@ void BKE_ptcache_load_external(PTCacheID *pid) if(cache->startframe != MAXFRAME) { PTCacheFile *pf; - int elemsize = ptcache_pid_elemsize(pid); - int incr = elemsize / sizeof(float); - float *data = NULL; - pf= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cache->startframe); - if(pf) { - data = MEM_callocN(elemsize, "pointcache read data"); - while(BKE_ptcache_file_read_floats(pf, data, incr)) - cache->totpoint++; - - BKE_ptcache_file_close(pf); - MEM_freeN(data); + /* read totpoint from info file (frame 0) */ + if(info) { + pf= ptcache_file_open(pid, PTCACHE_FILE_READ, 0); + + if(pf) { + if(ptcache_file_read_header_begin(pf)) { + if(pf->type == pid->type && pid->read_header(pf)) { + cache->totpoint = pf->totpoint; + cache->flag |= PTCACHE_READ_INFO; + } + else { + cache->totpoint = 0; + } + } + ptcache_file_close(pf); + } + } + /* or from any old format cache file */ + else { + float old_data[14]; + int elemsize = ptcache_pid_old_elemsize(pid); + pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cache->startframe); + + if(pf) { + while(ptcache_file_read(pf, old_data, 1, elemsize)) + cache->totpoint++; + + ptcache_file_close(pf); + } } } @@ -1511,3 +2276,65 @@ void BKE_ptcache_load_external(PTCacheID *pid) BKE_ptcache_update_info(pid); } + +void BKE_ptcache_update_info(PTCacheID *pid) +{ + PointCache *cache = pid->cache; + int totframes = 0; + char mem_info[64]; + + if(cache->flag & PTCACHE_EXTERNAL) { + int cfra = cache->startframe; + + for(; cfra<=cache->endframe; cfra++) { + if(BKE_ptcache_id_exist(pid, cfra)) + totframes++; + } + + if(totframes && cache->totpoint) + sprintf(cache->info, "%i points found!", cache->totpoint); + else + sprintf(cache->info, "No valid data to read!"); + return; + } + + if(cache->flag & PTCACHE_DISK_CACHE) { + int cfra = cache->startframe; + + for(; cfra<=cache->endframe; cfra++) { + if(BKE_ptcache_id_exist(pid, cfra)) + totframes++; + } + + sprintf(mem_info, "%i frames on disk", totframes); + } + else { + PTCacheMem *pm = cache->mem_cache.first; + float framesize = 0.0f, bytes = 0.0f; + int mb; + + if(pm) + framesize = (float)ptcache_pid_old_elemsize(pid) * (float)pm->totpoint; + + for(; pm; pm=pm->next) + totframes++; + + bytes = totframes * framesize; + + mb = (bytes > 1024.0f * 1024.0f); + + sprintf(mem_info, "%i frames in memory (%.1f %s)", + totframes, + bytes / (mb ? 1024.0f * 1024.0f : 1024.0f), + mb ? "Mb" : "kb"); + } + + if(cache->flag & PTCACHE_OUTDATED) { + sprintf(cache->info, "%s, cache is outdated!", mem_info); + } + else if(cache->flag & PTCACHE_FRAMES_SKIPPED) { + sprintf(cache->info, "%s, not exact since frame %i.", mem_info, cache->last_exact); + } + else + sprintf(cache->info, "%s.", mem_info); +} diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 74d2347ec39..139895bbdaf 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -35,6 +35,8 @@ #include #include +#include + #include "MEM_guardedalloc.h" #include "DNA_text_types.h" @@ -410,6 +412,7 @@ void init_actuator(bActuator *act) { /* also use when actuator changes type */ bObjectActuator *oa; + bSoundActuator *sa; if(act->data) MEM_freeN(act->data); act->data= 0; @@ -422,10 +425,14 @@ void init_actuator(bActuator *act) break; #endif case ACT_SOUND: - act->data= MEM_callocN(sizeof(bSoundActuator), "soundact"); - break; - case ACT_CD: - act->data= MEM_callocN(sizeof(bCDActuator), "cdact"); + sa = act->data= MEM_callocN(sizeof(bSoundActuator), "soundact"); + sa->volume = 1.0f; + sa->sound3D.rolloff_factor = 1.0f; + sa->sound3D.reference_distance = 1.0f; + sa->sound3D.max_gain = 1.0f; + sa->sound3D.cone_inner_angle = 360.0f; + sa->sound3D.cone_outer_angle = 360.0f; + sa->sound3D.max_distance = FLT_MAX; break; case ACT_OBJECT: act->data= MEM_callocN(sizeof(bObjectActuator), "objectact"); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index d629654c426..2a8fd765386 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -54,6 +54,7 @@ #include "DNA_meta_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_screen_types.h" #include "DNA_texture_types.h" #include "DNA_userdef_types.h" @@ -75,8 +76,8 @@ #include "BKE_main.h" #include "BKE_node.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_scene.h" -#include "BKE_sculpt.h" #include "BKE_sequence.h" #include "BKE_world.h" #include "BKE_utildefines.h" @@ -125,7 +126,112 @@ void free_qtcodecdata(QuicktimeCodecData *qcd) } } -/* copy_scene moved to src/header_info.c... should be back */ +Scene *copy_scene(Main *bmain, Scene *sce, int type) +{ + Scene *scen; + ToolSettings *ts; + Base *base, *obase; + + if(type == SCE_COPY_EMPTY) { + ListBase lb; + scen= add_scene(sce->id.name+2); + + lb= scen->r.layers; + scen->r= sce->r; + scen->r.layers= lb; + } + else { + scen= copy_libblock(sce); + BLI_duplicatelist(&(scen->base), &(sce->base)); + + clear_id_newpoins(); + + id_us_plus((ID *)scen->world); + id_us_plus((ID *)scen->set); + id_us_plus((ID *)scen->ima); + id_us_plus((ID *)scen->gm.dome.warptext); + + scen->ed= NULL; + scen->theDag= NULL; + scen->obedit= NULL; + scen->toolsettings= MEM_dupallocN(sce->toolsettings); + + ts= scen->toolsettings; + if(ts) { + if(ts->vpaint) { + ts->vpaint= MEM_dupallocN(ts->vpaint); + ts->vpaint->paintcursor= NULL; + ts->vpaint->vpaint_prev= NULL; + ts->vpaint->wpaint_prev= NULL; + copy_paint(&ts->vpaint->paint, &ts->vpaint->paint); + } + if(ts->wpaint) { + ts->wpaint= MEM_dupallocN(ts->wpaint); + ts->wpaint->paintcursor= NULL; + ts->wpaint->vpaint_prev= NULL; + ts->wpaint->wpaint_prev= NULL; + copy_paint(&ts->wpaint->paint, &ts->wpaint->paint); + } + if(ts->sculpt) { + ts->sculpt= MEM_dupallocN(ts->sculpt); + copy_paint(&ts->sculpt->paint, &ts->sculpt->paint); + } + + copy_paint(&ts->imapaint.paint, &ts->imapaint.paint); + ts->imapaint.paintcursor= NULL; + + ts->particle.paintcursor= NULL; + } + + BLI_duplicatelist(&(scen->markers), &(sce->markers)); + BLI_duplicatelist(&(scen->transform_spaces), &(sce->transform_spaces)); + BLI_duplicatelist(&(scen->r.layers), &(sce->r.layers)); + BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); + + scen->nodetree= ntreeCopyTree(sce->nodetree, 0); + + obase= sce->base.first; + base= scen->base.first; + while(base) { + id_us_plus(&base->object->id); + if(obase==sce->basact) scen->basact= base; + + obase= obase->next; + base= base->next; + } + } + + /* make a private copy of the avicodecdata */ + if(sce->r.avicodecdata) { + scen->r.avicodecdata = MEM_dupallocN(sce->r.avicodecdata); + scen->r.avicodecdata->lpFormat = MEM_dupallocN(scen->r.avicodecdata->lpFormat); + scen->r.avicodecdata->lpParms = MEM_dupallocN(scen->r.avicodecdata->lpParms); + } + + /* make a private copy of the qtcodecdata */ + if(sce->r.qtcodecdata) { + scen->r.qtcodecdata = MEM_dupallocN(sce->r.qtcodecdata); + scen->r.qtcodecdata->cdParms = MEM_dupallocN(scen->r.qtcodecdata->cdParms); + } + + /* NOTE: part of SCE_COPY_LINK_DATA and SCE_COPY_FULL operations + * are done outside of blenkernel with ED_objects_single_users! */ + + /* camera */ + if(type == SCE_COPY_LINK_DATA || type == SCE_COPY_FULL) { + ID_NEW(scen->camera); + } + + /* world */ + if(type == SCE_COPY_FULL) { + if(scen->world) { + id_us_plus((ID *)scen->world); + scen->world= copy_world(scen->world); + } + } + + return scen; +} /* do not free scene itself */ void free_scene(Scene *sce) @@ -140,7 +246,7 @@ void free_scene(Scene *sce) /* do not free objects! */ BLI_freelistN(&sce->base); - seq_free_editing(sce->ed); + seq_free_editing(sce); BKE_free_animdata((ID *)sce); BKE_keyingsets_free(&sce->keyingsets); @@ -166,15 +272,20 @@ void free_scene(Scene *sce) BLI_freelistN(&sce->r.layers); if(sce->toolsettings) { - if(sce->toolsettings->vpaint) + if(sce->toolsettings->vpaint) { + free_paint(&sce->toolsettings->vpaint->paint); MEM_freeN(sce->toolsettings->vpaint); - if(sce->toolsettings->wpaint) + } + if(sce->toolsettings->wpaint) { + free_paint(&sce->toolsettings->wpaint->paint); MEM_freeN(sce->toolsettings->wpaint); + } if(sce->toolsettings->sculpt) { - sculptsession_free(sce->toolsettings->sculpt); + free_paint(&sce->toolsettings->sculpt->paint); MEM_freeN(sce->toolsettings->sculpt); } - + free_paint(&sce->toolsettings->imapaint.paint); + MEM_freeN(sce->toolsettings); sce->toolsettings = NULL; } @@ -280,6 +391,9 @@ Scene *add_scene(char *name) sce->toolsettings->proportional_size = 1.0f; + + sce->unit.scale_length = 1.0f; + pset= &sce->toolsettings->particle; pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER; pset->emitterdist= 0.25f; @@ -294,7 +408,7 @@ Scene *add_scene(char *name) pset->brush[PE_BRUSH_CUT].strength= 100; sce->jumpframe = 10; - sce->audio.mixrate = 44100; + sce->r.audio.mixrate = 44100; strcpy(sce->r.backbuf, "//backbuf"); strcpy(sce->r.pic, U.renderdir); @@ -328,6 +442,9 @@ Scene *add_scene(char *name) sce->gm.physubstep = 1; sce->gm.maxphystep = 5; + sce->gm.flag = GAME_DISPLAY_LISTS; + sce->gm.matmode = GAME_MAT_MULTITEX; + return sce; } @@ -387,7 +504,7 @@ void set_scene_bg(Scene *scene) base->flag |= flag; /* not too nice... for recovering objects with lost data */ - if(ob->pose==NULL) base->flag &= ~OB_POSEMODE; + //if(ob->pose==NULL) base->flag &= ~OB_POSEMODE; ob->flag= base->flag; ob->ctime= -1234567.0; /* force ipo to be calculated later */ @@ -410,6 +527,30 @@ void set_scene_name(char *name) //XXX error("Can't find scene: %s", name); } +void unlink_scene(Main *bmain, Scene *sce, Scene *newsce) +{ + Scene *sce1; + bScreen *sc; + + /* check all sets */ + for(sce1= bmain->scene.first; sce1; sce1= sce1->id.next) + if(sce1->set == sce) + sce1->set= NULL; + + /* check all sequences */ + clear_scene_in_allseqs(sce); + + /* check render layer nodes in other scenes */ + clear_scene_in_nodes(bmain, sce); + + /* al screens */ + for(sc= bmain->screen.first; sc; sc= sc->id.next) + if(sc->scene == sce) + sc->scene= newsce; + + free_libblock(&bmain->scene, sce); +} + /* used by metaballs * doesnt return the original duplicated object, only dupli's */ @@ -674,26 +815,6 @@ void scene_add_render_layer(Scene *sce) srl->passflag= SCE_PASS_COMBINED|SCE_PASS_Z; } -void sculptsession_free(Sculpt *sculpt) -{ - SculptSession *ss= sculpt->session; - if(ss) { - if(ss->projverts) - MEM_freeN(ss->projverts); - - if(ss->fmap) - MEM_freeN(ss->fmap); - - if(ss->fmap_mem) - MEM_freeN(ss->fmap_mem); - - if(ss->texcache) - MEM_freeN(ss->texcache); - MEM_freeN(ss); - sculpt->session= NULL; - } -} - /* render simplification */ int get_render_subsurf_level(RenderData *r, int lvl) diff --git a/source/blender/blenkernel/intern/sequence.c b/source/blender/blenkernel/intern/sequence.c index 3b675a87e59..159a60ad3af 100644 --- a/source/blender/blenkernel/intern/sequence.c +++ b/source/blender/blenkernel/intern/sequence.c @@ -52,6 +52,10 @@ #include "BLI_threads.h" #include +#include "BKE_context.h" +#include "BKE_sound.h" +#include "AUD_C-API.h" + #ifdef WIN32 #define snprintf _snprintf #endif @@ -178,12 +182,16 @@ void seq_free_strip(Strip *strip) MEM_freeN(strip); } -void seq_free_sequence(Editing *ed, Sequence *seq) +void seq_free_sequence(Scene *scene, Sequence *seq) { + Editing *ed = scene->ed; + if(seq->strip) seq_free_strip(seq->strip); if(seq->anim) IMB_free_anim(seq->anim); - //XXX if(seq->hdaudio) sound_close_hdaudio(seq->hdaudio); + + if(seq->sound_handle) + sound_delete_handle(scene, seq->sound_handle); if (seq->type & SEQ_EFFECT) { struct SeqEffectHandle sh = get_sequence_effect(seq); @@ -208,8 +216,9 @@ Editing *seq_give_editing(Scene *scene, int alloc) return scene->ed; } -void seq_free_editing(Editing *ed) +void seq_free_editing(Scene *scene) { + Editing *ed = scene->ed; MetaStack *ms; Sequence *seq; @@ -217,7 +226,7 @@ void seq_free_editing(Editing *ed) return; SEQ_BEGIN(ed, seq) { - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); } SEQ_END @@ -444,6 +453,8 @@ void calc_sequence_disp(Sequence *seq) else if(seq->enddisp-seq->startdisp > 250) { seq->handsize= (float)((seq->enddisp-seq->startdisp)/25); } + + seq_update_sound(seq); } void calc_sequence(Sequence *seq) @@ -515,8 +526,8 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) char str[FILE_MAXDIR+FILE_MAXFILE]; if (!(seq->type == SEQ_MOVIE || seq->type == SEQ_IMAGE || - seq->type == SEQ_HD_SOUND || seq->type == SEQ_RAM_SOUND || - seq->type == SEQ_SCENE || seq->type == SEQ_META)) { + seq->type == SEQ_SOUND || + seq->type == SEQ_SCENE || seq->type == SEQ_META)) { return; } @@ -558,23 +569,8 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) seq->len = 0; } seq->strip->len = seq->len; - } else if (seq->type == SEQ_HD_SOUND) { -// XXX if(seq->hdaudio) sound_close_hdaudio(seq->hdaudio); -// seq->hdaudio = sound_open_hdaudio(str); - - if (!seq->hdaudio) { - return; - } - -// XXX seq->len = sound_hdaudio_get_duration(seq->hdaudio, FPS) - seq->anim_startofs - seq->anim_endofs; - if (seq->len < 0) { - seq->len = 0; - } - seq->strip->len = seq->len; - } else if (seq->type == SEQ_RAM_SOUND) { - seq->len = (int) ( ((float)(seq->sound->streamlen-1)/ - ((float)scene->audio.mixrate*4.0 )) - * FPS); + } else if (seq->type == SEQ_SOUND) { + seq->len = AUD_getInfo(seq->sound->snd_sound).length * FPS; seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { @@ -693,8 +689,7 @@ char *give_seqname_by_type(int type) case SEQ_IMAGE: return "Image"; case SEQ_SCENE: return "Scene"; case SEQ_MOVIE: return "Movie"; - case SEQ_RAM_SOUND: return "Audio (RAM)"; - case SEQ_HD_SOUND: return "Audio (HD)"; + case SEQ_SOUND: return "Audio"; case SEQ_CROSS: return "Cross"; case SEQ_GAMCROSS: return "Gamma Cross"; case SEQ_ADD: return "Add"; @@ -1071,10 +1066,9 @@ int evaluate_seq_frame(Scene *scene, int cfra) static int video_seq_is_rendered(Sequence * seq) { - return (seq - && !(seq->flag & SEQ_MUTE) - && seq->type != SEQ_RAM_SOUND - && seq->type != SEQ_HD_SOUND); + return (seq + && !(seq->flag & SEQ_MUTE) + && seq->type != SEQ_SOUND); } static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Sequence ** seq_arr_out) @@ -3309,7 +3303,7 @@ void seq_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag) } /* sounds cannot be extended past their endpoints */ - if (seq->type == SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND) { + if (seq->type == SEQ_SOUND) { seq->startstill= 0; seq->endstill= 0; } @@ -3406,3 +3400,15 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test) return 1; } } + +void seq_update_sound(struct Sequence *seq) +{ + if(seq->type == SEQ_SOUND) + { + seq->sound_handle->startframe = seq->startdisp; + seq->sound_handle->endframe = seq->enddisp; + seq->sound_handle->frameskip = seq->startofs + seq->anim_startofs; + seq->sound_handle->mute = seq->flag & SEQ_MUTE ? 1 : 0; + seq->sound_handle->changed = -1; + } +} diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index c619c3e25ab..22ea41276ff 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1,5 +1,5 @@ /** - * BKE_cloth.h + * smoke.c * * $Id$ * @@ -48,6 +48,7 @@ #include "BLI_kdtree.h" #include "BLI_kdopbvh.h" +#include "BKE_bvhutils.h" #include "BKE_cdderivedmesh.h" #include "BKE_customdata.h" #include "BKE_DerivedMesh.h" @@ -134,7 +135,9 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive float size[3]; MVert *verts = dm->getVertArray(dm); float scale = 0.0; - int res = smd->domain->maxres; + int res; + + res = smd->domain->maxres; // get BB of domain for(i = 0; i < dm->getNumVerts(dm); i++) @@ -204,12 +207,16 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive // printf("res[0]: %d, res[1]: %d, res[2]: %d\n", smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]); // dt max is 0.1 - smd->domain->fluid = smoke_init(smd->domain->res, smd->domain->amplify, smd->domain->p0, smd->domain->p1, 2.5 / FPS); + smd->domain->fluid = smoke_init(smd->domain->res, smd->domain->p0, 0.1); + smd->domain->wt = smoke_turbulence_init(smd->domain->res, (smd->domain->flags & MOD_SMOKE_HIGHRES) ? (smd->domain->amplify + 1) : 0, smd->domain->noise); smd->time = scene->r.cfra; smd->domain->firstframe = smd->time; smoke_initBlenderRNA(smd->domain->fluid, &(smd->domain->alpha), &(smd->domain->beta)); + if(smd->domain->wt) + smoke_initWaveletBlenderRNA(smd->domain->wt, &(smd->domain->strength)); + return 1; } else if((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) @@ -221,6 +228,17 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive // update particle lifetime to be one frame // smd->flow->psys->part->lifetime = scene->r.efra + 1; +/* + if(!smd->flow->bvh) + { + // smd->flow->bvh = MEM_callocN(sizeof(BVHTreeFromMesh), "smoke_bvhfromfaces"); + // bvhtree_from_mesh_faces(smd->flow->bvh, dm, 0.0, 2, 6); + + // copy obmat + // Mat4CpyMat4(smd->flow->mat, ob->obmat); + // Mat4CpyMat4(smd->flow->mat_old, ob->obmat); + } +*/ return 1; } @@ -242,9 +260,13 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive int *tridivs = NULL; float cell_len = 1.0 / 50.0; // for res = 50 size_t newdivs = 0; - size_t max_points = 0; + //size_t max_points = 0; size_t quads = 0, facecounter = 0; + // copy obmat + Mat4CpyMat4(scs->mat, ob->obmat); + Mat4CpyMat4(scs->mat_old, ob->obmat); + // count quads for(i = 0; i < dm->getNumFaces(dm); i++) { @@ -280,7 +302,7 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive size_t j, k; int divs1 = tridivs[3 * facecounter + 0]; int divs2 = tridivs[3 * facecounter + 1]; - int divs3 = tridivs[3 * facecounter + 2]; + //int divs3 = tridivs[3 * facecounter + 2]; float side1[3], side2[3], trinormorg[3], trinorm[3]; if(again == 1 && mface[i].v4) @@ -370,6 +392,11 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive MEM_freeN(tridivs); } + if(!smd->coll->bvhtree) + { + smd->coll->bvhtree = NULL; // bvhtree_build_from_smoke ( ob->obmat, dm->getFaceArray(dm), dm->getNumFaces(dm), dm->getVertArray(dm), dm->getNumVerts(dm), 0.0 ); + } + } return 0; @@ -420,12 +447,12 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int if(INPR(side1, side1) > fsTri*fsTri) { float tmp = Normalize(side1); - divs1 = (int)(tmp/fsTri); + divs1 = (int)ceil(tmp/fsTri); } if(INPR(side2, side2) > fsTri*fsTri) { float tmp = Normalize(side2); - divs2 = (int)(tmp/fsTri); + divs2 = (int)ceil(tmp/fsTri); /* // debug @@ -445,9 +472,11 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int facecounter++; - VECCOPY(p1, verts[faces[i].v3].co); + VECCOPY(p0, verts[faces[i].v3].co); + Mat4MulVecfl (ob->obmat, p0); + VECCOPY(p1, verts[faces[i].v4].co); Mat4MulVecfl (ob->obmat, p1); - VECCOPY(p2, verts[faces[i].v4].co); + VECCOPY(p2, verts[faces[i].v1].co); Mat4MulVecfl (ob->obmat, p2); VECSUB(side1, p1, p0); @@ -457,12 +486,12 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int if(INPR(side1, side1) > fsTri*fsTri) { float tmp = Normalize(side1); - divs1 = (int)(tmp/fsTri); + divs1 = (int)ceil(tmp/fsTri); } if(INPR(side2, side2) > fsTri*fsTri) { float tmp = Normalize(side2); - divs2 = (int)(tmp/fsTri); + divs2 = (int)ceil(tmp/fsTri); } (*tridivs)[3 * facecounter + 0] = divs1; @@ -495,9 +524,11 @@ void smokeModifier_freeDomain(SmokeModifierData *smd) MEM_freeN(smd->domain->tvoxbig); if(smd->domain->fluid) - { smoke_free(smd->domain->fluid); - } + + if(smd->domain->wt) + smoke_turbulence_free(smd->domain->wt); + MEM_freeN(smd->domain); smd->domain = NULL; } @@ -507,6 +538,14 @@ void smokeModifier_freeFlow(SmokeModifierData *smd) { if(smd->flow) { +/* + if(smd->flow->bvh) + { + free_bvhtree_from_mesh(smd->flow->bvh); + MEM_freeN(smd->flow->bvh); + } + smd->flow->bvh = NULL; +*/ MEM_freeN(smd->flow); smd->flow = NULL; } @@ -522,6 +561,16 @@ void smokeModifier_freeCollision(SmokeModifierData *smd) smd->coll->points = NULL; } + if(smd->coll->bvhtree) + { + BLI_bvhtree_free(smd->coll->bvhtree); + smd->coll->bvhtree = NULL; + } + + if(smd->coll->dm) + smd->coll->dm->release(smd->coll->dm); + smd->coll->dm = NULL; + MEM_freeN(smd->coll); smd->coll = NULL; } @@ -541,7 +590,10 @@ void smokeModifier_reset(struct SmokeModifierData *smd) smd->domain->bind = NULL; } smd->domain->max_textures = 0; - smd->domain->viewsettings = 0; // reset view for new frame + if(smd->domain->viewsettings < MOD_SMOKE_VIEW_USEBIG) + smd->domain->viewsettings = 0; + else + smd->domain->viewsettings = MOD_SMOKE_VIEW_USEBIG; if(smd->domain->tray) MEM_freeN(smd->domain->tray); @@ -562,10 +614,23 @@ void smokeModifier_reset(struct SmokeModifierData *smd) smoke_free(smd->domain->fluid); smd->domain->fluid = NULL; } + + if(smd->domain->wt) + { + smoke_turbulence_free(smd->domain->wt); + smd->domain->wt = NULL; + } } else if(smd->flow) { - + /* + if(smd->flow->bvh) + { + free_bvhtree_from_mesh(smd->flow->bvh); + MEM_freeN(smd->flow->bvh); + } + smd->flow->bvh = NULL; + */ } else if(smd->coll) { @@ -574,6 +639,17 @@ void smokeModifier_reset(struct SmokeModifierData *smd) MEM_freeN(smd->coll->points); smd->coll->points = NULL; } + + if(smd->coll->bvhtree) + { + BLI_bvhtree_free(smd->coll->bvhtree); + smd->coll->bvhtree = NULL; + } + + if(smd->coll->dm) + smd->coll->dm->release(smd->coll->dm); + smd->coll->dm = NULL; + } } } @@ -603,17 +679,20 @@ void smokeModifier_createType(struct SmokeModifierData *smd) /* set some standard values */ smd->domain->fluid = NULL; + smd->domain->wt = NULL; smd->domain->eff_group = NULL; smd->domain->fluid_group = NULL; smd->domain->coll_group = NULL; smd->domain->maxres = 32; - smd->domain->amplify = 2; - smd->domain->omega = 0.5; + smd->domain->amplify = 1; + smd->domain->omega = 1.0; smd->domain->alpha = -0.001; smd->domain->beta = 0.1; - smd->domain->flags = 0; + smd->domain->flags = MOD_SMOKE_DISSOLVE_LOG; + smd->domain->strength = 2.0; smd->domain->noise = MOD_SMOKE_NOISEWAVE; smd->domain->visibility = 1; + smd->domain->diss_speed = 5; // init 3dview buffer smd->domain->tvox = NULL; @@ -650,6 +729,8 @@ void smokeModifier_createType(struct SmokeModifierData *smd) smd->coll->smd = smd; smd->coll->points = NULL; smd->coll->numpoints = 0; + smd->coll->bvhtree = NULL; + smd->coll->dm = NULL; } } } @@ -657,7 +738,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd) // forward declaration void smoke_calc_transparency(struct SmokeModifierData *smd, float *light, int big); -void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm) +void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc) { if(scene->r.cfra >= smd->time) smokeModifier_init(smd, ob, scene, dm); @@ -667,6 +748,13 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM if(scene->r.cfra > smd->time) { // XXX TODO + smd->time = scene->r.cfra; + + // rigid movement support + /* + Mat4CpyMat4(smd->flow->mat_old, smd->flow->mat); + Mat4CpyMat4(smd->flow->mat, ob->obmat); + */ } else if(scene->r.cfra < smd->time) { @@ -674,7 +762,29 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM smokeModifier_reset(smd); } } - else if((smd->type & MOD_SMOKE_TYPE_DOMAIN)) + else if(smd->type & MOD_SMOKE_TYPE_COLL) + { + if(scene->r.cfra > smd->time) + { + // XXX TODO + smd->time = scene->r.cfra; + + if(smd->coll->dm) + smd->coll->dm->release(smd->coll->dm); + + smd->coll->dm = CDDM_copy(dm); + + // rigid movement support + Mat4CpyMat4(smd->coll->mat_old, smd->coll->mat); + Mat4CpyMat4(smd->coll->mat, ob->obmat); + } + else if(scene->r.cfra < smd->time) + { + smd->time = scene->r.cfra; + smokeModifier_reset(smd); + } + } + else if(smd->type & MOD_SMOKE_TYPE_DOMAIN) { SmokeDomainSettings *sds = smd->domain; @@ -682,40 +792,30 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM { GroupObject *go = NULL; Base *base = NULL; - int cnt_domain = 0; tstart(); - - sds->viewsettings = 0; // reset view for new frame - - // check for 2nd domain, if not there -> no groups are necessary - for(base = scene->base.first; base; base= base->next) + + if(sds->flags & MOD_SMOKE_DISSOLVE) { - Object *ob1= base->object; + smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); - if(ob1 && ob1 != ob) - { - ModifierData *tmd = modifiers_findByType(ob1, eModifierType_Smoke); - - if(tmd && tmd->mode & (eModifierMode_Realtime | eModifierMode_Render)) - { - SmokeModifierData *tsmd = (SmokeModifierData *)tmd; - - if((tsmd->type & MOD_SMOKE_TYPE_DOMAIN)) - { - cnt_domain++; - } - } - } + if(sds->wt) + smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); } + /* reset view for new frame */ + if(sds->viewsettings < MOD_SMOKE_VIEW_USEBIG) + sds->viewsettings = 0; + else + sds->viewsettings = MOD_SMOKE_VIEW_USEBIG; + // do flows and fluids - if(sds->fluid_group || !cnt_domain) + if(1) { Object *otherobj = NULL; ModifierData *md = NULL; - if(cnt_domain && !sds->fluid_group) // we use groups since we have 2 domains + if(sds->fluid_group) // we use groups since we have 2 domains go = sds->fluid_group->gobject.first; else base = scene->base.first; @@ -724,7 +824,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM { otherobj = NULL; - if(cnt_domain && !sds->fluid_group) + if(sds->fluid_group) { if(go->ob) otherobj = go->ob; @@ -734,7 +834,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM if(!otherobj) { - if(cnt_domain && !sds->fluid_group) + if(sds->fluid_group) go = go->next; else base= base->next; @@ -762,14 +862,15 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM ParticleData *pa = NULL; int p = 0; float *density = smoke_get_density(sds->fluid); - float *bigdensity = smoke_get_bigdensity(sds->fluid); + float *bigdensity = smoke_turbulence_get_density(sds->wt); float *heat = smoke_get_heat(sds->fluid); float *velocity_x = smoke_get_velocity_x(sds->fluid); float *velocity_y = smoke_get_velocity_y(sds->fluid); float *velocity_z = smoke_get_velocity_z(sds->fluid); - int bigres[3]; + unsigned char *obstacle = smoke_get_obstacle(sds->fluid); + int bigres[3]; - smoke_get_bigres(smd->domain->fluid, bigres); + printf("found flow psys\n"); // mostly copied from particle code for(p=0, pa=psys->particles; ptotpart; p++, pa++) @@ -777,6 +878,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM int cell[3]; size_t i = 0; size_t index = 0; + int badcell = 0; if(pa->alive == PARS_KILLED) continue; else if(pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0) continue; @@ -793,35 +895,51 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM for(i = 0; i < 3; i++) { if((cell[i] > sds->res[i] - 1) || (cell[i] < 0)) - continue; + { + badcell = 1; + break; + } } + + if(badcell) + continue; // 2. set cell values (heat, density and velocity) index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); - if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW)) // this is inflow + if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) && !(obstacle[index] & 2)) // this is inflow { + // heat[index] += sfs->temp * 0.1; + // density[index] += sfs->density * 0.1; + heat[index] = sfs->temp; density[index] = sfs->density; + + /* velocity_x[index] = pa->state.vel[0]; velocity_y[index] = pa->state.vel[1]; velocity_z[index] = pa->state.vel[2]; + */ + obstacle[index] |= 2; // we need different handling for the high-res feature if(bigdensity) { // init all surrounding cells according to amplification, too int i, j, k; - for(i = 0; i < smd->domain->amplify; i++) - for(j = 0; j < smd->domain->amplify; j++) - for(k = 0; k < smd->domain->amplify; k++) + + smoke_turbulence_get_res(smd->domain->wt, bigres); + + for(i = 0; i < smd->domain->amplify + 1; i++) + for(j = 0; j < smd->domain->amplify + 1; j++) + for(k = 0; k < smd->domain->amplify + 1; k++) { - index = smoke_get_index(smd->domain->amplify * cell[0] + i, bigres[0], smd->domain->amplify * cell[1] + j, bigres[1], smd->domain->amplify * cell[2] + k); + index = smoke_get_index((smd->domain->amplify + 1)* cell[0] + i, bigres[0], (smd->domain->amplify + 1)* cell[1] + j, bigres[1], (smd->domain->amplify + 1)* cell[2] + k); bigdensity[index] = sfs->density; } } } - else // outflow + else if(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) // outflow { heat[index] = 0.f; density[index] = 0.f; @@ -834,21 +952,38 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM { // init all surrounding cells according to amplification, too int i, j, k; - for(i = 0; i < smd->domain->amplify; i++) - for(j = 0; j < smd->domain->amplify; j++) - for(k = 0; k < smd->domain->amplify; k++) + + smoke_turbulence_get_res(smd->domain->wt, bigres); + + for(i = 0; i < smd->domain->amplify + 1; i++) + for(j = 0; j < smd->domain->amplify + 1; j++) + for(k = 0; k < smd->domain->amplify + 1; k++) { - index = smoke_get_index(smd->domain->amplify * cell[0] + i, bigres[0], smd->domain->amplify * cell[1] + j, bigres[1], smd->domain->amplify * cell[2] + k); + index = smoke_get_index((smd->domain->amplify + 1)* cell[0] + i, bigres[0], (smd->domain->amplify + 1)* cell[1] + j, bigres[1], (smd->domain->amplify + 1)* cell[2] + k); bigdensity[index] = 0.f; } } } } - } + } + else + { + /* + for() + { + // no psys + BVHTreeNearest nearest; + + nearest.index = -1; + nearest.dist = FLT_MAX; + + BLI_bvhtree_find_nearest(sfs->bvh->tree, pco, &nearest, sfs->bvh->nearest_callback, sfs->bvh); + }*/ + } } } - if(cnt_domain && !sds->fluid_group) + if(sds->fluid_group) go = go->next; else base= base->next; @@ -873,12 +1008,12 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM */ // do collisions - if(sds->coll_group || !cnt_domain) + if(1) { Object *otherobj = NULL; ModifierData *md = NULL; - if(cnt_domain && !sds->coll_group) // we use groups since we have 2 domains + if(sds->coll_group) // we use groups since we have 2 domains go = sds->coll_group->gobject.first; else base = scene->base.first; @@ -887,7 +1022,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM { otherobj = NULL; - if(cnt_domain && !sds->coll_group) + if(sds->coll_group) { if(go->ob) otherobj = go->ob; @@ -897,7 +1032,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM if(!otherobj) { - if(cnt_domain && !sds->coll_group) + if(sds->coll_group) go = go->next; else base= base->next; @@ -916,23 +1051,34 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM { // we got nice collision object SmokeCollSettings *scs = smd2->coll; - int cell[3]; - size_t index = 0; size_t i, j; unsigned char *obstacles = smoke_get_obstacle(smd->domain->fluid); for(i = 0; i < scs->numpoints; i++) { + int badcell = 0; + size_t index = 0; + int cell[3]; + // 1. get corresponding cell get_cell(smd, &scs->points[3 * i], cell, 0); // check if cell is valid (in the domain boundary) for(j = 0; j < 3; j++) if((cell[j] > sds->res[j] - 1) || (cell[j] < 0)) - continue; - + { + badcell = 1; + break; + } + + if(badcell) + continue; + // 2. set cell values (heat, density and velocity) index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); + + // printf("cell[0]: %d, cell[1]: %d, cell[2]: %d\n", cell[0], cell[1], cell[2]); + // printf("res[0]: %d, res[1]: %d, res[2]: %d, index: %d\n\n", sds->res[0], sds->res[1], sds->res[2], index); obstacles[index] = 1; @@ -960,7 +1106,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } } - if(cnt_domain && !sds->coll_group) + if(sds->coll_group) go = go->next; else base= base->next; @@ -971,7 +1117,9 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM smd->time = scene->r.cfra; // simulate the actual smoke (c++ code in intern/smoke) - smoke_step(sds->fluid); + smoke_step(sds->fluid, smd->time); + if(sds->wt) + smoke_turbulence_step(sds->wt, sds->fluid); tend(); printf ( "Frame: %d, Time: %f\n", (int)smd->time, ( float ) tval() ); @@ -1015,7 +1163,7 @@ void smoke_prepare_View(SmokeModifierData *smd, float *light) // formula taken from "Visual Simulation of Smoke" / Fedkiw et al. pg. 4 // T_vox = exp(-C_ext * h) // C_ext/sigma_t = density * C_ext - smoke_set_tvox(smd, index, exp(-density[index] * 4.0 * smd->domain->dx)); + smoke_set_tvox(smd, index, exp(-density[index] * 7.0 * smd->domain->dx)); } smoke_calc_transparency(smd, light, 0); } @@ -1027,7 +1175,7 @@ void smoke_prepare_bigView(SmokeModifierData *smd, float *light) size_t i = 0; int bigres[3]; - smoke_get_bigres(smd->domain->fluid, bigres); + smoke_turbulence_get_res(smd->domain->wt, bigres); if(!smd->domain->traybig) { @@ -1040,14 +1188,14 @@ void smoke_prepare_bigView(SmokeModifierData *smd, float *light) smd->domain->tvoxbig = MEM_callocN(sizeof(float)*bigres[0]*bigres[1]*bigres[2], "Smoke_tVoxBig"); } - density = smoke_get_bigdensity(smd->domain->fluid); + density = smoke_turbulence_get_density(smd->domain->wt); for (i = 0; i < bigres[0] * bigres[1] * bigres[2]; i++) { // Transparency computation // formula taken from "Visual Simulation of Smoke" / Fedkiw et al. pg. 4 // T_vox = exp(-C_ext * h) // C_ext/sigma_t = density * C_ext - smoke_set_bigtvox(smd, i, exp(-density[i] * 4.0 * smd->domain->dx / smd->domain->amplify) ); + smoke_set_bigtvox(smd, i, exp(-density[i] * 7.0 * smd->domain->dx / (smd->domain->amplify + 1)) ); } smoke_calc_transparency(smd, light, 1); } @@ -1126,7 +1274,7 @@ static void calc_voxel_transp_big(SmokeModifierData *smd, int *pixel, float *tRa int bigres[3]; size_t index; - smoke_get_bigres(smd->domain->fluid, bigres); + smoke_turbulence_get_res(smd->domain->wt, bigres); index = smoke_get_index(pixel[0], bigres[0], pixel[1], bigres[1], pixel[2]); /* @@ -1258,11 +1406,11 @@ static void get_bigcell(struct SmokeModifierData *smd, float *pos, int *cell, in { float tmp[3]; int res[3]; - smoke_get_bigres(smd->domain->fluid, res); + smoke_turbulence_get_res(smd->domain->wt, res); VECSUB(tmp, pos, smd->domain->p0); - VecMulf(tmp, smd->domain->amplify / smd->domain->dx ); + VecMulf(tmp, (smd->domain->amplify + 1)/ smd->domain->dx ); if(correct) { @@ -1310,8 +1458,8 @@ void smoke_calc_transparency(struct SmokeModifierData *smd, float *light, int bi } else { - smoke_get_bigres(smd->domain->fluid, res); - bigfactor = 1.0 / smd->domain->amplify; + smoke_turbulence_get_res(smd->domain->wt, res); + bigfactor = 1.0 / (smd->domain->amplify + 1); } #pragma omp parallel for schedule(static) private(y, z) shared(big, smd, light, res, bigfactor) diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 0a1963c84f2..68f918b0c68 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3687,87 +3687,6 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, } } -static void softbody_write_state(int index, void *soft_v, float *data) -{ - SoftBody *soft= soft_v; - BodyPoint *bp = soft->bpoint + index; - - memcpy(data, bp->pos, 3 * sizeof(float)); - memcpy(data + 3, bp->vec, 3 * sizeof(float)); -} -static void softbody_read_state(int index, void *soft_v, float *data) -{ - SoftBody *soft= soft_v; - BodyPoint *bp = soft->bpoint + index; - - memcpy(bp->pos, data, 3 * sizeof(float)); - memcpy(bp->vec, data + 3, 3 * sizeof(float)); -} -static void softbody_cache_interpolate(int index, void *soft_v, float frs_sec, float cfra, float cfra1, float cfra2, float *data1, float *data2) -{ - SoftBody *soft= soft_v; - BodyPoint *bp = soft->bpoint + index; - ParticleKey keys[4]; - float dfra; - - if(cfra1 == cfra2) { - softbody_read_state(index, soft, data1); - return; - } - - memcpy(keys[1].co, data1, 3 * sizeof(float)); - memcpy(keys[1].vel, data1 + 3, 3 * sizeof(float)); - - memcpy(keys[2].co, data2, 3 * sizeof(float)); - memcpy(keys[2].vel, data2 + 3, 3 * sizeof(float)); - - dfra = cfra2 - cfra1; - - VecMulf(keys[1].vel, dfra); - VecMulf(keys[2].vel, dfra); - - psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1); - - VecMulf(keys->vel, 1.0f / dfra); - - memcpy(bp->pos, keys->co, 3 * sizeof(float)); - memcpy(bp->vec, keys->vel, 3 * sizeof(float)); -} -void softbody_write_cache(Object *ob, SoftBody *soft, int cfra) -{ - PTCacheWriter writer; - PTCacheID pid; - - BKE_ptcache_id_from_softbody(&pid, ob, soft); - - writer.calldata = soft; - writer.cfra = cfra; - writer.set_elem = softbody_write_state; - writer.pid = &pid; - writer.totelem = soft->totpoint; - - BKE_ptcache_write_cache(&writer); -} - -int softbody_read_cache(Scene *scene, Object *ob, SoftBody *soft, float cfra, int *old_framenr) -{ - PTCacheReader reader; - PTCacheID pid; - - BKE_ptcache_id_from_softbody(&pid, ob, soft); - - reader.calldata = soft; - reader.cfra = cfra; - reader.interpolate_elem = softbody_cache_interpolate; - reader.old_frame = old_framenr; - reader.pid = &pid; - reader.scene = scene; - reader.set_elem = softbody_read_state; - reader.totelem = soft->totpoint; - - return BKE_ptcache_read_cache(&reader); -} - /* +++ ************ maintaining scratch *************** */ static void sb_new_scratch(SoftBody *sb) { @@ -3827,7 +3746,7 @@ SoftBody *sbNew(Scene *scene) sb->shearstiff = 1.0f; sb->solverflags |= SBSO_OLDERR; - sb->pointcache = BKE_ptcache_add(); + sb->pointcache = BKE_ptcache_add(&sb->ptcaches); return sb; } @@ -3836,7 +3755,8 @@ SoftBody *sbNew(Scene *scene) void sbFree(SoftBody *sb) { free_softbody_intern(sb); - BKE_ptcache_free(sb->pointcache); + BKE_ptcache_free_list(&sb->ptcaches); + sb->pointcache = NULL; MEM_freeN(sb); } @@ -4135,7 +4055,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i PTCacheID pid; float dtime, timescale; int framedelta, framenr, startframe, endframe; - int cache_result, old_framenr; + int cache_result; cache= sb->pointcache; @@ -4221,7 +4141,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i } /* try to read from cache */ - cache_result = softbody_read_cache(scene, ob, sb, framenr, &old_framenr); + cache_result = BKE_ptcache_read_cache(&pid, framenr, scene->r.frs_sec); if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { cache->flag |= PTCACHE_SIMULATION_VALID; @@ -4235,7 +4155,6 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i else if(cache_result==PTCACHE_READ_OLD) { BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE); cache->flag |= PTCACHE_SIMULATION_VALID; - cache->simframe= old_framenr; } else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) { /* if baked and nothing in cache, do nothing */ @@ -4263,7 +4182,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i else { /* if on second frame, write cache for first frame */ if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) - softbody_write_cache(ob, sb, startframe); + BKE_ptcache_write_cache(&pid, startframe); softbody_update_positions(ob, sb, vertexCos, numVerts); @@ -4279,7 +4198,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i if(sb->particles==0) softbody_to_object(ob, vertexCos, numVerts, 0); - softbody_write_cache(ob, sb, framenr); + BKE_ptcache_write_cache(&pid, framenr); } } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 2c5b49246fb..a3275792a85 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -1,6 +1,6 @@ /** * sound.c (mar-2001 nzc) - * + * * $Id$ */ @@ -14,125 +14,463 @@ #include "DNA_scene_types.h" #include "DNA_sound_types.h" #include "DNA_packedFile_types.h" +#include "DNA_screen_types.h" +#include "DNA_userdef_types.h" + +#include "AUD_C-API.h" #include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_sound.h" +#include "BKE_context.h" +#include "BKE_library.h" #include "BKE_packedFile.h" #ifdef HAVE_CONFIG_H #include #endif -ListBase _samples = {0,0}, *samples = &_samples; - -void sound_free_sound(bSound *sound) +void sound_init() { - /* when sounds have been loaded, but not played, the packedfile was not copied - to sample block and not freed otherwise */ - if(sound->sample==NULL) { - if (sound->newpackedfile) { - freePackedFile(sound->newpackedfile); - sound->newpackedfile = NULL; - } - } - if (sound->stream) free(sound->stream); -} + AUD_Specs specs; + int device, buffersize, success; -void sound_free_sample(bSample *sample) -{ - if (sample) { - if (sample->data != &sample->fakedata[0] && sample->data != NULL) { - MEM_freeN(sample->data); - sample->data = &sample->fakedata[0]; - } - - if (sample->packedfile) { - freePackedFile(sample->packedfile); //FIXME: crashes sometimes - sample->packedfile = NULL; - } - - if (sample->alindex != SAMPLE_INVALID) { -// AUD_free_sample(sample->snd_sample); - sample->alindex = SAMPLE_INVALID; - } + device = U.audiodevice; + buffersize = U.mixbufsize; + specs.channels = U.audiochannels; + specs.format = U.audioformat; + specs.rate = U.audiorate; - sample->type = SAMPLE_INVALID; + if(buffersize < 128) + buffersize = AUD_DEFAULT_BUFFER_SIZE; + + if(specs.rate < AUD_RATE_8000) + specs.rate = AUD_RATE_44100; + + if(specs.format <= AUD_FORMAT_INVALID) + specs.format = AUD_FORMAT_S16; + + if(specs.channels <= AUD_CHANNELS_INVALID) + specs.channels = AUD_CHANNELS_STEREO; + + if(!AUD_init(device, specs, buffersize)) { + if(device == AUD_SDL_DEVICE) + success= AUD_init(AUD_OPENAL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4); + else + success= AUD_init(AUD_SDL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4); + + if(!success) + AUD_init(AUD_NULL_DEVICE, specs, buffersize); } } -/* this is called after file reading or undos */ -void sound_free_all_samples(void) +void sound_exit() { - bSample *sample; - bSound *sound; - - /* ensure no sample pointers exist, and check packedfile */ - for(sound= G.main->sound.first; sound; sound= sound->id.next) { - if(sound->sample && sound->sample->packedfile==sound->newpackedfile) - sound->newpackedfile= NULL; - sound->sample= NULL; - } - - /* now free samples */ - for(sample= samples->first; sample; sample= sample->id.next) - sound_free_sample(sample); - BLI_freelistN(samples); - + AUD_exit(); } -void sound_set_packedfile(bSample *sample, PackedFile *pf) +struct bSound* sound_new_file(struct Main *main, char* filename) { - bSound *sound; - - if (sample) { - sample->packedfile = pf; - sound = G.main->sound.first; - while (sound) { - if (sound->sample == sample) { - sound->newpackedfile = pf; - if (pf == NULL) { - strcpy(sound->name, sample->name); + bSound* sound = NULL; + + char str[FILE_MAX]; + int len; + + strcpy(str, filename); + BLI_convertstringcode(str, G.sce); + + len = strlen(filename); + while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') + len--; + + sound = alloc_libblock(&main->sound, ID_SO, filename+len); + strcpy(sound->name, filename); + sound->type = SOUND_TYPE_FILE; + + sound_load(sound); + + if(!sound->snd_sound) + { + free_libblock(&main->sound, sound); + sound = NULL; + } + + return sound; +} + +// XXX unused currently +#if 0 +struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source) +{ + bSound* sound = NULL; + + char name[25]; + strcpy(name, "buf_"); + strcpy(name + 4, source->id.name); + + sound = alloc_libblock(&CTX_data_main(C)->sound, ID_SO, name); + + sound->child_sound = source; + sound->type = SOUND_TYPE_BUFFER; + + sound_load(sound); + + if(!sound->snd_sound) + { + free_libblock(&CTX_data_main(C)->sound, sound); + sound = NULL; + } + + return sound; +} + +struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, float start, float end) +{ + bSound* sound = NULL; + + char name[25]; + strcpy(name, "lim_"); + strcpy(name + 4, source->id.name); + + sound = alloc_libblock(&CTX_data_main(C)->sound, ID_SO, name); + + sound->child_sound = source; + sound->start = start; + sound->end = end; + sound->type = SOUND_TYPE_LIMITER; + + sound_load(sound); + + if(!sound->snd_sound) + { + free_libblock(&CTX_data_main(C)->sound, sound); + sound = NULL; + } + + return sound; +} +#endif + +void sound_delete(struct bContext *C, struct bSound* sound) +{ + if(sound) + { + sound_free(sound); + + sound_unlink(C, sound); + + free_libblock(&CTX_data_main(C)->sound, sound); + } +} + +void sound_cache(struct bSound* sound, int ignore) +{ + if(sound->cache && !ignore) + AUD_unload(sound->cache); + + sound->cache = AUD_bufferSound(sound->snd_sound); +} + +void sound_load(struct bSound* sound) +{ + if(sound) + { + if(sound->snd_sound) + { + AUD_unload(sound->snd_sound); + sound->snd_sound = NULL; + } + + switch(sound->type) + { + case SOUND_TYPE_FILE: + { + char fullpath[FILE_MAX]; + char *path; + + /* load sound */ + PackedFile* pf = sound->packedfile; + + /* dont modify soundact->sound->name, only change a copy */ + BLI_strncpy(fullpath, sound->name, sizeof(fullpath)); + + if(sound->id.lib) + path = sound->id.lib->filename; + else + path = G.sce; + + BLI_convertstringcode(fullpath, path); + + /* but we need a packed file then */ + if (pf) + sound->snd_sound = AUD_loadBuffer((unsigned char*) pf->data, pf->size); + /* or else load it from disk */ + else + sound->snd_sound = AUD_load(fullpath); + break; + } + case SOUND_TYPE_BUFFER: + if(sound->child_sound && sound->child_sound->snd_sound) + sound->snd_sound = AUD_bufferSound(sound->child_sound->snd_sound); + break; + case SOUND_TYPE_LIMITER: + if(sound->child_sound && sound->child_sound->snd_sound) + sound->snd_sound = AUD_limitSound(sound->child_sound, sound->start, sound->end); + break; + } + + if(sound->cache) + { + + } + } +} + +void sound_free(struct bSound* sound) +{ + if (sound->packedfile) + { + freePackedFile(sound->packedfile); + sound->packedfile = NULL; + } + + if(sound->snd_sound) + { + AUD_unload(sound->snd_sound); + sound->snd_sound = NULL; + } +} + +void sound_unlink(struct bContext *C, struct bSound* sound) +{ + bSound *snd; + Scene *scene; + SoundHandle *handle; + + for(snd = CTX_data_main(C)->sound.first; snd; snd = snd->id.next) + { + if(snd->child_sound == sound) + { + snd->child_sound = NULL; + if(snd->snd_sound) + { + AUD_unload(sound->snd_sound); + snd->snd_sound = NULL; + } + + sound_unlink(C, snd); + } + } + + for(scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next) + { + for(handle = scene->sound_handles.first; handle; handle = handle->next) + { + if(handle->source == sound) + { + handle->source = NULL; + if(handle->handle) + AUD_stop(handle->handle); + } + } + } +} + +struct SoundHandle* sound_new_handle(struct Scene *scene, struct bSound* sound, int startframe, int endframe, int frameskip) +{ + ListBase* handles = &scene->sound_handles; + + SoundHandle* handle = MEM_callocN(sizeof(SoundHandle), "sound_handle"); + handle->source = sound; + handle->startframe = startframe; + handle->endframe = endframe; + handle->frameskip = frameskip; + handle->state = AUD_STATUS_INVALID; + handle->volume = 1.0f; + + BLI_addtail(handles, handle); + + return handle; +} + +void sound_delete_handle(struct Scene *scene, struct SoundHandle *handle) +{ + if(handle == NULL) + return; + + if(handle->handle) + AUD_stop(handle->handle); + + BLI_freelinkN(&scene->sound_handles, handle); +} + +void sound_stop_all(struct bContext *C) +{ + SoundHandle *handle; + + for(handle = CTX_data_scene(C)->sound_handles.first; handle; handle = handle->next) + { + if(handle->state == AUD_STATUS_PLAYING) + { + AUD_pause(handle->handle); + handle->state = AUD_STATUS_PAUSED; + } + } +} + +#define SOUND_PLAYBACK_LAMBDA 1.0 + +void sound_update_playing(struct bContext *C) +{ + SoundHandle *handle; + Scene* scene = CTX_data_scene(C); + int cfra = CFRA; + float fps = FPS; + int action; + + AUD_lock(); + + for(handle = scene->sound_handles.first; handle; handle = handle->next) + { + if(cfra < handle->startframe || cfra >= handle->endframe || handle->mute) + { + if(handle->state == AUD_STATUS_PLAYING) + { + AUD_pause(handle->handle); + handle->state = AUD_STATUS_PAUSED; + } + } + else + { + action = 0; + + if(handle->changed != handle->source->changed) + { + handle->changed = handle->source->changed; + action = 3; + if(handle->state != AUD_STATUS_INVALID) + { + AUD_stop(handle->handle); + handle->state = AUD_STATUS_INVALID; } } - sound = sound->id.next; + else + { + if(handle->state != AUD_STATUS_PLAYING) + action = 3; + else + { + handle->state = AUD_getStatus(handle->handle); + if(handle->state != AUD_STATUS_PLAYING) + action = 3; + else + { + float diff = AUD_getPosition(handle->handle) - (cfra - handle->startframe) / fps; +// AUD_XXX float diff = AUD_getPosition(handle->handle) * fps - cfra + handle->startframe + if(diff < 0.0) + diff = -diff; + if(diff > SOUND_PLAYBACK_LAMBDA) +// AUD_XXX if(diff > 5.0f) + { + action = 2; + } + } + } + } + + if(action & 1) + { + if(handle->state == AUD_STATUS_INVALID) + { + if(handle->source && handle->source->snd_sound) + { + AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->snd_sound, handle->frameskip / fps, (handle->frameskip + handle->endframe - handle->startframe)/fps); + handle->handle = AUD_play(limiter, 1); + AUD_unload(limiter); + if(handle->handle) + handle->state = AUD_STATUS_PLAYING; + if(cfra == handle->startframe) + action &= ~2; + } + } + else + if(AUD_resume(handle->handle)) + handle->state = AUD_STATUS_PLAYING; + else + handle->state = AUD_STATUS_INVALID; + } + + if(action & 2) + AUD_seek(handle->handle, (cfra - handle->startframe) / fps); } } + + AUD_unlock(); +} + +void sound_scrub(struct bContext *C) +{ + SoundHandle *handle; + Scene* scene = CTX_data_scene(C); + int cfra = CFRA; + float fps = FPS; + + if(scene->r.audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer) + { + AUD_lock(); + + for(handle = scene->sound_handles.first; handle; handle = handle->next) + { + if(cfra >= handle->startframe && cfra < handle->endframe && !handle->mute) + { + if(handle->source && handle->source->snd_sound) + { + int frameskip = handle->frameskip + cfra - handle->startframe; + AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->snd_sound, frameskip / fps, (frameskip + 1)/fps); + AUD_play(limiter, 0); + AUD_unload(limiter); + } + } + } + + AUD_unlock(); + } } -PackedFile* sound_find_packedfile(bSound *sound) +AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int end) { - bSound *search; - PackedFile *pf = NULL; - char soundname[FILE_MAXDIR + FILE_MAXFILE], searchname[FILE_MAXDIR + FILE_MAXFILE]; - - // convert sound->name to abolute filename - strcpy(soundname, sound->name); - BLI_convertstringcode(soundname, G.sce); - - search = G.main->sound.first; - while (search) { - if (search->sample && search->sample->packedfile) { - strcpy(searchname, search->sample->name); - BLI_convertstringcode(searchname, G.sce); - - if (BLI_streq(searchname, soundname)) { - pf = search->sample->packedfile; - break; - } - } - - if (search->newpackedfile) { - strcpy(searchname, search->name); - BLI_convertstringcode(searchname, G.sce); - if (BLI_streq(searchname, soundname)) { - pf = search->newpackedfile; - break; + AUD_Device* mixdown = AUD_openReadDevice(specs); + SoundHandle *handle; + float fps = FPS; + AUD_Sound *limiter, *delayer; + int frameskip, s, e; + + end++; + + for(handle = scene->sound_handles.first; handle; handle = handle->next) + { + if(start < handle->endframe && end > handle->startframe && !handle->mute && handle->source && handle->source->snd_sound) + { + frameskip = handle->frameskip; + s = handle->startframe - start; + e = handle->frameskip + AUD_MIN(handle->endframe, end) - handle->startframe; + + if(s < 0) + { + frameskip -= s; + s = 0; } + + limiter = AUD_limitSound(handle->source->snd_sound, frameskip / fps, e / fps); + delayer = AUD_delaySound(limiter, s / fps); + + AUD_playDevice(mixdown, delayer); + + AUD_unload(delayer); + AUD_unload(limiter); } - search = search->id.next; } - - return (pf); + + return mixdown; } diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c new file mode 100644 index 00000000000..f8e3b3c5ad2 --- /dev/null +++ b/source/blender/blenkernel/intern/unit.c @@ -0,0 +1,585 @@ +/** + * + * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include +#include +#include +#include + +#if defined(WIN32) && (!(defined snprintf)) +#define snprintf _snprintf +#endif + +#define TEMP_STR_SIZE 256 + +#define SEP_CHR '#' +#define SEP_STR "#" + +#define EUL 0.000001 + + +/* define a single unit */ +typedef struct bUnitDef { + char *name; + char *name_plural; /* abused a bit for the display name */ + char *name_short; /* this is used for display*/ + char *name_alt; /* can be NULL */ + + char *name_display; /* can be NULL */ + + double scalar; + double bias; /* not used yet, needed for converting temperature */ + int flag; +} bUnitDef; + +#define B_UNIT_DEF_NONE 0 +#define B_UNIT_DEF_SUPPRESS 1 /* Use for units that are not used enough to be translated into for common use */ + +/* define a single unit */ +typedef struct bUnitCollection { + struct bUnitDef *units; + int base_unit; /* use for 0.0, or none given */ + int flag; /* options for this system */ + int length; /* to quickly find the last item */ +} bUnitCollection; + +/* Dummy */ +static struct bUnitDef buDummyDef[] = { + {"", NULL, "", NULL, NULL, 1.0, 0.0}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buDummyCollecton = {buDummyDef, 0, 0, sizeof(buDummyDef)}; + + +/* Lengths */ +static struct bUnitDef buMetricLenDef[] = { + {"kilometer", "kilometers", "km", NULL, "Kilometers", 1000.0, 0.0, B_UNIT_DEF_NONE}, + {"hectometer", "hectometers", "hm", NULL, "10 Meters", 100.0, 0.0, B_UNIT_DEF_SUPPRESS}, + {"dekameter", "dekameters", "dkm",NULL, "10 Meters", 10.0, 0.0, B_UNIT_DEF_SUPPRESS}, + {"meter", "meters", "m", NULL, "Meters", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"decimetre", "decimetres", "dm", NULL, "10 Centimeters", 0.1, 0.0, B_UNIT_DEF_SUPPRESS}, + {"centimeter", "centimeters", "cm", NULL, "Centimeters", 0.01, 0.0, B_UNIT_DEF_NONE}, + {"millimeter", "millimeters", "mm", NULL, "Millimeters", 0.001, 0.0, B_UNIT_DEF_NONE}, + {"micrometer", "micrometers", "um", "µm", "Micrometers", 0.000001, 0.0, B_UNIT_DEF_NONE}, // micron too? + + /* These get displayed because of float precision problems in the transform header, + * could work around, but for now probably people wont use these */ + /* + {"nanometer", "Nanometers", "nm", NULL, 0.000000001, 0.0, B_UNIT_DEF_NONE}, + {"picometer", "Picometers", "pm", NULL, 0.000000000001, 0.0,B_UNIT_DEF_NONE}, + */ + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buMetricLenCollecton = {buMetricLenDef, 3, 0, sizeof(buMetricLenDef)/sizeof(bUnitDef)}; + +static struct bUnitDef buImperialLenDef[] = { + {"mile", "miles", "mi", "m", "Miles", 1609.344, 0.0, B_UNIT_DEF_NONE}, + {"furlong", "furlongs", "fur", NULL, "Furlongs",201.168, 0.0, B_UNIT_DEF_SUPPRESS}, + {"chain", "chains", "ch", NULL, "Chains", 0.9144*22.0, 0.0, B_UNIT_DEF_SUPPRESS}, + {"yard", "yards", "yd", NULL, "Yards", 0.9144, 0.0, B_UNIT_DEF_NONE}, + {"foot", "feet", "'", "ft", "Feet", 0.3048, 0.0, B_UNIT_DEF_NONE}, + {"inch", "inches", "\"", "in", "Inches", 0.0254, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"thou", "thous", "mil", NULL, "Thous", 0.0000254, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef)/sizeof(bUnitDef)}; + + +/* Time */ +static struct bUnitDef buNaturalTimeDef[] = { + /* weeks? - probably not needed for blender */ + {"day", "days", "d", NULL, "Days", 90000.0, 0.0, B_UNIT_DEF_NONE}, + {"hour", "hours", "hr", "h", "Hours", 3600.0, 0.0, B_UNIT_DEF_NONE}, + {"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE}, + {"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0 , B_UNIT_DEF_NONE}, + {"microsecond", "microseconds", "us", NULL, "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef)/sizeof(bUnitDef)}; + +#define UNIT_SYSTEM_MAX 3 +static struct bUnitCollection *bUnitSystems[][8] = { + {0,0,0,0,0,0,0,0}, + {0,&buMetricLenCollecton, 0,0,0,0, &buNaturalTimeCollecton,0}, /* metric */ + {0,&buImperialLenCollecton, 0,0,0,0, &buNaturalTimeCollecton,0}, /* imperial */ + {0,0,0,0,0,0,0,0} +}; + +/* internal, has some option not exposed */ +static bUnitCollection *unit_get_system(int system, int type) +{ + return bUnitSystems[system][type]; /* select system to use, metric/imperial/other? */ +} + +static bUnitDef *unit_default(bUnitCollection *usys) +{ + return &usys->units[usys->base_unit]; +} + +static bUnitDef *unit_best_fit(double value, bUnitCollection *usys, bUnitDef *unit_start, int suppress) +{ + bUnitDef *unit; + double value_abs= value>0.0?value:-value; + + for(unit= unit_start ? unit_start:usys->units; unit->name; unit++) { + + if(suppress && (unit->flag & B_UNIT_DEF_SUPPRESS)) + continue; + + if (value_abs >= unit->scalar*(1.0-EUL)) /* scale down scalar so 1cm doesnt convert to 10mm because of float error */ + return unit; + } + + return unit_default(usys); +} + + + +/* convert into 2 units and 2 values for "2ft, 3inch" syntax */ +static void unit_dual_convert(double value, bUnitCollection *usys, + bUnitDef **unit_a, bUnitDef **unit_b, double *value_a, double *value_b) +{ + bUnitDef *unit= unit_best_fit(value, usys, NULL, 1); + + *value_a= floor(value/unit->scalar) * unit->scalar; + *value_b= value - (*value_a); + + *unit_a= unit; + *unit_b= unit_best_fit(*value_b, usys, *unit_a, 1); +} + +static int unit_as_string(char *str, int len_max, double value, int prec, bUnitCollection *usys, + /* non exposed options */ + bUnitDef *unit, char pad) +{ + double value_conv; + int len, i; + + if(unit) { + /* use unit without finding the best one */ + } + else if(value == 0.0) { + /* use the default units since there is no way to convert */ + unit= unit_default(usys); + } + else { + unit= unit_best_fit(value, usys, NULL, 1); + } + + value_conv= value/unit->scalar; + + /* Convert to a string */ + { + char conv_str[6] = {'%', '.', '0'+prec, 'l', 'f', '\0'}; /* "%.2lf" when prec is 2, must be under 10 */ + len= snprintf(str, len_max, conv_str, (float)value_conv); + + if(len >= len_max) + len= len_max; + } + + /* Add unit prefix and strip zeros */ + + /* replace trailing zero's with spaces + * so the number is less complicated but allignment in a button wont + * jump about while dragging */ + i= len-1; + + while(i>0 && str[i]=='0') { /* 4.300 -> 4.3 */ + str[i--]= pad; + } + + if(i>0 && str[i]=='.') { /* 10. -> 10 */ + str[i--]= pad; + } + + /* Now add the suffix */ + if(iname_short[j] && (i < len_max)) { + str[i++]= unit->name_short[j++]; + } + + if(pad) { + /* this loop only runs if so many zeros were removed that + * the unit name only used padded chars, + * In that case add padding for the name. */ + + while(i<=len+j && (i < len_max)) { + str[i++]= pad; + } + } + } + + /* terminate no matter whats done with padding above */ + if(i >= len_max) + i= len_max-1; + + str[i] = '\0'; + return i; +} + + +/* Used for drawing number buttons, try keep fast */ +void bUnit_AsString(char *str, int len_max, double value, int prec, int system, int type, int split, int pad) +{ + bUnitCollection *usys = unit_get_system(system, type); + + if(usys==NULL || usys->units[0].name==NULL) + usys= &buDummyCollecton; + + if(split) { + int i; + bUnitDef *unit_a, *unit_b; + double value_a, value_b; + + unit_dual_convert(value, usys, &unit_a, &unit_b, &value_a, &value_b); + + /* check the 2 is a smaller unit */ + if(unit_b > unit_a) { + i= unit_as_string(str, len_max, value_a, prec, usys, unit_a, '\0'); + + /* is there enough space for at least 1 char of the next unit? */ + if(i+2 < len_max) { + str[i++]= ' '; + + /* use low precision since this is a smaller unit */ + unit_as_string(str+i, len_max-i, value_b, prec?1:0, usys, unit_b, '\0'); + } + return; + } + } + + unit_as_string(str, len_max, value, prec, usys, NULL, pad?' ':'\0'); +} + + +static char *unit_find_str(char *str, char *substr) +{ + char *str_found; + + if(substr && substr[0] != '\0') { + str_found= strstr(str, substr); + if(str_found) { + /* previous char cannot be a letter */ + if (str_found == str || isalpha(*(str_found-1))==0) { + /* next char cannot be alphanum */ + int len_name = strlen(substr); + + if (!isalpha(*(str_found+len_name))) { + return str_found; + } + } + } + + } + return NULL; + +} + +/* Note that numbers are added within brackets + * ") " - is used to detect numbers we added so we can detect if commas need to be added + * + * "1m1cm+2mm" - Original value + * "1*1#1*0.01#+2*0.001#" - Replace numbers + * "1*1,1*0.01 +2*0.001 " - Add comma's if ( - + * / % ^ < > ) not found in between + * + */ + +/* not too strict, (- = * /) are most common */ +static int ch_is_op(char op) +{ + switch(op) { + case '+': + case '-': + case '*': + case '/': + case '|': + case '&': + case '~': + case '<': + case '>': + case '^': + case '!': + case '=': + case '%': + return 1; + default: + return 0; + } +} + +static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit, char *replace_str) +{ + char *str_found; + + if((len_max>0) && (str_found= unit_find_str(str, replace_str))) { /* XXX - investigate, does not respect len_max properly */ + int len, len_num, len_name, len_move, found_ofs; + + found_ofs = (int)(str_found-str); + + len= strlen(str); + + len_name = strlen(replace_str); + len_move= (len - (found_ofs+len_name)) + 1; /* 1+ to copy the string terminator */ + len_num= snprintf(str_tmp, TEMP_STR_SIZE, "*%lg"SEP_STR, unit->scalar/scale_pref); /* # removed later */ + + if(len_num > len_max) + len_num= len_max; + + if(found_ofs+len_num+len_move > len_max) { + /* can't move the whole string, move just as much as will fit */ + len_move -= (found_ofs+len_num+len_move) - len_max; + } + + if(len_move>0) { + /* resize the last part of the string */ + memmove(str_found+len_num, str_found+len_name, len_move); /* may grow or shrink the string */ + } + + if(found_ofs+len_num > len_max) { + /* not even the number will fit into the string, only copy part of it */ + len_num -= (found_ofs+len_num) - len_max; + } + + if(len_num > 0) { + /* its possible none of the number could be copied in */ + memcpy(str_found, str_tmp, len_num); /* without the string terminator */ + } + + /* since the null terminator wont be moved if the stringlen_max + * was not long enough to fit everything in it */ + str[len_max-1]= '\0'; + return found_ofs + len_num; + } + return 0; +} + +static int unit_replace(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit) +{ + int ofs= 0; + ofs += unit_scale_str(str+ofs, len_max-ofs, str_tmp, scale_pref, unit, unit->name_short); + ofs += unit_scale_str(str+ofs, len_max-ofs, str_tmp, scale_pref, unit, unit->name_plural); + ofs += unit_scale_str(str+ofs, len_max-ofs, str_tmp, scale_pref, unit, unit->name_alt); + ofs += unit_scale_str(str+ofs, len_max-ofs, str_tmp, scale_pref, unit, unit->name); + return ofs; +} + +static int unit_find(char *str, bUnitDef *unit) +{ + if (unit_find_str(str, unit->name_short)) return 1; + if (unit_find_str(str, unit->name_plural)) return 1; + if (unit_find_str(str, unit->name_alt)) return 1; + if (unit_find_str(str, unit->name)) return 1; + + return 0; +} + +/* make a copy of the string that replaces the units with numbers + * this is used before parsing + * This is only used when evaluating user input and can afford to be a bit slower + * + * This is to be used before python evaluation so.. + * 10.1km -> 10.1*1000.0 + * ...will be resolved by python. + * + * values will be split by a comma's + * 5'2" -> 5'0.0254, 2*0.3048 + * + * str_prev is optional, when valid it is used to get a base unit when none is set. + * + * return true of a change was made. + */ +int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pref, int system, int type) +{ + bUnitCollection *usys = unit_get_system(system, type); + + bUnitDef *unit; + char str_tmp[TEMP_STR_SIZE]; + int change= 0; + + if(usys==NULL || usys->units[0].name==NULL) { + return 0; + } + + + { /* make lowercase */ + int i; + char *ch= str; + + for(i=0; (i>=len_max || *ch=='\0'); i++, ch++) + if((*ch>='A') && (*ch<='Z')) + *ch += ('a'-'A'); + } + + + for(unit= usys->units; unit->name; unit++) { + + if(unit->flag & B_UNIT_DEF_SUPPRESS) + continue; + + /* incase there are multiple instances */ + while(unit_replace(str, len_max, str_tmp, scale_pref, unit)) + change= 1; + } + unit= NULL; + + { + /* try other unit systems now, so we can evaluate imperial when metric is set for eg. */ + bUnitCollection *usys_iter; + int system_iter; + + for(system_iter= 1; system_iterunits; unit->name; unit++) { + + if((unit->flag & B_UNIT_DEF_SUPPRESS) == 0) { + int ofs = 0; + /* incase there are multiple instances */ + while((ofs=unit_replace(str+ofs, len_max-ofs, str_tmp, scale_pref, unit))) + change= 1; + } + } + } + } + } + unit= NULL; + + if(change==0) { + /* no units given so infer a unit from the previous string or default */ + if(str_prev) { + /* see which units the original value had */ + for(unit= usys->units; unit->name; unit++) { + + if(unit->flag & B_UNIT_DEF_SUPPRESS) + continue; + + if (unit_find(str_prev, unit)) + break; + } + } + + if(unit==NULL) + unit= unit_default(usys); + + /* add the unit prefic and re-run, use brackets incase there was an expression given */ + if(snprintf(str_tmp, sizeof(str_tmp), "(%s)%s", str, unit->name) < sizeof(str_tmp)) { + strncpy(str, str_tmp, len_max); + return bUnit_ReplaceString(str, len_max, NULL, scale_pref, system, type); + } + else { + /* snprintf would not fit into str_tmp, cant do much in this case + * check for this because otherwise bUnit_ReplaceString could call its self forever */ + return 0; + } + + } + + /* replace # with commas when there is no operator between it and the next number + * + * "1*1# 3*100# * 3" -> "1 *1, 3 *100 * 3" + * + * */ + { + char *str_found= str; + char *ch= str; + + while((str_found= strchr(str_found, SEP_CHR))) { + + int op_found= 0; + /* any operators after this?*/ + for(ch= str_found+1; *ch!='\0'; ch++) { + + if(*ch==' ' || *ch=='\t') { + /* do nothing */ + } + else if (ch_is_op(*ch) || *ch==',') { /* found an op, no need to insert a ,*/ + op_found= 1; + break; + } + else { /* found a non-op character */ + op_found= 0; + break; + } + } + + *str_found++ = op_found ? ' ':','; + } + } + + // printf("replace %s\n", str); + return change; +} + + +double bUnit_ClosestScalar(double value, int system, int type) +{ + bUnitCollection *usys = unit_get_system(system, type); + bUnitDef *unit; + + if(usys==NULL) + return -1; + + unit= unit_best_fit(value, usys, NULL, 1); + if(unit==NULL) + return -1; + + return unit->scalar; +} + +double bUnit_BaseScalar(int system, int type) +{ + bUnitCollection *usys = unit_get_system(system, type); + return unit_default(usys)->scalar; +} + +/* external access */ +void bUnit_GetSystem(void **usys_pt, int *len, int system, int type) +{ + bUnitCollection *usys = unit_get_system(system, type); + *usys_pt= usys; + + if(usys==NULL) { + *len= 0; + return; + } + + *len= usys->length; +} + +char *bUnit_GetName(void *usys_pt, int index) +{ + return ((bUnitCollection *)usys_pt)->units[index].name; +} +char *bUnit_GetNameDisplay(void *usys_pt, int index) +{ + return ((bUnitCollection *)usys_pt)->units[index].name_display; +} + +double bUnit_GetScaler(void *usys_pt, int index) +{ + return ((bUnitCollection *)usys_pt)->units[index].scalar; +} diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index cfbe3f629d6..7c58a4f9499 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -127,7 +127,7 @@ void makeavistring (RenderData *rd, char *string) } } -void start_avi(RenderData *rd, int rectx, int recty) +void start_avi(struct Scene *scene, RenderData *rd, int rectx, int recty) { int x, y; char name[256]; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 5e3c8024524..e7164dc4794 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -65,6 +65,10 @@ #include "DNA_scene_types.h" +#include "AUD_C-API.h" +#include "BKE_sound.h" +#include "BKE_main.h" + #ifdef HAVE_CONFIG_H #include #endif @@ -96,6 +100,8 @@ static int audio_input_frame_size = 0; static uint8_t* audio_output_buffer = 0; static int audio_outbuf_size = 0; +static AUD_Device* audio_mixdown_device = 0; + #define FFMPEG_AUTOSPLIT_SIZE 2000000000 /* Delete a picture buffer */ @@ -127,9 +133,8 @@ static int write_audio_frame(void) c = get_codec_from_stream(audio_stream); - //XXX audiostream_fill(audio_input_buffer, - // audio_input_frame_size - // * sizeof(short) * c->channels); + if(audio_mixdown_device) + AUD_readDevice(audio_mixdown_device, audio_input_buffer, audio_input_frame_size); av_init_packet(&pkt); @@ -827,11 +832,21 @@ static void makeffmpegstring(RenderData* rd, char* string) { } -void start_ffmpeg(RenderData *rd, int rectx, int recty) +void start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty) { ffmpeg_autosplit_count = 0; start_ffmpeg_impl(rd, rectx, recty); + + if(ffmpeg_multiplex_audio && audio_stream) + { + AVCodecContext* c = get_codec_from_stream(audio_stream); + AUD_Specs specs; + specs.channels = c->channels; + specs.format = AUD_FORMAT_S16; + specs.rate = rd->audio.mixrate; + audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, rd->efra); + } } void end_ffmpeg(void); @@ -884,6 +899,12 @@ void end_ffmpeg(void) if (audio_stream && video_stream) { write_audio_frames(); } + + if(audio_mixdown_device) + { + AUD_closeReadDevice(audio_mixdown_device); + audio_mixdown_device = 0; + } if (outfile) { av_write_trailer(outfile); diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 2d3a2e6b883..0780cd0dc48 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -101,7 +101,7 @@ static int closesocket(int fd) } #endif -void start_frameserver(RenderData *rd, int rectx, int recty) +void start_frameserver(struct Scene *scene, RenderData *rd, int rectx, int recty) { struct sockaddr_in addr; int arg = 1; diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 334c8e6906b..a0bf2367b98 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -28,8 +28,7 @@ FILE(GLOB SRC intern/*.c) SET(INC . ../makesdna ../blenkernel ../../../intern/guardedalloc ../include - ${FREETYPE_INC} - ${SDL_INC} + ${FREETYPE_INCLUDE_DIRS} ${ZLIB_INC} ) diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 84de9f9d862..07e81b291f5 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -1530,7 +1530,6 @@ float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, fl { BVHRayCastData data; float dist = 0.0; - int i; data.hit.dist = FLT_MAX; diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index 79a46da4c66..1f3a861ba6a 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -374,7 +374,7 @@ int BLI_kdtree_range_search(KDTree *tree, float range, float *co, float *nor, KD KDTreeNode **stack, *defaultstack[100]; KDTreeNearest *foundstack=NULL; float range2 = range*range, dist2; - int i, totstack, cur=0, found=0, totfoundstack=0; + int totstack, cur=0, found=0, totfoundstack=0; if(!tree || !tree->root) return 0; diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index db7bae8a91d..7d5e1eec53e 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -16,28 +16,22 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Campbell barton + * Contributor(s): Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ -#include +#include /* for qsort */ -#include "BKE_utildefines.h" #include "MEM_guardedalloc.h" #include "BLI_boxpack2d.h" -/* BoxPacker ported from Python by Campbell Barton +/* BoxPacker for backing 2D rectangles into a square * * The defined Below are for internal use only */ /* free vert flags */ -#define eul 0.0000001 +#define eul 0.0000001f #define BLF 1 #define TRF 2 #define TLF 4 @@ -79,6 +73,9 @@ BOXRIGHT(b1)-eul<=BOXLEFT(b2) ||\ BOXTOP(b1)-eul<=BOXBOTTOM(b2) )) +#define MIN2(x,y) ( (x)<(y) ? (x) : (y) ) +#define MAX2(x,y) ( (x)>(y) ? (x) : (y) ) + /* #define BOXDEBUG(b)\ * printf("\tBox Debug i %i, w:%.3f h:%.3f x:%.3f y:%.3f\n",\ * b->index, b->w, b->h, b->x, b->y) */ @@ -141,11 +138,11 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) int box_index, verts_pack_len, i, j, k, isect; int quad_flags[4]= {BLF,TRF,TLF,BRF}; /* use for looping */ boxPack *box, *box_test; /*current box and another for intersection tests*/ - int *vertex_pack_indicies; /*an array of indicies used for sorting verts*/ + int *vertex_pack_indicies; /*an array of indices used for sorting verts*/ if (!len) { - *tot_width = 0.0; - *tot_height = 0.0; + *tot_width = 0.0f; + *tot_height = 0.0f; return; } @@ -153,8 +150,8 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) qsort(boxarray, len, sizeof(boxPack), box_areasort); /* add verts to the boxes, these are only used internally */ - vert = vertarray = MEM_mallocN( len*4*sizeof(boxVert), "boxPack verts"); - vertex_pack_indicies = MEM_mallocN( len*3*sizeof(int), "boxPack indicies"); + vert = vertarray = MEM_mallocN( len*4*sizeof(boxVert), "boxPack Verts"); + vertex_pack_indicies = MEM_mallocN( len*3*sizeof(int), "boxPack Indices"); for (box=boxarray, box_index=0, i=0; box_index < len; box_index++, box++) { @@ -194,11 +191,11 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) /* Pack the First box! - * then enter the main boxpacking loop */ + * then enter the main box-packing loop */ box = boxarray; /* get the first box */ /* First time, no boxes packed */ - box->v[BL]->free = 0; /* Cant use any if these */ + box->v[BL]->free = 0; /* Can't use any if these */ box->v[BR]->free &= ~(BLF|BRF); box->v[TL]->free &= ~(BLF|TLF); @@ -206,9 +203,9 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) *tot_height = box->h; /* This sets all the vertex locations */ - SET_BOXLEFT(box, 0.0); - SET_BOXBOTTOM(box, 0.0); - box->x = box->y = 0.0; + SET_BOXLEFT(box, 0.0f); + SET_BOXBOTTOM(box, 0.0f); + box->x = box->y = 0.0f; for (i=0; i<3; i++) vertex_pack_indicies[i] = box->v[i+1]->index; @@ -219,7 +216,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) /* Main boxpacking loop */ for (box_index=1; box_index < len; box_index++, box++) { - /* Sort the verts, these constants are used in sorting */ + /* These static floatds are used for sorting */ box_width = box->w; box_height = box->h; @@ -234,7 +231,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) /* printf("\ttesting vert %i %i %i %f %f\n", i, * vert->free, verts_pack_len, vert->x, vert->y); */ - /* This vert has a free quaderent + /* This vert has a free quadrant * Test if we can place the box here * vert->free & quad_flags[j] - Checks * */ @@ -266,7 +263,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) isect = 0; if (/* Constrain boxes to positive X/Y values */ - BOXLEFT(box)<0.0 || BOXBOTTOM(box) < 0.0 || + BOXLEFT(box)<0.0f || BOXBOTTOM(box) < 0.0f || /* check for last intersected */ ( vert->isect_cache[j] && BOXINTERSECT(box, vert->isect_cache[j]) ) @@ -274,13 +271,13 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) /* Here we check that the last intersected * box will intersect with this one using * isect_cache that can store a pointer to a - * box for each quaderent + * box for each quadrant * big speedup */ isect = 1; } else { - /* do a full saech for colliding box - * this is realy slow, some spacialy divided - * datastructure would be better */ + /* do a full search for colliding box + * this is really slow, some spacialy divided + * data-structure would be better */ for (box_test=boxarray; box_test != box; box_test++) { if BOXINTERSECT(box, box_test) { /* Store the last intersecting here as cache @@ -321,7 +318,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) } /* Mask free flags for verts that are - * on the bottom or side so we dont get + * on the bottom or side so we don't get * boxes outside the given rectangle ares * * We can do an else/if here because only the first @@ -392,7 +389,7 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) verts_pack_len++; } } - /* The Box verts are only used interially + /* The Box verts are only used internally * Update the box x and y since thats what external * functions will see */ box->x = BOXLEFT(box); @@ -403,8 +400,8 @@ void boxPack2D(boxPack *boxarray, int len, float *tot_width, float *tot_height) } } - /* free all the verts, not realy needed because they shouldebt be - * touched anymore but accessing the pointers woud crash blender */ + /* free all the verts, not really needed because they shouldn't be + * touched anymore but accessing the pointers would crash blender */ for (box_index=0; box_index < len; box_index++) { box = boxarray+box_index; box->v[0] = box->v[1] = box->v[2] = box->v[3] = NULL; diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 85a95fa6e66..6c89afe7173 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -51,7 +51,7 @@ /* for sequence */ //XXX #include "BSE_sequence.h" //XXX define below from BSE_sequence.h - otherwise potentially odd behaviour -#define SEQ_HAS_PATH(seq) (seq->type==SEQ_MOVIE || seq->type==SEQ_HD_SOUND || seq->type==SEQ_RAM_SOUND || seq->type==SEQ_IMAGE) +#define SEQ_HAS_PATH(seq) (seq->type==SEQ_MOVIE || seq->type==SEQ_IMAGE) /* path/file handeling stuff */ #ifndef WIN32 diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index 1064c8ac1bf..3194593374f 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -347,11 +347,11 @@ void BLI_duplicatelist(ListBase *list1, ListBase *list2) /* copy from 2 to 1 */ { struct Link *link1, *link2; + /* in this order, to ensure it works if list1 == list2 */ + link2= list2->first; list1->first= list1->last= 0; - link2= list2->first; while(link2) { - link1= MEM_dupallocN(link2); BLI_addtail(list1, link1); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 0a416e624cb..e6e37c58805 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -47,13 +47,13 @@ #include #include -#if defined (__sun__) || defined (__sun) || defined (__sgi) +#if defined (__sun__) || defined (__sun) || defined (__sgi) || defined (__NetBSD__) #include /* Other modern unix os's should probably use this also */ #elif !defined(__FreeBSD__) && !defined(linux) && (defined(__sparc) || defined(__sparc__)) #include #endif -#if defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) +#if defined (__FreeBSD__) || defined (__OpenBSD__) #include #include #endif @@ -173,7 +173,7 @@ double BLI_diskfree(char *dir) return (double) (freec*bytesps*sectorspc); #else -#if defined (__sun__) || defined (__sun) || defined (__sgi) +#if defined (__sun__) || defined (__sun) || defined (__sgi) || defined (__NetBSD__) struct statvfs disk; #else struct statfs disk; @@ -195,7 +195,7 @@ double BLI_diskfree(char *dir) if (statfs(name, &disk)) return(-1); #endif -#if defined (__sun__) || defined (__sun) || defined (__sgi) +#if defined (__sun__) || defined (__sun) || defined (__sgi) || defined (__NetBSD__) if (statvfs(name, &disk)) return(-1); #elif !defined(__FreeBSD__) && !defined(linux) && (defined(__sparc) || defined(__sparc__)) /* WARNING - This may not be supported by geeneric unix os's - Campbell */ diff --git a/source/blender/blenloader/BLO_sys_types.h b/source/blender/blenloader/BLO_sys_types.h index 49155260b31..4032f778f4b 100644 --- a/source/blender/blenloader/BLO_sys_types.h +++ b/source/blender/blenloader/BLO_sys_types.h @@ -78,7 +78,7 @@ typedef unsigned long uintptr_t; #define _UINTPTR_T_DEFINED #endif -#elif defined(__linux__) +#elif defined(__linux__) || defined(__NetBSD__) /* Linux-i386, Linux-Alpha, Linux-ppc */ #include diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 876b07eef89..779a898bd6a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -149,6 +149,8 @@ #include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND #include "BKE_idprop.h" +#include "BKE_sound.h" + //XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes //XXX #include "BIF_filelist.h" // badlevel too, where to move this? - elubie //XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo @@ -1364,7 +1366,7 @@ void IDP_LibLinkProperty(IDProperty *prop, int switch_endian, FileData *fd); static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData *fd) { - IDProperty **array; + IDProperty *array; int i; /*since we didn't save the extra buffer, set totallen to len.*/ @@ -1372,11 +1374,10 @@ static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData prop->data.pointer = newdataadr(fd, prop->data.pointer); if (switch_endian) { - test_pointer_array(fd, prop->data.pointer); - array= (IDProperty**) prop->data.pointer; + array= (IDProperty*) prop->data.pointer; for(i=0; ilen; i++) - IDP_DirectLinkProperty(array[i], switch_endian, fd); + IDP_DirectLinkProperty(&array[i], switch_endian, fd); } } @@ -2488,7 +2489,8 @@ static void lib_link_mball(FileData *fd, Main *main) mb= main->mball.first; while(mb) { if(mb->id.flag & LIB_NEEDLINK) { - + if (mb->adt) lib_link_animdata(fd, &mb->id, mb->adt); + for(a=0; atotcol; a++) mb->mat[a]= newlibadr_us(fd, mb->id.lib, mb->mat[a]); mb->ipo= newlibadr_us(fd, mb->id.lib, mb->ipo); // XXX depreceated - old animation system @@ -2501,6 +2503,9 @@ static void lib_link_mball(FileData *fd, Main *main) static void direct_link_mball(FileData *fd, MetaBall *mb) { + mb->adt= newdataadr(fd, mb->adt); + direct_link_animdata(fd, mb->adt); + mb->mat= newdataadr(fd, mb->mat); test_pointer_array(fd, (void **)&mb->mat); @@ -2923,13 +2928,21 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache) { if((cache->flag & PTCACHE_DISK_CACHE)==0) { PTCacheMem *pm; + int i; link_list(fd, &cache->mem_cache); pm = cache->mem_cache.first; - for(; pm; pm=pm->next) - pm->data = newdataadr(fd, pm->data); + for(; pm; pm=pm->next) { + if(pm->index_array) + pm->index_array = newdataadr(fd, pm->index_array); + + for(i=0; idata[i] && pm->data_types & (1<data[i] = newdataadr(fd, pm->data[i]); + } + } } else cache->mem_cache.first = cache->mem_cache.last = NULL; @@ -2938,6 +2951,26 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache) cache->simframe= 0; } +static void direct_link_pointcache_list(FileData *fd, ListBase *ptcaches, PointCache **ocache) +{ + PointCache *cache; + + if(ptcaches->first) { + link_list(fd, ptcaches); + for(cache=ptcaches->first; cache; cache=cache->next) + direct_link_pointcache(fd, cache); + + *ocache = newdataadr(fd, *ocache); + } + else if(*ocache) { + /* old "single" caches need to be linked too */ + *ocache = newdataadr(fd, *ocache); + direct_link_pointcache(fd, *ocache); + + ptcaches->first = ptcaches->last = *ocache; + } +} + static void lib_link_particlesettings(FileData *fd, Main *main) { ParticleSettings *part; @@ -3083,9 +3116,7 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) sb->bspring= NULL; sb->scratch= NULL; - sb->pointcache= newdataadr(fd, sb->pointcache); - if(sb->pointcache) - direct_link_pointcache(fd, sb->pointcache); + direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache); } link_list(fd, &psys->targets); @@ -3098,9 +3129,7 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) psys->childcachebufs.first = psys->childcachebufs.last = 0; psys->reactevents.first = psys->reactevents.last = 0; - psys->pointcache= newdataadr(fd, psys->pointcache); - if(psys->pointcache) - direct_link_pointcache(fd, psys->pointcache); + direct_link_pointcache_list(fd, &psys->ptcaches, &psys->pointcache); psys->tree = NULL; } @@ -3400,7 +3429,7 @@ static void lib_link_object(FileData *fd, Main *main) if(ob->pose) { free_pose(ob->pose); ob->pose= NULL; - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; } } for(a=0; atotcol; a++) ob->mat[a]= newlibadr_us(fd, ob->id.lib, ob->mat[a]); @@ -3461,9 +3490,6 @@ static void lib_link_object(FileData *fd, Main *main) bSoundActuator *sa= act->data; sa->sound= newlibadr_us(fd, ob->id.lib, sa->sound); } - else if(act->type==ACT_CD) { - /* bCDActuator *cda= act->data; */ - } else if(act->type==ACT_GAME) { /* bGameActuator *ga= act->data; */ } @@ -3625,10 +3651,8 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) clmd->sim_parms= newdataadr(fd, clmd->sim_parms); clmd->coll_parms= newdataadr(fd, clmd->coll_parms); - clmd->point_cache= newdataadr(fd, clmd->point_cache); - if(clmd->point_cache) - direct_link_pointcache(fd, clmd->point_cache); + direct_link_pointcache_list(fd, &clmd->ptcaches, &clmd->point_cache); if(clmd->sim_parms) { if(clmd->sim_parms->presets > 10) @@ -3655,13 +3679,23 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) smd->domain->smd = smd; smd->domain->fluid = NULL; + smd->domain->wt = NULL; smd->domain->tvox = NULL; smd->domain->tray = NULL; smd->domain->tvoxbig = NULL; smd->domain->traybig = NULL; smd->domain->bind = NULL; - smd->domain->max_textures = 0; - smd->domain->viewsettings = 0; // reset view for new frame + smd->domain->max_textures= 0; + + // do_versions trick + if(smd->domain->strength < 1.0) + smd->domain->strength = 2.0; + + // reset 3dview + if(smd->domain->viewsettings < MOD_SMOKE_VIEW_USEBIG) + smd->domain->viewsettings = 0; + else + smd->domain->viewsettings = MOD_SMOKE_VIEW_USEBIG; } else if(smd->type==MOD_SMOKE_TYPE_FLOW) { @@ -3873,9 +3907,7 @@ static void direct_link_object(FileData *fd, Object *ob) } } - sb->pointcache= newdataadr(fd, sb->pointcache); - if(sb->pointcache) - direct_link_pointcache(fd, sb->pointcache); + direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache); } ob->bsoft= newdataadr(fd, ob->bsoft); ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */ @@ -3961,6 +3993,9 @@ static void direct_link_object(FileData *fd, Object *ob) ob->derivedDeform= NULL; ob->derivedFinal= NULL; ob->gpulamp.first= ob->gpulamp.last= NULL; + + if(ob->sculpt) + ob->sculpt= MEM_callocN(sizeof(SculptSession), "reload sculpt session"); } /* ************ READ SCENE ***************** */ @@ -3975,6 +4010,14 @@ static void composite_patch(bNodeTree *ntree, Scene *scene) node->id= &scene->id; } +static void link_paint(FileData *fd, Scene *sce, Paint *p) +{ + if(p && p->brushes) { + int i; + for(i = 0; i < p->brush_count; ++i) + p->brushes[i]= newlibadr_us(fd, sce->id.lib, p->brushes[i]); + } +} static void lib_link_scene(FileData *fd, Main *main) { @@ -3998,18 +4041,11 @@ static void lib_link_scene(FileData *fd, Main *main) sce->set= newlibadr(fd, sce->id.lib, sce->set); sce->ima= newlibadr_us(fd, sce->id.lib, sce->ima); - sce->toolsettings->imapaint.brush= - newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.brush); - if(sce->toolsettings->sculpt) - sce->toolsettings->sculpt->brush= - newlibadr_us(fd, sce->id.lib, sce->toolsettings->sculpt->brush); - if(sce->toolsettings->vpaint) - sce->toolsettings->vpaint->brush= - newlibadr_us(fd, sce->id.lib, sce->toolsettings->vpaint->brush); - if(sce->toolsettings->wpaint) - sce->toolsettings->wpaint->brush= - newlibadr_us(fd, sce->id.lib, sce->toolsettings->wpaint->brush); - + link_paint(fd, sce, &sce->toolsettings->sculpt->paint); + link_paint(fd, sce, &sce->toolsettings->vpaint->paint); + link_paint(fd, sce, &sce->toolsettings->wpaint->paint); + link_paint(fd, sce, &sce->toolsettings->imapaint.paint); + sce->toolsettings->skgen_template = newlibadr(fd, sce->id.lib, sce->toolsettings->skgen_template); for(base= sce->base.first; base; base= next) { @@ -4038,14 +4074,16 @@ static void lib_link_scene(FileData *fd, Main *main) if(seq->ipo) seq->ipo= newlibadr_us(fd, sce->id.lib, seq->ipo); if(seq->scene) seq->scene= newlibadr(fd, sce->id.lib, seq->scene); if(seq->sound) { - seq->sound= newlibadr(fd, sce->id.lib, seq->sound); + if(seq->type == SEQ_HD_SOUND) + seq->type = SEQ_SOUND; + else + seq->sound= newlibadr(fd, sce->id.lib, seq->sound); if (seq->sound) { seq->sound->id.us++; - seq->sound->flags |= SOUND_FLAGS_SEQUENCE; + seq->sound_handle= sound_new_handle(sce, seq->sound, seq->startdisp, seq->enddisp, seq->startofs); } } seq->anim= 0; - seq->hdaudio = 0; } SEQ_END @@ -4080,6 +4118,13 @@ static void link_recurs_seq(FileData *fd, ListBase *lb) link_recurs_seq(fd, &seq->seqbase); } +static void direct_link_paint(FileData *fd, Paint **paint) +{ + (*paint)= newdataadr(fd, (*paint)); + if(*paint) + (*paint)->brushes= newdataadr(fd, (*paint)->brushes); +} + static void direct_link_scene(FileData *fd, Scene *sce) { Editing *ed; @@ -4089,7 +4134,9 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->theDag = NULL; sce->dagisvalid = 0; sce->obedit= NULL; - + + memset(&sce->sound_handles, 0, sizeof(sce->sound_handles)); + /* set users to one by default, not in lib-link, this will increase it for compo nodes */ sce->id.us= 1; @@ -4105,14 +4152,14 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->toolsettings= newdataadr(fd, sce->toolsettings); if(sce->toolsettings) { - sce->toolsettings->vpaint= newdataadr(fd, sce->toolsettings->vpaint); - sce->toolsettings->wpaint= newdataadr(fd, sce->toolsettings->wpaint); - sce->toolsettings->sculpt= newdataadr(fd, sce->toolsettings->sculpt); + direct_link_paint(fd, (Paint**)&sce->toolsettings->sculpt); + direct_link_paint(fd, (Paint**)&sce->toolsettings->vpaint); + direct_link_paint(fd, (Paint**)&sce->toolsettings->wpaint); + + sce->toolsettings->imapaint.paint.brushes= newdataadr(fd, sce->toolsettings->imapaint.paint.brushes); + sce->toolsettings->imapaint.paintcursor= NULL; sce->toolsettings->particle.paintcursor= NULL; - - if(sce->toolsettings->sculpt) - sce->toolsettings->sculpt->session= MEM_callocN(sizeof(SculptSession), "reload sculpt session"); } if(sce->ed) { @@ -5010,7 +5057,6 @@ static void fix_relpaths_library(const char *basepath, Main *main) static void direct_link_sound(FileData *fd, bSound *sound) { - sound->sample = NULL; sound->snd_sound = NULL; sound->packedfile = direct_link_packedfile(fd, sound->packedfile); @@ -5027,6 +5073,8 @@ static void lib_link_sound(FileData *fd, Main *main) sound->id.flag -= LIB_NEEDLINK; sound->ipo= newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX depreceated - old animation system sound->stream = 0; + + sound_load(sound); } sound= sound->id.next; } @@ -5297,6 +5345,9 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead) bfd->curscene= fg->curscene; MEM_freeN(fg); + + fd->globalf= bfd->globalf; + fd->fileflags= bfd->fileflags; return blo_nextbhead(fd, bhead); } @@ -5688,7 +5739,7 @@ static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me) tf = ((MTFace*)me->fdata.layers[b].data) + a; tf->mode &= ~TF_ALPHASORT; - if(ma && (ma->mode & MA_ZTRA)) + if(ma && (ma->mode & MA_ZTRANSP)) if(ELEM(tf->transp, TF_ALPHA, TF_ADD) || (texalpha && (tf->transp != TF_CLIP))) tf->mode |= TF_ALPHASORT; } @@ -8283,20 +8334,20 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* add point caches */ for(ob=main->object.first; ob; ob=ob->id.next) { if(ob->soft && !ob->soft->pointcache) - ob->soft->pointcache= BKE_ptcache_add(); + ob->soft->pointcache= BKE_ptcache_add(&ob->soft->ptcaches); for(psys=ob->particlesystem.first; psys; psys=psys->next) { if(psys->soft && !psys->soft->pointcache) - psys->soft->pointcache= BKE_ptcache_add(); + psys->soft->pointcache= BKE_ptcache_add(&psys->soft->ptcaches); if(!psys->pointcache) - psys->pointcache= BKE_ptcache_add(); + psys->pointcache= BKE_ptcache_add(&psys->ptcaches); } for(md=ob->modifiers.first; md; md=md->next) { if(md->type==eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData*) md; if(!clmd->point_cache) - clmd->point_cache= BKE_ptcache_add(); + clmd->point_cache= BKE_ptcache_add(&clmd->ptcaches); } } } @@ -8584,7 +8635,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* create new particle system */ psys = MEM_callocN(sizeof(ParticleSystem), "particle_system"); - psys->pointcache = BKE_ptcache_add(); + psys->pointcache = BKE_ptcache_add(&psys->ptcaches); part = psys->part = psys_new_settings("ParticleSettings", main); @@ -9170,9 +9221,69 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Tex *tx; ParticleSettings *part; Object *ob; - PTCacheID *pid; - ListBase pidlist; - + //PTCacheID *pid; + //ListBase pidlist; + + bSound *sound; + Sequence *seq; + bActuator *act; + + for(sound = main->sound.first; sound; sound = sound->id.next) + { + if(sound->newpackedfile) + { + sound->packedfile = sound->newpackedfile; + sound->newpackedfile = NULL; + } + } + + for(ob = main->object.first; ob; ob= ob->id.next) { + for(act= ob->actuators.first; act; act= act->next) { + if (act->type == ACT_SOUND) { + bSoundActuator *sAct = (bSoundActuator*) act->data; + if(sAct->sound) + { + sound = newlibadr(fd, lib, sAct->sound); + sAct->flag = sound->flags | SOUND_FLAGS_3D ? ACT_SND_3D_SOUND : 0; + sAct->pitch = sound->pitch; + sAct->volume = sound->volume; + sAct->sound3D.reference_distance = sound->distance; + sAct->sound3D.max_gain = sound->max_gain; + sAct->sound3D.min_gain = sound->min_gain; + sAct->sound3D.rolloff_factor = sound->attenuation; + } + else + { + sAct->sound3D.reference_distance = 1.0f; + sAct->volume = 1.0f; + sAct->sound3D.max_gain = 1.0f; + sAct->sound3D.rolloff_factor = 1.0f; + } + sAct->sound3D.cone_inner_angle = 360.0f; + sAct->sound3D.cone_outer_angle = 360.0f; + sAct->sound3D.max_distance = FLT_MAX; + } + } + } + + for(scene = main->scene.first; scene; scene = scene->id.next) + { + if(scene->ed && scene->ed->seqbasep) + { + for(seq = scene->ed->seqbasep->first; seq; seq = seq->next) + { + if(seq->type == SEQ_HD_SOUND) + { + char str[FILE_MAX]; + BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name); + BLI_convertstringcode(str, G.sce); + BLI_convertstringframe(str, scene->r.cfra); + seq->sound = sound_new_file(main, str); + } + } + } + } + for(screen= main->screen.first; screen; screen= screen->id.next) { do_versions_windowmanager_2_50(screen); do_versions_gpencil_2_50(main, screen); @@ -9201,7 +9312,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* move to cameras */ if(sce->r.scemode & R_PANORAMA) { - for(base=scene->base.first; base; base=base->next) { + for(base=sce->base.first; base; base=base->next) { ob= newlibadr(fd, lib, base->object); if(ob->type == OB_CAMERA && !ob->id.lib) { @@ -9245,30 +9356,34 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* set old pointcaches to have disk cache flag */ for(ob = main->object.first; ob; ob= ob->id.next) { - BKE_ptcache_ids_from_object(&pidlist, ob); + //BKE_ptcache_ids_from_object(&pidlist, ob); - for(pid=pidlist.first; pid; pid=pid->next) - pid->cache->flag |= PTCACHE_DISK_CACHE; + //for(pid=pidlist.first; pid; pid=pid->next) + // pid->cache->flag |= PTCACHE_DISK_CACHE; - BLI_freelistN(&pidlist); + //BLI_freelistN(&pidlist); } } if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 1)) { - } - - /* TODO: should be moved into one of the version blocks once this branch moves to trunk and we can - bump the version (or sub-version.) */ - { - World *wo; Object *ob; Material *ma; Tex *tex; Scene *sce; ToolSettings *ts; + //PTCacheID *pid; + //ListBase pidlist; int i, a; for(ob = main->object.first; ob; ob = ob->id.next) { + //BKE_ptcache_ids_from_object(&pidlist, ob); + + //for(pid=pidlist.first; pid; pid=pid->next) { + // if(pid->ptcaches->first == NULL) + // pid->ptcaches->first = pid->ptcaches->last = pid->cache; + //} + + //BLI_freelistN(&pidlist); if(ob->type == OB_MESH) { Mesh *me = newlibadr(fd, lib, ob->data); @@ -9356,13 +9471,25 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ma->mode &= ~MA_HALO; } + if(ma->mode & (MA_ZTRANSP|MA_RAYTRANSP)) { + ma->mode |= MA_TRANSP; + } + else { + ma->mode |= MA_ZTRANSP; + ma->mode &= ~MA_TRANSP; + } + /* set new bump for unused slots */ for(a=0; amtex[a]) { - if(!ma->mtex[a]->tex) - ma->mtex[a]->texflag |= MTEX_NEW_BUMP; - else if(((Tex*)newlibadr(fd, ma->id.lib, ma->mtex[a]->tex))->type == 0) + tex= ma->mtex[a]->tex; + if(!tex) ma->mtex[a]->texflag |= MTEX_NEW_BUMP; + else { + tex= (Tex*)newlibadr(fd, ma->id.lib, tex); + if(tex && tex->type == 0) /* invalid type */ + ma->mtex[a]->texflag |= MTEX_NEW_BUMP; + } } } } @@ -9425,31 +9552,57 @@ static void do_versions(FileData *fd, Library *lib, Main *main) sce->gm.depth= sce->r.depth; //Physic (previously stored in world) - //temporarily getting the correct world address - wo = newlibadr(fd, sce->id.lib, sce->world); - if (wo){ - sce->gm.gravity = wo->gravity; - sce->gm.physicsEngine= wo->physicsEngine; - sce->gm.mode = wo->mode; - sce->gm.occlusionRes = wo->occlusionRes; - sce->gm.ticrate = wo->ticrate; - sce->gm.maxlogicstep = wo->maxlogicstep; - sce->gm.physubstep = wo->physubstep; - sce->gm.maxphystep = wo->maxphystep; - } - else{ - sce->gm.gravity =9.8f; - sce->gm.physicsEngine= WOPHY_BULLET;// Bullet by default - sce->gm.mode = WO_DBVT_CULLING; // DBVT culling by default - sce->gm.occlusionRes = 128; - sce->gm.ticrate = 60; - sce->gm.maxlogicstep = 5; - sce->gm.physubstep = 1; - sce->gm.maxphystep = 5; - } + sce->gm.gravity =9.8f; + sce->gm.physicsEngine= WOPHY_BULLET;// Bullet by default + sce->gm.mode = WO_DBVT_CULLING; // DBVT culling by default + sce->gm.occlusionRes = 128; + sce->gm.ticrate = 60; + sce->gm.maxlogicstep = 5; + sce->gm.physubstep = 1; + sce->gm.maxphystep = 5; } } + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) { + Scene *sce; + + for(sce = main->scene.first; sce; sce = sce->id.next) { + if(fd->fileflags & G_FILE_ENABLE_ALL_FRAMES) + sce->gm.flag |= GAME_ENABLE_ALL_FRAMES; + if(fd->fileflags & G_FILE_SHOW_DEBUG_PROPS) + sce->gm.flag |= GAME_SHOW_DEBUG_PROPS; + if(fd->fileflags & G_FILE_SHOW_FRAMERATE) + sce->gm.flag |= GAME_SHOW_FRAMERATE; + if(fd->fileflags & G_FILE_SHOW_PHYSICS) + sce->gm.flag |= GAME_SHOW_PHYSICS; + if(fd->fileflags & G_FILE_GLSL_NO_SHADOWS) + sce->gm.flag |= GAME_GLSL_NO_SHADOWS; + if(fd->fileflags & G_FILE_GLSL_NO_SHADERS) + sce->gm.flag |= GAME_GLSL_NO_SHADERS; + if(fd->fileflags & G_FILE_GLSL_NO_RAMPS) + sce->gm.flag |= GAME_GLSL_NO_RAMPS; + if(fd->fileflags & G_FILE_GLSL_NO_NODES) + sce->gm.flag |= GAME_GLSL_NO_NODES; + if(fd->fileflags & G_FILE_GLSL_NO_EXTRA_TEX) + sce->gm.flag |= GAME_GLSL_NO_EXTRA_TEX; + if(fd->fileflags & G_FILE_IGNORE_DEPRECATION_WARNINGS) + sce->gm.flag |= GAME_IGNORE_DEPRECATION_WARNINGS; + + if(fd->fileflags & G_FILE_GAME_MAT_GLSL) + sce->gm.matmode= GAME_MAT_GLSL; + else if(fd->fileflags & G_FILE_GAME_MAT) + sce->gm.matmode= GAME_MAT_MULTITEX; + else + sce->gm.matmode= GAME_MAT_TEXFACE; + + sce->gm.flag |= GAME_DISPLAY_LISTS; + } + } + + /* put 2.50 compatibility code here until next subversion bump */ + { + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */ @@ -9500,7 +9653,17 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) // XXX bfd->user->uifonts.first= bfd->user->uifonts.last= NULL; bfd->user->uistyles.first= bfd->user->uistyles.last= NULL; - + + // AUD_XXX + if(bfd->user->audiochannels == 0) + bfd->user->audiochannels = 2; + if(bfd->user->audiodevice == 0) + bfd->user->audiodevice = 1; + if(bfd->user->audioformat == 0) + bfd->user->audioformat = 0x12; + if(bfd->user->audiorate == 0) + bfd->user->audiorate = 44100; + bhead = blo_nextbhead(fd, bhead); /* read all attached data */ @@ -9946,6 +10109,9 @@ static void expand_mball(FileData *fd, Main *mainvar, MetaBall *mb) for(a=0; atotcol; a++) { expand_doit(fd, mainvar, mb->mat[a]); } + + if(mb->adt) + expand_animdata(fd, mainvar, mb->adt); } static void expand_curve(FileData *fd, Main *mainvar, Curve *cu) @@ -10550,7 +10716,7 @@ static void append_named_part(FileData *fd, Main *mainvar, Scene *scene, char *n } } - if(idcode==ID_OB) { /* loose object: give a base */ + if(idcode==ID_OB && scene) { /* loose object: give a base */ base= MEM_callocN( sizeof(Base), "app_nam_part"); BLI_addtail(&scene->base, base); @@ -10690,7 +10856,8 @@ void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, if(fd) fd->reports= NULL; /* do we need to do this? */ - DAG_scene_sort(scene); + if(scene) + DAG_scene_sort(scene); *bh= (BlendHandle*)fd; } diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index f0e00b75b67..e39fefa8205 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -69,6 +69,7 @@ typedef struct FileData { int fileversion; int id_name_offs; /* used to retrieve ID names from (bhead+1) */ + int globalf, fileflags; /* for do_versions patching */ struct OldNewMap *datamap; struct OldNewMap *globmap; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index da68132700d..62ec1b71938 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -157,6 +157,7 @@ Any case: direct data is ALWAYS after the lib block #include "BKE_main.h" #include "BKE_node.h" #include "BKE_packedFile.h" // for packAll +#include "BKE_pointcache.h" #include "BKE_report.h" #include "BKE_screen.h" // for waitcursor #include "BKE_sequence.h" @@ -406,13 +407,13 @@ static void IDP_WriteIDPArray(IDProperty *prop, void *wd) { /*REMEMBER to set totalen to len in the linking code!!*/ if (prop->data.pointer) { - IDProperty **array = prop->data.pointer; + IDProperty *array = prop->data.pointer; int a; - writedata(wd, DATA, MEM_allocN_len(prop->data.pointer), prop->data.pointer); + writestruct(wd, DATA, "IDProperty", prop->len, array); for(a=0; alen; a++) - IDP_WriteProperty(array[a], wd); + IDP_WriteProperty_OnlyData(&array[a], wd); } } @@ -582,19 +583,27 @@ static void write_boid_state(WriteData *wd, BoidState *state) /* TODO: replace *cache with *cachelist once it's coded */ #define PTCACHE_WRITE_PSYS 0 #define PTCACHE_WRITE_CLOTH 1 -static void write_pointcaches(WriteData *wd, PointCache *cache, int type) +static void write_pointcaches(WriteData *wd, ListBase *ptcaches) { - writestruct(wd, DATA, "PointCache", 1, cache); + PointCache *cache = ptcaches->first; + int i; - if((cache->flag & PTCACHE_DISK_CACHE)==0) { - PTCacheMem *pm = cache->mem_cache.first; + for(; cache; cache=cache->next) { + writestruct(wd, DATA, "PointCache", 1, cache); - for(; pm; pm=pm->next) { - writestruct(wd, DATA, "PTCacheMem", 1, pm); - if(type==PTCACHE_WRITE_PSYS) - writestruct(wd, DATA, "ParticleKey", pm->totpoint, pm->data); - else if(type==PTCACHE_WRITE_CLOTH) - writedata(wd, DATA, 9 * sizeof(float) * pm->totpoint, pm->data); + if((cache->flag & PTCACHE_DISK_CACHE)==0) { + PTCacheMem *pm = cache->mem_cache.first; + + for(; pm; pm=pm->next) { + writestruct(wd, DATA, "PTCacheMem", 1, pm); + if(pm->index_array) + writedata(wd, DATA, sizeof(int) * pm->totpoint, pm->index_array); + + for(i=0; idata[i] && pm->data_types & (1<totpoint, pm->data[i]); + } + } } } } @@ -652,8 +661,8 @@ static void write_particlesystems(WriteData *wd, ListBase *particles) if(psys->child) writestruct(wd, DATA, "ChildParticle", psys->totchild ,psys->child); writestruct(wd, DATA, "SoftBody", 1, psys->soft); - if(psys->soft) write_pointcaches(wd, psys->soft->pointcache, PTCACHE_WRITE_PSYS); - write_pointcaches(wd, psys->pointcache, PTCACHE_WRITE_PSYS); + if(psys->soft) write_pointcaches(wd, &psys->soft->ptcaches); + write_pointcaches(wd, &psys->ptcaches); } } @@ -771,9 +780,6 @@ static void write_actuators(WriteData *wd, ListBase *lb) case ACT_SOUND: writestruct(wd, DATA, "bSoundActuator", 1, act->data); break; - case ACT_CD: - writestruct(wd, DATA, "bCDActuator", 1, act->data); - break; case ACT_OBJECT: writestruct(wd, DATA, "bObjectActuator", 1, act->data); break; @@ -1115,7 +1121,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase, int write_undo) writestruct(wd, DATA, "ClothSimSettings", 1, clmd->sim_parms); writestruct(wd, DATA, "ClothCollSettings", 1, clmd->coll_parms); - write_pointcaches(wd, clmd->point_cache, PTCACHE_WRITE_CLOTH); + write_pointcaches(wd, &clmd->ptcaches); } else if(md->type==eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData*) md; @@ -1297,6 +1303,7 @@ static void write_mballs(WriteData *wd, ListBase *idbase) /* direct data */ writedata(wd, DATA, sizeof(void *)*mb->totcol, mb->mat); + if (mb->adt) write_animdata(wd, mb->adt); ml= mb->elems.first; while(ml) { @@ -1669,6 +1676,11 @@ static void write_lamps(WriteData *wd, ListBase *idbase) } } +static void write_paint(WriteData *wd, Paint *p) +{ + if(p && p->brushes) + writedata(wd, DATA, p->brush_count * sizeof(Brush*), p->brushes); +} static void write_scenes(WriteData *wd, ListBase *scebase) { @@ -1681,6 +1693,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase) TimeMarker *marker; TransformOrientation *ts; SceneRenderLayer *srl; + ToolSettings *tos; sce= scebase->first; while(sce) { @@ -1698,13 +1711,22 @@ static void write_scenes(WriteData *wd, ListBase *scebase) base= base->next; } - writestruct(wd, DATA, "ToolSettings", 1, sce->toolsettings); - if(sce->toolsettings->vpaint) - writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->vpaint); - if(sce->toolsettings->wpaint) - writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->wpaint); - if(sce->toolsettings->sculpt) - writestruct(wd, DATA, "Sculpt", 1, sce->toolsettings->sculpt); + tos = sce->toolsettings; + writestruct(wd, DATA, "ToolSettings", 1, tos); + if(tos->vpaint) { + writestruct(wd, DATA, "VPaint", 1, tos->vpaint); + write_paint(wd, &tos->vpaint->paint); + } + if(tos->wpaint) { + writestruct(wd, DATA, "VPaint", 1, tos->wpaint); + write_paint(wd, &tos->wpaint->paint); + } + if(tos->sculpt) { + writestruct(wd, DATA, "Sculpt", 1, tos->sculpt); + write_paint(wd, &tos->sculpt->paint); + } + + write_paint(wd, &tos->imapaint.paint); ed= sce->ed; if(ed) { @@ -2001,6 +2023,10 @@ static void write_screens(WriteData *wd, ListBase *scrbase) else if(sl->spacetype==SPACE_CONSOLE) { writestruct(wd, DATA, "SpaceConsole", 1, sl); } + else if(sl->spacetype==SPACE_USERPREF) { + writestruct(wd, DATA, "SpaceUserPref", 1, sl); + } + sl= sl->next; } } @@ -2136,45 +2162,21 @@ static void write_texts(WriteData *wd, ListBase *idbase) static void write_sounds(WriteData *wd, ListBase *idbase) { bSound *sound; - bSample *sample; PackedFile * pf; - // set all samples to unsaved status - - sample = samples->first; // samples is a global defined in sound.c - while (sample) { - sample->flags |= SAMPLE_NEEDS_SAVE; - sample = sample->id.next; - } - sound= idbase->first; while(sound) { if(sound->id.us>0 || wd->current) { - // do we need to save the packedfile as well ? - sample = sound->sample; - if (sample) { - if (sample->flags & SAMPLE_NEEDS_SAVE) { - sound->newpackedfile = sample->packedfile; - sample->flags &= ~SAMPLE_NEEDS_SAVE; - } else { - sound->newpackedfile = NULL; - } - } - /* write LibData */ writestruct(wd, ID_SO, "bSound", 1, sound); if (sound->id.properties) IDP_WriteProperty(sound->id.properties, wd); - if (sound->newpackedfile) { - pf = sound->newpackedfile; + if (sound->packedfile) { + pf = sound->packedfile; writestruct(wd, DATA, "PackedFile", 1, pf); writedata(wd, DATA, pf->size, pf->data); } - - if (sample) { - sound->newpackedfile = sample->packedfile; - } } sound= sound->id.next; } diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 28cfcb3ff6e..96b6fa5b7ab 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -33,15 +33,19 @@ SET(INC ../windowmanager ../include ../imbuf ../render/extern/include ../../../intern/bsp/extern ../radiosity/extern/include ../../../intern/decimation/extern ../blenloader ../python - ../../kernel/gen_system ../../../intern/SoundSystem ../readstreamglue + ../../kernel/gen_system ../readstreamglue ../quicktime ../../../intern/elbeem/extern ../../../intern/ghost ../../../intern/opennl/extern ../../../extern/glew/include ../../../intern/smoke/extern + ../../../intern/audaspace/intern ../nodes ../gpu ../blenfont - ${SDL_INC} ) +IF(WITH_GAMEENGINE) + ADD_DEFINITIONS(-DGAMEBLENDER) +ENDIF(WITH_GAMEENGINE) + IF(WITH_INTERNATIONAL) ADD_DEFINITIONS(-DINTERNATIONAL) ENDIF(WITH_INTERNATIONAL) diff --git a/source/blender/editors/Makefile b/source/blender/editors/Makefile index dbd0ca779aa..bbbb3fb985f 100644 --- a/source/blender/editors/Makefile +++ b/source/blender/editors/Makefile @@ -65,5 +65,6 @@ DIRS = armature \ space_text \ space_sequencer \ space_logic \ + space_userpref \ include nan_subdirs.mk diff --git a/source/blender/editors/SConscript b/source/blender/editors/SConscript index 0a13082faaf..05f17dae1a1 100644 --- a/source/blender/editors/SConscript +++ b/source/blender/editors/SConscript @@ -32,6 +32,7 @@ SConscript(['datafiles/SConscript', 'space_sequencer/SConscript', 'space_logic/SConscript', 'space_console/SConscript', + 'space_userpref/SConscript', 'transform/SConscript', 'screen/SConscript', 'sculpt_paint/SConscript', diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c new file mode 100644 index 00000000000..acf7467713b --- /dev/null +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -0,0 +1,2180 @@ +/** + * $Id$ + * + * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung + * All rights reserved. + * + * Contributor(s): Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" + +#include "DNA_listBase.h" +#include "DNA_anim_types.h" +#include "DNA_action_types.h" +#include "DNA_armature_types.h" +#include "DNA_camera_types.h" +#include "DNA_curve_types.h" +#include "DNA_object_types.h" +#include "DNA_particle_types.h" +#include "DNA_screen_types.h" +#include "DNA_scene_types.h" +#include "DNA_space_types.h" +#include "DNA_constraint_types.h" +#include "DNA_key_types.h" +#include "DNA_lamp_types.h" +#include "DNA_material_types.h" +#include "DNA_meta_types.h" +#include "DNA_userdef_types.h" +#include "DNA_gpencil_types.h" +#include "DNA_windowmanager_types.h" +#include "DNA_world_types.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "BKE_animsys.h" +#include "BKE_action.h" +#include "BKE_depsgraph.h" +#include "BKE_fcurve.h" +#include "BKE_key.h" +#include "BKE_material.h" +#include "BKE_object.h" +#include "BKE_context.h" +#include "BKE_utildefines.h" + +#include "UI_interface.h" +#include "UI_interface_icons.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "ED_anim_api.h" +#include "ED_keyframes_edit.h" // XXX move the select modes out of there! +#include "ED_screen.h" +#include "ED_space_api.h" + +#include "BIF_gl.h" + +#include "WM_api.h" +#include "WM_types.h" + +/* *********************************************** */ +// XXX constant defines to be moved elsewhere? + +/* extra padding for lengths (to go under scrollers) */ +#define EXTRA_SCROLL_PAD 100.0f + +/* size of indent steps */ +#define INDENT_STEP_SIZE 7 + +/* macros used for type defines */ + /* get the pointer used for some flag */ +#define GET_ACF_FLAG_PTR(ptr) \ + { \ + *type= sizeof((ptr)); \ + return &(ptr); \ + } + + +/* XXX */ +extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); +extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown); + + +/* *********************************************** */ +/* Generic Functions (Type independent) */ + +/* Draw Backdrop ---------------------------------- */ + +/* backdrop for top-level widgets (Scene and Object only) */ +static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; + short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + + /* darker blue for top-level widgets */ + UI_ThemeColor(TH_DOPESHEET_CHANNELOB); + + /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ + uiSetRoundBox((expanded)? (1):(1|8)); + gl_round_box(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); +} + +/* backdrop for data expanders under top-level Scene/Object */ +static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + + /* lighter color than top-level widget */ + UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); + + /* no rounded corner - just rectangular box */ + glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc); +} + +/* backdrop for generic channels */ +static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + SpaceAction *saction = NULL; + bActionGroup *grp = NULL; + short indent= (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0; + short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + + /* get context info needed... */ + if ((ac->sa) && (ac->sa->spacetype == SPACE_ACTION)) + saction= (SpaceAction *)ac->sa->spacedata.first; + + if (ale->type == ANIMTYPE_FCURVE) { + FCurve *fcu= (FCurve *)ale->data; + grp= fcu->grp; + } + + /* set color for normal channels + * - use 3 shades of color group/standard color for 3 indention level + * - only use group colors if allowed to, and if actually feasible + */ + if ( (saction && !(saction->flag & SACTION_NODRAWGCOLORS)) && + ((grp) && (grp->customCol)) ) + { + char cp[3]; + + if (indent == 2) { + VECCOPY(cp, grp->cs.solid); + } + else if (indent == 1) { + VECCOPY(cp, grp->cs.select); + } + else { + VECCOPY(cp, grp->cs.active); + } + + glColor3ub(cp[0], cp[1], cp[2]); + } + else // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)? + UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); + + /* no rounded corners - just rectangular box */ + glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc); +} + +/* Indention + Offset ------------------------------------------- */ + +/* indention level is always the value in the name */ +static short acf_generic_indention_0(bAnimContext *ac, bAnimListElem *ale) +{ + return 0; +} +static short acf_generic_indention_1(bAnimContext *ac, bAnimListElem *ale) +{ + return 1; +} +#if 0 // XXX not used +static short acf_generic_indention_2(bAnimContext *ac, bAnimListElem *ale) +{ + return 2; +} +#endif + +/* indention which varies with the grouping status */ +static short acf_generic_indention_flexible(bAnimContext *ac, bAnimListElem *ale) +{ + short indent= 0; + + if (ale->id) { + /* special exception for materials and particles */ + if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) + indent++; + } + + /* grouped F-Curves need extra level of indention */ + if (ale->type == ANIMTYPE_FCURVE) { + FCurve *fcu= (FCurve *)ale->data; + + // TODO: we need some way of specifying that the indention color should be one less... + if (fcu->grp) + indent++; + } + + /* no indention */ + return indent; +} + +/* basic offset for channels derived from indention */ +static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + + if (acf && acf->get_indent_level) + return acf->get_indent_level(ac, ale) * INDENT_STEP_SIZE; + else + return 0; +} + +/* offset for groups + grouped entities */ +static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) +{ + short offset= acf_generic_basic_offset(ac, ale); + + if (ale->id) { + /* special exception for materials and particles */ + if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) + offset += 21; + + /* if not in Action Editor mode, groupings must carry some offset too... */ + else if (ac->datatype != ANIMCONT_ACTION) + offset += 14; + } + + /* offset is just the normal type - i.e. based on indention */ + return offset; +} + +/* Name ------------------------------------------- */ + +/* name for ID block entries */ +static void acf_generic_idblock_name(bAnimListElem *ale, char *name) +{ + ID *id= (ID *)ale->data; /* data pointed to should be an ID block */ + + /* just copy the name... */ + if (id && name) + strcpy(name, id->name+2); +} + +/* Settings ------------------------------------------- */ + +/* check if some setting exists for this object-based data-expander (category only) */ +static short acf_generic_dsexpand_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* only expand supported */ + case ACHANNEL_SETTING_EXPAND: + return 1; + + /* visible - only available in Graph Editor */ + case ACHANNEL_SETTING_VISIBLE: + return ((ac) && (ac->spacetype == SPACE_IPO)); + + default: + return 0; + } +} + +/* get pointer to the setting (category only) */ +static void *acf_generic_dsexpand_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Object *ob= (Object *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(ob->nlaflag); // XXX + + default: /* unsupported */ + return NULL; + } +} + +/* check if some setting exists for this object-based data-expander (datablock only) */ +static short acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* expand is always supported */ + case ACHANNEL_SETTING_EXPAND: + return 1; + + /* mute is only supported for NLA */ + case ACHANNEL_SETTING_MUTE: + return ((ac) && (ac->spacetype == SPACE_NLA)); + + /* other flags are never supported */ + default: + return 0; + } +} + +/* *********************************************** */ +/* Type Specific Functions + Defines */ + +/* Scene ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_scene_icon(bAnimListElem *ale) +{ + return ICON_SCENE_DATA; +} + +/* check if some setting exists for this channel */ +static short acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* muted only in NLA */ + case ACHANNEL_SETTING_MUTE: + return ((ac) && (ac->spacetype == SPACE_NLA)); + + /* visible only in Graph Editor */ + case ACHANNEL_SETTING_VISIBLE: + return ((ac) && (ac->spacetype == SPACE_IPO)); + + /* only select and expand supported otherwise */ + case ACHANNEL_SETTING_SELECT: + case ACHANNEL_SETTING_EXPAND: + return 1; + + default: + return 0; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_scene_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return SCE_DS_SELECTED; + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return SCE_DS_COLLAPSED; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_scene_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Scene *scene= (Scene *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + GET_ACF_FLAG_PTR(scene->flag); + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(scene->flag); + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (scene->adt) + GET_ACF_FLAG_PTR(scene->adt->flag) + else + return NULL; + + default: /* unsupported */ + return 0; + } +} + +/* scene type define */ +static bAnimChannelType ACF_SCENE = +{ + acf_generic_root_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + NULL, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_scene_icon, /* icon */ + + acf_scene_setting_valid, /* has setting */ + acf_scene_setting_flag, /* flag for setting */ + acf_scene_setting_ptr /* pointer for setting */ +}; + +/* Object ------------------------------------------- */ + +static int acf_object_icon(bAnimListElem *ale) +{ + Base *base= (Base *)ale->data; + Object *ob= base->object; + + /* icon depends on object-type */ + if (ob->type == OB_ARMATURE) + return ICON_ARMATURE_DATA; + else + return ICON_OBJECT_DATA; +} + +/* name for object */ +static void acf_object_name(bAnimListElem *ale, char *name) +{ + Base *base= (Base *)ale->data; + Object *ob= base->object; + + /* just copy the name... */ + if (ob && name) + strcpy(name, ob->id.name+2); +} + +/* check if some setting exists for this channel */ +static short acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* muted only in NLA */ + case ACHANNEL_SETTING_MUTE: + return ((ac) && (ac->spacetype == SPACE_NLA)); + + /* visible only in Graph Editor */ + case ACHANNEL_SETTING_VISIBLE: + return ((ac) && (ac->spacetype == SPACE_IPO)); + + /* only select and expand supported otherwise */ + case ACHANNEL_SETTING_SELECT: + case ACHANNEL_SETTING_EXPAND: + return 1; + + default: + return 0; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_object_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return SELECT; + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return OB_ADS_COLLAPSED; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_object_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Base *base= (Base *)ale->data; + Object *ob= base->object; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + GET_ACF_FLAG_PTR(ob->flag); + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(ob->nlaflag); // xxx + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (ob->adt) + GET_ACF_FLAG_PTR(ob->adt->flag) + else + return NULL; + + default: /* unsupported */ + return 0; + } +} + +/* object type define */ +static bAnimChannelType ACF_OBJECT = +{ + acf_generic_root_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + NULL, /* offset */ + + acf_object_name, /* name */ + acf_object_icon, /* icon */ + + acf_object_setting_valid, /* has setting */ + acf_object_setting_flag, /* flag for setting */ + acf_object_setting_ptr /* pointer for setting */ +}; + +/* Group ------------------------------------------- */ + +/* backdrop for group widget */ +static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; + short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + + /* only for action group channels */ + if (ale->flag & AGRP_ACTIVE) + UI_ThemeColorShade(TH_GROUP_ACTIVE, 10); + else + UI_ThemeColorShade(TH_GROUP, 20); + + /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ + uiSetRoundBox((expanded)? (1):(1|8)); + gl_round_box(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); +} + +/* name for group entries */ +static void acf_group_name(bAnimListElem *ale, char *name) +{ + bActionGroup *agrp= (bActionGroup *)ale->data; + + /* just copy the name... */ + if (agrp && name) + strcpy(name, agrp->name); +} + +/* check if some setting exists for this channel */ +static short acf_group_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + /* for now, all settings are supported, though some are only conditionally */ + switch (setting) { + case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ + return ((ac->sa) && (ac->sa->spacetype==SPACE_IPO)); + + default: /* always supported */ + return 1; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_group_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return AGRP_SELECTED; + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return AGRP_EXPANDED; + + case ACHANNEL_SETTING_MUTE: /* muted */ + return AGRP_MUTED; + + case ACHANNEL_SETTING_PROTECT: /* protected */ + //*neg= 1; - if we change this to edtiability + return AGRP_PROTECTED; + + case ACHANNEL_SETTING_VISIBLE: /* visiblity - graph editor */ + *neg= 1; + return AGRP_NOTVISIBLE; + } + + /* this shouldn't happen */ + return 0; +} + +/* get pointer to the setting */ +static void *acf_group_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + bActionGroup *agrp= (bActionGroup *)ale->data; + + /* all flags are just in agrp->flag for now... */ + GET_ACF_FLAG_PTR(agrp->flag); +} + +/* group type define */ +static bAnimChannelType ACF_GROUP = +{ + acf_group_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_generic_group_offset, /* offset */ + + acf_group_name, /* name */ + NULL, /* icon */ + + acf_group_setting_valid, /* has setting */ + acf_group_setting_flag, /* flag for setting */ + acf_group_setting_ptr /* pointer for setting */ +}; + +/* F-Curve ------------------------------------------- */ + +/* name for fcurve entries */ +static void acf_fcurve_name(bAnimListElem *ale, char *name) +{ + getname_anim_fcurve(name, ale->id, ale->data); +} + +/* check if some setting exists for this channel */ +static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + FCurve *fcu= (FCurve *)ale->data; + + switch (setting) { + /* unsupported */ + case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */ + return 0; + + /* conditionally available */ + case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */ + if (fcu->bezt) + return 1; + else + return 0; // NOTE: in this special case, we need to draw ICON_ZOOMOUT + + case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ + return ((ac->sa) && (ac->sa->spacetype==SPACE_IPO)); + + /* always available */ + default: + return 1; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fcurve_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return FCURVE_SELECTED; + + case ACHANNEL_SETTING_MUTE: /* muted */ + return FCURVE_MUTED; + + case ACHANNEL_SETTING_PROTECT: /* protected */ + //*neg= 1; - if we change this to edtiability + return FCURVE_PROTECTED; + + case ACHANNEL_SETTING_VISIBLE: /* visiblity - graph editor */ + return FCURVE_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_fcurve_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + FCurve *fcu= (FCurve *)ale->data; + + /* all flags are just in agrp->flag for now... */ + GET_ACF_FLAG_PTR(fcu->flag); +} + +/* fcurve type define */ +static bAnimChannelType ACF_FCURVE = +{ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only? + acf_generic_group_offset, /* offset */ + + acf_fcurve_name, /* name */ + NULL, /* icon */ + + acf_fcurve_setting_valid, /* has setting */ + acf_fcurve_setting_flag, /* flag for setting */ + acf_fcurve_setting_ptr /* pointer for setting */ +}; + +/* Object Action Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_fillactd_icon(bAnimListElem *ale) +{ + return ICON_ACTION; +} + +/* check if some setting exists for this channel */ +static short acf_fillactd_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* only select and expand supported */ + case ACHANNEL_SETTING_SELECT: + case ACHANNEL_SETTING_EXPAND: + return 1; + + default: + return 0; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fillactd_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return ACT_SELECTED; + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return ACT_COLLAPSED; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_fillactd_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + bAction *act= (bAction *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + GET_ACF_FLAG_PTR(act->flag); + + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(act->flag); + + default: /* unsupported */ + return 0; + } +} + +/* object action expander type define */ +static bAnimChannelType ACF_FILLACTD = +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_fillactd_icon, /* icon */ + + acf_fillactd_setting_valid, /* has setting */ + acf_fillactd_setting_flag, /* flag for setting */ + acf_fillactd_setting_ptr /* pointer for setting */ +}; + +/* Drivers Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_filldrivers_icon(bAnimListElem *ale) +{ + return ICON_ANIM_DATA; +} + +static void acf_filldrivers_name(bAnimListElem *ale, char *name) +{ + strcpy(name, "Drivers"); +} + +/* check if some setting exists for this channel */ +// TODO: this could be made more generic +static short acf_filldrivers_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +{ + switch (setting) { + /* only expand supported */ + case ACHANNEL_SETTING_EXPAND: + return 1; + + default: + return 0; + } +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_filldrivers_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return ADT_DRIVERS_COLLAPSED; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + AnimData *adt= (AnimData *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(adt->flag); + + default: /* unsupported */ + return 0; + } +} + +/* drivers expander type define */ +static bAnimChannelType ACF_FILLDRIVERS = +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_filldrivers_name, /* name */ + acf_filldrivers_icon, /* icon */ + + acf_filldrivers_setting_valid, /* has setting */ + acf_filldrivers_setting_flag, /* flag for setting */ + acf_filldrivers_setting_ptr /* pointer for setting */ +}; + +/* Materials Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_fillmatd_icon(bAnimListElem *ale) +{ + return ICON_MATERIAL_DATA; +} + +static void acf_fillmatd_name(bAnimListElem *ale, char *name) +{ + strcpy(name, "Materials"); +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fillmatd_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return OB_ADS_SHOWMATS; + + default: /* unsupported */ + return 0; + } +} + +/* materials expander type define */ +static bAnimChannelType ACF_FILLMATD= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_fillmatd_name, /* name */ + acf_fillmatd_icon, /* icon */ + + acf_generic_dsexpand_setting_valid, /* has setting */ + acf_fillmatd_setting_flag, /* flag for setting */ + acf_generic_dsexpand_setting_ptr /* pointer for setting */ +}; + +/* Particles Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_fillpartd_icon(bAnimListElem *ale) +{ + return ICON_PARTICLE_DATA; +} + +static void acf_fillpartd_name(bAnimListElem *ale, char *name) +{ + strcpy(name, "Particles"); +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_fillpartd_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + *neg= 1; + return OB_ADS_SHOWPARTS; + + default: /* unsupported */ + return 0; + } +} + +/* particles expander type define */ +static bAnimChannelType ACF_FILLPARTD= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_fillpartd_name, /* name */ + acf_fillpartd_icon, /* icon */ + + acf_generic_dsexpand_setting_valid, /* has setting */ + acf_fillpartd_setting_flag, /* flag for setting */ + acf_generic_dsexpand_setting_ptr /* pointer for setting */ +}; + +/* Material Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dsmat_icon(bAnimListElem *ale) +{ + return ICON_MATERIAL_DATA; +} + +/* offset for material expanders */ +static short acf_dsmat_offset(bAnimContext *ac, bAnimListElem *ale) +{ + return 21; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dsmat_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return MA_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dsmat_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Material *ma= (Material *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(ma->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (ma->adt) + GET_ACF_FLAG_PTR(ma->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* material expander type define */ +static bAnimChannelType ACF_DSMAT= +{ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_dsmat_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dsmat_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsmat_setting_flag, /* flag for setting */ + acf_dsmat_setting_ptr /* pointer for setting */ +}; + +/* Lamp Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dslam_icon(bAnimListElem *ale) +{ + return ICON_LAMP_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dslam_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return LA_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dslam_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Lamp *la= (Lamp *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(la->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (la->adt) + GET_ACF_FLAG_PTR(la->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* lamp expander type define */ +static bAnimChannelType ACF_DSLAM= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dslam_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dslam_setting_flag, /* flag for setting */ + acf_dslam_setting_ptr /* pointer for setting */ +}; + +/* Camera Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dscam_icon(bAnimListElem *ale) +{ + return ICON_CAMERA_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dscam_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return CAM_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dscam_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Camera *ca= (Camera *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(ca->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (ca->adt) + GET_ACF_FLAG_PTR(ca->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* camera expander type define */ +static bAnimChannelType ACF_DSCAM= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dscam_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dscam_setting_flag, /* flag for setting */ + acf_dscam_setting_ptr /* pointer for setting */ +}; + +/* Curve Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dscur_icon(bAnimListElem *ale) +{ + return ICON_CURVE_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dscur_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return CU_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dscur_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Curve *cu= (Curve *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(cu->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (cu->adt) + GET_ACF_FLAG_PTR(cu->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* curve expander type define */ +static bAnimChannelType ACF_DSCUR= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dscur_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dscur_setting_flag, /* flag for setting */ + acf_dscur_setting_ptr /* pointer for setting */ +}; + +/* Shape Key Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dsskey_icon(bAnimListElem *ale) +{ + return ICON_SHAPEKEY_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dsskey_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return KEYBLOCK_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dsskey_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Key *key= (Key *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(key->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (key->adt) + GET_ACF_FLAG_PTR(key->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* shapekey expander type define */ +static bAnimChannelType ACF_DSSKEY= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dsskey_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsskey_setting_flag, /* flag for setting */ + acf_dsskey_setting_ptr /* pointer for setting */ +}; + +/* World Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dswor_icon(bAnimListElem *ale) +{ + return ICON_WORLD_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dswor_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return WO_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dswor_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + World *wo= (World *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(wo->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (wo->adt) + GET_ACF_FLAG_PTR(wo->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* world expander type define */ +static bAnimChannelType ACF_DSWOR= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dswor_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dswor_setting_flag, /* flag for setting */ + acf_dswor_setting_ptr /* pointer for setting */ +}; + +/* Particle Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dspart_icon(bAnimListElem *ale) +{ + return ICON_PARTICLE_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dspart_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return PART_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dspart_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + ParticleSettings *part= (ParticleSettings *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(part->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (part->adt) + GET_ACF_FLAG_PTR(part->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* particle expander type define */ +static bAnimChannelType ACF_DSPART= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dspart_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dspart_setting_flag, /* flag for setting */ + acf_dspart_setting_ptr /* pointer for setting */ +}; + +/* MetaBall Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dsmball_icon(bAnimListElem *ale) +{ + return ICON_META_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dsmball_setting_flag(int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return MB_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dsmball_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + MetaBall *mb= (MetaBall *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(mb->flag); + + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (mb->adt) + GET_ACF_FLAG_PTR(mb->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* metaball expander type define */ +static bAnimChannelType ACF_DSMBALL= +{ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dsmball_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsmball_setting_flag, /* flag for setting */ + acf_dsmball_setting_ptr /* pointer for setting */ +}; + +/* ShapeKey Entry ------------------------------------------- */ +// XXX ... this is currently obsolete... + +#if 0 +static void dummy_olddraw_shapekeys () +{ + case ANIMTYPE_SHAPEKEY: /* shapekey channel */ + { + KeyBlock *kb = (KeyBlock *)ale->data; + + indent = 0; + special = -1; + + offset= (ale->id) ? 21 : 0; + + if (kb->name[0] == '\0') + sprintf(name, "Key %d", ale->index); + else + strcpy(name, kb->name); + } + break; +} +#endif + +/* Grease Pencil entries ------------------------------------------- */ +// XXX ... this is currently not restored yet + +#if 0 +static void dummy_olddraw_gpencil () +{ + /* determine what needs to be drawn */ + switch (ale->type) { + case ANIMTYPE_GPDATABLOCK: /* gpencil datablock */ + { + bGPdata *gpd = (bGPdata *)ale->data; + ScrArea *sa = (ScrArea *)ale->owner; + + indent = 0; + group= 3; + + /* only show expand if there are any channels */ + if (gpd->layers.first) { + if (gpd->flag & GP_DATA_EXPAND) + expand = ICON_TRIA_DOWN; + else + expand = ICON_TRIA_RIGHT; + } + + switch (sa->spacetype) { + case SPACE_VIEW3D: + { + /* this shouldn't cause any overflow... */ + //sprintf(name, "3DView:%s", view3d_get_name(sa->spacedata.first)); // XXX missing func.. + strcpy(name, "3dView"); + special= ICON_VIEW3D; + } + break; + case SPACE_NODE: + { + SpaceNode *snode= sa->spacedata.first; + char treetype[12]; + + if (snode->treetype == 1) + strcpy(treetype, "Composite"); + else + strcpy(treetype, "Material"); + sprintf(name, "Nodes:%s", treetype); + + special= ICON_NODE; + } + break; + case SPACE_SEQ: + { + SpaceSeq *sseq= sa->spacedata.first; + char imgpreview[10]; + + switch (sseq->mainb) { + case 1: sprintf(imgpreview, "Image..."); break; + case 2: sprintf(imgpreview, "Luma..."); break; + case 3: sprintf(imgpreview, "Chroma..."); break; + case 4: sprintf(imgpreview, "Histogram"); break; + + default: sprintf(imgpreview, "Sequence"); break; + } + sprintf(name, "Sequencer:%s", imgpreview); + + special= ICON_SEQUENCE; + } + break; + case SPACE_IMAGE: + { + SpaceImage *sima= sa->spacedata.first; + + if (sima->image) + sprintf(name, "Image:%s", sima->image->id.name+2); + else + strcpy(name, "Image:"); + + special= ICON_IMAGE_COL; + } + break; + + default: + { + sprintf(name, ""); + special= -1; + } + break; + } + } + break; + case ANIMTYPE_GPLAYER: /* gpencil layer */ + { + bGPDlayer *gpl = (bGPDlayer *)ale->data; + + indent = 0; + special = -1; + expand = -1; + group = 1; + + if (EDITABLE_GPL(gpl)) + protect = ICON_UNLOCKED; + else + protect = ICON_LOCKED; + + if (gpl->flag & GP_LAYER_HIDE) + mute = ICON_MUTE_IPO_ON; + else + mute = ICON_MUTE_IPO_OFF; + + sel = SEL_GPL(gpl); + BLI_snprintf(name, 32, gpl->info); + } + break; + } + + if (group == 3) { + /* only for gp-data channels */ + UI_ThemeColorShade(TH_GROUP, 20); + uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); + gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); + } +} +#endif + +/* *********************************************** */ +/* Type Registration and General Access */ + +/* These globals only ever get directly accessed in this file */ +static bAnimChannelType *animchannelTypeInfo[ANIMTYPE_NUM_TYPES]; +static short ACF_INIT= 1; /* when non-zero, the list needs to be updated */ + +/* Initialise type info definitions */ +void ANIM_init_channel_typeinfo_data (void) +{ + int type= 0; + + /* start initialising if necessary... */ + if (ACF_INIT) { + ACF_INIT= 0; + + animchannelTypeInfo[type++]= NULL; /* None */ + animchannelTypeInfo[type++]= NULL; /* AnimData */ + animchannelTypeInfo[type++]= NULL; /* Special */ + + animchannelTypeInfo[type++]= &ACF_SCENE; /* Scene */ + animchannelTypeInfo[type++]= &ACF_OBJECT; /* Object */ + animchannelTypeInfo[type++]= &ACF_GROUP; /* Group */ + animchannelTypeInfo[type++]= &ACF_FCURVE; /* F-Curve */ + + animchannelTypeInfo[type++]= &ACF_FILLACTD; /* Object Action Expander */ + animchannelTypeInfo[type++]= &ACF_FILLDRIVERS; /* Drivers Expander */ + animchannelTypeInfo[type++]= &ACF_FILLMATD; /* Materials Expander */ + animchannelTypeInfo[type++]= &ACF_FILLPARTD; /* Particles Expander */ + + animchannelTypeInfo[type++]= &ACF_DSMAT; /* Material Channel */ + animchannelTypeInfo[type++]= &ACF_DSLAM; /* Lamp Channel */ + animchannelTypeInfo[type++]= &ACF_DSCAM; /* Camera Channel */ + animchannelTypeInfo[type++]= &ACF_DSCUR; /* Curve Channel */ + animchannelTypeInfo[type++]= &ACF_DSSKEY; /* ShapeKey Channel */ + animchannelTypeInfo[type++]= &ACF_DSWOR; /* World Channel */ + animchannelTypeInfo[type++]= &ACF_DSPART; /* Particle Channel */ + animchannelTypeInfo[type++]= &ACF_DSMBALL; /* MetaBall Channel */ + + animchannelTypeInfo[type++]= NULL; /* ShapeKey */ // XXX this is no longer used for now... + + // XXX not restored yet + animchannelTypeInfo[type++]= NULL; /* Grease Pencil Datablock */ + animchannelTypeInfo[type++]= NULL; /* Grease Pencil Layer */ + + // TODO: these types still need to be implemented!!! + // probably need a few extra flags for these special cases... + animchannelTypeInfo[type++]= NULL; /* NLA Track */ + animchannelTypeInfo[type++]= NULL; /* NLA Action */ + } +} + +/* Get type info from given channel type */ +bAnimChannelType *ANIM_channel_get_typeinfo (bAnimListElem *ale) +{ + /* santiy checks */ + if (ale == NULL) + return NULL; + + /* init the typeinfo if not available yet... */ + ANIM_init_channel_typeinfo_data(); + + /* check if type is in bounds... */ + if ((ale->type >= 0) && (ale->type < ANIMTYPE_NUM_TYPES)) + return animchannelTypeInfo[ale->type]; + else + return NULL; +} + +/* --------------------------- */ + +/* Check if some setting for a channel is enabled + * Returns: 1 = On, 0 = Off, -1 = Invalid + */ +short ANIM_channel_setting_get (bAnimContext *ac, bAnimListElem *ale, int setting) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + + /* 1) check that the setting exists for the current context */ + if ( (acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting)) ) + { + /* 2) get pointer to check for flag in, and the flag to check for */ + short negflag, ptrsize; + int flag; + void *ptr; + + flag= acf->setting_flag(setting, &negflag); + ptr= acf->setting_ptr(ale, setting, &ptrsize); + + /* check if flag is enabled */ + if (ptr && flag) { + switch (ptrsize) { + case sizeof(int): /* integer pointer for setting */ + { + int *val= (int *)ptr; + + if (negflag) + return ((*val) & flag) == 0; + else + return ((*val) & flag) != 0; + } + break; + + case sizeof(short): /* short pointer for setting */ + { + short *val= (short *)ptr; + + if (negflag) + return ((*val) & flag) == 0; + else + return ((*val) & flag) != 0; + } + break; + + case sizeof(char): /* char pointer for setting */ + { + char *val= (char *)ptr; + + if (negflag) + return ((*val) & flag) == 0; + else + return ((*val) & flag) != 0; + } + break; + } + } + } + + /* not found... */ + return -1; +} + + +/* quick macro for use in ANIM_channel_setting_set - set flag for setting according the mode given */ +#define ACF_SETTING_SET(sval, sflag, smode) \ + {\ + if (negflag) {\ + if (smode == ACHANNEL_SETFLAG_TOGGLE) (sval) ^= (sflag); \ + else if (smode == ACHANNEL_SETFLAG_ADD) (sval) &= ~(sflag); \ + else (sval) |= (sflag); \ + } \ + else {\ + if (smode == ACHANNEL_SETFLAG_TOGGLE) (sval) ^= (sflag); \ + else if (smode == ACHANNEL_SETFLAG_ADD) (sval) |= (sflag); \ + else (sval) &= ~(sflag); \ + }\ + } + +/* Change value of some setting for a channel + * - setting: eAnimChannel_Settings + * - mode: eAnimChannels_SetFlag + */ +void ANIM_channel_setting_set (bAnimContext *ac, bAnimListElem *ale, int setting, short mode) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + + /* 1) check that the setting exists for the current context */ + if ( (acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting)) ) + { + /* 2) get pointer to check for flag in, and the flag to check for */ + short negflag, ptrsize; + int flag; + void *ptr; + + flag= acf->setting_flag(setting, &negflag); + ptr= acf->setting_ptr(ale, setting, &ptrsize); + + /* check if flag is enabled */ + if (ptr && flag) { + switch (ptrsize) { + case sizeof(int): /* integer pointer for setting */ + { + int *val= (int *)ptr; + ACF_SETTING_SET(*val, flag, mode); + } + break; + + case sizeof(short): /* short pointer for setting */ + { + short *val= (short *)ptr; + ACF_SETTING_SET(*val, flag, mode); + } + break; + + case sizeof(char): /* char pointer for setting */ + { + char *val= (char *)ptr; + ACF_SETTING_SET(*val, flag, mode); + } + break; + } + } + } +} + +/* --------------------------- */ + +// XXX hardcoded size of icons +#define ICON_WIDTH 17 + +/* Draw the given channel */ +// TODO: make this use UI controls for the buttons +void ANIM_channel_draw (bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + short selected, offset; + float y, ymid, ytext; + + /* sanity checks - don't draw anything */ + if ELEM(NULL, acf, ale) + return; + + /* get initial offset */ + if (acf->get_offset) + offset= acf->get_offset(ac, ale); + else + offset= 0; + + /* calculate appropriate y-coordinates for icon buttons + * 7 is hardcoded factor for half-height of icons + */ + y= (ymaxc - yminc)/2 + yminc; + ymid= y - 7; + /* y-coordinates for text is only 4 down from middle */ + ytext= y - 4; + + /* check if channel is selected */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) + selected= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); + else + selected= 0; + + /* set blending again, as may not be set in previous step */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + /* step 1) draw backdrop ........................................... */ + if (acf->draw_backdrop) + acf->draw_backdrop(ac, ale, yminc, ymaxc); + + /* step 2) draw expand widget ....................................... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) { + /* just skip - drawn as widget now */ + offset += ICON_WIDTH; + } + + /* step 3) draw icon ............................................... */ + if (acf->icon) { + UI_icon_draw(offset, ymid, acf->icon(ale)); + offset += ICON_WIDTH; + } + + /* step 4) draw special toggles ................................. + * - in Graph Editor, checkboxes for visibility in curves area + * - in NLA Editor, glowing dots for solo/not solo... + */ + if (ac->sa) { + if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { + /* for F-Curves, draw color-preview of curve behind checkbox */ + if (ale->type == ANIMTYPE_FCURVE) { + FCurve *fcu= (FCurve *)ale->data; + + /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever + * color the curve has stored + */ + glColor3fv(fcu->color); + + /* just a solid color rect + * hardcoded 17 pixels width is slightly wider than icon width, so that + * there's a slight border around it + */ + glRectf(offset, yminc, offset+17, ymaxc); + } + + /* icon is drawn as widget now... */ + offset += ICON_WIDTH; + } + else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) { + /* just skip - drawn as widget now */ + offset += ICON_WIDTH; + } + } + + /* step 5) draw name ............................................... */ + if (acf->name) { + char name[256]; /* hopefully this will be enough! */ + + /* set text color */ + if (selected) + UI_ThemeColor(TH_TEXT_HI); + else + UI_ThemeColor(TH_TEXT); + + /* get name */ + acf->name(ale, name); + + offset += 3; + UI_DrawString(offset, ytext, name); + } + + /* step 6) draw mute+protection toggles + (sliders) ....................... */ + /* reset offset - now goes from RHS of panel */ + offset = 0; + + // TODO: we need a mechanism of drawing over (and hiding) stuff from here... + // TODO: when drawing sliders, make those draw instead of these toggles if not enough space + + if (v2d) { + /* protect... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { + /* just skip - drawn as widget now */ + offset += ICON_WIDTH; + } + /* mute... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) { + /* just skip - drawn as widget now */ + offset += ICON_WIDTH; + } + } +} + +/* ------------------ */ + +/* callback for widget settings - send notifiers */ +static void achannel_setting_widget_cb(bContext *C, void *poin, void *poin2) +{ + WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); +} + +/* Draw a widget for some setting */ +static void draw_setting_widget (bAnimContext *ac, bAnimListElem *ale, bAnimChannelType *acf, uiBlock *block, int xpos, int ypos, int setting) +{ + short negflag, ptrsize, enabled, butType; + int flag, icon; + void *ptr; + char *tooltip; + uiBut *but = NULL; + + /* get the flag and the pointer to that flag */ + flag= acf->setting_flag(setting, &negflag); + ptr= acf->setting_ptr(ale, setting, &ptrsize); + enabled= ANIM_channel_setting_get(ac, ale, setting); + + /* get the base icon for the setting */ + switch (setting) { + case ACHANNEL_SETTING_VISIBLE: /* visibility checkboxes */ + //icon= ((enabled)? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT); + icon= ICON_CHECKBOX_DEHLT; + + if (ale->type == ANIMTYPE_FCURVE) + tooltip= "F-Curve is visible in Graph Editor for editing."; + else + tooltip= "F-Curve(s) are visible in Graph Editor for editing."; + break; + + case ACHANNEL_SETTING_EXPAND: /* expanded triangle */ + //icon= ((enabled)? ICON_TRIA_DOWN : ICON_TRIA_RIGHT); + icon= ICON_TRIA_RIGHT; + tooltip= "Make channels grouped under this channel visible."; + break; + + case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */ + //icon= ((enabled)? ICON_LAYER_ACTIVE : ICON_LAYER_USED); + icon= ICON_LAYER_USED; + tooltip= "NLA Track is the only one evaluated for the AnimData block it belongs to."; + break; + + /* --- */ + + case ACHANNEL_SETTING_PROTECT: /* protected lock */ + // TODO: what about when there's no protect needed? + //icon= ((enabled)? ICON_LOCKED : ICON_UNLOCKED); + icon= ICON_UNLOCKED; + tooltip= "Editability of keyframes for this channel."; + break; + + case ACHANNEL_SETTING_MUTE: /* muted eye */ + //icon= ((enabled)? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF); + icon= ICON_MUTE_IPO_OFF; + + if (ale->type == ALE_FCURVE) + tooltip= "Does F-Curve contribute to result."; + else + tooltip= "Do channels contribute to result."; + break; + + default: + tooltip= NULL; + icon= 0; + break; + } + + /* type of button */ + if (negflag) + butType= ICONTOGN; + else + butType= ICONTOG; + + /* draw button for setting */ + if (ptr && flag) { + switch (ptrsize) { + case sizeof(int): /* integer pointer for setting */ + but= uiDefIconButBitI(block, butType, flag, 0, icon, + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + break; + + case sizeof(short): /* short pointer for setting */ + but= uiDefIconButBitS(block, butType, flag, 0, icon, + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + break; + + case sizeof(char): /* char pointer for setting */ + but= uiDefIconButBitC(block, butType, flag, 0, icon, + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + break; + } + + /* set call to send relevant notifiers */ + // NOTE: for now, we only need to send 'edited' + if (but) + uiButSetFunc(but, achannel_setting_widget_cb, NULL, NULL); + } +} + +/* Draw UI widgets the given channel */ +// TODO: make this use UI controls for the buttons +void ANIM_channel_draw_widgets (bAnimContext *ac, bAnimListElem *ale, uiBlock *block, float yminc, float ymaxc) +{ + bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + View2D *v2d= &ac->ar->v2d; + float y, ymid, ytext; + short offset; + + /* sanity checks - don't draw anything */ + if ELEM3(NULL, acf, ale, block) + return; + + /* get initial offset */ + if (acf->get_offset) + offset= acf->get_offset(ac, ale); + else + offset= 0; + + /* calculate appropriate y-coordinates for icon buttons + * 7 is hardcoded factor for half-height of icons + */ + y= (ymaxc - yminc)/2 + yminc; + ymid= y - 7; + /* y-coordinates for text is only 4 down from middle */ + ytext= y - 4; + + /* no button backdrop behind icons */ + uiBlockSetEmboss(block, UI_EMBOSSN); + + /* step 1) draw expand widget ....................................... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) { + draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_EXPAND); + offset += ICON_WIDTH; + } + + /* step 2) draw icon ............................................... */ + if (acf->icon) { + /* icon is not drawn here (not a widget) */ + offset += ICON_WIDTH; + } + + /* step 3) draw special toggles ................................. + * - in Graph Editor, checkboxes for visibility in curves area + * - in NLA Editor, glowing dots for solo/not solo... + */ + if (ac->sa) { + if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { + /* visibility toggle */ + draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_VISIBLE); + offset += ICON_WIDTH; + } + else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) { + /* 'solo' setting for NLA Tracks */ + draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_SOLO); + offset += ICON_WIDTH; + } + } + + /* step 4) draw text... */ + /* NOTE: this is not done here, since nothing to be clicked on... */ + + /* step 5) draw mute+protection toggles + (sliders) ....................... */ + /* reset offset - now goes from RHS of panel */ + offset = 0; + + // TODO: when drawing sliders, make those draw instead of these toggles if not enough space + + if (v2d) { + /* protect... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { + offset += ICON_WIDTH; + draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_PROTECT); + } + /* mute... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) { + offset += ICON_WIDTH; + draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_MUTE); + } + } +} + +/* *********************************************** */ diff --git a/source/blender/editors/animation/anim_channels.c b/source/blender/editors/animation/anim_channels_edit.c similarity index 77% rename from source/blender/editors/animation/anim_channels.c rename to source/blender/editors/animation/anim_channels_edit.c index f518b5b0a2e..72d8f71bc26 100644 --- a/source/blender/editors/animation/anim_channels.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -17,11 +17,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung * All rights reserved. * - * The Original Code is: all of this file. - * * Contributor(s): Joshua Leung * * ***** END GPL LICENSE BLOCK ***** @@ -56,6 +54,7 @@ #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" +#include "DNA_meta_types.h" #include "DNA_userdef_types.h" #include "DNA_gpencil_types.h" #include "DNA_windowmanager_types.h" @@ -883,14 +882,6 @@ void ANIM_OT_channels_visibility_toggle (wmOperatorType *ot) /* ********************** Set Flags Operator *********************** */ -enum { -// ACHANNEL_SETTING_SELECT = 0, - ACHANNEL_SETTING_PROTECT = 1, - ACHANNEL_SETTING_MUTE, - ACHANNEL_SETTING_VISIBLE, - ACHANNEL_SETTING_EXPAND, -} eAnimChannel_Settings; - /* defines for setting animation-channel flags */ EnumPropertyItem prop_animchannel_setflag_types[] = { {ACHANNEL_SETFLAG_CLEAR, "DISABLE", 0, "Disable", ""}, @@ -900,6 +891,7 @@ EnumPropertyItem prop_animchannel_setflag_types[] = { }; /* defines for set animation-channel settings */ +// TODO: could add some more types, but those are really quite dependent on the mode... EnumPropertyItem prop_animchannel_settings_types[] = { {ACHANNEL_SETTING_PROTECT, "PROTECT", 0, "Protect", ""}, {ACHANNEL_SETTING_MUTE, "MUTE", 0, "Mute", ""}, @@ -931,202 +923,8 @@ static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, /* affect selected channels */ for (ale= anim_data.first; ale; ale= ale->next) { - switch (ale->type) { - case ANIMTYPE_OBJECT: - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - if (setting == ACHANNEL_SETTING_EXPAND) { - // XXX - settings should really be moved out of ob->nlaflag - if (mode == ACHANNEL_SETFLAG_TOGGLE) ob->nlaflag ^= OB_ADS_COLLAPSED; - else if (mode == ACHANNEL_SETFLAG_ADD) ob->nlaflag &= ~OB_ADS_COLLAPSED; - else ob->nlaflag |= OB_ADS_COLLAPSED; - } - } - break; - - case ANIMTYPE_FILLACTD: - { - bAction *act= (bAction *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG_NEG(act, mode, ACT_COLLAPSED); - } - } - } - break; - case ANIMTYPE_FILLDRIVERS: - { - AnimData *adt= (AnimData *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG_NEG(adt, mode, ADT_DRIVERS_COLLAPSED); - } - } - } - break; - case ANIMTYPE_FILLMATD: - { - Object *ob= (Object *)ale->data; - - // XXX - settings should really be moved out of ob->nlaflag - if ((onlysel == 0) || (ob->flag & SELECT)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - if (mode == ACHANNEL_SETFLAG_TOGGLE) ob->nlaflag ^= OB_ADS_SHOWMATS; - else if (mode == ACHANNEL_SETFLAG_ADD) ob->nlaflag |= OB_ADS_SHOWMATS; - else ob->nlaflag &= ~OB_ADS_SHOWMATS; - } - } - } - break; - case ANIMTYPE_FILLPARTD: - { - Object *ob= (Object *)ale->data; - - // XXX - settings should really be moved out of ob->nlaflag - if ((onlysel == 0) || (ob->flag & SELECT)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - if (mode == ACHANNEL_SETFLAG_TOGGLE) ob->nlaflag ^= OB_ADS_SHOWPARTS; - else if (mode == ACHANNEL_SETFLAG_ADD) ob->nlaflag |= OB_ADS_SHOWPARTS; - else ob->nlaflag &= ~OB_ADS_SHOWPARTS; - } - } - } - break; - - case ANIMTYPE_DSMAT: - { - Material *ma= (Material *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(ma, mode, MA_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSLAM: - { - Lamp *la= (Lamp *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(la, mode, LA_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSCAM: - { - Camera *ca= (Camera *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(ca, mode, CAM_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSCUR: - { - Curve *cu= (Curve *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(cu, mode, CU_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSSKEY: - { - Key *key= (Key *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(key, mode, KEYBLOCK_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSWOR: - { - World *wo= (World *)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(wo, mode, WO_DS_EXPAND); - } - } - } - break; - case ANIMTYPE_DSPART: - { - ParticleSettings *part= (ParticleSettings*)ale->data; - - if (ASUBCHANNEL_SEL_OK(ale)) { - if (setting == ACHANNEL_SETTING_EXPAND) { - ACHANNEL_SET_FLAG(part, mode, PART_DS_EXPAND); - } - } - } - break; - - case ANIMTYPE_GROUP: - { - bActionGroup *agrp= (bActionGroup *)ale->data; - - switch (setting) { - case ACHANNEL_SETTING_PROTECT: - ACHANNEL_SET_FLAG(agrp, mode, AGRP_PROTECTED); - break; - case ACHANNEL_SETTING_EXPAND: - ACHANNEL_SET_FLAG(agrp, mode, AGRP_EXPANDED); - break; - case ACHANNEL_SETTING_MUTE: - ACHANNEL_SET_FLAG(agrp, mode, AGRP_MUTED); - break; - case ACHANNEL_SETTING_VISIBLE: - ACHANNEL_SET_FLAG_NEG(agrp, mode, AGRP_NOTVISIBLE); - break; - } - } - break; - case ANIMTYPE_FCURVE: - { - FCurve *fcu= (FCurve *)ale->data; - - switch (setting) { - case ACHANNEL_SETTING_MUTE: - ACHANNEL_SET_FLAG(fcu, mode, FCURVE_MUTED); - break; - case ACHANNEL_SETTING_PROTECT: - ACHANNEL_SET_FLAG(fcu, mode, FCURVE_PROTECTED); - break; - case ACHANNEL_SETTING_VISIBLE: - ACHANNEL_SET_FLAG(fcu, mode, FCURVE_VISIBLE); - break; - } - } - break; - case ANIMTYPE_GPLAYER: - { - bGPDlayer *gpl= (bGPDlayer *)ale->data; - - switch (setting) { - case ACHANNEL_SETTING_MUTE: - ACHANNEL_SET_FLAG(gpl, mode, GP_LAYER_HIDE); - break; - case ACHANNEL_SETTING_PROTECT: - ACHANNEL_SET_FLAG(gpl, mode, GP_LAYER_LOCKED); - break; - } - } - break; - } + /* set the setting in the appropriate way (if available) */ + ANIM_channel_setting_set(ac, ale, setting, mode); } BLI_freelistN(&anim_data); @@ -1395,47 +1193,19 @@ static void borderselect_anim_channels (bAnimContext *ac, rcti *rect, short sele /* if channel is within border-select region, alter it */ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) { - /* only the following types can be selected */ + /* set selection flags only */ + ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_SELECT, selectmode); + + /* type specific actions */ switch (ale->type) { - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - ACHANNEL_SET_FLAG(base, selectmode, SELECT); - ACHANNEL_SET_FLAG(ob, selectmode, SELECT); - } - break; - case ANIMTYPE_GROUP: /* action group */ + case ANIMTYPE_GROUP: { bActionGroup *agrp= (bActionGroup *)ale->data; - ACHANNEL_SET_FLAG(agrp, selectmode, AGRP_SELECTED); + /* always clear active flag after doing this */ agrp->flag &= ~AGRP_ACTIVE; } break; - case ANIMTYPE_FCURVE: /* F-Curve channel */ - { - FCurve *fcu = (FCurve *)ale->data; - - ACHANNEL_SET_FLAG(fcu, selectmode, FCURVE_SELECTED); - } - break; - case ANIMTYPE_GPLAYER: /* grease-pencil layer */ - { - bGPDlayer *gpl = (bGPDlayer *)ale->data; - - ACHANNEL_SET_FLAG(gpl, selectmode, GP_LAYER_SELECT); - } - break; - - case ANIMTYPE_NLATRACK: /* nla-track */ - { - NlaTrack *nlt= (NlaTrack *)ale->data; - - ACHANNEL_SET_FLAG(nlt, selectmode, NLATRACK_SELECTED); - } - break; } } @@ -1507,11 +1277,7 @@ void ANIM_OT_channels_select_border(wmOperatorType *ot) } /* ******************** Mouse-Click Operator *********************** */ -/* Depending on the channel that was clicked on, the mouse click will activate whichever - * part of the channel is relevant. - * - * NOTE: eventually, this should probably be phased out when many of these things are replaced with buttons - */ +/* Handle selection changes due to clicking on channels. Settings will get caught by UI code... */ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, short selectmode) { @@ -1549,24 +1315,16 @@ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, sh { Scene *sce= (Scene *)ale->data; - if (x < 16) { - /* toggle expand */ - sce->flag ^= SCE_DS_COLLAPSED; - - notifierFlags |= ND_ANIMCHAN_EDIT; + /* set selection status */ + if (selectmode == SELECT_INVERT) { + /* swap select */ + sce->flag ^= SCE_DS_SELECTED; } else { - /* set selection status */ - if (selectmode == SELECT_INVERT) { - /* swap select */ - sce->flag ^= SCE_DS_SELECTED; - } - else { - sce->flag |= SCE_DS_SELECTED; - } - - notifierFlags |= ND_ANIMCHAN_SELECT; + sce->flag |= SCE_DS_SELECTED; } + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_OBJECT: @@ -1576,226 +1334,87 @@ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, sh Base *base= (Base *)ale->data; Object *ob= base->object; - if (x < 16) { - /* toggle expand */ - ob->nlaflag ^= OB_ADS_COLLAPSED; // XXX - - notifierFlags |= ND_ANIMCHAN_EDIT; + /* set selection status */ + if (selectmode == SELECT_INVERT) { + /* swap select */ + base->flag ^= SELECT; + ob->flag= base->flag; } else { - /* set selection status */ - if (selectmode == SELECT_INVERT) { - /* swap select */ - base->flag ^= SELECT; - ob->flag= base->flag; - } - else { - Base *b; - - /* deleselect all */ - for (b= sce->base.first; b; b= b->next) { - b->flag &= ~SELECT; - b->object->flag= b->flag; - } - - /* select object now */ - base->flag |= SELECT; - ob->flag |= SELECT; + Base *b; + + /* deleselect all */ + for (b= sce->base.first; b; b= b->next) { + b->flag &= ~SELECT; + b->object->flag= b->flag; } - /* xxx should be ED_base_object_activate(), but we need context pointer for that... */ - //set_active_base(base); - - notifierFlags |= ND_ANIMCHAN_SELECT; + /* select object now */ + base->flag |= SELECT; + ob->flag |= SELECT; } - } - break; - case ANIMTYPE_FILLACTD: - { - bAction *act= (bAction *)ale->data; - act->flag ^= ACT_COLLAPSED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_FILLDRIVERS: - { - AnimData *adt= (AnimData* )ale->data; - adt->flag ^= ADT_DRIVERS_COLLAPSED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_FILLMATD: - { - Object *ob= (Object *)ale->data; - ob->nlaflag ^= OB_ADS_SHOWMATS; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_FILLPARTD: - { - Object *ob= (Object *)ale->data; - ob->nlaflag ^= OB_ADS_SHOWPARTS; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - - case ANIMTYPE_DSMAT: - { - Material *ma= (Material *)ale->data; - ma->flag ^= MA_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSLAM: - { - Lamp *la= (Lamp *)ale->data; - la->flag ^= LA_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSCAM: - { - Camera *ca= (Camera *)ale->data; - ca->flag ^= CAM_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSCUR: - { - Curve *cu= (Curve *)ale->data; - cu->flag ^= CU_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSSKEY: - { - Key *key= (Key *)ale->data; - key->flag ^= KEYBLOCK_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSWOR: - { - World *wo= (World *)ale->data; - wo->flag ^= WO_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSPART: - { - ParticleSettings *part= (ParticleSettings *)ale->data; - part->flag ^= PART_DS_EXPAND; - notifierFlags |= ND_ANIMCHAN_EDIT; + + /* xxx should be ED_base_object_activate(), but we need context pointer for that... */ + //set_active_base(base); + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_GROUP: { bActionGroup *agrp= (bActionGroup *)ale->data; - short offset= (ELEM3(ac->datatype, ANIMCONT_DOPESHEET, ANIMCONT_FCURVES, ANIMCONT_DRIVERS))? 18 : 0; - if ((x < (offset+17)) && (agrp->channels.first)) { - /* toggle expand */ - agrp->flag ^= AGRP_EXPANDED; - notifierFlags |= ND_ANIMCHAN_EDIT; + /* select/deselect group */ + if (selectmode == SELECT_INVERT) { + /* inverse selection status of this group only */ + agrp->flag ^= AGRP_SELECTED; } - else if ((x < (offset+32)) && (ac->spacetype==SPACE_IPO)) { - /* toggle visibility (of grouped F-Curves in Graph editor) */ - agrp->flag ^= AGRP_NOTVISIBLE; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) { - /* toggle protection/locking */ - agrp->flag ^= AGRP_PROTECTED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if (x >= (ACHANNEL_NAMEWIDTH-2*ACHANNEL_BUTTON_WIDTH)) { - /* toggle mute */ - agrp->flag ^= AGRP_MUTED; - notifierFlags |= ND_ANIMCHAN_EDIT; + else if (selectmode == -1) { + /* select all in group (and deselect everthing else) */ + FCurve *fcu; + + /* deselect all other channels */ + ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + + /* only select channels in group and group itself */ + for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) + fcu->flag |= FCURVE_SELECTED; + agrp->flag |= AGRP_SELECTED; } else { - /* select/deselect group */ - if (selectmode == SELECT_INVERT) { - /* inverse selection status of this group only */ - agrp->flag ^= AGRP_SELECTED; - } - else if (selectmode == -1) { - /* select all in group (and deselect everthing else) */ - FCurve *fcu; - - /* deselect all other channels */ - ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - - /* only select channels in group and group itself */ - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) - fcu->flag |= FCURVE_SELECTED; - agrp->flag |= AGRP_SELECTED; - } - else { - /* select group by itself */ - ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - agrp->flag |= AGRP_SELECTED; - } - - /* if group is selected now, make group the 'active' one in the visible list */ - if (agrp->flag & AGRP_SELECTED) - ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); - - notifierFlags |= ND_ANIMCHAN_SELECT; + /* select group by itself */ + ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + agrp->flag |= AGRP_SELECTED; } + + /* if group is selected now, make group the 'active' one in the visible list */ + if (agrp->flag & AGRP_SELECTED) + ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_FCURVE: { FCurve *fcu= (FCurve *)ale->data; - short offset; - if (ac->datatype != ANIMCONT_ACTION) { - /* for now, special case for materials */ - if (ale->ownertype == ANIMTYPE_DSMAT) - offset= 21; - else - offset= 18; - } - else - offset = 0; - - if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) { - /* toggle protection (only if there's a toggle there) */ - if (fcu->bezt) { - fcu->flag ^= FCURVE_PROTECTED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - } - else if (x >= (ACHANNEL_NAMEWIDTH-2*ACHANNEL_BUTTON_WIDTH)) { - /* toggle mute */ - fcu->flag ^= FCURVE_MUTED; - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if ((x < (offset+17)) && (ac->spacetype==SPACE_IPO)) { - /* toggle visibility */ - fcu->flag ^= FCURVE_VISIBLE; - notifierFlags |= ND_ANIMCHAN_EDIT; + /* select/deselect */ + if (selectmode == SELECT_INVERT) { + /* inverse selection status of this F-Curve only */ + fcu->flag ^= FCURVE_SELECTED; } else { - /* select/deselect */ - if (selectmode == SELECT_INVERT) { - /* inverse selection status of this F-Curve only */ - fcu->flag ^= FCURVE_SELECTED; - } - else { - /* select F-Curve by itself */ - ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - fcu->flag |= FCURVE_SELECTED; - } - - /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */ - if (fcu->flag & FCURVE_SELECTED) - ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE); - - notifierFlags |= ND_ANIMCHAN_SELECT; + /* select F-Curve by itself */ + ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + fcu->flag |= FCURVE_SELECTED; } + + /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */ + if (fcu->flag & FCURVE_SELECTED) + ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE); + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_GPDATABLOCK: diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index 13667159fe0..af2355b91a5 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -138,6 +138,7 @@ void ANIM_action_to_pose_sync (Object *ob) */ void ANIM_pose_to_action_sync (Object *ob, ScrArea *sa) { +#if 0 // XXX old animation system SpaceAction *saction= (SpaceAction *)sa->spacedata.first; bArmature *arm= (bArmature *)ob->data; bAction *act= (bAction *)ob->action; @@ -174,4 +175,5 @@ void ANIM_pose_to_action_sync (Object *ob, ScrArea *sa) // XXX step 2 needs to be coded still... currently missing action/bone group API to do any more work here... // XXX step 3 needs to be coded still... it's a messy case to deal with (we'll use the temp indices for this?) +#endif // XXX old animation system } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 4e479bd75d0..37c8aeac13a 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -62,6 +62,7 @@ #include "DNA_key_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" +#include "DNA_meta_types.h" #include "DNA_object_types.h" #include "DNA_particle_types.h" #include "DNA_space_types.h" @@ -373,27 +374,29 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac) */ #define ANIMDATA_FILTER_CASES(id, adtOk, nlaOk, driversOk, keysOk) \ {\ - if (filter_mode & ANIMFILTER_ANIMDATA) {\ - if ((id)->adt) {\ - adtOk\ - }\ - }\ - else if (ads->filterflag & ADS_FILTER_ONLYNLA) {\ - if (ANIMDATA_HAS_NLA(id)) {\ - nlaOk\ - }\ - else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) {\ - nlaOk\ - }\ - }\ - else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) {\ - if (ANIMDATA_HAS_DRIVERS(id)) {\ - driversOk\ - }\ - }\ - else {\ - if (ANIMDATA_HAS_KEYS(id)) {\ - keysOk\ + if ((id)->adt) {\ + if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE)) {\ + if (filter_mode & ANIMFILTER_ANIMDATA) {\ + adtOk\ + }\ + else if (ads->filterflag & ADS_FILTER_ONLYNLA) {\ + if (ANIMDATA_HAS_NLA(id)) {\ + nlaOk\ + }\ + else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) {\ + nlaOk\ + }\ + }\ + else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) {\ + if (ANIMDATA_HAS_DRIVERS(id)) {\ + driversOk\ + }\ + }\ + else {\ + if (ANIMDATA_HAS_KEYS(id)) {\ + keysOk\ + }\ + }\ }\ }\ } @@ -1090,6 +1093,14 @@ static int animdata_filter_dopesheet_obdata (ListBase *anim_data, bDopeSheet *ad expanded= FILTER_CUR_OBJD(cu); } break; + case OB_MBALL: /* ------- MetaBall ---------- */ + { + MetaBall *mb= (MetaBall *)ob->data; + + type= ANIMTYPE_DSMBALL; + expanded= FILTER_MBALL_OBJD(mb); + } + break; } /* special exception for drivers instead of action */ @@ -1273,12 +1284,25 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B } } break; + case OB_MBALL: /* ------- MetaBall ---------- */ + { + MetaBall *mb= (MetaBall *)ob->data; + + if ((ads->filterflag & ADS_FILTER_NOMBA) == 0) { + ANIMDATA_FILTER_CASES(mb, + { /* AnimData blocks - do nothing... */ }, + obdata_ok= 1;, + obdata_ok= 1;, + obdata_ok= 1;) + } + } + break; } if (obdata_ok) items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode); /* particles */ - if(ob->particlesystem.first && !(ads->filterflag & ADS_FILTER_NOPART)) + if (ob->particlesystem.first && !(ads->filterflag & ADS_FILTER_NOPART)) items += animdata_filter_dopesheet_particles(anim_data, ads, base, filter_mode); /* return the number of items added to the list */ @@ -1443,6 +1467,14 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int worOk= !(ads->filterflag & ADS_FILTER_NOWOR);) } + /* if only F-Curves with visible flags set can be shown, check that + * datablocks haven't been set to invisible + */ + if (filter_mode & ANIMFILTER_CURVEVISIBLE) { + if ((sce->adt) && (sce->adt->flag & ADT_CURVES_NOT_VISIBLE)) + sceOk= worOk= 0; + } + /* check if not all bad (i.e. so there is something to show) */ if ( !(!sceOk && !worOk) ) { /* add scene data to the list of filtered channels */ @@ -1459,7 +1491,7 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int Key *key= ob_get_key(ob); short actOk=1, keyOk=1, dataOk=1, matOk=1, partOk=1; - /* firstly, check if object can be included, by the following fanimors: + /* firstly, check if object can be included, by the following factors: * - if only visible, must check for layer and also viewport visibility * - if only selected, must check if object is selected * - there must be animation data to edit @@ -1473,6 +1505,14 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int if (ob->restrictflag & OB_RESTRICT_VIEW) continue; } + /* if only F-Curves with visible flags set can be shown, check that + * datablock hasn't been set to invisible + */ + if (filter_mode & ANIMFILTER_CURVEVISIBLE) { + if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE)) + continue; + } + /* additionally, dopesheet filtering also affects what objects to consider */ if (ads->filterflag) { /* check selection and object type filters */ @@ -1595,6 +1635,23 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int dataOk= !(ads->filterflag & ADS_FILTER_NOCUR);) } break; + case OB_MBALL: /* ------- MetaBall ---------- */ + { + MetaBall *mb= (MetaBall *)ob->data; + dataOk= 0; + ANIMDATA_FILTER_CASES(mb, + if ((ads->filterflag & ADS_FILTER_NOMBA)==0) { + /* for the special AnimData blocks only case, we only need to add + * the block if it is valid... then other cases just get skipped (hence ok=0) + */ + ANIMDATA_ADD_ANIMDATA(mb); + dataOk=0; + }, + dataOk= !(ads->filterflag & ADS_FILTER_NOMBA);, + dataOk= !(ads->filterflag & ADS_FILTER_NOMBA);, + dataOk= !(ads->filterflag & ADS_FILTER_NOMBA);) + } + break; default: /* --- other --- */ dataOk= 0; break; @@ -1671,6 +1728,12 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int dataOk= ANIMDATA_HAS_KEYS(cu); } break; + case OB_MBALL: /* -------- Metas ---------- */ + { + MetaBall *mb= (MetaBall *)ob->data; + dataOk= ANIMDATA_HAS_KEYS(mb); + } + break; default: /* --- other --- */ dataOk= 0; break; diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index aecf437a30b..394cc53dda2 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -149,25 +149,13 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* Array Index - only if applicable */ if (RNA_property_array_length(prop)) { - static char *vectoritem[4]= {"X ", "Y ", "Z ", "W "}; - static char *quatitem[4]= {"W ", "X ", "Y ", "Z "}; - static char *coloritem[4]= {"R ", "G ", "B ", "A "}; + char c= RNA_property_array_item_char(prop, fcu->array_index); - int tot= RNA_property_array_length(prop); - int propsubtype= RNA_property_subtype(prop); - - /* get string to use for array index */ - if ((tot == 4) && (propsubtype == PROP_ROTATION)) - arrayname= quatitem[fcu->array_index]; - else if ( (tot <= 4) && ((propsubtype == PROP_VECTOR) || (propsubtype == PROP_ROTATION)) ) - arrayname= vectoritem[fcu->array_index]; - else if ((tot <= 4) && (propsubtype == PROP_COLOR)) - arrayname= coloritem[fcu->array_index]; - else { - /* we need to write the index to a temp buffer (in py syntax), as it is a number... */ - sprintf(arrayindbuf, "[%d]", fcu->array_index); - arrayname= &arrayindbuf[0]; - } + /* we need to write the index to a temp buffer (in py syntax) */ + if(c) sprintf(arrayindbuf, "%c ", c); + else sprintf(arrayindbuf, "[%d]", fcu->array_index); + + arrayname= &arrayindbuf[0]; } else { /* no array index */ diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 9c039693b72..ffa44e60d00 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -56,6 +56,8 @@ #include "ED_markers.h" #include "ED_screen.h" +#include "BKE_sound.h" + /* ********************** frame change operator ***************************/ /* Set any flags that are necessary to indicate modal time-changing operation */ @@ -91,6 +93,8 @@ static void change_frame_apply(bContext *C, wmOperator *op) if (cfra < MINAFRAME) cfra= MINAFRAME; CFRA= cfra; + sound_scrub(C); + WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); } @@ -121,6 +125,7 @@ static int change_frame_exec(bContext *C, wmOperator *op) change_frame_apply(C, op); change_frame_exit(C, op); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index ffc93340f8c..5bd37ba7831 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -899,7 +899,7 @@ short keyingset_context_ok_poll (bContext *C, KeyingSet *ks) Object *obact= CTX_data_active_object(C); /* if in posemode, check if 'pose-channels' requested for in KeyingSet */ - if ((obact && obact->pose) && (obact->flag & OB_POSEMODE)) { + if ((obact && obact->pose) && (obact->mode & OB_MODE_POSE)) { /* check for posechannels */ } @@ -930,7 +930,7 @@ static short modifykey_get_context_v3d_data (bContext *C, ListBase *dsources, Ke /* check if the active object is in PoseMode (i.e. only deal with bones) */ // TODO: check with the templates to see what we really need to store - if ((obact && obact->pose) && (obact->flag & OB_POSEMODE)) { + if ((obact && obact->pose) && (obact->mode & OB_MODE_POSE)) { /* Pose Mode: Selected bones */ #if 0 //set_pose_keys(ob); /* sets pchan->flag to POSE_KEY if bone selected, and clears if not */ diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index c1b24375b3d..632f037679f 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -713,7 +713,7 @@ int join_armature_exec(bContext *C, wmOperator *op) /* get pose of active object and move it out of posemode */ pose= ob->pose; - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { if ((base->object->type==OB_ARMATURE) && (base->object!=ob)) { @@ -724,8 +724,8 @@ int join_armature_exec(bContext *C, wmOperator *op) /* Get Pose of current armature */ opose= base->object->pose; - base->object->flag &= ~OB_POSEMODE; - BASACT->flag &= ~OB_POSEMODE; + base->object->mode &= ~OB_MODE_POSE; + //BASACT->flag &= ~OB_MODE_POSE; /* Find the difference matrix */ Mat4Invert(oimat, ob->obmat); @@ -1034,8 +1034,8 @@ static int separate_armature_exec (bContext *C, wmOperator *op) /* 1) store starting settings and exit editmode */ oldob= obedit; oldbase= BASACT; - oldob->flag &= ~OB_POSEMODE; - oldbase->flag &= ~OB_POSEMODE; + oldob->mode &= ~OB_MODE_POSE; + //oldbase->flag &= ~OB_POSEMODE; ED_armature_from_edit(scene, obedit); ED_armature_edit_free(obedit); @@ -4332,7 +4332,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor } /* in weightpaint we select the associated vertex group too */ - if (G.f & G_WEIGHTPAINT) { + if (ob->mode & OB_MODE_WEIGHT_PAINT) { if (nearBone->flag & BONE_ACTIVE) { vertexgroup_select_by_name(OBACT, nearBone->name); DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA); @@ -4424,7 +4424,7 @@ static int bone_skinnable(Object *ob, Bone *bone, void *datap) int a, segments; struct { Object *armob; void *list; int heat; } *data = datap; - if(!(G.f & G_WEIGHTPAINT) || !(bone->flag & BONE_HIDDEN_P)) { + if(!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) segments = bone->segments; @@ -4489,7 +4489,7 @@ static int dgroup_skinnable(Object *ob, Bone *bone, void *datap) int a, segments; struct { Object *armob; void *list; int heat; } *data= datap; - if (!(G.f & G_WEIGHTPAINT) || !(bone->flag & BONE_HIDDEN_P)) { + if (!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) segments = bone->segments; @@ -4588,7 +4588,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m float (*root)[3], (*tip)[3], (*verts)[3]; int *selected; int numbones, vertsfilled = 0, i, j, segments = 0; - int wpmode = (G.f & G_WEIGHTPAINT); + int wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT); struct { Object *armob; void *list; int heat; } looper_data; looper_data.armob = par; diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index f3f7bccde04..79d3d7b1366 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -2320,7 +2320,7 @@ void sk_drawSketch(Scene *scene, View3D *v3d, SK_Sketch *sketch, int with_names) for (p = sketch->depth_peels.first; p; p = p->next) { - int index = (int)(p->ob); + int index = GET_INT_FROM_POINTER(p->ob); index = (index >> 5) & 7; glColor3fv(colors[index]); @@ -2466,8 +2466,10 @@ static int sketch_delete(bContext *C, wmOperator *op, wmEvent *event) void BIF_sk_selectStroke(bContext *C, short mval[2], short extend) { + ToolSettings *ts = CTX_data_tool_settings(C); SK_Sketch *sketch = contextSketch(C, 0); - if (sketch) + + if (sketch != NULL && ts->bone_sketching & BONE_SKETCHING) { sk_selectStroke(C, sketch, mval, extend); } diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index ef2e5188487..021bec05a3b 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -342,7 +342,7 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *evt) uiItemIntO(layout, "Add New (Current Frame)", 0, "POSELIB_OT_pose_add", "frame", CFRA); /* replace existing - submenu */ - uiItemMenuF(layout, "Replace Existing...", 0, poselib_add_menu_invoke__replacemenu); + uiItemMenuF(layout, "Replace Existing...", 0, poselib_add_menu_invoke__replacemenu, NULL); } uiPupMenuEnd(C, pup); diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 174bb39d7b9..5b378878f91 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -126,7 +126,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base) switch (ob->type){ case OB_ARMATURE: - ob->flag |= OB_POSEMODE; + ob->mode |= OB_MODE_POSE; base->flag= ob->flag; WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_POSE, NULL); @@ -135,7 +135,8 @@ void ED_armature_enter_posemode(bContext *C, Base *base) default: return; } - ED_view3d_exit_paint_modes(C); + + ED_object_toggle_modes(C, ob->mode); } void ED_armature_exit_posemode(bContext *C, Base *base) @@ -143,7 +144,7 @@ void ED_armature_exit_posemode(bContext *C, Base *base) if(base) { Object *ob= base->object; - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; base->flag= ob->flag; WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); @@ -527,7 +528,7 @@ void pose_select_constraint_target(Scene *scene) /* paranoia checks */ if (!ob && !ob->pose) return; - if (ob==obedit || (ob->flag & OB_POSEMODE)==0) return; + if (ob==obedit || (ob->mode & OB_MODE_POSE)==0) return; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if (arm->layer & pchan->bone->layer) { @@ -715,7 +716,7 @@ void pose_copy_menu(Scene *scene) /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return; - if ((ob==obedit) || (ob->flag & OB_POSEMODE)==0) return; + if ((ob==obedit) || (ob->mode & OB_MODE_POSE)==0) return; /* find active */ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { @@ -1105,7 +1106,7 @@ void pose_adds_vgroups(Scene *scene, Object *meshobj, int heatweights) // XXX extern VPaint Gwp; /* from vpaint */ Object *poseobj= modifiers_isDeformedByArmature(meshobj); - if(poseobj==NULL || (poseobj->flag & OB_POSEMODE)==0) { + if(poseobj==NULL || (poseobj->mode & OB_MODE_POSE)==0) { error("The active object must have a deforming armature in pose mode"); return; } @@ -1646,10 +1647,10 @@ void pose_activate_flipped_bone(Scene *scene) if(ob==NULL) return; - if(G.f & G_WEIGHTPAINT) { + if(ob->mode && OB_MODE_WEIGHT_PAINT) { ob= modifiers_isDeformedByArmature(ob); } - if(ob && (ob->flag & OB_POSEMODE)) { + if(ob && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan, *pchanf; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { @@ -1670,7 +1671,7 @@ void pose_activate_flipped_bone(Scene *scene) pchanf->bone->flag |= (BONE_SELECTED|BONE_ACTIVE); /* in weightpaint we select the associated vertex group too */ - if(G.f & G_WEIGHTPAINT) { + if(ob->mode & OB_MODE_WEIGHT_PAINT) { vertexgroup_select_by_name(OBACT, name); DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA); } @@ -2150,7 +2151,7 @@ void pose_special_editmenu(Scene *scene) /* paranoia checks */ if(!ob && !ob->pose) return; - if(ob==obedit || (ob->flag & OB_POSEMODE)==0) return; + if(ob==obedit || (ob->mode & OB_MODE_POSE)==0) return; nr= pupmenu("Specials%t|Select Constraint Target%x1|Flip Left-Right Names%x2|Calculate Paths%x3|Clear Paths%x4|Clear User Transform %x5|Relax Pose %x6|%l|AutoName Left-Right%x7|AutoName Front-Back%x8|AutoName Top-Bottom%x9"); if(nr==1) { diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 8f7c0ceeab6..179f362b13f 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -46,6 +46,8 @@ struct bActionGroup; struct FCurve; struct FModifier; +struct uiBlock; + /* ************************************************ */ /* ANIMATION CHANNEL FILTERING */ /* anim_filter.c */ @@ -107,7 +109,10 @@ typedef struct bAnimListElem { } bAnimListElem; -/* Some types for easier type-testing */ +/* Some types for easier type-testing + * NOTE: need to keep the order of these synchronised with the channels define code + * which is used for drawing and handling channel lists for + */ // XXX was ACTTYPE_* typedef enum eAnim_ChannelType { ANIMTYPE_NONE= 0, @@ -131,6 +136,7 @@ typedef enum eAnim_ChannelType { ANIMTYPE_DSSKEY, ANIMTYPE_DSWOR, ANIMTYPE_DSPART, + ANIMTYPE_DSMBALL, ANIMTYPE_SHAPEKEY, // XXX probably can become depreceated??? @@ -139,6 +145,9 @@ typedef enum eAnim_ChannelType { ANIMTYPE_NLATRACK, ANIMTYPE_NLAACTION, + + /* always as last item, the total number of channel types... */ + ANIMTYPE_NUM_TYPES, } eAnim_ChannelType; /* types of keyframe data in bAnimListElem */ @@ -196,6 +205,7 @@ typedef enum eAnimFilter_Flags { #define FILTER_CAM_OBJD(ca) ((ca->flag & CAM_DS_EXPAND)) #define FILTER_CUR_OBJD(cu) ((cu->flag & CU_DS_EXPAND)) #define FILTER_PART_OBJD(part) ((part->flag & PART_DS_EXPAND)) +#define FILTER_MBALL_OBJD(mb) ((mb->flag2 & MB_DS_EXPAND)) /* 'Sub-object/Action' channels (flags stored in Action) */ #define SEL_ACTC(actc) ((actc->flag & ACT_SELECTED)) #define EXPANDED_ACTC(actc) ((actc->flag & ACT_COLLAPSED)==0) @@ -273,9 +283,82 @@ short ANIM_animdata_context_getdata(bAnimContext *ac); /* ************************************************ */ /* ANIMATION CHANNELS LIST */ -/* anim_channels.c */ +/* anim_channels_*.c */ + +/* ------------------------ Drawing TypeInfo -------------------------- */ + +/* flag-setting behaviour */ +typedef enum eAnimChannels_SetFlag { + ACHANNEL_SETFLAG_CLEAR = 0, + ACHANNEL_SETFLAG_ADD, + ACHANNEL_SETFLAG_TOGGLE +} eAnimChannels_SetFlag; + +/* types of settings for AnimChanels */ +typedef enum eAnimChannel_Settings { + ACHANNEL_SETTING_SELECT = 0, + ACHANNEL_SETTING_PROTECT, // warning: for drawing UI's, need to check if this is off (maybe inverse this later) + ACHANNEL_SETTING_MUTE, + ACHANNEL_SETTING_EXPAND, + ACHANNEL_SETTING_VISIBLE, /* only for Graph Editor */ + ACHANNEL_SETTING_SOLO, /* only for NLA Tracks */ +} eAnimChannel_Settings; + + +/* Drawing, mouse handling, and flag setting behaviour... */ +typedef struct bAnimChannelType { + /* drawing */ + /* draw backdrop strip for channel */ + void (*draw_backdrop)(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc); + /* get depth of indention (relative to the depth channel is nested at) */ + short (*get_indent_level)(bAnimContext *ac, bAnimListElem *ale); + /* get offset in pixels for the start of the channel (in addition to the indent depth) */ + short (*get_offset)(bAnimContext *ac, bAnimListElem *ale); + + + /* get name (for channel lists) */ + void (*name)(bAnimListElem *ale, char *name); + /* get icon (for channel lists) */ + int (*icon)(bAnimListElem *ale); + + /* settings */ + /* check if the given setting is valid in the current context */ + short (*has_setting)(bAnimContext *ac, bAnimListElem *ale, int setting); + /* get the flag used for this setting */ + int (*setting_flag)(int setting, short *neg); + /* get the pointer to int/short where data is stored, + * with type being sizeof(ptr_data) which should be fine for runtime use... + * - assume that setting has been checked to be valid for current context + */ + void *(*setting_ptr)(bAnimListElem *ale, int setting, short *type); +} bAnimChannelType; + +/* ------------------------ Drawing API -------------------------- */ + +/* Get typeinfo for the given channel */ +bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale); + +/* Draw the given channel */ +void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc); +/* Draw the widgets for the given channel */ +void ANIM_channel_draw_widgets(bAnimContext *ac, bAnimListElem *ale, struct uiBlock *block, float yminc, float ymaxc); + + +/* ------------------------ Editing API -------------------------- */ + +/* Check if some setting for a channel is enabled + * Returns: 1 = On, 0 = Off, -1 = Invalid + * + * - setting: eAnimChannel_Settings + */ +short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting); + +/* Change value of some setting for a channel + * - setting: eAnimChannel_Settings + * - mode: eAnimChannels_SetFlag + */ +void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, short mode); -/* ------------------------ API -------------------------- */ /* Deselect all animation channels */ void ANIM_deselect_anim_channels(void *data, short datatype, short test, short sel); @@ -283,15 +366,6 @@ void ANIM_deselect_anim_channels(void *data, short datatype, short test, short s /* Set the 'active' channel of type channel_type, in the given action */ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int filter, void *channel_data, short channel_type); -/* --------------- Settings and/or Defines -------------- */ - -/* flag-setting behaviour */ -enum { - ACHANNEL_SETFLAG_CLEAR = 0, - ACHANNEL_SETFLAG_ADD, - ACHANNEL_SETFLAG_TOGGLE -} eAnimChannels_SetFlag; - /* ************************************************ */ /* DRAWING API */ /* anim_draw.c */ @@ -332,14 +406,16 @@ void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, struct ID *id, List /* ------------ Animation F-Curves <-> Icons/Names Mapping ------------ */ /* anim_ipo_utils.c */ +/* Get icon for type of setting F-Curve is for */ +// XXX include this in the getname() method via RNA? int geticon_anim_blocktype(short blocktype); +/* Get name for channel-list displays for F-Curve */ void getname_anim_fcurve(char *name, struct ID *id, struct FCurve *fcu); - +/* Automatically determine a color for the nth F-Curve */ void ipo_rainbow(int cur, int tot, float *out); - /* ------------- NLA-Mapping ----------------------- */ /* anim_draw.c */ diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 0cd5551f17f..bf4632dc3da 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -28,8 +28,17 @@ #ifndef ED_NODE_H #define ED_NODE_H +struct Material; +struct Scene; +struct Tex; + /* drawnode.c */ void ED_init_node_butfuncs(void); +/* node_edit.c */ +void ED_node_shader_default(struct Material *ma); +void ED_node_composit_default(struct Scene *sce); +void ED_node_texture_default(struct Tex *tex);; + #endif /* ED_NODE_H */ diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index c8a72a2aa97..d31f85d08ea 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -59,6 +59,8 @@ struct Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int void ED_object_parent(struct Object *ob, struct Object *parent, int type, const char *substr); +void ED_object_toggle_modes(struct bContext *C, int mode); + /* bitflags for enter/exit editmode */ #define EM_FREEDATA 1 #define EM_FREEUNDO 2 @@ -69,6 +71,8 @@ void ED_object_enter_editmode(struct bContext *C, int flag); void ED_object_base_init_from_view(struct bContext *C, struct Base *base); +void ED_object_single_users(struct Scene *scene, int full); + /* cleanup */ int object_is_libdata(struct Object *ob); int object_data_is_libdata(struct Object *ob); @@ -89,6 +93,9 @@ void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con) void mouse_lattice(struct bContext *C, short mval[2], int extend); void undo_push_lattice(struct bContext *C, char *name); +/* editmball.c */ +void undo_push_mball(struct bContext *C, char *name); + /* editkey.c */ void insert_shapekey(struct Scene *scene, struct Object *ob); void delete_key(struct Scene *scene, struct Object *ob); diff --git a/source/blender/editors/include/ED_previewrender.h b/source/blender/editors/include/ED_previewrender.h index 41cbecb5353..7e0d71db7e1 100644 --- a/source/blender/editors/include/ED_previewrender.h +++ b/source/blender/editors/include/ED_previewrender.h @@ -34,6 +34,7 @@ struct Image; struct Render; struct bContext; struct ID; +struct MTex; #define PREVIEW_RENDERSIZE 140 @@ -70,9 +71,9 @@ pr_method: void ED_preview_init_dbase(void); void ED_preview_free_dbase(void); -void ED_preview_shader_job(const struct bContext *C, void *owner, struct ID *id, struct ID *parent, int sizex, int sizey); +void ED_preview_shader_job(const struct bContext *C, void *owner, struct ID *id, struct ID *parent, struct MTex *slot, int sizex, int sizey); void ED_preview_iconrender(struct Scene *scene, struct ID *id, unsigned int *rect, int sizex, int sizey); -void ED_preview_draw(const struct bContext *C, void *idp, void *parentp, rcti *rect); +void ED_preview_draw(const struct bContext *C, void *idp, void *parentp, void *slot, rcti *rect); #endif diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index fc29d64eb37..6cb7593e07d 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -89,10 +89,13 @@ void ED_screen_do_listen(struct wmWindow *win, struct wmNotifier *note); bScreen *ED_screen_duplicate(struct wmWindow *win, struct bScreen *sc); bScreen *ED_screen_add(struct wmWindow *win, struct Scene *scene, char *name); void ED_screen_set(struct bContext *C, struct bScreen *sc); +void ED_screen_delete(struct bContext *C, struct bScreen *sc); void ED_screen_set_scene(struct bContext *C, struct Scene *scene); +void ED_screen_delete_scene(struct bContext *C, struct Scene *scene); void ED_screen_set_subwinactive(struct wmWindow *win, struct wmEvent *event); void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen); -void ED_screen_animation_timer(struct bContext *C, int redraws, int enable); +void ED_screen_animation_timer(struct bContext *C, int redraws, int sync, int enable); +void ED_screen_animation_timer_update(struct bContext *C, int redraws); int ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type); void ED_screen_full_prevspace(struct bContext *C); diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h index 76a2a55c29e..72afe7704b4 100644 --- a/source/blender/editors/include/ED_screen_types.h +++ b/source/blender/editors/include/ED_screen_types.h @@ -31,9 +31,9 @@ /* for animplayer */ typedef struct ScreenAnimData { - ARegion *ar; /* do not read from this, only for comparing if region exists */ + ARegion *ar; /* do not read from this, only for comparing if region exists */ int redraws; - int flag; /* flags for playback */ + int flag; /* flags for playback */ } ScreenAnimData; /* for animplayer */ @@ -42,6 +42,10 @@ enum { ANIMPLAY_FLAG_REVERSE = (1<<0), /* temporary - playback just jumped to the start/end */ ANIMPLAY_FLAG_JUMPED = (1<<1), + /* drop frames as needed to maintain framerate */ + ANIMPLAY_FLAG_SYNC = (1<<2), + /* don't drop frames (and ignore AUDIO_SYNC flag) */ + ANIMPLAY_FLAG_NO_SYNC = (1<<3), }; diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h index efaf0f56f92..04b6be3bcaa 100644 --- a/source/blender/editors/include/ED_space_api.h +++ b/source/blender/editors/include/ED_space_api.h @@ -52,6 +52,7 @@ void ED_spacetype_text(void); void ED_spacetype_sequencer(void); void ED_spacetype_logic(void); void ED_spacetype_console(void); +void ED_spacetype_userpref(void); /* calls for instancing and freeing spacetype static data called in WM_init_exit */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index b576299c1d0..07aa44cadd8 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -130,8 +130,6 @@ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, int lasso_inside(short mcords[][2], short moves, short sx, short sy); int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, int y1); -/* modes */ -void ED_view3d_exit_paint_modes(struct bContext *C); /* get 3d region from context, also if mouse is in header or toolbar */ struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 70fbad3216d..42280ad17c9 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -60,6 +60,7 @@ struct Image; struct ImageUser; struct uiWidgetColors; struct Tex; +struct MTex; typedef struct uiBut uiBut; typedef struct uiBlock uiBlock; @@ -490,7 +491,7 @@ void uiButSetNFunc (uiBut *but, uiButHandleNFunc func, void *argN, void *arg2) void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg); -void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const struct bContext *C, void *, void *, struct rcti *rect), void *arg); +void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const struct bContext *C, void *, void *, void *, struct rcti *rect), void *arg1, void *arg2); /* Autocomplete * @@ -545,6 +546,7 @@ void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v); struct rctf; void curvemap_buttons(uiBlock *block, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect); +void curvemap_layout(uiLayout *layout, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect); void colorband_buttons(uiBlock *block, struct ColorBand *coba, struct rctf *rect, int small); @@ -607,6 +609,7 @@ int uiLayoutGetEnabled(uiLayout *layout); int uiLayoutGetRedAlert(uiLayout *layout); int uiLayoutGetAlignment(uiLayout *layout); int uiLayoutGetKeepAspect(uiLayout *layout); +int uiLayoutGetWidth(uiLayout *layout); float uiLayoutGetScaleX(uiLayout *layout); float uiLayoutGetScaleY(uiLayout *layout); ListBase *uiLayoutBoxGetList(uiLayout *layout); @@ -623,20 +626,24 @@ uiLayout *uiLayoutSplit(uiLayout *layout, float percentage); uiBlock *uiLayoutFreeBlock(uiLayout *layout); /* templates */ -void uiTemplateHeader(uiLayout *layout, struct bContext *C); +void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus); void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *newop, char *unlinkop); uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr); uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); -void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent); +void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent, struct MTex *slot); void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand); -void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type); +void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type, int compact); void uiTemplateTriColorSet(uiLayout *layout, struct PointerRNA *ptr, char *propname); void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname); void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser); void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C); void uiTemplateOperatorSearch(uiLayout *layout); void uiTemplateHeader3D(uiLayout *layout, struct bContext *C); +void uiTemplate_view3d_select_metaballmenu(uiLayout *layout, struct bContext *C); +void uiTemplate_view3d_select_armaturemenu(uiLayout *layout, struct bContext *C); +void uiTemplate_view3d_select_posemenu(uiLayout *layout, struct bContext *C); +void uiTemplate_view3d_select_faceselmenu(uiLayout *layout, struct bContext *C); void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex); typedef struct uiListItem { @@ -671,7 +678,7 @@ void uiItemM(uiLayout *layout, struct bContext *C, char *name, int icon, char *m void uiItemV(uiLayout *layout, char *name, int icon, int argval); /* value */ void uiItemS(uiLayout *layout); /* separator */ -void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func); +void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg); void uiItemMenuEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname); void uiItemMenuEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname); diff --git a/source/blender/editors/interface/Makefile b/source/blender/editors/interface/Makefile index a3d0692f1e1..5968660eb91 100644 --- a/source/blender/editors/interface/Makefile +++ b/source/blender/editors/interface/Makefile @@ -48,6 +48,7 @@ CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../makesrna CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../blenfont +CPPFLAGS += -I../../python # own include diff --git a/source/blender/editors/interface/SConscript b/source/blender/editors/interface/SConscript index bac3742c12f..e44de5410f1 100644 --- a/source/blender/editors/interface/SConscript +++ b/source/blender/editors/interface/SConscript @@ -9,6 +9,7 @@ for source in env.Glob('*_api.c'): incs = '../include ../../blenlib ../../blenfont ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../makesrna ../../windowmanager #/intern/guardedalloc' incs += ' #/extern/glew/include' +incs += ' ../../python/' # python button eval defs = [] diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 9e9b6165a73..92a3a4cf841 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -48,6 +48,7 @@ #include "BKE_screen.h" #include "BKE_texture.h" #include "BKE_utildefines.h" +#include "BKE_unit.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -66,6 +67,8 @@ #include "RNA_access.h" #include "RNA_types.h" +#include "BPY_extern.h" + #include "interface_intern.h" #define MENU_WIDTH 120 @@ -1139,6 +1142,21 @@ int ui_is_but_float(uiBut *but) return 0; } +int ui_is_but_unit(uiBut *but) +{ + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + if(scene->unit.system == USER_UNIT_NONE) + return 0; + + if(but->rnaprop==NULL) + return 0; + + if(RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop))==0) + return 0; + + return 1; +} + double ui_get_but_val(uiBut *but) { PropertyRNA *prop; @@ -1305,6 +1323,55 @@ int ui_get_but_string_max_length(uiBut *but) return UI_MAX_DRAW_STR; } +static double ui_get_but_scale_unit(uiBut *but, double value) +{ + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + int subtype= RNA_property_subtype(but->rnaprop); + + if(subtype & PROP_UNIT_LENGTH) { + return value * scene->unit.scale_length; + } + else if(subtype & PROP_UNIT_TIME) { /* WARNING - using evil_C :| */ + return FRA2TIME(value); + } + else { + return value; + } +} + +static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, int pad) +{ + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + int do_split= scene->unit.flag & USER_UNIT_OPT_SPLIT; + int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + int precission= but->a2; + + if(scene->unit.scale_length<0.0001) scene->unit.scale_length= 1.0; // XXX do_versions + + /* Sanity checks */ + if(precission>4) precission= 4; + else if(precission==0) precission= 2; + + bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precission, scene->unit.system, unit_type, do_split, pad); +} + +static float ui_get_but_step_unit(uiBut *but, double value, float step_default) +{ + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + float step; + + step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, value), scene->unit.system, unit_type); + + if(step > 0.0) { /* -1 is an error value */ + return (step/ui_get_but_scale_unit(but, 1.0))*100; + } + else { + return step_default; + } +} + + void ui_get_but_string(uiBut *but, char *str, int maxlen) { if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { @@ -1360,7 +1427,10 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen) value= ui_get_but_val(but); if(ui_is_but_float(but)) { - if(but->a2) { /* amount of digits defined */ + if(ui_is_but_unit(but)) { + ui_get_but_string_unit(but, str, maxlen, value, 0); + } + else if(but->a2) { /* amount of digits defined */ if(but->a2==1) BLI_snprintf(str, maxlen, "%.1f", value); else if(but->a2==2) BLI_snprintf(str, maxlen, "%.2f", value); else if(but->a2==3) BLI_snprintf(str, maxlen, "%.3f", value); @@ -1433,14 +1503,30 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) /* number editing */ double value; - /* XXX 2.50 missing python api */ -#if 0 - if(BPY_button_eval(str, &value)) { - BKE_report(CTX_reports(C), RPT_WARNING, "Invalid Python expression, check console"); - value = 0.0f; /* Zero out value on error */ - - if(str[0]) - return 0; +#ifndef DISABLE_PYTHON + { + char str_unit_convert[256]; + int unit_type; + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + + if(but->rnaprop) + unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + else + unit_type= 0; + + BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert)); + + if(scene->unit.system != USER_UNIT_NONE && unit_type) { + /* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */ + bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type); + } + + if(BPY_button_eval(C, str_unit_convert, &value)) { + value = ui_get_but_val(but); /* use its original value */ + + if(str[0]) + return 0; + } } #else value= atof(str); @@ -1786,6 +1872,12 @@ void ui_check_but(uiBut *but) if(ui_is_but_float(but)) { if(value == FLT_MAX) sprintf(but->drawstr, "%sinf", but->str); else if(value == -FLT_MAX) sprintf(but->drawstr, "%s-inf", but->str); + /* support length type buttons */ + else if(ui_is_but_unit(but)) { + char new_str[sizeof(but->drawstr)]; + ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE); + BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str); + } else if(but->a2) { /* amount of digits defined */ if(but->a2==1) sprintf(but->drawstr, "%s%.1f", but->str, value); else if(but->a2==2) sprintf(but->drawstr, "%s%.2f", but->str, value); @@ -2325,6 +2417,10 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, but->lockstr = ""; } + /* If this button uses units, calculate the step from this */ + if(ui_is_but_unit(but)) + but->a1= ui_get_but_step_unit(but, ui_get_but_val(but), but->a1); + if(freestr) MEM_freeN(str); @@ -2835,10 +2931,11 @@ void uiButSetRenameFunc(uiBut *but, uiButHandleRenameFunc func, void *arg1) but->rename_arg1= arg1; } -void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const bContext *C, void *idv, void *argv, rcti *rect), void *arg) +void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const bContext *C, void *idv, void *arg1, void *arg2, rcti *rect), void *arg1, void *arg2) { block->drawextra= func; - block->drawextra_arg= arg; + block->drawextra_arg1= arg1; + block->drawextra_arg2= arg2; } void uiButSetFunc(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2) @@ -2952,7 +3049,6 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int but->flag|= UI_HAS_ICON; but->flag|= UI_ICON_LEFT; - but->flag|= UI_ICON_SUBMENU; but->block_create_func= func; ui_check_but(but); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 30cfafb24f8..e3518b446ba 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -315,6 +315,7 @@ static void ui_apply_autokey_undo(bContext *C, uiBut *but) static void ui_apply_but_funcs_after(bContext *C) { uiAfterFunc *afterf, after; + PointerRNA opptr; ListBase funcs; /* copy to avoid recursive calls */ @@ -328,13 +329,18 @@ static void ui_apply_but_funcs_after(bContext *C) if(after.context) CTX_store_set(C, after.context); - if(after.optype) - WM_operator_name_call(C, after.optype->idname, after.opcontext, after.opptr); if(after.opptr) { - WM_operator_properties_free(after.opptr); + /* free in advance to avoid leak on exit */ + opptr= *after.opptr, MEM_freeN(after.opptr); } + if(after.optype) + WM_operator_name_call(C, after.optype->idname, after.opcontext, (after.opptr)? &opptr: NULL); + + if(after.opptr) + WM_operator_properties_free(&opptr); + if(after.rnapoin.data) RNA_property_update(C, &after.rnapoin, after.rnaprop); @@ -968,7 +974,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, char *str; opptr= uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */ - str= WM_operator_pystring(but->optype, opptr, 0); + str= WM_operator_pystring(C, but->optype, opptr, 0); WM_clipboard_text_set(str, 0); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 04c0c417fdb..9ef5d65b69f 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -273,8 +273,9 @@ struct uiBlock { int (*block_event_func)(const struct bContext *C, struct uiBlock *, struct wmEvent *); /* extra draw function for custom blocks */ - void (*drawextra)(const struct bContext *C, void *idv, void *argv, rcti *rect); - void *drawextra_arg; + void (*drawextra)(const struct bContext *C, void *idv, void *arg1, void *arg2, rcti *rect); + void *drawextra_arg1; + void *drawextra_arg2; int afterval, flag; @@ -337,6 +338,7 @@ extern void ui_set_but_soft_range(uiBut *but, double value); extern void ui_check_but(uiBut *but); extern int ui_is_but_float(uiBut *but); +extern int ui_is_but_unit(uiBut *but); extern void ui_update_block_buts_hsv(uiBlock *block, float *hsv); extern void ui_bounds_block(uiBlock *block); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 6932ad350b0..fc4f7da56d2 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -215,16 +215,16 @@ static int ui_layout_vary_direction(uiLayout *layout) } /* estimated size of text + icon */ -static int ui_text_icon_width(uiLayout *layout, char *name, int icon) +static int ui_text_icon_width(uiLayout *layout, char *name, int icon, int compact) { int variable = ui_layout_vary_direction(layout) == UI_ITEM_VARY_X; if(icon && !name[0]) return UI_UNIT_X; /* icon only */ else if(icon) - return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */ + return (variable)? UI_GetStringWidth(name) + (compact? 5: 10) + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */ else - return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* text only */ + return (variable)? UI_GetStringWidth(name) + (compact? 5: 10) + UI_UNIT_X: 10*UI_UNIT_X; /* text only */ } static void ui_item_size(uiItem *item, int *r_w, int *r_h) @@ -379,31 +379,25 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon but->type= NUMSLI; } } - else if(len <= 4 && ELEM3(subtype, PROP_ROTATION, PROP_VECTOR, PROP_COLOR)) { - if(subtype == PROP_COLOR) + else { + if(ELEM(subtype, PROP_COLOR, PROP_RGB)) uiDefAutoButR(block, ptr, prop, -1, "", 0, 0, 0, w, UI_UNIT_Y); - if(subtype != PROP_COLOR || expand) { + if(!ELEM(subtype, PROP_COLOR, PROP_RGB) || expand) { /* layout for known array subtypes */ - static char vectoritem[4]= {'X', 'Y', 'Z', 'W'}; - static char quatitem[4]= {'W', 'X', 'Y', 'Z'}; - static char coloritem[4]= {'R', 'G', 'B', 'A'}; char str[3]; for(a=0; atype= NUMSLI; } } - else if(subtype == PROP_COLOR && len == 4) { + else if(ELEM(subtype, PROP_COLOR, PROP_RGB) && len == 4) { but= uiDefAutoButR(block, ptr, prop, 3, "A:", 0, 0, 0, w, UI_UNIT_Y); if(slider && but->type==NUM) but->type= NUMSLI; } } - else { - for(a=0; atype==NUM) - but->type= NUMSLI; - } - } uiBlockSetCurLayout(block, layout); } @@ -446,7 +433,7 @@ static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, name= (!uiname || uiname[0])? (char*)item[a].name: ""; icon= item[a].icon; value= item[a].value; - itemw= ui_text_icon_width(block->curlayout, name, icon); + itemw= ui_text_icon_width(block->curlayout, name, icon, 0); if(icon && strcmp(name, "") != 0) uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL); @@ -539,7 +526,7 @@ static void ui_item_disabled(uiLayout *layout, char *name) if(!name) name= ""; - w= ui_text_icon_width(layout, name, 0); + w= ui_text_icon_width(layout, name, 0, 0); but= uiDefBut(block, LABEL, 0, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); but->flag |= UI_BUT_DISABLED; @@ -568,7 +555,7 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDPropert /* create button */ uiBlockSetCurLayout(block, layout); - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 0); if(icon && strcmp(name, "") != 0) but= uiDefIconTextButO(block, BUT, ot->idname, context, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL); @@ -759,7 +746,7 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA else if(type == PROP_BOOLEAN && !name[0]) icon= ICON_DOT; - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 0); h= UI_UNIT_Y; /* increase height for arrays */ @@ -779,6 +766,8 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA w += UI_UNIT_X; else if(type == PROP_ENUM) w += UI_UNIT_X/2; + else if(type == PROP_FLOAT || type == PROP_INT) + w += UI_UNIT_X*2; } *r_w= w; @@ -1123,7 +1112,7 @@ static void ui_item_menu(uiLayout *layout, char *name, int icon, uiMenuCreateFun if(layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 1); h= UI_UNIT_Y; if(layout->root->type == UI_LAYOUT_HEADER) /* ugly .. */ @@ -1181,7 +1170,7 @@ void uiItemL(uiLayout *layout, char *name, int icon) if(layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 0); if(icon && strcmp(name, "") != 0) but= uiDefIconTextBut(block, LABEL, 0, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); @@ -1206,7 +1195,7 @@ void uiItemV(uiLayout *layout, char *name, int icon, int argval) if(layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; - w= ui_text_icon_width(layout, name, icon); + w= ui_text_icon_width(layout, name, icon, 0); if(icon && strcmp(name, "") != 0) uiDefIconTextButF(block, BUTM, 0, icon, (char*)name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, argval, ""); @@ -1226,12 +1215,12 @@ void uiItemS(uiLayout *layout) } /* level items */ -void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func) +void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg) { if(!func) return; - ui_item_menu(layout, name, icon, func, NULL, NULL); + ui_item_menu(layout, name, icon, func, arg, NULL); } typedef struct MenuItemLevel { @@ -1984,6 +1973,11 @@ int uiLayoutGetAlignment(uiLayout *layout) return layout->alignment; } +int uiLayoutGetWidth(uiLayout *layout) +{ + return layout->w; +} + float uiLayoutGetScaleX(uiLayout *layout) { return layout->scale[0]; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 846fbe75072..05001109b53 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -104,7 +104,7 @@ static int panel_aligned(ScrArea *sa, ARegion *ar) SpaceButs *sbuts= sa->spacedata.first; return sbuts->align; } - else if(sa->spacetype==SPACE_INFO && ar->regiontype == RGN_TYPE_WINDOW) + else if(sa->spacetype==SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW) return BUT_VERTICAL; else if(sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) return BUT_VERTICAL; @@ -1247,7 +1247,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) if(!pa || pa->paneltab!=NULL) continue; - if(pa->type && pa->type->flag & PNL_NO_HEADER) + if(pa->type && pa->type->flag & PNL_NO_HEADER) // XXX - accessed freed panels when scripts reload, need to fix. continue; if(block->minx <= mx && block->maxx >= mx) diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index b59db055647..bf921715524 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -396,7 +396,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) char *str; opptr= uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */ - str= WM_operator_pystring(but->optype, opptr, 0); + str= WM_operator_pystring(C, but->optype, opptr, 0); /* operator info */ BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s", str); diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 67ee29a1d3c..cb9216ec1c5 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -248,9 +248,6 @@ void uiStyleInit(void) BLF_size(11, U.dpi); BLF_size(12, U.dpi); BLF_size(14, U.dpi); - - if (!(U.transopts & USER_USETEXTUREFONT)) - BLF_mode(BLF_MODE_BITMAP); } } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index edf01f4da2c..0557512cc2a 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -56,12 +56,13 @@ void ui_template_fix_linking() /********************** Header Template *************************/ -void uiTemplateHeader(uiLayout *layout, bContext *C) +void uiTemplateHeader(uiLayout *layout, bContext *C, int menus) { uiBlock *block; block= uiLayoutFreeBlock(layout); - ED_area_header_standardbuttons(C, block, 0); + if(menus) ED_area_header_standardbuttons(C, block, 0); + else ED_area_header_switchbutton(C, block, 0); } /********************** Search Callbacks *************************/ @@ -236,7 +237,7 @@ static void template_ID(bContext *C, uiBlock *block, TemplateID *template, Struc int w= idptr.data?UI_UNIT_X:UI_UNIT_X*6; if(newop) { - but= uiDefIconTextButO(block, BUT, newop, WM_OP_EXEC_REGION_WIN, ICON_ZOOMIN, "Add New", 0, 0, w, UI_UNIT_Y, NULL); + but= uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_REGION_WIN, ICON_ZOOMIN, "Add New", 0, 0, w, UI_UNIT_Y, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); } else { @@ -248,7 +249,7 @@ static void template_ID(bContext *C, uiBlock *block, TemplateID *template, Struc /* delete button */ if(idptr.data && (flag & UI_ID_DELETE)) { if(unlinkop) { - but= uiDefIconButO(block, BUT, unlinkop, WM_OP_EXEC_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); + but= uiDefIconButO(block, BUT, unlinkop, WM_OP_INVOKE_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); } else { but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); @@ -483,7 +484,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i if(md->type==eModifierType_ParticleSystem) { ParticleSystem *psys= ((ParticleSystemModifierData *)md)->psys; - if(!(G.f & G_PARTICLEEDIT)) + if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) if(ELEM3(psys->part->ren_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) uiItemO(row, "Convert", 0, "OBJECT_OT_modifier_convert"); } @@ -628,7 +629,7 @@ static void verify_constraint_name_func (bContext *C, void *con_v, void *name_v) /* some commonly used macros in the constraints drawing code */ #define is_armature_target(target) (target && target->type==OB_ARMATURE) -#define is_armature_owner(ob) ((ob->type == OB_ARMATURE) && (ob->flag & OB_POSEMODE)) +#define is_armature_owner(ob) ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE)) #define is_geom_target(target) (target && (ELEM(target->type, OB_MESH, OB_LATTICE)) ) /* Helper function for draw constraint - draws constraint space stuff @@ -911,82 +912,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) draw_constraint_spaceselect(block, con, xco, yco-(73+theight), is_armature_owner(ob), -1); } break; -#endif /* DISABLE_PYTHON */ - - /*case CONSTRAINT_TYPE_RIGIDBODYJOINT: - { - if (data->type==CONSTRAINT_RB_GENERIC6DOF) { - // Draw Pairs of LimitToggle+LimitValue - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"min x limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMaxX", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum x limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"max x limit"); - uiBlockEndAlign(block); - - offsetY += 20; - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 2, B_CONSTRAINT_TEST, "LinMinY", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[1]), -extremeLin, extremeLin, 0.1,0.5,"min y limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 2, B_CONSTRAINT_TEST, "LinMaxY", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum y limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[1]), -extremeLin, extremeLin, 0.1,0.5,"max y limit"); - uiBlockEndAlign(block); - - offsetY += 20; - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 4, B_CONSTRAINT_TEST, "LinMinZ", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[2]), -extremeLin, extremeLin, 0.1,0.5,"min z limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 4, B_CONSTRAINT_TEST, "LinMaxZ", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum z limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[2]), -extremeLin, extremeLin, 0.1,0.5,"max z limit"); - uiBlockEndAlign(block); - offsetY += 20; - } - if ((data->type==CONSTRAINT_RB_GENERIC6DOF) || (data->type==CONSTRAINT_RB_CONETWIST)) { - // Draw Pairs of LimitToggle+LimitValue / - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"min x limit"); - uiBlockEndAlign(block); - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMaxX", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum x limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"max x limit"); - uiBlockEndAlign(block); - - offsetY += 20; - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 16, B_CONSTRAINT_TEST, "AngMinY", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[4]), -extremeAngY, extremeAngY, 0.1,0.5,"min y limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 16, B_CONSTRAINT_TEST, "AngMaxY", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum y limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[4]), -extremeAngY, extremeAngY, 0.1,0.5,"max y limit"); - uiBlockEndAlign(block); - - offsetY += 20; - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 32, B_CONSTRAINT_TEST, "AngMinZ", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[5]), -extremeAngZ, extremeAngZ, 0.1,0.5,"min z limit"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, 32, B_CONSTRAINT_TEST, "AngMaxZ", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum z limit"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[5]), -extremeAngZ, extremeAngZ, 0.1,0.5,"max z limit"); - uiBlockEndAlign(block); - } - - } - break; - */ +#endif case CONSTRAINT_TYPE_NULL: { @@ -1162,7 +1088,7 @@ static void do_preview_buttons(bContext *C, void *arg, int event) } } -void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent) +void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent, MTex *slot) { uiLayout *row, *col; uiBlock *block; @@ -1203,7 +1129,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent) /* add preview */ uiDefBut(block, BUT_EXTRA, 0, "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, pid, 0.0, 0.0, 0, 0, ""); - uiBlockSetDrawExtraFunc(block, ED_preview_draw, pparent); + uiBlockSetDrawExtraFunc(block, ED_preview_draw, pparent, slot); uiBlockSetHandleFunc(block, do_preview_buttons, NULL); /* add buttons */ @@ -1257,17 +1183,21 @@ void uiTemplateColorRamp(uiLayout *layout, ColorBand *coba, int expand) #include "DNA_color_types.h" -void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type) +void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type, int compact) { - uiBlock *block; rctf rect; if(cumap) { - rect.xmin= 0; rect.xmax= 200; - rect.ymin= 0; rect.ymax= 190; + if(compact) { + rect.xmin= 0; rect.xmax= 150; + rect.ymin= 0; rect.ymax= 140; + } + else { + rect.xmin= 0; rect.xmax= 200; + rect.ymin= 0; rect.ymax= 190; + } - block= uiLayoutFreeBlock(layout); - curvemap_buttons(block, cumap, type, 0, 0, &rect); + curvemap_layout(layout, cumap, type, 0, 0, &rect); } } @@ -1524,7 +1454,8 @@ ListBase uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr /* init numbers */ RNA_property_int_range(activeptr, activeprop, &min, &max); - len= max - min + 1; + if(prop) + len= RNA_property_collection_length(ptr, prop); items= CLAMPIS(len, rows, 5); pa->list_scroll= MIN2(pa->list_scroll, len-items); @@ -1650,7 +1581,7 @@ static void do_running_jobs(bContext *C, void *arg, int event) WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C)); break; case B_STOPANIM: - ED_screen_animation_timer(C, 0, 0); + WM_operator_name_call(C, "SCREEN_OT_animation_play", WM_OP_INVOKE_SCREEN, NULL); break; } } diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 8ff9e857407..4201850f5e4 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -152,8 +152,6 @@ void uiDefAutoButsRNA(const bContext *C, uiLayout *layout, PointerRNA *ptr, int uiLayout *split, *col; char *name; - uiItemL(layout, (char*)RNA_struct_ui_name(ptr->type), 0); - RNA_STRUCT_BEGIN(ptr, prop) { if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) continue; @@ -945,6 +943,72 @@ void curvemap_buttons(uiBlock *block, CurveMapping *cumap, char labeltype, short cumap, 0.0f, 1.0f, 0, 0, ""); } +/* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */ +void curvemap_layout(uiLayout *layout, CurveMapping *cumap, char labeltype, short event, short redraw, rctf *rect) +{ + uiLayout *row; + uiBlock *block; + uiBut *bt; + float dx, fy= rect->ymax-18.0f; + int icon; + + block= uiLayoutGetBlock(layout); + + /* curve choice options + tools/settings, 8 icons + spacer */ + dx= UI_UNIT_X; + + row= uiLayoutRow(layout, 0); + uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); + + if(labeltype=='v') { /* vector */ + row= uiLayoutRow(layout, 1); + + if(cumap->cm[0].curve) + uiDefButI(block, ROW, redraw, "X", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + if(cumap->cm[1].curve) + uiDefButI(block, ROW, redraw, "Y", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + if(cumap->cm[2].curve) + uiDefButI(block, ROW, redraw, "Z", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + } + else if(labeltype=='c') { /* color */ + row= uiLayoutRow(layout, 1); + + if(cumap->cm[3].curve) + uiDefButI(block, ROW, redraw, "C", 0, 0, dx, 16, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); + if(cumap->cm[0].curve) + uiDefButI(block, ROW, redraw, "R", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + if(cumap->cm[1].curve) + uiDefButI(block, ROW, redraw, "G", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + if(cumap->cm[2].curve) + uiDefButI(block, ROW, redraw, "B", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + } + + row= uiLayoutRow(row, 1); + + uiBlockSetEmboss(block, UI_EMBOSSN); + bt= uiDefIconBut(block, BUT, redraw, ICON_ZOOMIN, 0, 0, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom in"); + uiButSetFunc(bt, curvemap_buttons_zoom_in, cumap, NULL); + + bt= uiDefIconBut(block, BUT, redraw, ICON_ZOOMOUT, 0, 0, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom out"); + uiButSetFunc(bt, curvemap_buttons_zoom_out, cumap, NULL); + + bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, event, ICON_MODIFIER, 0, 0, dx, 18, "Tools"); + + if(cumap->flag & CUMA_DO_CLIP) icon= ICON_CLIPUV_HLT; else icon= ICON_CLIPUV_DEHLT; + bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, event, icon, 0, 0, dx, 18, "Clipping Options"); + + bt= uiDefIconBut(block, BUT, event, ICON_X, 0, 0, dx, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Delete points"); + uiButSetFunc(bt, curvemap_buttons_delete, cumap, NULL); + + uiBlockSetEmboss(block, UI_EMBOSS); + + row= uiLayoutRow(layout, 0); + uiDefBut(block, BUT_CURVE, event, "", + rect->xmin, rect->ymin, rect->xmax-rect->xmin, fy-rect->ymin, + cumap, 0.0f, 1.0f, 0, 0, ""); +} + + #define B_BANDCOL 1 static int vergcband(const void *a1, const void *a2) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index eed4425b7ad..a70fbab1aa4 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -889,7 +889,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB rect->xmin += UI_icon_get_width(but->icon+but->iconadd); if(but->editstr || (but->flag & UI_TEXT_LEFT)) - rect->xmin += 10; + rect->xmin += 5; } else if((but->flag & UI_TEXT_LEFT)) rect->xmin += 5; @@ -1949,7 +1949,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int widget_init(&wtb); /* fully rounded */ - round_box_edges(&wtb, roundboxalign, rect, rad); + round_box_edges(&wtb, 15, rect, rad); widgetbase_draw(&wtb, wcol); } @@ -2065,7 +2065,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType * if(but->block->drawextra) { /* note: drawextra can change rect +1 or -1, to match round errors of existing previews */ - but->block->drawextra(C, but->poin, but->block->drawextra_arg, rect); + but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect); /* make mask to draw over image */ UI_GetThemeColor3ubv(TH_BACK, col); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 297e22610a6..5b51d898235 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -150,6 +150,9 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) case SPACE_INFO: ts= &btheme->tinfo; break; + case SPACE_USERPREF: + ts= &btheme->tuserpref; + break; case SPACE_TIME: ts= &btheme->ttime; break; @@ -402,6 +405,7 @@ static void ui_theme_init_new(bTheme *btheme) ui_theme_init_new_do(&btheme->ttime); ui_theme_init_new_do(&btheme->tnode); ui_theme_init_new_do(&btheme->tlogic); + ui_theme_init_new_do(&btheme->tuserpref); } @@ -583,6 +587,10 @@ void ui_theme_init_userdef(void) btheme->tinfo= btheme->tv3d; SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0); + /* space user preferences */ + btheme->tuserpref= btheme->tv3d; + SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0); + /* space sound */ btheme->tsnd= btheme->tv3d; SETCOLF(btheme->tsnd.back, 0.45, 0.45, 0.45, 1.0); @@ -1233,6 +1241,7 @@ void init_userdef_do_versions(void) } SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0); + SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0); } } diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index e32dd0e8ac7..17838d6042c 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -67,6 +67,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_pointcache.h" #include "BKE_softbody.h" #include "BKE_texture.h" @@ -873,11 +874,11 @@ void make_editMesh(Scene *scene, Object *ob) if(cacheedit) { if(pid.type == PTCACHE_TYPE_CLOTH) { - cloth= ((ClothModifierData*)pid.data)->clothObject; + cloth= ((ClothModifierData*)pid.calldata)->clothObject; VECCOPY(cacheco, cloth->verts[a].x) } else if(pid.type == PTCACHE_TYPE_SOFTBODY) { - sb= (SoftBody*)pid.data; + sb= (SoftBody*)pid.calldata; VECCOPY(cacheco, sb->bpoint[a].pos) } @@ -891,7 +892,7 @@ void make_editMesh(Scene *scene, Object *ob) evlist[a]= eve; // face select sets selection in next loop - if( (FACESEL_PAINT_TEST)==0 ) + if(!paint_facesel_test(ob)) eve->f |= (mvert->flag & 1); if (mvert->flag & ME_HIDE) eve->h= 1; @@ -966,7 +967,7 @@ void make_editMesh(Scene *scene, Object *ob) if(mface->flag & ME_FACE_SEL) { efa->f |= SELECT; - if(FACESEL_PAINT_TEST) { + if(paint_facesel_test(ob)) { EM_select_face(efa, 1); /* flush down */ } } @@ -1095,7 +1096,7 @@ void load_editMesh(Scene *scene, Object *ob) while(eve) { if(cacheedit) { if(pid.type == PTCACHE_TYPE_CLOTH) { - clmd= (ClothModifierData*)pid.data; + clmd= (ClothModifierData*)pid.calldata; cloth= clmd->clothObject; /* assign position */ @@ -1110,7 +1111,7 @@ void load_editMesh(Scene *scene, Object *ob) VECADD(cloth->verts[a].v, cloth->verts[a].v, cacheco); } else if(pid.type == PTCACHE_TYPE_SOFTBODY) { - sb= (SoftBody*)pid.data; + sb= (SoftBody*)pid.calldata; /* assign position */ VECCOPY(cacheco, sb->bpoint[a].pos) @@ -1156,12 +1157,8 @@ void load_editMesh(Scene *scene, Object *ob) } /* write changes to cache */ - if(cacheedit) { - if(pid.type == PTCACHE_TYPE_CLOTH) - cloth_write_cache(ob, pid.data, pid.cache->editframe); - else if(pid.type == PTCACHE_TYPE_SOFTBODY) - softbody_write_cache(ob, pid.data, pid.cache->editframe); - } + if(cacheedit) + BKE_ptcache_write_cache(&pid, pid.cache->editframe); /* the edges */ a= 0; @@ -1626,6 +1623,7 @@ void MESH_OT_separate(wmOperatorType *ot) { /* identifiers */ ot->name= "Separate"; + ot->description= "Separate selected geometry into a new mesh."; ot->idname= "MESH_OT_separate"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 34eca8748bc..19078d2f6ff 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -227,6 +227,7 @@ void MESH_OT_dupli_extrude_cursor(wmOperatorType *ot) { /* identifiers */ ot->name= "Duplicate or Extrude at 3D Cursor"; + ot->description= "Duplicate and extrude selected vertices, edges or faces towards 3D Cursor."; ot->idname= "MESH_OT_dupli_extrude_cursor"; /* api callbacks */ @@ -358,6 +359,7 @@ void MESH_OT_fgon_make(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Make F-gon"; + ot->description= "Make fgon from selected faces."; ot->idname= "MESH_OT_fgon_make"; /* api callbacks */ @@ -390,6 +392,7 @@ void MESH_OT_fgon_clear(struct wmOperatorType *ot) { /* identifiers */ ot->name= "Clear F-gon"; + ot->description= "Clear fgon from selected face."; ot->idname= "MESH_OT_fgon_clear"; /* api callbacks */ @@ -801,6 +804,7 @@ void MESH_OT_edge_face_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Make Edge/Face"; + ot->description= "Add an edge or face to selected."; ot->idname= "MESH_OT_edge_face_add"; /* api callbacks */ @@ -1327,6 +1331,7 @@ void MESH_OT_primitive_plane_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Plane"; + ot->description= "Construct a filled planar mesh with 4 vertices."; ot->idname= "MESH_OT_primitive_plane_add"; /* api callbacks */ @@ -1359,6 +1364,7 @@ void MESH_OT_primitive_cube_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Cube"; + ot->description= "Construct a cube mesh."; ot->idname= "MESH_OT_primitive_cube_add"; /* api callbacks */ @@ -1391,6 +1397,7 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Circle"; + ot->description= "Construct a circle mesh."; ot->idname= "MESH_OT_primitive_circle_add"; /* api callbacks */ @@ -1428,6 +1435,7 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Cylinder"; + ot->description= "Construct a cylindrical mesh (ends filled)."; ot->idname= "MESH_OT_primitive_cylinder_add"; /* api callbacks */ @@ -1465,6 +1473,7 @@ void MESH_OT_primitive_tube_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Tube"; + ot->description= "Construct a cylindrical mesh (ends not filled)."; ot->idname= "MESH_OT_primitive_tube_add"; /* api callbacks */ @@ -1502,6 +1511,7 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Cone"; + ot->description= "Construct a conic mesh (ends filled)."; ot->idname= "MESH_OT_primitive_cone_add"; /* api callbacks */ @@ -1541,6 +1551,7 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Grid"; + ot->description= "Construct a grid mesh."; ot->idname= "MESH_OT_primitive_grid_add"; /* api callbacks */ @@ -1576,6 +1587,7 @@ void MESH_OT_primitive_monkey_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Monkey"; + ot->description= "Construct a Suzanne mesh."; ot->idname= "MESH_OT_primitive_monkey_add"; /* api callbacks */ @@ -1608,6 +1620,7 @@ void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add UV Sphere"; + ot->description= "Construct a UV sphere mesh."; ot->idname= "MESH_OT_primitive_uv_sphere_add"; /* api callbacks */ @@ -1645,6 +1658,7 @@ void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Ico Sphere"; + ot->description= "Construct an Icosphere mesh."; ot->idname= "MESH_OT_primitive_ico_sphere_add"; /* api callbacks */ @@ -1690,6 +1704,7 @@ void MESH_OT_duplicate(wmOperatorType *ot) { /* identifiers */ ot->name= "Duplicate"; + ot->description= "Duplicate selected vertices, edges or faces."; ot->idname= "MESH_OT_duplicate"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh_loop.c b/source/blender/editors/mesh/editmesh_loop.c index 20fd33fc731..b46f745e8f5 100644 --- a/source/blender/editors/mesh/editmesh_loop.c +++ b/source/blender/editors/mesh/editmesh_loop.c @@ -717,6 +717,7 @@ void MESH_OT_knife_cut(wmOperatorType *ot) PropertyRNA *prop; ot->name= "Knife Cut"; + ot->description= "Cut selected edges and faces into parts."; ot->idname= "MESH_OT_knife_cut"; ot->invoke= WM_gesture_lines_invoke; diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 86910706540..d27aa3f7e3a 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -65,6 +65,7 @@ editmesh_mods.c, UI level access, no geometry changes #include "BKE_global.h" #include "BKE_mesh.h" #include "BKE_material.h" +#include "BKE_paint.h" #include "BKE_texture.h" #include "BKE_utildefines.h" #include "BKE_report.h" @@ -242,7 +243,7 @@ int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, s /* method in use for face selecting too */ if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST); + if(paint_facesel_test(vc->obact)); else return 0; } else if(vc->v3d->drawtypev3d->flag & V3D_ZBUF_SELECT)==0) return 0; @@ -297,7 +298,7 @@ int EM_init_backbuf_circle(ViewContext *vc, short xs, short ys, short rads) /* method in use for face selecting too */ if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST); + if(paint_facesel_test(vc->obact)); else return 0; } else if(vc->v3d->drawtypev3d->flag & V3D_ZBUF_SELECT)==0) return 0; @@ -1271,6 +1272,7 @@ void MESH_OT_select_similar(wmOperatorType *ot) /* identifiers */ ot->name= "Select Similar"; + ot->description= "Select similar vertices, edges or faces by property types."; ot->idname= "MESH_OT_select_similar"; /* api callbacks */ @@ -1999,6 +2001,7 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) { /* identifiers */ ot->name= "Multi Select Loops"; + ot->description= "Select a loop of connected edges by connection type."; ot->idname= "MESH_OT_loop_multi_select"; /* api callbacks */ @@ -2077,6 +2080,7 @@ void MESH_OT_loop_select(wmOperatorType *ot) { /* identifiers */ ot->name= "Loop Select"; + ot->description= "Select a loop of connected edges."; ot->idname= "MESH_OT_loop_select"; /* api callbacks */ @@ -2176,6 +2180,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot) { /* identifiers */ ot->name= "Shortest Path Select"; + ot->description= "Select shortest path between two selections."; ot->idname= "MESH_OT_select_shortest_path"; /* api callbacks */ @@ -2467,6 +2472,7 @@ void MESH_OT_select_linked_pick(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Linked"; + ot->description= "(un)select all vertices linked to the active mesh."; ot->idname= "MESH_OT_select_linked_pick"; /* api callbacks */ @@ -2549,6 +2555,7 @@ void MESH_OT_select_linked(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Linked All"; + ot->description= "Select all vertices linked to the active mesh."; ot->idname= "MESH_OT_select_linked"; /* api callbacks */ @@ -2684,6 +2691,7 @@ void MESH_OT_hide(wmOperatorType *ot) { /* identifiers */ ot->name= "Hide Selection"; + ot->description= "Hide (un)selected vertices, edges or faces."; ot->idname= "MESH_OT_hide"; /* api callbacks */ @@ -2750,6 +2758,7 @@ void MESH_OT_reveal(wmOperatorType *ot) { /* identifiers */ ot->name= "Reveal Hidden"; + ot->description= "Reveal all hidden vertices, edges and faces."; ot->idname= "MESH_OT_reveal"; /* api callbacks */ @@ -2804,6 +2813,7 @@ void MESH_OT_select_by_number_vertices(wmOperatorType *ot) /* identifiers */ ot->name= "Select by Number of Vertices"; + ot->description= "Select vertices or faces by vertex count."; ot->idname= "MESH_OT_select_by_number_vertices"; /* api callbacks */ @@ -2924,6 +2934,7 @@ void MESH_OT_edges_select_sharp(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Sharp Edges"; + ot->description= "Marked selected edges as sharp."; ot->idname= "MESH_OT_edges_select_sharp"; /* api callbacks */ @@ -3091,6 +3102,7 @@ void MESH_OT_faces_select_linked_flat(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Linked Flat Faces"; + ot->description= "Select linked faces by angle."; ot->idname= "MESH_OT_faces_select_linked_flat"; /* api callbacks */ @@ -3191,6 +3203,7 @@ void MESH_OT_select_non_manifold(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Non Manifold"; + ot->description= "Select all non-manifold vertices or edges."; ot->idname= "MESH_OT_select_non_manifold"; /* api callbacks */ @@ -3254,6 +3267,7 @@ void MESH_OT_select_inverse(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Inverse"; + ot->description= "Select inverse of (un)selected vertices, edges or faces."; ot->idname= "MESH_OT_select_inverse"; /* api callbacks */ @@ -3291,6 +3305,7 @@ void MESH_OT_select_all_toggle(wmOperatorType *ot) { /* identifiers */ ot->name= "Select/Deselect All"; + ot->description= "(de)select all vertices, edges or faces."; ot->idname= "MESH_OT_select_all_toggle"; /* api callbacks */ @@ -3361,6 +3376,7 @@ void MESH_OT_select_more(wmOperatorType *ot) { /* identifiers */ ot->name= "Select More"; + ot->description= "Select more vertices, edges or faces connected to initial selection."; ot->idname= "MESH_OT_select_more"; /* api callbacks */ @@ -3450,6 +3466,7 @@ void MESH_OT_select_less(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Less"; + ot->description= "Select less vertices, edges or faces connected to initial selection."; ot->idname= "MESH_OT_select_less"; /* api callbacks */ @@ -3519,6 +3536,7 @@ void MESH_OT_select_random(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Random"; + ot->description= "Randomly select vertices."; ot->idname= "MESH_OT_select_random"; /* api callbacks */ @@ -3610,6 +3628,7 @@ void MESH_OT_selection_type(wmOperatorType *ot) { /* identifiers */ ot->name= "Selection Mode"; + ot->description= "Set the selection mode type."; ot->idname= "MESH_OT_selection_type"; /* api callbacks */ @@ -3672,6 +3691,7 @@ void MESH_OT_mark_seam(wmOperatorType *ot) { /* identifiers */ ot->name= "Mark Seam"; + ot->description= "(un)mark selected edges as a seam."; ot->idname= "MESH_OT_mark_seam"; /* api callbacks */ @@ -3724,6 +3744,7 @@ void MESH_OT_mark_sharp(wmOperatorType *ot) { /* identifiers */ ot->name= "Mark Sharp"; + ot->description= "(un)mark selected edges as sharp."; ot->idname= "MESH_OT_mark_sharp"; /* api callbacks */ @@ -3973,6 +3994,7 @@ void MESH_OT_normals_make_consistent(wmOperatorType *ot) { /* identifiers */ ot->name= "Make Normals Consistent"; + ot->description= "Flip all selected vertex and face normals in a consistent direction."; ot->idname= "MESH_OT_normals_make_consistent"; /* api callbacks */ @@ -4299,18 +4321,35 @@ static int smooth_vertex(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int smooth_vertex_exec(bContext *C, wmOperator *op) +{ + int repeat = RNA_int_get(op->ptr, "repeat"); + int i; + + if (!repeat) repeat = 1; + + for (i=0; iname= "Smooth Vertex"; + ot->description= "Flatten angles of selected vertices."; ot->idname= "MESH_OT_vertices_smooth"; /* api callbacks */ - ot->exec= smooth_vertex; + ot->exec= smooth_vertex_exec; ot->poll= ED_operator_editmesh; /* flags */ - ot->flag= OPTYPE_UNDO; + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_int(ot->srna, "repeat", 1, 1, 100, "Number of times to smooth the mesh", "", 1, INT_MAX); } void vertexnoise(Object *obedit, EditMesh *em) @@ -4436,6 +4475,7 @@ void MESH_OT_vertices_transform_to_sphere(wmOperatorType *ot) { /* identifiers */ ot->name= "Vertices to Sphere"; + ot->description= "Move selected vertices outward in a spherical shape."; ot->idname= "MESH_OT_vertices_transform_to_sphere"; /* api callbacks */ @@ -4499,6 +4539,7 @@ void MESH_OT_flip_normals(wmOperatorType *ot) { /* identifiers */ ot->name= "Flip Normals"; + ot->description= "Toggle the direction of selected face's vertex and face normals."; ot->idname= "MESH_OT_flip_normals"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index d29a4e21913..ac65820bfea 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -507,6 +507,7 @@ void MESH_OT_remove_doubles(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove Doubles"; + ot->description= "Remove duplicate vertices."; ot->idname= "MESH_OT_remove_doubles"; /* api callbacks */ @@ -747,6 +748,7 @@ void MESH_OT_extrude(wmOperatorType *ot) { /* identifiers */ ot->name= "Extrude"; + ot->description= "Extrude selected vertices, edges or faces."; ot->idname= "MESH_OT_extrude"; /* api callbacks */ @@ -756,11 +758,6 @@ void MESH_OT_extrude(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - /* to give to transform */ - Properties_Proportional(ot); - Properties_Constraints(ot); - RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", ""); } static int split_mesh(bContext *C, wmOperator *op) @@ -790,6 +787,7 @@ void MESH_OT_split(wmOperatorType *ot) { /* identifiers */ ot->name= "Split"; + ot->description= "Split selected geometry into separate disconnected mesh."; ot->idname= "MESH_OT_split"; /* api callbacks */ @@ -850,6 +848,7 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot) { /* identifiers */ ot->name= "Extrude Repeat Mesh"; + ot->description= "Extrude selected vertices, edges or faces repeatedly."; ot->idname= "MESH_OT_extrude_repeat"; /* api callbacks */ @@ -984,6 +983,7 @@ void MESH_OT_spin(wmOperatorType *ot) { /* identifiers */ ot->name= "Spin"; + ot->description= "Extrude selected vertices in a circle around the cursor in indicated viewport."; ot->idname= "MESH_OT_spin"; /* api callbacks */ @@ -1092,6 +1092,7 @@ void MESH_OT_screw(wmOperatorType *ot) { /* identifiers */ ot->name= "Screw"; + ot->description= "Extrude selected vertices in screw-shaped rotation around the cursor in indicated viewport."; ot->idname= "MESH_OT_screw"; /* api callbacks */ @@ -1324,6 +1325,7 @@ void MESH_OT_delete(wmOperatorType *ot) { /* identifiers */ ot->name= "Delete"; + ot->description= "Delete selected vertices, edges or faces."; ot->idname= "MESH_OT_delete"; /* api callbacks */ @@ -3768,6 +3770,7 @@ void MESH_OT_edge_rotate(wmOperatorType *ot) { /* identifiers */ ot->name= "Rotate Selected Edge"; + ot->description= "Rotate selected edge or adjoining faces."; ot->idname= "MESH_OT_edge_rotate"; /* api callbacks */ @@ -5002,6 +5005,7 @@ void MESH_OT_rip(wmOperatorType *ot) { /* identifiers */ ot->name= "Rip"; + ot->description= "Rip selection from mesh (quads only)."; ot->idname= "MESH_OT_rip"; /* api callbacks */ @@ -5848,6 +5852,7 @@ void MESH_OT_merge(wmOperatorType *ot) /* identifiers */ ot->name= "Merge"; + ot->description= "Merge selected vertices."; ot->idname= "MESH_OT_merge"; /* api callbacks */ @@ -6050,6 +6055,7 @@ void MESH_OT_select_vertex_path(wmOperatorType *ot) /* identifiers */ ot->name= "Select Vertex Path"; + ot->description= "Select shortest path between two vertices by distance type."; ot->idname= "MESH_OT_select_vertex_path"; /* api callbacks */ @@ -6111,6 +6117,7 @@ void MESH_OT_region_to_loop(wmOperatorType *ot) { /* identifiers */ ot->name= "Region to Loop"; + ot->description= "Select a region as a loop of connected edges."; ot->idname= "MESH_OT_region_to_loop"; /* api callbacks */ @@ -6286,6 +6293,7 @@ void MESH_OT_loop_to_region(wmOperatorType *ot) { /* identifiers */ ot->name= "Loop to Region"; + ot->description= "Select a loop of connected edges as a region."; ot->idname= "MESH_OT_loop_to_region"; /* api callbacks */ @@ -6584,6 +6592,7 @@ void MESH_OT_uvs_rotate(wmOperatorType *ot) { /* identifiers */ ot->name= "Rotate UVs"; + ot->description= "Rotate selected UVs."; ot->idname= "MESH_OT_uvs_rotate"; /* api callbacks */ @@ -6601,6 +6610,7 @@ void MESH_OT_uvs_mirror(wmOperatorType *ot) { /* identifiers */ ot->name= "Mirror UVs"; + ot->description= "Mirror selected UVs."; ot->idname= "MESH_OT_uvs_mirror"; /* api callbacks */ @@ -6618,6 +6628,7 @@ void MESH_OT_colors_rotate(wmOperatorType *ot) { /* identifiers */ ot->name= "Rotate Colors"; + ot->description= "Rotate UV/image color layer."; ot->idname= "MESH_OT_colors_rotate"; /* api callbacks */ @@ -6635,6 +6646,7 @@ void MESH_OT_colors_mirror(wmOperatorType *ot) { /* identifiers */ ot->name= "Mirror Colors"; + ot->description= "Mirror UV/image color layer."; ot->idname= "MESH_OT_colors_mirror"; /* api callbacks */ @@ -6668,7 +6680,7 @@ static int subdivide_exec(bContext *C, wmOperator *op) esubdivideflag(obedit, em, 1, smooth, fractal, scene->toolsettings->editbutflag|flag, cuts, 0); DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); return OPERATOR_FINISHED; } @@ -6677,6 +6689,7 @@ void MESH_OT_subdivide(wmOperatorType *ot) { /* identifiers */ ot->name= "Subdivide"; + ot->description= "Subdivide selected edges."; ot->idname= "MESH_OT_subdivide"; /* api callbacks */ @@ -6959,6 +6972,7 @@ void MESH_OT_fill(wmOperatorType *ot) { /* identifiers */ ot->name= "Fill"; + ot->description= "Create a segment, edge or face."; ot->idname= "MESH_OT_fill"; /* api callbacks */ @@ -6989,6 +7003,7 @@ void MESH_OT_beauty_fill(wmOperatorType *ot) { /* identifiers */ ot->name= "Beauty Fill"; + ot->description= "Arrange geometry on a selected surface to avoid skinny faces."; ot->idname= "MESH_OT_beauty_fill"; /* api callbacks */ @@ -7020,6 +7035,7 @@ void MESH_OT_quads_convert_to_tris(wmOperatorType *ot) { /* identifiers */ ot->name= "Quads to Tris"; + ot->description= "Convert selected quads to triangles."; ot->idname= "MESH_OT_quads_convert_to_tris"; /* api callbacks */ @@ -7049,6 +7065,7 @@ void MESH_OT_tris_convert_to_quads(wmOperatorType *ot) { /* identifiers */ ot->name= "Tris to Quads"; + ot->description= "Convert selected triangles to quads."; ot->idname= "MESH_OT_tris_convert_to_quads"; /* api callbacks */ @@ -7078,6 +7095,7 @@ void MESH_OT_edge_flip(wmOperatorType *ot) { /* identifiers */ ot->name= "Edge Flip"; + ot->description= "Flip selected edge or adjoining faces."; ot->idname= "MESH_OT_edge_flip"; /* api callbacks */ @@ -7124,6 +7142,7 @@ void MESH_OT_faces_shade_smooth(wmOperatorType *ot) { /* identifiers */ ot->name= "Shade Smooth"; + ot->description= "Display faces 'smooth' (using vertex normals)."; ot->idname= "MESH_OT_faces_shade_smooth"; /* api callbacks */ @@ -7152,6 +7171,7 @@ void MESH_OT_faces_shade_flat(wmOperatorType *ot) { /* identifiers */ ot->name= "Shade Flat"; + ot->description= "Display faces 'flat'."; ot->idname= "MESH_OT_faces_shade_flat"; /* api callbacks */ diff --git a/source/blender/editors/mesh/mesh_layers.c b/source/blender/editors/mesh/mesh_layers.c index 99d50d1a9b0..17a448ecf90 100644 --- a/source/blender/editors/mesh/mesh_layers.c +++ b/source/blender/editors/mesh/mesh_layers.c @@ -54,12 +54,14 @@ #include "WM_types.h" #include "ED_mesh.h" +#include "ED_object.h" #include "ED_view3d.h" #include "mesh_intern.h" -static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer) +static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *layer) { + Mesh *me = ob->data; CustomData *data= (me->edit_mesh)? &me->edit_mesh->fdata: &me->fdata; void *actlayerdata, *rndlayerdata, *clonelayerdata, *masklayerdata, *layerdata=layer->data; int type= layer->type; @@ -87,9 +89,8 @@ static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer) mesh_update_customdata_pointers(me); } - if(!CustomData_has_layer(data, type)) - if(type == CD_MCOL && (G.f & G_VERTEXPAINT)) - G.f &= ~G_VERTEXPAINT; /* get out of vertexpaint mode */ + if(!CustomData_has_layer(data, type) && (type == CD_MCOL && (ob->mode & OB_MODE_VERTEX_PAINT))) + ED_object_toggle_modes(C, OB_MODE_VERTEX_PAINT); /* reconstruct active layer */ if (actlayerdata != layerdata) { @@ -198,6 +199,7 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add UV Texture"; + ot->description= "Add UV texture layer."; ot->idname= "MESH_OT_uv_texture_add"; /* api callbacks */ @@ -225,7 +227,7 @@ static int uv_texture_remove_exec(bContext *C, wmOperator *op) if(!cdl) return OPERATOR_CANCELLED; - delete_customdata_layer(me, cdl); + delete_customdata_layer(C, ob, cdl); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); @@ -237,6 +239,7 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove UV Texture"; + ot->description= "Remove UV texture layer."; ot->idname= "MESH_OT_uv_texture_remove"; /* api callbacks */ @@ -301,6 +304,7 @@ void MESH_OT_vertex_color_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Vertex Color"; + ot->description= "Add vertex color layer."; ot->idname= "MESH_OT_vertex_color_add"; /* api callbacks */ @@ -328,7 +332,7 @@ static int vertex_color_remove_exec(bContext *C, wmOperator *op) if(!cdl) return OPERATOR_CANCELLED; - delete_customdata_layer(me, cdl); + delete_customdata_layer(C, ob, cdl); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); @@ -340,6 +344,7 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove Vertex Color"; + ot->description= "Remove vertex color layer."; ot->idname= "MESH_OT_vertex_color_remove"; /* api callbacks */ @@ -377,6 +382,7 @@ void MESH_OT_sticky_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Sticky"; + ot->description= "Add sticky UV texture layer."; ot->idname= "MESH_OT_sticky_add"; /* api callbacks */ @@ -413,6 +419,7 @@ void MESH_OT_sticky_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove Sticky"; + ot->description= "Remove sticky UV texture layer."; ot->idname= "MESH_OT_sticky_remove"; /* api callbacks */ diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index edb131d7da2..c545f7d70d6 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -90,6 +90,7 @@ static void MESH_OT_vertex_specials(wmOperatorType *ot) { /* identifiers */ ot->name= "Vertex Specials"; + //ot->description= "Perform special vertex operations."; ot->idname= "MESH_OT_vertex_specials"; /* api callbacks */ @@ -128,6 +129,7 @@ static void MESH_OT_edge_specials(wmOperatorType *ot) { /* identifiers */ ot->name= "Edge Specials"; + //ot->description= "Perform special edge operations."; ot->idname= "MESH_OT_edge_specials"; /* api callbacks */ @@ -178,6 +180,7 @@ static void MESH_OT_face_specials(wmOperatorType *ot) { /* identifiers */ ot->name= "Face Specials"; + //ot->description= "Perform special face operations."; ot->idname= "MESH_OT_face_specials"; /* api callbacks */ @@ -219,6 +222,7 @@ static void MESH_OT_specials(wmOperatorType *ot) { /* identifiers */ ot->name= "Specials"; + //ot->description= "Perform special vertice, edge or face operations."; ot->idname= "MESH_OT_specials"; /* api callbacks */ diff --git a/source/blender/editors/object/editconstraint.c b/source/blender/editors/object/editconstraint.c index 9e8205e58ab..23b3caf8e26 100644 --- a/source/blender/editors/object/editconstraint.c +++ b/source/blender/editors/object/editconstraint.c @@ -87,7 +87,7 @@ ListBase *get_active_constraints (Object *ob) if (ob == NULL) return NULL; - if (ob->flag & OB_POSEMODE) { + if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; pchan = get_active_posechannel(ob); @@ -1065,7 +1065,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase { /* if this constraint is being added to a posechannel, make sure * the constraint gets evaluated in pose-space */ - if (ob->flag & OB_POSEMODE) { + if (ob->mode & OB_MODE_POSE) { con->ownspace = CONSTRAINT_SPACE_POSE; con->flag |= CONSTRAINT_SPACEONCE; } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index a6bd38752ae..f8d969d2462 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -98,6 +98,7 @@ #include "BKE_mesh.h" #include "BKE_nla.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_property.h" #include "BKE_report.h" @@ -126,6 +127,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" /* for menu/popup icons etc etc*/ #include "UI_interface.h" @@ -177,10 +179,6 @@ void ED_base_object_activate(bContext *C, Base *base) Scene *scene= CTX_data_scene(C); Base *tbase; - /* activating a non-mesh, should end a couple of modes... */ - if(base && base->object->type!=OB_MESH) - ED_view3d_exit_paint_modes(C); - /* sets scene->basact */ BASACT= base; @@ -272,9 +270,6 @@ static Object *object_add_type(bContext *C, int type) Scene *scene= CTX_data_scene(C); Object *ob; - /* XXX hrms, this is editor level operator, remove? */ - ED_view3d_exit_paint_modes(C); - /* for as long scene has editmode... */ if (CTX_data_edit_object(C)) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */ @@ -751,8 +746,6 @@ static int object_delete_exec(bContext *C, wmOperator *op) if(CTX_data_edit_object(C)) return OPERATOR_CANCELLED; - ED_view3d_exit_paint_modes(C); - CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { if(base->object->type==OB_LAMP) islamp= 1; @@ -2246,7 +2239,7 @@ static int object_location_clear_exec(bContext *C, wmOperator *op) int armature_clear= 0; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if((G.f & G_WEIGHTPAINT)==0) { + if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) { if ((ob->protectflag & OB_LOCK_LOCX)==0) ob->loc[0]= ob->dloc[0]= 0.0f; if ((ob->protectflag & OB_LOCK_LOCY)==0) @@ -2289,7 +2282,7 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op) int armature_clear= 0; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if((G.f & G_WEIGHTPAINT)==0) { + if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) { /* eulers can only get cleared if they are not protected */ if ((ob->protectflag & OB_LOCK_ROTX)==0) ob->rot[0]= ob->drot[0]= 0.0f; @@ -2333,7 +2326,7 @@ static int object_scale_clear_exec(bContext *C, wmOperator *op) int armature_clear= 0; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if((G.f & G_WEIGHTPAINT)==0) { + if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) { if ((ob->protectflag & OB_LOCK_SCALEX)==0) { ob->dsize[0]= 0.0f; ob->size[0]= 1.0f; @@ -3700,7 +3693,7 @@ void ED_object_exit_editmode(bContext *C, int flag) me->edit_mesh= NULL; } - if(G.f & G_WEIGHTPAINT) + if(obedit->restore_mode & OB_MODE_WEIGHT_PAINT) mesh_octree_table(obedit, NULL, NULL, 'e'); } else if (obedit->type==OB_ARMATURE) { @@ -3724,7 +3717,7 @@ void ED_object_exit_editmode(bContext *C, int flag) load_editMball(obedit); if(freedata) free_editMball(obedit); } - + /* freedata only 0 now on file saves */ if(freedata) { /* for example; displist make is different in editmode */ @@ -3739,6 +3732,9 @@ void ED_object_exit_editmode(bContext *C, int flag) WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene); } + + obedit->mode &= ~OB_MODE_EDIT; + ED_object_toggle_modes(C, obedit->restore_mode); } @@ -3772,7 +3768,10 @@ void ED_object_enter_editmode(bContext *C, int flag) if(flag & EM_WAITCURSOR) waitcursor(1); - ED_view3d_exit_paint_modes(C); + ob->restore_mode = ob->mode; + ED_object_toggle_modes(C, ob->mode); + + ob->mode |= OB_MODE_EDIT; if(ob->type==OB_MESH) { Mesh *me= ob->data; @@ -3860,6 +3859,16 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int editmode_toggle_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + + return ob && (ob->type == OB_MESH || ob->type == OB_ARMATURE || + ob->type == OB_FONT || ob->type == OB_MBALL || + ob->type == OB_LATTICE || ob->type == OB_SURF || + ob->type == OB_CURVE); +} + void OBJECT_OT_editmode_toggle(wmOperatorType *ot) { @@ -3871,7 +3880,7 @@ void OBJECT_OT_editmode_toggle(wmOperatorType *ot) /* api callbacks */ ot->exec= editmode_toggle_exec; - ot->poll= ED_operator_object_active; + ot->poll= editmode_toggle_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3888,7 +3897,7 @@ static int posemode_exec(bContext *C, wmOperator *op) ED_object_exit_editmode(C, EM_FREEDATA); ED_armature_enter_posemode(C, base); } - else if(base->object->flag & OB_POSEMODE) + else if(base->object->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); else ED_armature_enter_posemode(C, base); @@ -4111,10 +4120,10 @@ void special_editmenu(Scene *scene, View3D *v3d) if(obedit==NULL) { - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { // XXX pose_special_editmenu(); } - else if(FACESEL_PAINT_TEST) { + else if(paint_facesel_test(ob)) { Mesh *me= get_mesh(ob); MTFace *tface; MFace *mface; @@ -4160,7 +4169,7 @@ void special_editmenu(Scene *scene, View3D *v3d) } DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } - else if(G.f & G_VERTEXPAINT) { + else if(ob->mode & OB_MODE_VERTEX_PAINT) { Mesh *me= get_mesh(ob); if(me==0 || (me->mcol==NULL && me->mtface==NULL) ) return; @@ -4173,17 +4182,17 @@ void special_editmenu(Scene *scene, View3D *v3d) DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } } - else if(G.f & G_WEIGHTPAINT) { + else if(ob->mode & OB_MODE_WEIGHT_PAINT) { Object *par= modifiers_isDeformedByArmature(ob); - if(par && (par->flag & OB_POSEMODE)) { + if(par && (par->mode & OB_MODE_POSE)) { nr= pupmenu("Specials%t|Apply Bone Envelopes to Vertex Groups %x1|Apply Bone Heat Weights to Vertex Groups %x2"); // XXX if(nr==1 || nr==2) // XXX pose_adds_vgroups(ob, (nr == 2)); } } - else if(G.f & G_PARTICLEEDIT) { + else if(ob->mode & OB_MODE_PARTICLE_EDIT) { #if 0 // XXX ParticleSystem *psys = PE_get_current(ob); @@ -5725,7 +5734,7 @@ void new_id_matar(Material **matar, int totcol) } } -void single_obdata_users(Scene *scene, View3D *v3d, int flag) +void single_obdata_users(Scene *scene, int flag) { Object *ob; Lamp *la; @@ -5848,7 +5857,7 @@ void single_obdata_users(Scene *scene, View3D *v3d, int flag) } } -void single_ipo_users(Scene *scene, View3D *v3d, int flag) +void single_ipo_users(Scene *scene, int flag) { #if 0 // XXX old animation system Object *ob; @@ -5871,7 +5880,7 @@ void single_ipo_users(Scene *scene, View3D *v3d, int flag) #endif // XXX old animation system } -void single_mat_users(Scene *scene, View3D *v3d, int flag) +void single_mat_users(Scene *scene, int flag) { Object *ob; Base *base; @@ -6057,19 +6066,19 @@ void single_user(Scene *scene, View3D *v3d) else if(nr==2) { single_object_users(scene, v3d, 1); - single_obdata_users(scene, v3d, 1); + single_obdata_users(scene, 1); } else if(nr==3) { single_object_users(scene, v3d, 1); - single_obdata_users(scene, v3d, 1); - single_mat_users(scene, v3d, 1); /* also tex */ + single_obdata_users(scene, 1); + single_mat_users(scene, 1); /* also tex */ } else if(nr==4) { - single_mat_users(scene, v3d, 1); + single_mat_users(scene, 1); } else if(nr==5) { - single_ipo_users(scene, v3d, 1); + single_ipo_users(scene, 1); } @@ -6078,6 +6087,20 @@ void single_user(Scene *scene, View3D *v3d) } } +/* used for copying scenes */ +void ED_object_single_users(Scene *scene, int full) +{ + single_object_users(scene, NULL, 0); + + if(full) { + single_obdata_users(scene, 0); + single_mat_users_expand(); + single_tex_users_expand(); + } + + clear_id_newpoins(); +} + /* ************************************************************* */ /* helper for below, ma was checked to be not NULL */ @@ -6282,7 +6305,7 @@ static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag int a, didit; ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { ; /* nothing? */ } else { @@ -7018,3 +7041,97 @@ void hookmenu(Scene *scene, View3D *v3d) if (changed) { } } + +static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem *input = object_mode_items; + EnumPropertyItem *item= NULL; + Object *ob; + int totitem= 0; + + if(!C) /* needed for docs */ + return object_mode_items; + + ob = CTX_data_active_object(C); + while(ob && input->identifier) { + if((input->value == OB_MODE_EDIT && ((ob->type == OB_MESH) || (ob->type == OB_ARMATURE) || + (ob->type == OB_CURVE) || (ob->type == OB_SURF) || + (ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) || + (input->value == OB_MODE_POSE && (ob->type == OB_ARMATURE)) || + (input->value == OB_MODE_PARTICLE_EDIT && ob->particlesystem.first) || + ((input->value == OB_MODE_SCULPT || input->value == OB_MODE_VERTEX_PAINT || + input->value == OB_MODE_WEIGHT_PAINT || input->value == OB_MODE_TEXTURE_PAINT) && (ob->type == OB_MESH)) || + (input->value == OB_MODE_OBJECT)) + RNA_enum_item_add(&item, &totitem, input); + ++input; + } + + RNA_enum_item_end(&item, &totitem); + + *free= 1; + + return item; +} + +static int object_mode_set_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_active_object(C); + int mode = RNA_enum_get(op->ptr, "mode"); + + if(!ob) + return OPERATOR_CANCELLED; + + if((mode == OB_MODE_EDIT) == !(ob->mode & OB_MODE_EDIT)) + WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if((mode == OB_MODE_SCULPT) == !(ob->mode & OB_MODE_SCULPT)) + WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if((mode == OB_MODE_VERTEX_PAINT) == !(ob->mode & OB_MODE_VERTEX_PAINT)) + WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if((mode == OB_MODE_WEIGHT_PAINT) == !(ob->mode & OB_MODE_WEIGHT_PAINT)) + WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if((mode == OB_MODE_TEXTURE_PAINT) == !(ob->mode & OB_MODE_TEXTURE_PAINT)) + WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if((mode == OB_MODE_PARTICLE_EDIT) == !(ob->mode & OB_MODE_PARTICLE_EDIT)) + WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if((mode == OB_MODE_POSE) == !(ob->mode & OB_MODE_POSE)) + WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_EXEC_REGION_WIN, NULL); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_mode_set(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name= "Set Object Mode"; + ot->description = "Sets the object interaction mode."; + ot->idname= "OBJECT_OT_mode_set"; + + /* api callbacks */ + ot->exec= object_mode_set_exec; + + ot->poll= ED_operator_object_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + prop= RNA_def_enum(ot->srna, "mode", object_mode_items, 0, "Mode", ""); + RNA_def_enum_funcs(prop, object_mode_set_itemsf); +} + + + +void ED_object_toggle_modes(bContext *C, int mode) +{ + if(mode & OB_MODE_SCULPT) + WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_VERTEX_PAINT) + WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_WEIGHT_PAINT) + WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_TEXTURE_PAINT) + WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); + if(mode & OB_MODE_PARTICLE_EDIT) + WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL); +} diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 17d4f5deaae..e47087a3c27 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -39,6 +39,7 @@ struct Mesh; /* object_edit.c */ +void OBJECT_OT_mode_set(struct wmOperatorType *ot); void OBJECT_OT_editmode_toggle(struct wmOperatorType *ot); void OBJECT_OT_posemode_toggle(struct wmOperatorType *ot); void OBJECT_OT_parent_set(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 6b9f2db0d96..9983e24f2c9 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -226,7 +226,7 @@ int ED_object_modifier_convert(ReportList *reports, Scene *scene, Object *ob, Mo int totpart=0, totchild=0; if(md->type != eModifierType_ParticleSystem) return 0; - if(G.f & G_PARTICLEEDIT) return 0; + if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) return 0; psys=((ParticleSystemModifierData *)md)->psys; part= psys->part; @@ -640,14 +640,19 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int multires_subdivide_poll(bContext *C) +{ + return NULL != CTX_data_active_object(C) && NULL == CTX_data_edit_object(C); +} + void OBJECT_OT_multires_subdivide(wmOperatorType *ot) { ot->name= "Multires Subdivide"; ot->description= "Add a new level of subdivision."; ot->idname= "OBJECT_OT_multires_subdivide"; - ot->poll= ED_operator_object_active; ot->exec= multires_subdivide_exec; + ot->poll= multires_subdivide_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index c1509e78502..f2e048284f4 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -65,6 +65,7 @@ void ED_operatortypes_object(void) { wmOperatorType *ot; + WM_operatortype_append(OBJECT_OT_mode_set); WM_operatortype_append(OBJECT_OT_editmode_toggle); WM_operatortype_append(OBJECT_OT_posemode_toggle); WM_operatortype_append(OBJECT_OT_parent_set); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 3d3e29bcc22..154ab14df60 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -57,6 +57,7 @@ #include "BKE_global.h" #include "BKE_lattice.h" #include "BKE_mesh.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" #include "RNA_access.h" @@ -1028,11 +1029,11 @@ void vgroup_assign_with_menu(Scene *scene, Object *ob) switch (mode) { case 1: /* add to new group */ add_defgroup(ob); - assign_verts_defgroup(ob, wp->brush->alpha); + assign_verts_defgroup(ob, paint_brush(&wp->paint)->alpha); BIF_undo_push("Assign to vertex group"); break; case 2: /* add to current group */ - assign_verts_defgroup(ob, wp->brush->alpha); + assign_verts_defgroup(ob, paint_brush(&wp->paint)->alpha); BIF_undo_push("Assign to vertex group"); break; case 3: /* remove from current group */ diff --git a/source/blender/editors/physics/ed_pointcache.c b/source/blender/editors/physics/ed_pointcache.c index 5d0a6d21fac..917e2b40d72 100644 --- a/source/blender/editors/physics/ed_pointcache.c +++ b/source/blender/editors/physics/ed_pointcache.c @@ -61,7 +61,6 @@ static int cache_break_test(void *cbd) { return G.afbreek==1; } -/**************************** general **********************************/ static int ptcache_bake_all_poll(bContext *C) { Scene *scene= CTX_data_scene(C); @@ -130,7 +129,7 @@ void PTCACHE_OT_bake_all(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); + RNA_def_boolean(ot->srna, "bake", 1, "Bake", ""); } void PTCACHE_OT_free_bake_all(wmOperatorType *ot) { @@ -145,32 +144,25 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } - -/**************************** softbody **********************************/ -static int ptcache_bake_softbody_poll(bContext *C) +static int ptcache_bake_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - SoftBody *sb = ob->soft; - - if(!scene || !ob || ob->id.lib || !sb) - return 0; - - return 1; -} - -static int ptcache_bake_softbody_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - SoftBody *sb = ob->soft; - PTCacheID pid; + Scene *scene = CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + Object *ob= ptr.id.data; + PointCache *cache= ptr.data; PTCacheBaker baker; + PTCacheID *pid; + ListBase pidlist; - BKE_ptcache_id_from_softbody(&pid, ob, sb); + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) + break; + } baker.scene = scene; - baker.pid = &pid; + baker.pid = pid; baker.bake = RNA_boolean_get(op->ptr, "bake"); baker.render = 0; baker.anim_init = 0; @@ -182,305 +174,160 @@ static int ptcache_bake_softbody_exec(bContext *C, wmOperator *op) BKE_ptcache_make_cache(&baker); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); - - return OPERATOR_FINISHED; -} -static int ptcache_free_bake_softbody_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - SoftBody *sb = ob->soft; - PTCacheID pid; - - BKE_ptcache_id_from_softbody(&pid, ob, sb); - pid.cache->flag &= ~PTCACHE_BAKED; + BLI_freelistN(&pidlist); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); return OPERATOR_FINISHED; } -void PTCACHE_OT_cache_softbody(wmOperatorType *ot) +static int ptcache_free_bake_exec(bContext *C, wmOperator *op) { - /* identifiers */ - ot->name= "Bake Softbody"; - ot->idname= "PTCACHE_OT_cache_softbody"; + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + PointCache *cache= ptr.data; - /* api callbacks */ - ot->exec= ptcache_bake_softbody_exec; - ot->poll= ptcache_bake_softbody_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); -} -void PTCACHE_OT_free_bake_softbody(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Free SoftBody Bake"; - ot->idname= "PTCACHE_OT_free_bake_softbody"; - - /* api callbacks */ - ot->exec= ptcache_free_bake_softbody_exec; - ot->poll= ptcache_bake_softbody_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} -static int ptcache_bake_from_softbody_cache_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_active_object(C); - SoftBody *sb = ob->soft; - PTCacheID pid; - - BKE_ptcache_id_from_softbody(&pid, ob, sb); - pid.cache->flag |= PTCACHE_BAKED; + cache->flag &= ~PTCACHE_BAKED; return OPERATOR_FINISHED; } -void PTCACHE_OT_bake_from_softbody_cache(wmOperatorType *ot) +static int ptcache_bake_from_cache_exec(bContext *C, wmOperator *op) +{ + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + PointCache *cache= ptr.data; + + cache->flag |= PTCACHE_BAKED; + + return OPERATOR_FINISHED; +} +void PTCACHE_OT_bake(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Bake Physics"; + ot->idname= "PTCACHE_OT_bake"; + + /* api callbacks */ + ot->exec= ptcache_bake_exec; + ot->poll= ptcache_bake_all_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "bake", 1, "Bake", ""); +} +void PTCACHE_OT_free_bake(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Free Physics Bake"; + ot->idname= "PTCACHE_OT_free_bake"; + + /* api callbacks */ + ot->exec= ptcache_free_bake_exec; + ot->poll= ptcache_bake_all_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} +void PTCACHE_OT_bake_from_cache(wmOperatorType *ot) { /* identifiers */ ot->name= "Bake From Cache"; - ot->idname= "PTCACHE_OT_bake_from_softbody_cache"; + ot->idname= "PTCACHE_OT_bake_from_cache"; /* api callbacks */ - ot->exec= ptcache_bake_from_softbody_cache_exec; - ot->poll= ptcache_bake_softbody_poll; + ot->exec= ptcache_bake_from_cache_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/**************************** cloth **********************************/ -static int ptcache_bake_cloth_poll(bContext *C) +static int ptcache_add_new_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); + Scene *scene = CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + Object *ob= ptr.id.data; + PointCache *cache= ptr.data; + PTCacheID *pid; + ListBase pidlist; - if(!scene || !ob || ob->id.lib || !clmd) - return 0; + BKE_ptcache_ids_from_object(&pidlist, ob); - return 1; -} + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + *(pid->cache_ptr) = BKE_ptcache_add(pid->ptcaches); + break; + } + } -static int ptcache_bake_cloth_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - PTCacheID pid; - PTCacheBaker baker; - - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - - baker.scene = scene; - baker.pid = &pid; - baker.bake = RNA_boolean_get(op->ptr, "bake"); - baker.render = 0; - baker.anim_init = 0; - baker.quick_step = 1; - baker.break_test = cache_break_test; - baker.break_data = NULL; - baker.progressbar = (void (*)(void *, int))WM_timecursor; - baker.progresscontext = CTX_wm_window(C); - - BKE_ptcache_make_cache(&baker); + BLI_freelistN(&pidlist); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); return OPERATOR_FINISHED; } -static int ptcache_free_bake_cloth_exec(bContext *C, wmOperator *op) +static int ptcache_remove_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - PTCacheID pid; + PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); + Object *ob= ptr.id.data; + PointCache *cache= ptr.data; + PTCacheID *pid; + ListBase pidlist; - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - pid.cache->flag &= ~PTCACHE_BAKED; + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + if(pid->ptcaches->first == pid->ptcaches->last) + continue; /* don't delete last cache */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + BLI_remlink(pid->ptcaches, pid->cache); + BKE_ptcache_free(pid->cache); + *(pid->cache_ptr) = pid->ptcaches->first; + + break; + } + } + + BLI_freelistN(&pidlist); return OPERATOR_FINISHED; } -void PTCACHE_OT_cache_cloth(wmOperatorType *ot) +void PTCACHE_OT_add_new(wmOperatorType *ot) { /* identifiers */ - ot->name= "Bake Cloth"; - ot->idname= "PTCACHE_OT_cache_cloth"; + ot->name= "Add new cache"; + ot->idname= "PTCACHE_OT_add_new"; /* api callbacks */ - ot->exec= ptcache_bake_cloth_exec; - ot->poll= ptcache_bake_cloth_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); -} -void PTCACHE_OT_free_bake_cloth(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Free Cloth Bake"; - ot->idname= "PTCACHE_OT_free_bake_cloth"; - - /* api callbacks */ - ot->exec= ptcache_free_bake_cloth_exec; - ot->poll= ptcache_bake_cloth_poll; + ot->exec= ptcache_add_new_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int ptcache_bake_from_cloth_cache_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_active_object(C); - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - PTCacheID pid; - - BKE_ptcache_id_from_cloth(&pid, ob, clmd); - pid.cache->flag |= PTCACHE_BAKED; - - return OPERATOR_FINISHED; -} -void PTCACHE_OT_bake_from_cloth_cache(wmOperatorType *ot) +void PTCACHE_OT_remove(wmOperatorType *ot) { /* identifiers */ - ot->name= "Bake From Cache"; - ot->idname= "PTCACHE_OT_bake_from_cloth_cache"; + ot->name= "Delete current cache"; + ot->idname= "PTCACHE_OT_remove"; /* api callbacks */ - ot->exec= ptcache_bake_from_cloth_cache_exec; - ot->poll= ptcache_bake_cloth_poll; + ot->exec= ptcache_remove_exec; + ot->poll= ptcache_bake_all_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } - -/**************************** particles **********************************/ -static int ptcache_bake_particle_system_poll(bContext *C) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - - if(!scene || !ob || ob->id.lib) - return 0; - - return (ob->particlesystem.first != NULL); -} - -static int ptcache_bake_particle_system_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ParticleSystem *psys =psys_get_current(ob); - PTCacheID pid; - PTCacheBaker baker; - - BKE_ptcache_id_from_particles(&pid, ob, psys); - - baker.scene = scene; - baker.pid = &pid; - baker.bake = RNA_boolean_get(op->ptr, "bake"); - baker.render = 0; - baker.anim_init = 0; - baker.quick_step = 1; - baker.break_test = cache_break_test; - baker.break_data = NULL; - baker.progressbar = (void (*)(void *, int))WM_timecursor; - baker.progresscontext = CTX_wm_window(C); - - BKE_ptcache_make_cache(&baker); - - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); - - return OPERATOR_FINISHED; -} -static int ptcache_free_bake_particle_system_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ParticleSystem *psys= psys_get_current(ob); - PTCacheID pid; - - BKE_ptcache_id_from_particles(&pid, ob, psys); - psys->pointcache->flag &= ~PTCACHE_BAKED; - - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); - - return OPERATOR_FINISHED; -} -void PTCACHE_OT_cache_particle_system(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Bake Particles"; - ot->idname= "PTCACHE_OT_cache_particle_system"; - - /* api callbacks */ - ot->exec= ptcache_bake_particle_system_exec; - ot->poll= ptcache_bake_particle_system_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_boolean(ot->srna, "bake", 0, "Bake", ""); -} -void PTCACHE_OT_free_bake_particle_system(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Free Particles Bake"; - ot->idname= "PTCACHE_OT_free_bake_particle_system"; - - /* api callbacks */ - ot->exec= ptcache_free_bake_particle_system_exec; - ot->poll= ptcache_bake_particle_system_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} -static int ptcache_bake_from_particles_cache_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_active_object(C); - ParticleSystem *psys= psys_get_current(ob); - PTCacheID pid; - - BKE_ptcache_id_from_particles(&pid, ob, psys); - psys->pointcache->flag |= PTCACHE_BAKED; - - return OPERATOR_FINISHED; -} -void PTCACHE_OT_bake_from_particles_cache(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Bake From Cache"; - ot->idname= "PTCACHE_OT_bake_from_particles_cache"; - - /* api callbacks */ - ot->exec= ptcache_bake_from_particles_cache_exec; - ot->poll= ptcache_bake_particle_system_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - /**************************** registration **********************************/ void ED_operatortypes_pointcache(void) { WM_operatortype_append(PTCACHE_OT_bake_all); WM_operatortype_append(PTCACHE_OT_free_bake_all); - WM_operatortype_append(PTCACHE_OT_cache_particle_system); - WM_operatortype_append(PTCACHE_OT_free_bake_particle_system); - WM_operatortype_append(PTCACHE_OT_bake_from_particles_cache); - WM_operatortype_append(PTCACHE_OT_cache_cloth); - WM_operatortype_append(PTCACHE_OT_free_bake_cloth); - WM_operatortype_append(PTCACHE_OT_bake_from_cloth_cache); - WM_operatortype_append(PTCACHE_OT_cache_softbody); - WM_operatortype_append(PTCACHE_OT_free_bake_softbody); - WM_operatortype_append(PTCACHE_OT_bake_from_softbody_cache); + WM_operatortype_append(PTCACHE_OT_bake); + WM_operatortype_append(PTCACHE_OT_free_bake); + WM_operatortype_append(PTCACHE_OT_bake_from_cache); + WM_operatortype_append(PTCACHE_OT_add_new); + WM_operatortype_append(PTCACHE_OT_remove); } //void ED_keymap_pointcache(wmWindowManager *wm) diff --git a/source/blender/editors/physics/editparticle.c b/source/blender/editors/physics/editparticle.c index 20033c747f9..b92632b45af 100644 --- a/source/blender/editors/physics/editparticle.c +++ b/source/blender/editors/physics/editparticle.c @@ -104,21 +104,13 @@ static int PE_poll(bContext *C) psys= PE_get_current(scene, ob); - return (psys && psys->edit && (G.f & G_PARTICLEEDIT)); + return (psys && psys->edit && (ob && ob->mode & OB_MODE_PARTICLE_EDIT)); } static int PE_poll_3dview(bContext *C) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - ParticleSystem *psys; - - if(!scene || !ob || !CTX_wm_region_view3d(C)) - return 0; - - psys= PE_get_current(scene, ob); - - return (psys && psys->edit && (G.f & G_PARTICLEEDIT)); + return PE_poll(C) && CTX_wm_area(C)->spacetype == SPACE_VIEW3D && + CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW; } static void PE_free_particle_edit(ParticleSystem *psys) @@ -164,7 +156,7 @@ static void PE_free_particle_edit(ParticleSystem *psys) int PE_can_edit(ParticleSystem *psys) { - return (psys && psys->edit && (G.f & G_PARTICLEEDIT)); + return (psys && psys->edit); } ParticleEditSettings *PE_settings(Scene *scene) @@ -194,7 +186,7 @@ ParticleSystem *PE_get_current(Scene *scene, Object *ob) /* this happens when Blender is started with particle * edit mode enabled XXX there's a draw error then? */ - if(psys && psys_check_enabled(ob, psys) && (ob == OBACT) && (G.f & G_PARTICLEEDIT)) + if(psys && psys_check_enabled(ob, psys) && (ob == OBACT) && (ob->mode & OB_MODE_PARTICLE_EDIT)) if(psys->part->type == PART_HAIR && psys->flag & PSYS_EDITED) if(psys->edit == NULL) PE_create_particle_edit(scene, ob, psys); @@ -2269,7 +2261,7 @@ static void toggle_particle_cursor(bContext *C, int enable) pset->paintcursor = NULL; } else if(enable) - pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll, brush_drawcursor, NULL); + pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll_3dview, brush_drawcursor, NULL); } /********************* radial control operator *********************/ @@ -3076,11 +3068,13 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys); ParticleBrushData *brush= &pset->brush[pset->brushtype]; ARegion *ar= CTX_wm_region(C); - float vec1[3], vec2[3]; + float vec1[3], vec2[3], mousef[2]; short mval[2], mvalo[2]; int flip, mouse[2], dx, dy, removed= 0, selected= 0; - RNA_int_get_array(itemptr, "mouse", mouse); + RNA_float_get_array(itemptr, "mouse", mousef); + mouse[0] = mousef[0]; + mouse[1] = mousef[1]; flip= RNA_boolean_get(itemptr, "flip"); if(bedit->first) { @@ -3291,7 +3285,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); PointerRNA itemptr; - int mouse[2]; + float mouse[2]; mouse[0]= event->x - ar->winrct.xmin; mouse[1]= event->y - ar->winrct.ymin; @@ -3299,7 +3293,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event) /* fill in stroke */ RNA_collection_add(op->ptr, "stroke", &itemptr); - RNA_int_set_array(&itemptr, "mouse", mouse); + RNA_float_set_array(&itemptr, "mouse", mouse); RNA_boolean_set(&itemptr, "flip", event->shift != 0); // XXX hardcoded /* apply */ @@ -3710,7 +3704,7 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) psys->flag |= PSYS_CURRENT; } - if(!(G.f & G_PARTICLEEDIT)) { + if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) { if(psys && psys->part->type == PART_HAIR && psys->flag & PSYS_EDITED) { if(psys_check_enabled(ob, psys)) { if(psys->edit==NULL) @@ -3720,12 +3714,12 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) } } - G.f |= G_PARTICLEEDIT; + ob->mode |= OB_MODE_PARTICLE_EDIT; toggle_particle_cursor(C, 1); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL); } else { - G.f &= ~G_PARTICLEEDIT; + ob->mode &= ~OB_MODE_PARTICLE_EDIT; toggle_particle_cursor(C, 0); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); } @@ -3773,7 +3767,7 @@ static int set_editable_exec(bContext *C, wmOperator *op) if(psys_check_enabled(ob, psys)) { psys->flag |= PSYS_EDITED; - if(G.f & G_PARTICLEEDIT) + if(ob->mode & OB_MODE_PARTICLE_EDIT) PE_create_particle_edit(scene, ob, psys); } else @@ -3814,7 +3808,7 @@ void PE_change_act(void *ob_v, void *act_v) psys->flag |= PSYS_CURRENT; if(psys_check_enabled(ob, psys)) { - if(G.f & G_PARTICLEEDIT && !psys->edit) + if(ob->mode & OB_MODE_PARTICLE_EDIT && !psys->edit) PE_create_particle_edit(scene, ob, psys); psys_update_world_cos(ob, psys); } @@ -3832,7 +3826,7 @@ void PE_change_act_psys(Scene *scene, Object *ob, ParticleSystem *psys) psys->flag |= PSYS_CURRENT; if(psys_check_enabled(ob, psys)) { - if(G.f & G_PARTICLEEDIT && !psys->edit) + if(ob->mode & OB_MODE_PARTICLE_EDIT && !psys->edit) PE_create_particle_edit(scene, ob, psys); psys_update_world_cos(ob, psys); diff --git a/source/blender/editors/physics/physics_boids.c b/source/blender/editors/physics/physics_boids.c index 2d3b11080e7..148359068ad 100644 --- a/source/blender/editors/physics/physics_boids.c +++ b/source/blender/editors/physics/physics_boids.c @@ -249,7 +249,6 @@ void BOID_OT_boidrule_move_down(wmOperatorType *ot) /************************ add/del boid state operators *********************/ static int boidstate_add_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; Object *ob= ptr.id.data; @@ -344,7 +343,6 @@ void BOID_OT_boidstate_del(wmOperatorType *ot) /************************ move up/down boid state operators *********************/ static int boidstate_move_up_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; Object *ob = ptr.id.data; @@ -385,7 +383,6 @@ static int boidstate_move_down_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; - Object *ob = ptr.id.data; BoidSettings *boids; BoidState *state; @@ -430,4 +427,4 @@ void ED_operatortypes_boids(void) WM_operatortype_append(BOID_OT_boidstate_del); WM_operatortype_append(BOID_OT_boidstate_move_up); WM_operatortype_append(BOID_OT_boidstate_move_down); -} \ No newline at end of file +} diff --git a/source/blender/editors/preview/previewrender.c b/source/blender/editors/preview/previewrender.c index c5a741b11ed..8fcf65202ee 100644 --- a/source/blender/editors/preview/previewrender.c +++ b/source/blender/editors/preview/previewrender.c @@ -113,6 +113,7 @@ typedef struct ShaderPreview { Scene *scene; ID *id; ID *parent; + MTex *slot; int sizex, sizey; int *pr_rect; @@ -304,7 +305,9 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre end_render_material(mat); /* turn on raytracing if needed */ - if(mat->mode_l & (MA_RAYTRANSP|MA_RAYMIRROR)) + if(mat->mode_l & MA_RAYMIRROR) + sce->r.mode |= R_RAYTRACE; + if((mat->mode_l & MA_RAYTRANSP) && (mat->mode_l & MA_TRANSP)) sce->r.mode |= R_RAYTRACE; if(mat->sss_flag & MA_DIFF_SSS) sce->r.mode |= R_SSS; @@ -362,6 +365,10 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre Material *mat= give_current_material(base->object, base->object->actcol); if(mat && mat->mtex[0]) { mat->mtex[0]->tex= tex; + + if(sp && sp->slot) + mat->mtex[0]->which_output = sp->slot->which_output; + /* show alpha in this case */ if(tex==NULL || (tex->flag & TEX_PRV_ALPHA)) { mat->mtex[0]->mapto |= MAP_ALPHA; @@ -455,13 +462,14 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int return 0; } -void ED_preview_draw(const bContext *C, void *idp, void *parentp, rcti *rect) +void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, rcti *rect) { if(idp) { ScrArea *sa= CTX_wm_area(C); Scene *sce = CTX_data_scene(C); ID *id = (ID *)idp; ID *parent= (ID *)parentp; + MTex *slot= (MTex *)slotp; SpaceButs *sbuts= sa->spacedata.first; rcti newrect; int ok; @@ -489,7 +497,7 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, rcti *rect) } if(ok==0) { - ED_preview_shader_job(C, sa, id, parent, newx, newy); + ED_preview_shader_job(C, sa, id, parent, slot, newx, newy); } } } @@ -930,7 +938,7 @@ static void shader_preview_free(void *customdata) MEM_freeN(sp); } -void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, int sizex, int sizey) +void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, MTex *slot, int sizex, int sizey) { wmJob *steve; ShaderPreview *sp; @@ -950,6 +958,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, i sp->pr_method= PR_DO_RENDER; sp->id = id; sp->parent= parent; + sp->slot= slot; /* setup job */ WM_jobs_customdata(steve, sp, shader_preview_free); diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index 4ed1e59a87f..6861f82ac3f 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -37,11 +37,10 @@ SET(INC ../../windowmanager ../../render/extern/include ../../../../intern/bsp/extern ../../radiosity/extern/include ../../../intern/decimation/extern ../../blenloader - ../../../kernel/gen_system ../../../../intern/SoundSystem ../../readstreamglue + ../../../kernel/gen_system ../../readstreamglue ../../quicktime ../../../../intern/elbeem/extern ../../../../intern/ghost ../../../../intern/opennl/extern ../../nodes - ${SDL_INC} ) IF(WITH_INTERNATIONAL) diff --git a/source/blender/editors/screen/Makefile b/source/blender/editors/screen/Makefile index 923a020afcf..00698917be5 100644 --- a/source/blender/editors/screen/Makefile +++ b/source/blender/editors/screen/Makefile @@ -54,3 +54,8 @@ CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include # own include CPPFLAGS += -I../include + +ifeq ($(WITH_OPENEXR), true) + CPPFLAGS += -DWITH_OPENEXR +endif + diff --git a/source/blender/editors/screen/SConscript b/source/blender/editors/screen/SConscript index 3972efd8eed..a4f73cfea7e 100644 --- a/source/blender/editors/screen/SConscript +++ b/source/blender/editors/screen/SConscript @@ -12,5 +12,7 @@ defs = '' if not env['WITH_BF_PYTHON']: defs += 'DISABLE_PYTHON' +if env['WITH_BF_OPENEXR']: + defs += ' WITH_OPENEXR' env.BlenderLib ( 'bf_editors_screen', sources, Split(incs), Split(defs), libtype=['core'], priority=[105] ) diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 79ba11a5c55..ea1541a4e02 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -499,7 +499,7 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, char edge) /* if more azones on 1 spot, set offset */ for(azt= sa->actionzones.first; azt; azt= azt->next) { if(az!=azt) { - if(az->x1==azt->x1 && az->y1==azt->y1) { + if( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) { if(edge=='t' || edge=='b') { az->x1+= AZONESPOT; az->x2+= AZONESPOT; @@ -1041,39 +1041,43 @@ void ED_area_prevspace(bContext *C) static char *windowtype_pup(void) { return( - "Window type:%t" //14 - "|3D View %x1" //30 + "Window type:%t" + "|3D View %x1" + + "|%l" + "|%l" - "|%l" // 33 + "|Timeline %x15" + "|Graph Editor %x2" + "|DopeSheet %x12" + "|NLA Editor %x13" - "|Graph Editor %x2" //54 - "|DopeSheet %x12" //73 - "|NLA Editor %x13" //94 + "|%l" + "|%l" - "|%l" //97 + "|UV/Image Editor %x6" - "|UV/Image Editor %x6" //117 - - "|Video Sequence Editor %x8" //143 - "|Timeline %x15" //163 - // "|Audio Window %x11" //163 - "|Text Editor %x9" //179 - - "|%l" //192 - - - "|User Preferences %x7" //213 - "|Outliner %x3" //232 - "|Buttons Window %x4" //251 + "|Video Sequence Editor %x8" + "|Text Editor %x9" "|Node Editor %x16" "|Logic Editor %x17" - "|%l" //254 - "|File Browser %x5" //290 + "|%l" + "|%l" - "|%l" //293 + "|Properties %x4" + "|Outliner %x3" + "|User Preferences %x19" + "|Info%x7" + + "|%l" + "|%l" + + "|File Browser %x5" + + "|%l" + "|%l" - // "|Scripts Window %x14"//313 "|Console %x18" ); } @@ -1309,7 +1313,7 @@ void ED_region_header(const bContext *C, ARegion *ar) HeaderType *ht; Header header = {0}; float col[3]; - int xco, yco; + int maxco, xco, yco; /* clear */ if(ED_screen_area_active(C)) @@ -1323,7 +1327,7 @@ void ED_region_header(const bContext *C, ARegion *ar) /* set view2d view matrix for scrolling (without scrollers) */ UI_view2d_view_ortho(C, &ar->v2d); - xco= 8; + xco= maxco= 8; yco= HEADERY-3; /* draw all headers types */ @@ -1335,15 +1339,25 @@ void ED_region_header(const bContext *C, ARegion *ar) header.type= ht; header.layout= layout; ht->draw(C, &header); + + /* for view2d */ + xco= uiLayoutGetWidth(layout); + if(xco > maxco) + maxco= xco; } uiBlockLayoutResolve(C, block, &xco, &yco); + + /* for view2d */ + if(xco > maxco) + maxco= xco; + uiEndBlock(C, block); uiDrawBlock(C, block); } /* always as last */ - UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); + UI_view2d_totRect_set(&ar->v2d, maxco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); /* restore view matrix? */ UI_view2d_view_restore(C); diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 3842dd3d62f..1e36a32b9e1 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -44,6 +44,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bScreen *sc= CTX_wm_screen(C); Scene *scene= sc->scene; Base *base; + Object *ob = NULL; + + if(scene && scene->basact) + ob = scene->basact->object; if(CTX_data_dir(member)) { static const char *dir[] = { @@ -112,32 +116,32 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if(CTX_data_equals(member, "sculpt_object")) { - if(G.f & G_SCULPTMODE && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_SCULPT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "vertex_paint_object")) { - if(G.f & G_VERTEXPAINT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_VERTEX_PAINT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "weight_paint_object")) { - if(G.f & G_WEIGHTPAINT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "texture_paint_object")) { - if(G.f & G_TEXTUREPAINT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_TEXTURE_PAINT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } else if(CTX_data_equals(member, "particle_edit_object")) { - if(G.f & G_PARTICLEEDIT && scene->basact) - CTX_data_id_pointer_set(result, &scene->basact->object->id); + if(ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) + CTX_data_id_pointer_set(result, &ob->id); return 1; } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 926768c98ab..aa36675fb90 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -923,12 +923,6 @@ bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc) newsc= ED_screen_add(win, sc->scene, sc->id.name+2); /* copy all data */ screen_copy(newsc, sc); - /* set in window */ - win->screen= newsc; - - /* store identifier */ - win->screen->winid= win->winid; - BLI_strncpy(win->screenname, win->screen->id.name+2, 21); return newsc; } @@ -1289,6 +1283,49 @@ void ED_screen_set(bContext *C, bScreen *sc) } } +static int ed_screen_used(wmWindowManager *wm, bScreen *sc) +{ + wmWindow *win; + + for(win=wm->windows.first; win; win=win->next) + if(win->screen == sc) + return 1; + + return 0; +} + +/* only call outside of area/region loops */ +void ED_screen_delete(bContext *C, bScreen *sc) +{ + Main *bmain= CTX_data_main(C); + wmWindowManager *wm= CTX_wm_manager(C); + wmWindow *win= CTX_wm_window(C); + bScreen *newsc; + int delete= 1; + + /* screen can only be in use by one window at a time, so as + long as we are able to find a screen that is unused, we + can safely assume ours is not in use anywhere an delete it */ + + for(newsc= sc->id.prev; newsc; newsc=newsc->id.prev) + if(!ed_screen_used(wm, newsc)) + break; + + if(!newsc) { + for(newsc= sc->id.next; newsc; newsc=newsc->id.next) + if(!ed_screen_used(wm, newsc)) + break; + } + + if(!newsc) + return; + + ED_screen_set(C, newsc); + + if(delete && win->screen != sc) + free_libblock(&bmain->screen, sc); +} + /* only call outside of area/region loops */ void ED_screen_set_scene(bContext *C, Scene *scene) { @@ -1346,6 +1383,24 @@ void ED_screen_set_scene(bContext *C, Scene *scene) } +/* only call outside of area/region loops */ +void ED_screen_delete_scene(bContext *C, Scene *scene) +{ + Main *bmain= CTX_data_main(C); + Scene *newscene; + + if(scene->id.prev) + newscene= scene->id.prev; + else if(scene->id.next) + newscene= scene->id.next; + else + return; + + ED_screen_set_scene(C, newscene); + + unlink_scene(bmain, scene, newscene); +} + /* this function toggles: if area is full then the parent will be restored */ void ed_screen_fullarea(bContext *C, ScrArea *sa) { @@ -1461,7 +1516,7 @@ void ED_screen_full_prevspace(bContext *C) /* redraws: uses defines from stime->redraws * enable: 1 - forward on, -1 - backwards on, 0 - off */ -void ED_screen_animation_timer(bContext *C, int redraws, int enable) +void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable) { bScreen *screen= CTX_wm_screen(C); wmWindow *win= CTX_wm_window(C); @@ -1472,12 +1527,13 @@ void ED_screen_animation_timer(bContext *C, int redraws, int enable) screen->animtimer= NULL; if(enable) { - struct ScreenAnimData *sad= MEM_mallocN(sizeof(ScreenAnimData), "ScreenAnimData"); + struct ScreenAnimData *sad= MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData"); screen->animtimer= WM_event_add_window_timer(win, TIMER0, (1.0/FPS)); sad->ar= CTX_wm_region(C); sad->redraws= redraws; - sad->flag= (enable < 0) ? ANIMPLAY_FLAG_REVERSE : 0; + sad->flag |= (enable < 0)? ANIMPLAY_FLAG_REVERSE: 0; + sad->flag |= (sync == 0)? ANIMPLAY_FLAG_NO_SYNC: (sync == 1)? ANIMPLAY_FLAG_SYNC: 0; screen->animtimer->customdata= sad; } @@ -1485,6 +1541,45 @@ void ED_screen_animation_timer(bContext *C, int redraws, int enable) WM_event_add_notifier(C, NC_SCREEN|ND_ANIMPLAY, screen); } +/* helper for screen_animation_play() - only to be used for TimeLine */ +static ARegion *time_top_left_3dwindow(bScreen *screen) +{ + ARegion *aret= NULL; + ScrArea *sa; + int min= 10000; + + for(sa= screen->areabase.first; sa; sa= sa->next) { + if(sa->spacetype==SPACE_VIEW3D) { + ARegion *ar; + for(ar= sa->regionbase.first; ar; ar= ar->next) { + if(ar->regiontype==RGN_TYPE_WINDOW) { + if(ar->winrct.xmin - ar->winrct.ymin < min) { + aret= ar; + min= ar->winrct.xmin - ar->winrct.ymin; + } + } + } + } + } + + return aret; +} + +void ED_screen_animation_timer_update(bContext *C, int redraws) +{ + bScreen *screen= CTX_wm_screen(C); + + if(screen && screen->animtimer) { + wmTimer *wt= screen->animtimer; + ScreenAnimData *sad= wt->customdata; + + sad->redraws= redraws; + sad->ar= NULL; + if(redraws & TIME_REGION) + sad->ar= time_top_left_3dwindow(screen); + } +} + unsigned int ED_screen_view3d_layers(bScreen *screen) { if(screen) { @@ -1503,7 +1598,6 @@ unsigned int ED_screen_view3d_layers(bScreen *screen) /* results in fully updated anim system */ -/* in future sound should be on WM level, only 1 sound can play! */ void ED_update_for_newframe(const bContext *C, int mute) { bScreen *screen= CTX_wm_screen(C); @@ -1515,7 +1609,7 @@ void ED_update_for_newframe(const bContext *C, int mute) /* XXX future: do all windows */ scene_update_for_newframe(scene, ED_screen_view3d_layers(screen)); /* BKE_scene.h */ - //if ( (CFRA>1) && (!mute) && (scene->audio.flag & AUDIO_SCRUB)) + //if ( (CFRA>1) && (!mute) && (scene->r.audio.flag & AUDIO_SCRUB)) // audiostream_scrub( CFRA ); /* 3d window, preview */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index f04e4c5b347..fab4de50568 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -54,8 +54,10 @@ #include "BKE_mesh.h" #include "BKE_multires.h" #include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "BKE_sound.h" #include "WM_api.h" #include "WM_types.h" @@ -230,7 +232,7 @@ int ED_operator_posemode(bContext *C) Object *obedit= CTX_data_edit_object(C); if ((obact != obedit) && (obact) && (obact->type==OB_ARMATURE)) - return (obact->flag & OB_POSEMODE)!=0; + return (obact->mode & OB_MODE_POSE)!=0; return 0; } @@ -1580,7 +1582,6 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot) ot->poll= ED_operator_screenactive; /* rna */ - RNA_def_pointer_runtime(ot->srna, "screen", &RNA_Screen, "Screen", ""); RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX); } @@ -2225,17 +2226,25 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) wmTimer *wt= screen->animtimer; ScreenAnimData *sad= wt->customdata; ScrArea *sa; + int sync; + + /* sync, don't sync, or follow scene setting */ + if(sad->flag & ANIMPLAY_FLAG_SYNC) sync= 1; + else if(sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync= 0; + else sync= (scene->r.audio.flag & AUDIO_SYNC); - if(scene->audio.flag & AUDIO_SYNC) { + if(sync) { + /* skip frames */ int step = floor(wt->duration * FPS); - if (sad->flag & ANIMPLAY_FLAG_REVERSE) // XXX does this option work with audio? + if(sad->flag & ANIMPLAY_FLAG_REVERSE) // XXX does this option work with audio? scene->r.cfra -= step; else scene->r.cfra += step; wt->duration -= ((float)step)/FPS; } else { - if (sad->flag & ANIMPLAY_FLAG_REVERSE) + /* one frame +/- */ + if(sad->flag & ANIMPLAY_FLAG_REVERSE) scene->r.cfra--; else scene->r.cfra++; @@ -2277,7 +2286,9 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) /* since we follow drawflags, we can't send notifier but tag regions ourselves */ ED_update_for_newframe(C, 1); - + + sound_update_playing(C); + for(sa= screen->areabase.first; sa; sa= sa->next) { ARegion *ar; for(ar= sa->regionbase.first; ar; ar= ar->next) { @@ -2311,38 +2322,34 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot) /* ****************** anim player, starts or ends timer ***************** */ -/* helper for screen_animation_play() - only to be used for TimeLine */ -// NOTE: defined in time_header.c for now... -extern ARegion *time_top_left_3dwindow(bScreen *screen); - /* toggle operator */ static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event) { bScreen *screen= CTX_wm_screen(C); if(screen->animtimer) { - ED_screen_animation_timer(C, 0, 0); + ED_screen_animation_timer(C, 0, 0, 0); + sound_stop_all(C); } else { ScrArea *sa= CTX_wm_area(C); int mode= (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1; + int sync= -1; + + if(RNA_property_is_set(op->ptr, "sync")) + sync= (RNA_boolean_get(op->ptr, "sync")); /* timeline gets special treatment since it has it's own menu for determining redraws */ if ((sa) && (sa->spacetype == SPACE_TIME)) { SpaceTime *stime= (SpaceTime *)sa->spacedata.first; - ED_screen_animation_timer(C, stime->redraws, mode); + ED_screen_animation_timer(C, stime->redraws, sync, mode); /* update region if TIME_REGION was set, to leftmost 3d window */ - if(screen->animtimer && (stime->redraws & TIME_REGION)) { - wmTimer *wt= screen->animtimer; - ScreenAnimData *sad= wt->customdata; - - sad->ar= time_top_left_3dwindow(screen); - } + ED_screen_animation_timer_update(C, stime->redraws); } else { - ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, mode); + ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, sync, mode); if(screen->animtimer) { wmTimer *wt= screen->animtimer; @@ -2368,6 +2375,7 @@ static void SCREEN_OT_animation_play(wmOperatorType *ot) ot->poll= ED_operator_screenactive; RNA_def_boolean(ot->srna, "reverse", 0, "Play in Reverse", "Animation is played backwards"); + RNA_def_boolean(ot->srna, "sync", 0, "Sync", "Drop frames to maintain framerate and stay in sync with audio."); } /* ************** border select operator (template) ***************************** */ @@ -2876,10 +2884,13 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) RenderJob *rj; Image *ima; - /* only one job at a time */ + /* only one render job at a time */ if(WM_jobs_test(CTX_wm_manager(C), scene)) return OPERATOR_CANCELLED; + /* stop all running jobs, currently previews frustrate Render */ + WM_jobs_stop_all(CTX_wm_manager(C)); + /* handle UI stuff */ WM_cursor_wait(1); @@ -3083,7 +3094,124 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot) ot->poll= ED_operator_screenactive; } +/********************* new screen operator *********************/ +static int screen_new_exec(bContext *C, wmOperator *op) +{ + wmWindow *win= CTX_wm_window(C); + bScreen *sc= CTX_wm_screen(C); + + sc= ED_screen_duplicate(win, sc); + WM_event_add_notifier(C, NC_SCREEN|ND_SCREENBROWSE, sc); + + return OPERATOR_FINISHED; +} + +void SCREEN_OT_new(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "New Screen"; + ot->idname= "SCREEN_OT_new"; + + /* api callbacks */ + ot->exec= screen_new_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/********************* delete screen operator *********************/ + +static int screen_delete_exec(bContext *C, wmOperator *op) +{ + bScreen *sc= CTX_wm_screen(C); + + WM_event_add_notifier(C, NC_SCREEN|ND_SCREENDELETE, sc); + + return OPERATOR_FINISHED; +} + +void SCREEN_OT_delete(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Delete Scene"; + ot->idname= "SCREEN_OT_delete"; + + /* api callbacks */ + ot->exec= screen_delete_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/********************* new scene operator *********************/ + +static int scene_new_exec(bContext *C, wmOperator *op) +{ + Scene *newscene, *scene= CTX_data_scene(C); + Main *bmain= CTX_data_main(C); + int type= RNA_enum_get(op->ptr, "type"); + + newscene= copy_scene(bmain, scene, type); + + /* these can't be handled in blenkernel curently, so do them here */ + if(type == SCE_COPY_LINK_DATA) + ED_object_single_users(newscene, 0); + else if(type == SCE_COPY_FULL) + ED_object_single_users(newscene, 1); + + WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_new(wmOperatorType *ot) +{ + static EnumPropertyItem type_items[]= { + {SCE_COPY_EMPTY, "EMPTY", 0, "Empty", "Add empty scene."}, + {SCE_COPY_LINK_OB, "LINK_OBJECTS", 0, "Link Objects", "Link to the objects from the current scene."}, + {SCE_COPY_LINK_DATA, "LINK_OBJECT_DATA", 0, "Link Object Data", "Copy objects linked to data from the current scene."}, + {SCE_COPY_FULL, "FULL_COPY", 0, "Full Copy", "Make a full copy of the current scene."}, + {0, NULL, 0, NULL, NULL}}; + + /* identifiers */ + ot->name= "New Scene"; + ot->idname= "SCENE_OT_new"; + + /* api callbacks */ + ot->exec= scene_new_exec; + ot->invoke= WM_menu_invoke; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); +} + +/********************* delete scene operator *********************/ + +static int scene_delete_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + + WM_event_add_notifier(C, NC_SCENE|ND_SCENEDELETE, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_delete(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Delete Scene"; + ot->idname= "SCENE_OT_delete"; + + /* api callbacks */ + ot->exec= scene_delete_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} /* **************** Assigning operatortypes to global list, adding handlers **************** */ @@ -3125,6 +3253,12 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_render_view_cancel); WM_operatortype_append(SCREEN_OT_render_view_show); + /* new/delete */ + WM_operatortype_append(SCREEN_OT_new); + WM_operatortype_append(SCREEN_OT_delete); + WM_operatortype_append(SCENE_OT_new); + WM_operatortype_append(SCENE_OT_delete); + /* tools shared by more space types */ WM_operatortype_append(ED_OT_undo); WM_operatortype_append(ED_OT_redo); @@ -3235,6 +3369,7 @@ void ED_keymap_screen(wmWindowManager *wm) /* play (forward and backwards) */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", KKEY, KM_PRESS, 0, LKEY); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "reverse", 1); keymap_modal_set(wm); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 2ae2712d02d..5ae1bdf84aa 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -228,7 +228,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update) rd.frs_sec_base= 1.0f; if(BKE_imtype_is_movie(rd.imtype)) - mh->start_movie(&rd, sj->dumpsx, sj->dumpsy); + mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy); else mh= NULL; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 48e07b7a489..465aa281e25 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -71,6 +71,7 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_node.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_report.h" @@ -4023,7 +4024,7 @@ static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, s if(texpaint || (sima && sima->lock)) { int w = imapaintpartial.x2 - imapaintpartial.x1; int h = imapaintpartial.y2 - imapaintpartial.y1; - GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h); + GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h, !texpaint); } } @@ -4375,15 +4376,17 @@ static Brush *image_paint_brush(bContext *C) Scene *scene= CTX_data_scene(C); ToolSettings *settings= scene->toolsettings; - return settings->imapaint.brush; + return paint_brush(&settings->imapaint.paint); } static int image_paint_poll(bContext *C) { + Object *obact = CTX_data_active_object(C); + if(!image_paint_brush(C)) return 0; - if((G.f & G_TEXTUREPAINT) && CTX_wm_region_view3d(C)) { + if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) { return 1; } else { @@ -4484,11 +4487,12 @@ static void paint_redraw(bContext *C, ImagePaintState *s, int final) } } -static int paint_init(bContext *C, wmOperator *op) +static int texture_paint_init(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); ToolSettings *settings= scene->toolsettings; PaintOperation *pop; + Brush *brush; pop= MEM_callocN(sizeof(PaintOperation), "PaintOperation"); pop->first= 1; @@ -4516,10 +4520,11 @@ static int paint_init(bContext *C, wmOperator *op) pop->ps.ar= CTX_wm_region(C); /* intialize brush */ - if(!settings->imapaint.brush) + brush= paint_brush(&settings->imapaint.paint); + if(!brush) return 0; - pop->s.brush = settings->imapaint.brush; + pop->s.brush = brush; pop->s.tool = settings->imapaint.tool; if(pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE)) pop->s.tool = PAINT_TOOL_DRAW; @@ -4607,11 +4612,13 @@ static int paint_init(bContext *C, wmOperator *op) static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) { PaintOperation *pop= op->customdata; - float time; + float time, mousef[2]; float pressure; int mouse[2], redraw; - RNA_int_get_array(itemptr, "mouse", mouse); + RNA_float_get_array(itemptr, "mouse", mousef); + mouse[0] = mousef[0]; + mouse[1] = mousef[1]; time= RNA_float_get(itemptr, "time"); pressure= RNA_float_get(itemptr, "pressure"); @@ -4670,7 +4677,7 @@ static void paint_exit(bContext *C, wmOperator *op) static int paint_exec(bContext *C, wmOperator *op) { - if(!paint_init(C, op)) { + if(!texture_paint_init(C, op)) { MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -4691,7 +4698,7 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) PaintOperation *pop= op->customdata; wmTabletData *wmtab; PointerRNA itemptr; - float pressure; + float pressure, mousef[2]; double time; int tablet, mouse[2]; @@ -4732,7 +4739,9 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) /* fill in stroke */ RNA_collection_add(op->ptr, "stroke", &itemptr); - RNA_int_set_array(&itemptr, "mouse", mouse); + mousef[0] = mouse[0]; + mousef[1] = mouse[1]; + RNA_float_set_array(&itemptr, "mouse", mousef); RNA_float_set(&itemptr, "time", (float)(time - pop->starttime)); RNA_float_set(&itemptr, "pressure", pressure); @@ -4744,7 +4753,7 @@ static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event) { PaintOperation *pop; - if(!paint_init(C, op)) { + if(!texture_paint_init(C, op)) { MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -4872,7 +4881,7 @@ static int paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *eve ToolSettings *ts = CTX_data_scene(C)->toolsettings; get_imapaint_zoom(C, &zoom, &zoom); toggle_paint_cursor(C, !ts->imapaint.paintcursor); - brush_radial_control_invoke(op, ts->imapaint.brush, 0.5 * zoom); + brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 0.5 * zoom); return WM_radial_control_invoke(C, op, event); } @@ -4891,7 +4900,7 @@ static int paint_radial_control_exec(bContext *C, wmOperator *op) int ret; char str[256]; get_imapaint_zoom(C, &zoom, &zoom); - ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->imapaint.brush, 2.0 / zoom); + ret = brush_radial_control_exec(op, paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint), 2.0 / zoom); WM_radial_control_string(op, str, 256); return ret; @@ -5144,13 +5153,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) me= get_mesh(ob); - if(!(G.f & G_TEXTUREPAINT) && !me) { + if(!(ob->mode & OB_MODE_TEXTURE_PAINT) && !me) { BKE_report(op->reports, RPT_ERROR, "Can only enter texture paint mode for mesh objects."); return OPERATOR_CANCELLED; } - if(G.f & G_TEXTUREPAINT) { - G.f &= ~G_TEXTUREPAINT; + if(ob->mode & OB_MODE_TEXTURE_PAINT) { + ob->mode &= ~OB_MODE_TEXTURE_PAINT; if(U.glreslimit != 0) GPU_free_images(); @@ -5159,13 +5168,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) toggle_paint_cursor(C, 0); } else { - G.f |= G_TEXTUREPAINT; + ob->mode |= OB_MODE_TEXTURE_PAINT; if(me->mtface==NULL) me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface); - brush_check_exists(&scene->toolsettings->imapaint.brush); + paint_init(&scene->toolsettings->imapaint.paint, "Brush"); if(U.glreslimit != 0) GPU_free_images(); @@ -5200,13 +5209,13 @@ static int texture_paint_radial_control_invoke(bContext *C, wmOperator *op, wmEv { ToolSettings *ts = CTX_data_scene(C)->toolsettings; toggle_paint_cursor(C, !ts->imapaint.paintcursor); - brush_radial_control_invoke(op, ts->imapaint.brush, 0.5); + brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 0.5); return WM_radial_control_invoke(C, op, event); } static int texture_paint_radial_control_exec(bContext *C, wmOperator *op) { - int ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->imapaint.brush, 2); + int ret = brush_radial_control_exec(op, paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint), 2); char str[256]; WM_radial_control_string(op, str, 256); @@ -5216,7 +5225,7 @@ static int texture_paint_radial_control_exec(bContext *C, wmOperator *op) static int texture_paint_poll(bContext *C) { if(texture_paint_toggle_poll(C)) - if(G.f & G_TEXTUREPAINT) + if(CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT) return 1; return 0; diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index b630975c934..40423e17fe4 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -59,6 +59,7 @@ int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsig void imapaint_pick_uv(struct Scene *scene, struct Object *ob, struct Mesh *mesh, unsigned int faceindex, int *xy, float *uv); void paint_sample_color(struct Scene *scene, struct ARegion *ar, int x, int y); +void BRUSH_OT_curve_preset(struct wmOperatorType *ot); #endif /* ED_PAINT_INTERN_H */ diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index e9263ddabf0..63a6591d057 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -1,15 +1,96 @@ +/** + * + * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "DNA_brush_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_brush.h" +#include "BKE_context.h" +#include "BKE_paint.h" #include "ED_sculpt.h" +#include "UI_resources.h" #include "WM_api.h" #include "WM_types.h" +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + #include "paint_intern.h" +#include + +/* Brush operators */ +static int brush_add_exec(bContext *C, wmOperator *op) +{ + /*int type = RNA_enum_get(op->ptr, "type");*/ + Brush *br = NULL; + + br = add_brush("Brush"); + + if(br) + paint_brush_set(paint_get_active(CTX_data_scene(C)), br); + + return OPERATOR_FINISHED; +} + +static EnumPropertyItem brush_type_items[] = { + {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""}, + {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""}, + {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""}, + {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""}, + {0, NULL, 0, NULL, NULL}}; + +void BRUSH_OT_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Brush"; + ot->idname= "BRUSH_OT_add"; + + /* api callbacks */ + ot->exec= brush_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_enum(ot->srna, "type", brush_type_items, OB_MODE_VERTEX_PAINT, "Type", "Which paint mode to create the brush for."); +} + +/* Paint operators */ +static int paint_poll(bContext *C) +{ + return !!paint_get_active(CTX_data_scene(C)); +} + /**************************** registration **********************************/ void ED_operatortypes_paint(void) { + /* brush */ + WM_operatortype_append(BRUSH_OT_add); + WM_operatortype_append(BRUSH_OT_curve_preset); + /* image */ WM_operatortype_append(PAINT_OT_texture_paint_toggle); WM_operatortype_append(PAINT_OT_texture_paint_radial_control); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 85ea55331dc..23bc119afb4 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -5,21 +5,31 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" + #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_view3d_types.h" +#include "RNA_access.h" +#include "RNA_define.h" + #include "BLI_arithb.h" #include "BKE_brush.h" +#include "BKE_context.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" +#include "BKE_paint.h" + #include "BKE_utildefines.h" #include "BIF_gl.h" #include "ED_view3d.h" +#include "WM_api.h" +#include "WM_types.h" + #include "paint_intern.h" /* 3D Paint */ @@ -160,7 +170,7 @@ int imapaint_pick_face(ViewContext *vc, Mesh *me, int *mval, unsigned int *index /* used for both 3d view and image window */ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */ { - Brush **br = current_brush_source(scene); + Brush *br = paint_brush(paint_get_active(scene)); unsigned int col; char *cp; @@ -173,10 +183,43 @@ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */ cp = (char *)&col; - if(br && *br) { - (*br)->rgb[0]= cp[0]/255.0f; - (*br)->rgb[1]= cp[1]/255.0f; - (*br)->rgb[2]= cp[2]/255.0f; + if(br) { + br->rgb[0]= cp[0]/255.0f; + br->rgb[1]= cp[1]/255.0f; + br->rgb[2]= cp[2]/255.0f; } } +static int brush_curve_preset_exec(bContext *C, wmOperator *op) +{ + Brush *br = paint_brush(paint_get_active(CTX_data_scene(C))); + brush_curve_preset(br, RNA_enum_get(op->ptr, "shape")); + + return OPERATOR_FINISHED; +} + +static int brush_curve_preset_poll(bContext *C) +{ + Brush *br = paint_brush(paint_get_active(CTX_data_scene(C))); + + return br && br->curve; +} + +void BRUSH_OT_curve_preset(wmOperatorType *ot) +{ + static EnumPropertyItem prop_shape_items[] = { + {BRUSH_PRESET_SHARP, "SHARP", 0, "Sharp", ""}, + {BRUSH_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {BRUSH_PRESET_MAX, "MAX", 0, "Max", ""}, + {0, NULL, 0, NULL, NULL}}; + + ot->name= "Preset"; + ot->idname= "BRUSH_OT_curve_preset"; + + ot->exec= brush_curve_preset_exec; + ot->poll= brush_curve_preset_poll; + + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_enum(ot->srna, "shape", prop_shape_items, BRUSH_PRESET_SHARP, "Mode", ""); +} diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 812c41f430e..1a548708ec8 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -76,6 +76,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" #include "WM_api.h" @@ -108,7 +109,10 @@ static void error() {} static int vp_poll(bContext *C) { - if(G.f & G_VERTEXPAINT) { + Object *ob = CTX_data_active_object(C); + + if(ob && ob->mode & OB_MODE_VERTEX_PAINT && + paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) { ScrArea *sa= CTX_wm_area(C); if(sa->spacetype==SPACE_VIEW3D) { ARegion *ar= CTX_wm_region(C); @@ -121,7 +125,10 @@ static int vp_poll(bContext *C) static int wp_poll(bContext *C) { - if(G.f & G_WEIGHTPAINT) { + Object *ob = CTX_data_active_object(C); + + if(ob && ob->mode & OB_MODE_WEIGHT_PAINT && + paint_brush(&CTX_data_tool_settings(C)->wpaint->paint)) { ScrArea *sa= CTX_wm_area(C); if(sa->spacetype==SPACE_VIEW3D) { ARegion *ar= CTX_wm_region(C); @@ -136,14 +143,14 @@ static int wp_poll(bContext *C) /* Cursors */ static void vp_drawcursor(bContext *C, int x, int y, void *customdata) { - ToolSettings *ts= CTX_data_tool_settings(C); + Brush *brush = paint_brush(&CTX_data_tool_settings(C)->vpaint->paint); glTranslatef((float)x, (float)y, 0.0f); glColor4ub(255, 255, 255, 128); glEnable( GL_LINE_SMOOTH ); glEnable(GL_BLEND); - glutil_draw_lined_arc(0.0, M_PI*2.0, ts->vpaint->brush->size, 40); + glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40); glDisable(GL_BLEND); glDisable( GL_LINE_SMOOTH ); @@ -152,14 +159,14 @@ static void vp_drawcursor(bContext *C, int x, int y, void *customdata) static void wp_drawcursor(bContext *C, int x, int y, void *customdata) { - ToolSettings *ts= CTX_data_tool_settings(C); - + Brush *brush = paint_brush(&CTX_data_tool_settings(C)->wpaint->paint); + glTranslatef((float)x, (float)y, 0.0f); glColor4ub(200, 200, 255, 128); glEnable( GL_LINE_SMOOTH ); glEnable(GL_BLEND); - glutil_draw_lined_arc(0.0, M_PI*2.0, ts->wpaint->brush->size, 40); + glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40); glDisable(GL_BLEND); glDisable( GL_LINE_SMOOTH ); @@ -232,7 +239,8 @@ unsigned int rgba_to_mcol(float r, float g, float b, float a) static unsigned int vpaint_get_current_col(VPaint *vp) { - return rgba_to_mcol(vp->brush->rgb[0], vp->brush->rgb[1], vp->brush->rgb[2], 1.0f); + Brush *brush = paint_brush(&vp->paint); + return rgba_to_mcol(brush->rgb[0], brush->rgb[1], brush->rgb[2], 1.0f); } void do_shared_vertexcol(Mesh *me) @@ -369,12 +377,12 @@ void clear_vpaint(Scene *scene) unsigned int *to, paintcol; int a; - if((G.f & G_VERTEXPAINT)==0) return; - ob= OBACT; me= get_mesh(ob); if(!ob || ob->id.lib) return; + if(!(ob->mode & OB_MODE_VERTEX_PAINT)) return; + if(me==0 || me->mcol==0 || me->totface==0) return; paintcol= vpaint_get_current_col(scene->toolsettings->vpaint); @@ -540,10 +548,10 @@ void vpaint_dogamma(Scene *scene) int a, temp; unsigned char *cp, gamtab[256]; - if((G.f & G_VERTEXPAINT)==0) return; - ob= OBACT; me= get_mesh(ob); + + if(!(ob->mode & OB_MODE_VERTEX_PAINT)) return; if(me==0 || me->mcol==0 || me->totface==0) return; igam= 1.0/vp->gamma; @@ -721,6 +729,7 @@ static unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac) static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, unsigned int paintcol, int alpha) { + Brush *brush = paint_brush(&vp->paint); if(vp->mode==VP_MIX || vp->mode==VP_BLUR) *col= mcol_blend( *col, paintcol, alpha); else if(vp->mode==VP_ADD) *col= mcol_add( *col, paintcol, alpha); @@ -734,7 +743,7 @@ static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, u unsigned int testcol=0, a; char *cp, *ct, *co; - alpha= (int)(255.0*vp->brush->alpha); + alpha= (int)(255.0*brush->alpha); if(vp->mode==VP_MIX || vp->mode==VP_BLUR) testcol= mcol_blend( *colorig, paintcol, alpha); else if(vp->mode==VP_ADD) testcol= mcol_add( *colorig, paintcol, alpha); @@ -800,6 +809,7 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], float *vert_nor, short *mval) { + Brush *brush = paint_brush(&vp->paint); float fac, dx, dy; int alpha; short vertco[2]; @@ -810,14 +820,14 @@ static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], floa dy= mval[1]-vertco[1]; fac= sqrt(dx*dx + dy*dy); - if(fac > vp->brush->size) return 0; + if(fac > brush->size) return 0; if(vp->flag & VP_HARD) alpha= 255; else - alpha= 255.0*vp->brush->alpha*(1.0-fac/vp->brush->size); + alpha= 255.0*brush->alpha*(1.0-fac/brush->size); } else { - alpha= 255.0*vp->brush->alpha; + alpha= 255.0*brush->alpha; } if(vp->flag & VP_NORMALS) { @@ -839,6 +849,7 @@ static int calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], floa static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float alpha, float paintval) { + Brush *brush = paint_brush(&wp->paint); if(dw==NULL || uw==NULL) return; @@ -864,7 +875,7 @@ static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float if((wp->flag & VP_SPRAY)==0) { float testw=0.0f; - alpha= wp->brush->alpha; + alpha= brush->alpha; if(wp->mode==VP_MIX || wp->mode==VP_BLUR) testw = paintval*alpha + uw->weight*(1.0-alpha); else if(wp->mode==VP_ADD) @@ -1092,12 +1103,12 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */ if(me && me->totface>=MAXINDEX) { error("Maximum number of faces: %d", MAXINDEX-1); - G.f &= ~G_WEIGHTPAINT; + ob->mode &= ~OB_MODE_WEIGHT_PAINT; return OPERATOR_CANCELLED; } - if(G.f & G_WEIGHTPAINT) G.f &= ~G_WEIGHTPAINT; - else G.f |= G_WEIGHTPAINT; + if(ob->mode & OB_MODE_WEIGHT_PAINT) ob->mode &= ~OB_MODE_WEIGHT_PAINT; + else ob->mode |= OB_MODE_WEIGHT_PAINT; /* Weightpaint works by overriding colors in mesh, @@ -1107,21 +1118,21 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */ */ DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - if(G.f & G_WEIGHTPAINT) { + if(ob->mode & OB_MODE_WEIGHT_PAINT) { Object *par; if(wp==NULL) wp= scene->toolsettings->wpaint= new_vpaint(1); - brush_check_exists(&wp->brush); - + paint_init(&wp->paint, "Brush"); + toggle_paint_cursor(C, 1); mesh_octree_table(ob, NULL, NULL, 's'); /* verify if active weight group is also active bone */ par= modifiers_isDeformedByArmature(ob); - if(par && (par->flag & OB_POSEMODE)) { + if(par && (par->mode & OB_MODE_POSE)) { bPoseChannel *pchan; for(pchan= par->pose->chanbase.first; pchan; pchan= pchan->next) if(pchan->bone->flag & BONE_ACTIVE) @@ -1174,8 +1185,10 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) static int vpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { + Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->vpaint->paint); + toggle_paint_cursor(C, 0); - brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->vpaint->brush, 1); + brush_radial_control_invoke(op, brush, 1); return WM_radial_control_invoke(C, op, event); } @@ -1189,13 +1202,15 @@ static int vpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve static int vpaint_radial_control_exec(bContext *C, wmOperator *op) { - return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->vpaint->brush, 1); + Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->vpaint->paint); + return brush_radial_control_exec(op, brush, 1); } static int wpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { + Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->wpaint->paint); toggle_paint_cursor(C, 1); - brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->wpaint->brush, 1); + brush_radial_control_invoke(op, brush, 1); return WM_radial_control_invoke(C, op, event); } @@ -1209,7 +1224,8 @@ static int wpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve static int wpaint_radial_control_exec(bContext *C, wmOperator *op) { - return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->wpaint->brush, 1); + Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->wpaint->paint); + return brush_radial_control_exec(op, brush, 1); } void PAINT_OT_weight_paint_radial_control(wmOperatorType *ot) @@ -1293,6 +1309,7 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event) { ToolSettings *ts= CTX_data_tool_settings(C); VPaint *wp= ts->wpaint; + Brush *brush = paint_brush(&wp->paint); switch(event->type) { case LEFTMOUSE: @@ -1328,7 +1345,7 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event) /* which faces are involved */ if(wp->flag & VP_AREA) { - totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], wp->brush->size); + totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush->size); } else { indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); @@ -1584,22 +1601,22 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ me= get_mesh(ob); if(me==NULL || object_data_is_libdata(ob)) { - G.f &= ~G_VERTEXPAINT; + ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_PASS_THROUGH; } if(me && me->totface>=MAXINDEX) { error("Maximum number of faces: %d", MAXINDEX-1); - G.f &= ~G_VERTEXPAINT; + ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_FINISHED; } if(me && me->mcol==NULL) make_vertexcol(scene, 0); /* toggle: end vpaint */ - if(G.f & G_VERTEXPAINT) { + if(ob->mode & OB_MODE_VERTEX_PAINT) { - G.f &= ~G_VERTEXPAINT; + ob->mode &= ~OB_MODE_VERTEX_PAINT; if(vp) { toggle_paint_cursor(C, 0); @@ -1607,17 +1624,17 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ } } else { - - G.f |= G_VERTEXPAINT; + ob->mode |= OB_MODE_VERTEX_PAINT; /* Turn off weight painting */ - if (G.f & G_WEIGHTPAINT) + if (ob->mode & OB_MODE_WEIGHT_PAINT) set_wpaint(C, op); if(vp==NULL) vp= scene->toolsettings->vpaint= new_vpaint(0); toggle_paint_cursor(C, 0); - brush_check_exists(&scene->toolsettings->vpaint->brush); + + paint_init(&vp->paint, "Brush"); } if (me) @@ -1696,6 +1713,7 @@ static int vpaint_modal(bContext *C, wmOperator *op, wmEvent *event) { ToolSettings *ts= CTX_data_tool_settings(C); VPaint *vp= ts->vpaint; + Brush *brush = paint_brush(&vp->paint); switch(event->type) { case LEFTMOUSE: @@ -1728,7 +1746,7 @@ static int vpaint_modal(bContext *C, wmOperator *op, wmEvent *event) /* which faces are involved */ if(vp->flag & VP_AREA) { - totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], vp->brush->size); + totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush->size); } else { indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index b1dcef39eee..f7f72d611dc 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -64,6 +64,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_multires.h" +#include "BKE_paint.h" #include "BKE_sculpt.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -124,19 +125,20 @@ typedef enum StrokeFlags { */ typedef struct StrokeCache { /* Invariants */ - float radius; + float initial_radius; float scale[3]; int flag; float clip_tolerance[3]; - int initial_mouse[2]; + float initial_mouse[2]; float depth; /* Variants */ + float radius; float true_location[3]; float location[3]; float flip; float pressure; - int mouse[2]; + float mouse[2]; /* The rest is temporary storage that isn't saved as a property */ @@ -145,8 +147,6 @@ typedef struct StrokeCache { ViewContext vc; bglMats *mats; - float *layer_disps; /* Displacements for each vertex */ - float (*mesh_store)[3]; /* Copy of the mesh vertices' locations */ short (*orig_norms)[3]; /* Copy of the mesh vertices' normals */ float (*face_norms)[3]; /* Copy of the mesh faces' normals */ float rotation; /* Texture rotation (radians) for anchored and rake modes */ @@ -215,36 +215,23 @@ static void project(bglMats *mats, const float v[3], short p[2]) * */ -/* Return modified brush size. Uses current tablet pressure (if available) to - shrink the brush. Skipped for grab brush because only the first mouse down - size is used, which is small if the user has just touched the pen to the - tablet */ -static char brush_size(Sculpt *sd) -{ - float size= sd->brush->size; - - if((sd->brush->sculpt_tool != SCULPT_TOOL_GRAB) && (sd->brush->flag & BRUSH_SIZE_PRESSURE)) - size *= sd->session->cache->pressure; - - return size; -} - /* Return modified brush strength. Includes the direction of the brush, positive values pull vertices, negative values push. Uses tablet pressure and a special multiplier found experimentally to scale the strength factor. */ static float brush_strength(Sculpt *sd, StrokeCache *cache) { + Brush *brush = paint_brush(&sd->paint); /* Primary strength input; square it to make lower values more sensitive */ - float alpha = sd->brush->alpha * sd->brush->alpha; + float alpha = brush->alpha * brush->alpha; - float dir= sd->brush->flag & BRUSH_DIR_IN ? -1 : 1; + float dir= brush->flag & BRUSH_DIR_IN ? -1 : 1; float pressure= 1; float flip= cache->flip ? -1:1; - if(sd->brush->flag & BRUSH_ALPHA_PRESSURE) + if(brush->flag & BRUSH_ALPHA_PRESSURE) pressure *= cache->pressure; - switch(sd->brush->sculpt_tool){ + switch(brush->sculpt_tool){ case SCULPT_TOOL_DRAW: case SCULPT_TOOL_INFLATE: case SCULPT_TOOL_CLAY: @@ -263,7 +250,7 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache) } /* Handles clipping against a mirror modifier and SCULPT_LOCK axis flags */ -static void sculpt_clip(Sculpt *sd, float *co, const float val[3]) +static void sculpt_clip(Sculpt *sd, SculptSession *ss, float *co, const float val[3]) { int i; @@ -271,7 +258,7 @@ static void sculpt_clip(Sculpt *sd, float *co, const float val[3]) if(sd->flags & (SCULPT_LOCK_X << i)) continue; - if((sd->session->cache->flag & (CLIP_X << i)) && (fabs(co[i]) <= sd->session->cache->clip_tolerance[i])) + if((ss->cache->flag & (CLIP_X << i)) && (fabs(co[i]) <= ss->cache->clip_tolerance[i])) co[i]= 0.0f; else co[i]= val[i]; @@ -293,23 +280,24 @@ static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], cons /* Currently only for the draw brush; finds average normal for all active vertices */ -static void calc_area_normal(Sculpt *sd, float out[3], const ListBase* active_verts) +static void calc_area_normal(Sculpt *sd, SculptSession *ss, float out[3], const ListBase* active_verts) { - StrokeCache *cache = sd->session->cache; + Brush *brush = paint_brush(&sd->paint); + StrokeCache *cache = ss->cache; ActiveData *node = active_verts->first; - const int view = 0; /* XXX: should probably be a flag, not number: sd->brush_type==SCULPT_TOOL_DRAW ? sculptmode_brush()->view : 0; */ + const int view = 0; /* XXX: should probably be a flag, not number: brush_type==SCULPT_TOOL_DRAW ? sculptmode_brush()->view : 0; */ float out_flip[3]; float *out_dir = cache->view_normal_symmetry; out[0]=out[1]=out[2] = out_flip[0]=out_flip[1]=out_flip[2] = 0; - if(sd->brush->flag & BRUSH_ANCHORED) { + if(brush->flag & BRUSH_ANCHORED) { for(; node; node = node->next) add_norm_if(out_dir, out, out_flip, cache->orig_norms[node->Index]); } else { for(; node; node = node->next) - add_norm_if(out_dir, out, out_flip, sd->session->mvert[node->Index].no); + add_norm_if(out_dir, out, out_flip, ss->mvert[node->Index].no); } if (out[0]==0.0 && out[1]==0.0 && out[2]==0.0) { @@ -332,7 +320,7 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_ float area_normal[3]; ActiveData *node= active_verts->first; - calc_area_normal(sd, area_normal, active_verts); + calc_area_normal(sd, ss, area_normal, active_verts); while(node){ float *co= ss->mvert[node->Index].co; @@ -341,7 +329,7 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_ co[1]+area_normal[1]*ss->cache->radius*node->Fade*ss->cache->scale[1], co[2]+area_normal[2]*ss->cache->radius*node->Fade*ss->cache->scale[2]}; - sculpt_clip(sd, co, val); + sculpt_clip(sd, ss, co, val); node= node->next; } @@ -391,37 +379,37 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert) VecCopyf(avg, ss->mvert[vert].co); } -static void do_smooth_brush(Sculpt *s, const ListBase* active_verts) +static void do_smooth_brush(Sculpt *s, SculptSession *ss, const ListBase* active_verts) { ActiveData *node= active_verts->first; int i; for(i = 0; i < 2; ++i) { while(node){ - float *co= s->session->mvert[node->Index].co; + float *co= ss->mvert[node->Index].co; float avg[3], val[3]; - neighbor_average(s->session, avg, node->Index); + neighbor_average(ss, avg, node->Index); val[0] = co[0]+(avg[0]-co[0])*node->Fade; val[1] = co[1]+(avg[1]-co[1])*node->Fade; val[2] = co[2]+(avg[2]-co[2])*node->Fade; - sculpt_clip(s, co, val); + sculpt_clip(s, ss, co, val); node= node->next; } } } -static void do_pinch_brush(Sculpt *s, const ListBase* active_verts) +static void do_pinch_brush(Sculpt *s, SculptSession *ss, const ListBase* active_verts) { ActiveData *node= active_verts->first; while(node) { - float *co= s->session->mvert[node->Index].co; - const float val[3]= {co[0]+(s->session->cache->location[0]-co[0])*node->Fade, - co[1]+(s->session->cache->location[1]-co[1])*node->Fade, - co[2]+(s->session->cache->location[2]-co[2])*node->Fade}; - sculpt_clip(s, co, val); + float *co= ss->mvert[node->Index].co; + const float val[3]= {co[0]+(ss->cache->location[0]-co[0])*node->Fade, + co[1]+(ss->cache->location[1]-co[1])*node->Fade, + co[2]+(ss->cache->location[2]-co[2])*node->Fade}; + sculpt_clip(s, ss, co, val); node= node->next; } } @@ -440,7 +428,7 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss) VecCopyf(add, grab_delta); VecMulf(add, node->Fade); VecAddf(add, add, co); - sculpt_clip(sd, co, add); + sculpt_clip(sd, ss, co, add); node= node->next; } @@ -456,10 +444,10 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active if(ss->cache->flip) lim = -lim; - calc_area_normal(sd, area_normal, active_verts); + calc_area_normal(sd, ss, area_normal, active_verts); while(node){ - float *disp= &ss->cache->layer_disps[node->Index]; + float *disp= &ss->layer_disps[node->Index]; float *co= ss->mvert[node->Index].co; float val[3]; @@ -469,20 +457,19 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active if((lim < 0 && *disp < lim) || (lim > 0 && *disp > lim)) *disp = lim; - val[0] = ss->cache->mesh_store[node->Index][0]+area_normal[0] * *disp*ss->cache->scale[0]; - val[1] = ss->cache->mesh_store[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1]; - val[2] = ss->cache->mesh_store[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2]; + val[0] = ss->mesh_co_orig[node->Index][0]+area_normal[0] * *disp*ss->cache->scale[0]; + val[1] = ss->mesh_co_orig[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1]; + val[2] = ss->mesh_co_orig[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2]; - sculpt_clip(sd, co, val); + sculpt_clip(sd, ss, co, val); node= node->next; } } -static void do_inflate_brush(Sculpt *s, const ListBase *active_verts) +static void do_inflate_brush(Sculpt *s, SculptSession *ss, const ListBase *active_verts) { ActiveData *node= active_verts->first; - SculptSession *ss = s->session; float add[3]; while(node) { @@ -498,7 +485,7 @@ static void do_inflate_brush(Sculpt *s, const ListBase *active_verts) add[2]*= ss->cache->scale[2]; VecAddf(add, add, co); - sculpt_clip(s, co, add); + sculpt_clip(s, ss, co, add); node= node->next; } @@ -527,46 +514,86 @@ static void calc_flatten_center(SculptSession *ss, ActiveData *node, float co[3] VecMulf(co, 1.0f / FLATTEN_SAMPLE_SIZE); } +/* Projects a point onto a plane along the plane's normal */ +static void point_plane_project(float intr[3], float co[3], float plane_normal[3], float plane_center[3]) +{ + float p1[3], sub1[3], sub2[3]; + + /* Find the intersection between squash-plane and vertex (along the area normal) */ + VecSubf(p1, co, plane_normal); + VecSubf(sub1, plane_center, p1); + VecSubf(sub2, co, p1); + VecSubf(intr, co, p1); + VecMulf(intr, Inpf(plane_normal, sub1) / Inpf(plane_normal, sub2)); + VecAddf(intr, intr, p1); +} + +static int plane_point_side(float co[3], float plane_normal[3], float plane_center[3], int flip) +{ + float delta[3]; + float d; + + VecSubf(delta, co, plane_center); + d = Inpf(plane_normal, delta); + + if(flip) + d = -d; + + return d <= 0.0f; +} + static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, const ListBase *active_verts, int clay) { ActiveData *node= active_verts->first; /* area_normal and cntr define the plane towards which vertices are squashed */ float area_normal[3]; - float cntr[3]; + float cntr[3], cntr2[3], bstr; + int flip = 0; - calc_area_normal(sd, area_normal, active_verts); + calc_area_normal(sd, ss, area_normal, active_verts); calc_flatten_center(ss, node, cntr); + if(clay) { + bstr= brush_strength(sd, ss->cache); + /* Limit clay application to here */ + cntr2[0]=cntr[0]+area_normal[0]*bstr*ss->cache->scale[0]; + cntr2[1]=cntr[1]+area_normal[1]*bstr*ss->cache->scale[1]; + cntr2[2]=cntr[2]+area_normal[2]*bstr*ss->cache->scale[2]; + flip = bstr < 0; + } + while(node){ float *co= ss->mvert[node->Index].co; - float p1[3], sub1[3], sub2[3], intr[3], val[3]; + float intr[3], val[3]; - /* Find the intersection between squash-plane and vertex (along the area normal) */ - VecSubf(p1, co, area_normal); - VecSubf(sub1, cntr, p1); - VecSubf(sub2, co, p1); - VecSubf(intr, co, p1); - VecMulf(intr, Inpf(area_normal, sub1) / Inpf(area_normal, sub2)); - VecAddf(intr, intr, p1); - - VecSubf(val, intr, co); - VecMulf(val, fabs(node->Fade)); - VecAddf(val, val, co); - - if(clay) { - /* Clay brush displaces after flattening */ - float tmp[3]; - VecCopyf(tmp, area_normal); - VecMulf(tmp, ss->cache->radius * node->Fade * 0.1); - VecAddf(val, val, tmp); - } + if(!clay || plane_point_side(co, area_normal, cntr2, flip)) { + /* Find the intersection between squash-plane and vertex (along the area normal) */ + point_plane_project(intr, co, area_normal, cntr); - sculpt_clip(sd, co, val); + VecSubf(val, intr, co); + + if(clay) { + if(bstr > FLT_EPSILON) + VecMulf(val, node->Fade / bstr); + else + VecMulf(val, node->Fade); + /* Clay displacement */ + val[0]+=area_normal[0] * ss->cache->scale[0]*node->Fade; + val[1]+=area_normal[1] * ss->cache->scale[1]*node->Fade; + val[2]+=area_normal[2] * ss->cache->scale[2]*node->Fade; + } + else + VecMulf(val, fabs(node->Fade)); + + VecAddf(val, val, co); + + sculpt_clip(sd, ss, co, val); + } node= node->next; } } - + /* Uses symm to selectively flip any axis of a coordinate. */ static void flip_coord(float out[3], float in[3], const char symm) { @@ -622,35 +649,29 @@ static float get_texcache_pixel_bilinear(const SculptSession *ss, float u, float } /* Return a multiplier for brush strength on a particular vertex. */ -static float tex_strength(Sculpt *sd, float *point, const float len) +static float tex_strength(Sculpt *sd, SculptSession *ss, float *point, const float len) { - SculptSession *ss= sd->session; - Brush *br = sd->brush; + Brush *br = paint_brush(&sd->paint); + MTex *tex = NULL; float avg= 1; - if(br->texact==-1 || !br->mtex[br->texact]) + if(br->texact >= 0) + tex = br->mtex[br->texact]; + + if(!tex) { avg= 1; - else if(br->tex_mode==BRUSH_TEX_3D) { - /* Get strength by feeding the vertex location directly - into a texture */ + } + else if(tex->brush_map_mode == MTEX_MAP_MODE_3D) { float jnk; - const float factor= 0.01; - MTex mtex; - memset(&mtex,0,sizeof(MTex)); - mtex.tex= br->mtex[br->texact]->tex; - mtex.projx= 1; - mtex.projy= 2; - mtex.projz= 3; - VecCopyf(mtex.size, br->mtex[br->texact]->size); - VecMulf(mtex.size, factor); - if(!sd->texsep) - mtex.size[1]= mtex.size[2]= mtex.size[0]; - - externtex(&mtex,point,&avg,&jnk,&jnk,&jnk,&jnk); + + /* Get strength by feeding the vertex + location directly into a texture */ + externtex(tex, point, &avg, + &jnk, &jnk, &jnk, &jnk); } else if(ss->texcache) { const float bsize= ss->cache->pixel_radius * 2; - const float rot= sd->brush->rot + ss->cache->rotation; + const float rot= tex->rot + ss->cache->rotation; int px, py; float flip[3], point_2d[2]; @@ -663,9 +684,9 @@ static float tex_strength(Sculpt *sd, float *point, const float len) /* For Tile and Drag modes, get the 2D screen coordinates of the and scale them up or down to the texture size. */ - if(br->tex_mode==BRUSH_TEX_TILE) { - const int sx= (const int)br->mtex[br->texact]->size[0]; - const int sy= (const int)sd->texsep ? br->mtex[br->texact]->size[1] : sx; + if(tex->brush_map_mode == MTEX_MAP_MODE_TILED) { + const int sx= (const int)tex->size[0]; + const int sy= (const int)tex->size[1]; float fx= point_2d[0]; float fy= point_2d[1]; @@ -685,7 +706,8 @@ static float tex_strength(Sculpt *sd, float *point, const float len) if(sy != 1) py %= sy-1; avg= get_texcache_pixel_bilinear(ss, ss->texcache_side*px/sx, ss->texcache_side*py/sy); - } else { + } + else if(tex->brush_map_mode == MTEX_MAP_MODE_FIXED) { float fx= (point_2d[0] - ss->cache->mouse[0]) / bsize; float fy= (point_2d[1] - ss->cache->mouse[1]) / bsize; @@ -699,7 +721,7 @@ static float tex_strength(Sculpt *sd, float *point, const float len) } } - avg*= brush_curve_strength(sd->brush, len, ss->cache->radius); /* Falloff curve */ + avg*= brush_curve_strength(br, len, ss->cache->radius); /* Falloff curve */ return avg; } @@ -737,9 +759,9 @@ static void sculpt_add_damaged_rect(SculptSession *ss) } } -static void do_brush_action(Sculpt *sd, StrokeCache *cache) +static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) { - SculptSession *ss = sd->session; + Brush *brush = paint_brush(&sd->paint); float av_dist; ListBase active_verts={0,0}; ListBase *grab_active_verts = &ss->cache->grab_active_verts[ss->cache->symmetry]; @@ -748,7 +770,7 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache) Mesh *me= NULL; /*XXX: get_mesh(OBACT); */ const float bstrength= brush_strength(sd, cache); KeyBlock *keyblock= NULL; /*XXX: ob_get_keyblock(OBACT); */ - Brush *b = sd->brush; + Brush *b = brush; int i; sculpt_add_damaged_rect(ss); @@ -768,7 +790,7 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache) adata->Index = i; /* Fade is used to store the final strength at which the brush should modify a particular vertex. */ - adata->Fade= tex_strength(sd, vert, av_dist) * bstrength; + adata->Fade= tex_strength(sd, ss, vert, av_dist) * bstrength; adata->dist = av_dist; if(b->sculpt_tool == SCULPT_TOOL_GRAB && cache->first_time) @@ -788,13 +810,13 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache) do_draw_brush(sd, ss, &active_verts); break; case SCULPT_TOOL_SMOOTH: - do_smooth_brush(sd, &active_verts); + do_smooth_brush(sd, ss, &active_verts); break; case SCULPT_TOOL_PINCH: - do_pinch_brush(sd, &active_verts); + do_pinch_brush(sd, ss, &active_verts); break; case SCULPT_TOOL_INFLATE: - do_inflate_brush(sd, &active_verts); + do_inflate_brush(sd, ss, &active_verts); break; case SCULPT_TOOL_GRAB: do_grab_brush(sd, ss); @@ -843,20 +865,21 @@ static void calc_brushdata_symm(StrokeCache *cache, const char symm) cache->symmetry= symm; } -static void do_symmetrical_brush_actions(Sculpt *sd, StrokeCache *cache) +static void do_symmetrical_brush_actions(Sculpt *sd, SculptSession *ss) { + StrokeCache *cache = ss->cache; const char symm = sd->flags & 7; int i; VecCopyf(cache->location, cache->true_location); VecCopyf(cache->grab_delta_symmetry, cache->grab_delta); cache->symmetry = 0; - do_brush_action(sd, cache); + do_brush_action(sd, ss, cache); for(i = 1; i <= symm; ++i) { if(symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5))) { calc_brushdata_symm(cache, i); - do_brush_action(sd, cache); + do_brush_action(sd, ss, cache); } } @@ -929,9 +952,9 @@ static void projverts_clear_inside(SculptSession *ss) } #endif -static void sculpt_update_tex(Sculpt *sd) +static void sculpt_update_tex(Sculpt *sd, SculptSession *ss) { - SculptSession *ss= sd->session; + Brush *brush = paint_brush(&sd->paint); if(ss->texcache) { MEM_freeN(ss->texcache); @@ -939,9 +962,9 @@ static void sculpt_update_tex(Sculpt *sd) } /* Need to allocate a bigger buffer for bigger brush size */ - ss->texcache_side = sd->brush->size * 2; + ss->texcache_side = brush->size * 2; if(!ss->texcache || ss->texcache_side > ss->texcache_actual) { - ss->texcache = brush_gen_texture_cache(sd->brush, sd->brush->size); + ss->texcache = brush_gen_texture_cache(brush, brush->size); ss->texcache_actual = ss->texcache_side; } } @@ -992,8 +1015,8 @@ static struct MultiresModifierData *sculpt_multires_active(Object *ob) static void sculpt_update_mesh_elements(bContext *C) { - SculptSession *ss = CTX_data_tool_settings(C)->sculpt->session; Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; int oldtotvert = ss->totvert; if((ss->multires = sculpt_multires_active(ob))) { @@ -1026,12 +1049,14 @@ static void sculpt_update_mesh_elements(bContext *C) static int sculpt_mode_poll(bContext *C) { - return G.f & G_SCULPTMODE; + Object *ob = CTX_data_active_object(C); + return ob && ob->mode & OB_MODE_SCULPT; } static int sculpt_poll(bContext *C) { - return G.f & G_SCULPTMODE && CTX_wm_area(C)->spacetype == SPACE_VIEW3D && + return sculpt_mode_poll(C) && paint_brush(&CTX_data_tool_settings(C)->sculpt->paint) && + CTX_wm_area(C)->spacetype == SPACE_VIEW3D && CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW; } @@ -1039,18 +1064,20 @@ static int sculpt_poll(bContext *C) static void draw_paint_cursor(bContext *C, int x, int y, void *customdata) { Sculpt *sd= CTX_data_tool_settings(C)->sculpt; + SculptSession *ss= CTX_data_active_object(C)->sculpt; + Brush *brush = paint_brush(&sd->paint); glColor4ub(255, 100, 100, 128); glEnable( GL_LINE_SMOOTH ); glEnable(GL_BLEND); glTranslatef((float)x, (float)y, 0.0f); - glutil_draw_lined_arc(0.0, M_PI*2.0, sd->brush->size, 40); + glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40); glTranslatef((float)-x, (float)-y, 0.0f); - if(sd->session && sd->session->cache && sd->brush && (sd->brush->flag & BRUSH_SMOOTH_STROKE)) { + if(ss && ss->cache && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) { ARegion *ar = CTX_wm_region(C); - sdrawline(x, y, sd->session->cache->mouse[0] - ar->winrct.xmin, sd->session->cache->mouse[1] - ar->winrct.ymin); + sdrawline(x, y, (int)ss->cache->mouse[0] - ar->winrct.xmin, (int)ss->cache->mouse[1] - ar->winrct.ymin); } glDisable(GL_BLEND); @@ -1061,19 +1088,21 @@ static void toggle_paint_cursor(bContext *C) { Sculpt *s = CTX_data_scene(C)->toolsettings->sculpt; - if(s->session->cursor) { - WM_paint_cursor_end(CTX_wm_manager(C), s->session->cursor); - s->session->cursor = NULL; + if(s->cursor) { + WM_paint_cursor_end(CTX_wm_manager(C), s->cursor); + s->cursor = NULL; } else { - s->session->cursor = + s->cursor = WM_paint_cursor_activate(CTX_wm_manager(C), sculpt_poll, draw_paint_cursor, NULL); } } static void sculpt_undo_push(bContext *C, Sculpt *sd) { - switch(sd->brush->sculpt_tool) { + Brush *brush = paint_brush(&sd->paint); + + switch(brush->sculpt_tool) { case SCULPT_TOOL_DRAW: ED_undo_push(C, "Draw Brush"); break; case SCULPT_TOOL_SMOOTH: @@ -1093,36 +1122,12 @@ static void sculpt_undo_push(bContext *C, Sculpt *sd) } } -static int sculpt_brush_curve_preset_exec(bContext *C, wmOperator *op) -{ - brush_curve_preset(CTX_data_scene(C)->toolsettings->sculpt->brush, RNA_enum_get(op->ptr, "mode")); - return OPERATOR_FINISHED; -} - -static void SCULPT_OT_brush_curve_preset(wmOperatorType *ot) -{ - static EnumPropertyItem prop_mode_items[] = { - {BRUSH_PRESET_SHARP, "SHARP", 0, "Sharp Curve", ""}, - {BRUSH_PRESET_SMOOTH, "SMOOTH", 0, "Smooth Curve", ""}, - {BRUSH_PRESET_MAX, "MAX", 0, "Max Curve", ""}, - {0, NULL, 0, NULL, NULL}}; - - ot->name= "Preset"; - ot->idname= "SCULPT_OT_brush_curve_preset"; - - ot->exec= sculpt_brush_curve_preset_exec; - ot->poll= sculpt_mode_poll; - - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_enum(ot->srna, "mode", prop_mode_items, BRUSH_PRESET_SHARP, "Mode", ""); -} - /**** Radial control ****/ static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { + Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint); toggle_paint_cursor(C); - brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->sculpt->brush, 1); + brush_radial_control_invoke(op, brush, 1); return WM_radial_control_invoke(C, op, event); } @@ -1136,7 +1141,9 @@ static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve static int sculpt_radial_control_exec(bContext *C, wmOperator *op) { - return brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->sculpt->brush, 1); + Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint); + + return brush_radial_control_exec(op, brush, 1); } static void SCULPT_OT_radial_control(wmOperatorType *ot) @@ -1170,31 +1177,31 @@ static float unproject_brush_radius(SculptSession *ss, float offset) static void sculpt_cache_free(StrokeCache *cache) { - if(cache->layer_disps) - MEM_freeN(cache->layer_disps); - if(cache->mesh_store) - MEM_freeN(cache->mesh_store); + int i; if(cache->orig_norms) MEM_freeN(cache->orig_norms); if(cache->face_norms) MEM_freeN(cache->face_norms); if(cache->mats) MEM_freeN(cache->mats); + for(i = 0; i < 8; ++i) + BLI_freelistN(&cache->grab_active_verts[i]); MEM_freeN(cache); } /* Initialize the stroke cache invariants from operator properties */ -static void sculpt_update_cache_invariants(Sculpt *sd, bContext *C, wmOperator *op) +static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bContext *C, wmOperator *op) { StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache"); + Brush *brush = paint_brush(&sd->paint); int i; - sd->session->cache = cache; + ss->cache = cache; RNA_float_get_array(op->ptr, "scale", cache->scale); cache->flag = RNA_int_get(op->ptr, "flag"); RNA_float_get_array(op->ptr, "clip_tolerance", cache->clip_tolerance); - RNA_int_get_array(op->ptr, "initial_mouse", cache->initial_mouse); + RNA_float_get_array(op->ptr, "initial_mouse", cache->initial_mouse); cache->depth = RNA_float_get(op->ptr, "depth"); cache->mouse[0] = cache->initial_mouse[0]; @@ -1209,63 +1216,83 @@ static void sculpt_update_cache_invariants(Sculpt *sd, bContext *C, wmOperator * sculpt_update_mesh_elements(C); - if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER) - cache->layer_disps = MEM_callocN(sizeof(float) * sd->session->totvert, "layer brush displacements"); + /* Initialize layer brush displacements */ + if(brush->sculpt_tool == SCULPT_TOOL_LAYER && + (!ss->layer_disps || !(brush->flag & BRUSH_PERSISTENT))) { + if(ss->layer_disps) + MEM_freeN(ss->layer_disps); + ss->layer_disps = MEM_callocN(sizeof(float) * ss->totvert, "layer brush displacements"); + } /* Make copies of the mesh vertex locations and normals for some tools */ - if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER || (sd->brush->flag & BRUSH_ANCHORED)) { - cache->mesh_store= MEM_mallocN(sizeof(float) * 3 * sd->session->totvert, "sculpt mesh vertices copy"); - for(i = 0; i < sd->session->totvert; ++i) - VecCopyf(cache->mesh_store[i], sd->session->mvert[i].co); + if(brush->sculpt_tool == SCULPT_TOOL_LAYER || (brush->flag & BRUSH_ANCHORED)) { + if(brush->sculpt_tool != SCULPT_TOOL_LAYER || + !ss->mesh_co_orig || !(brush->flag & BRUSH_PERSISTENT)) { + if(!ss->mesh_co_orig) + ss->mesh_co_orig= MEM_mallocN(sizeof(float) * 3 * ss->totvert, + "sculpt mesh vertices copy"); + for(i = 0; i < ss->totvert; ++i) + VecCopyf(ss->mesh_co_orig[i], ss->mvert[i].co); + } - if(sd->brush->flag & BRUSH_ANCHORED) { - cache->orig_norms= MEM_mallocN(sizeof(short) * 3 * sd->session->totvert, "Sculpt orig norm"); - for(i = 0; i < sd->session->totvert; ++i) { - cache->orig_norms[i][0] = sd->session->mvert[i].no[0]; - cache->orig_norms[i][1] = sd->session->mvert[i].no[1]; - cache->orig_norms[i][2] = sd->session->mvert[i].no[2]; + if(brush->flag & BRUSH_ANCHORED) { + cache->orig_norms= MEM_mallocN(sizeof(short) * 3 * ss->totvert, "Sculpt orig norm"); + for(i = 0; i < ss->totvert; ++i) { + cache->orig_norms[i][0] = ss->mvert[i].no[0]; + cache->orig_norms[i][1] = ss->mvert[i].no[1]; + cache->orig_norms[i][2] = ss->mvert[i].no[2]; } - if(sd->session->face_normals) { - float *fn = sd->session->face_normals; - cache->face_norms= MEM_mallocN(sizeof(float) * 3 * sd->session->totface, "Sculpt face norms"); - for(i = 0; i < sd->session->totface; ++i, fn += 3) + if(ss->face_normals) { + float *fn = ss->face_normals; + cache->face_norms= MEM_mallocN(sizeof(float) * 3 * ss->totface, "Sculpt face norms"); + for(i = 0; i < ss->totface; ++i, fn += 3) VecCopyf(cache->face_norms[i], fn); } } } unproject(cache->mats, cache->true_location, cache->initial_mouse[0], cache->initial_mouse[1], cache->depth); - cache->radius = unproject_brush_radius(sd->session, brush_size(sd)); + cache->initial_radius = unproject_brush_radius(ss, brush->size); cache->rotation = 0; cache->first_time = 1; } /* Initialize the stroke cache variants from operator properties */ -static void sculpt_update_cache_variants(Sculpt *sd, PointerRNA *ptr) +static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, PointerRNA *ptr) { - StrokeCache *cache = sd->session->cache; + StrokeCache *cache = ss->cache; + Brush *brush = paint_brush(&sd->paint); float grab_location[3]; + int dx, dy; - if(!(sd->brush->flag & BRUSH_ANCHORED)) + if(!(brush->flag & BRUSH_ANCHORED)) RNA_float_get_array(ptr, "location", cache->true_location); cache->flip = RNA_boolean_get(ptr, "flip"); - RNA_int_get_array(ptr, "mouse", cache->mouse); + RNA_float_get_array(ptr, "mouse", cache->mouse); + cache->pressure = RNA_float_get(ptr, "pressure"); /* Truly temporary data that isn't stored in properties */ cache->previous_pixel_radius = cache->pixel_radius; - cache->pixel_radius = brush_size(sd); + cache->pixel_radius = brush->size; - if(sd->brush->flag & BRUSH_ANCHORED) { + if(brush->flag & BRUSH_SIZE_PRESSURE) { + cache->pixel_radius *= cache->pressure; + cache->radius = cache->initial_radius * cache->pressure; + } + else + cache->radius = cache->initial_radius; + + if(brush->flag & BRUSH_ANCHORED) { dx = cache->mouse[0] - cache->initial_mouse[0]; dy = cache->mouse[1] - cache->initial_mouse[1]; cache->pixel_radius = sqrt(dx*dx + dy*dy); - cache->radius = unproject_brush_radius(sd->session, cache->pixel_radius); + cache->radius = unproject_brush_radius(ss, cache->pixel_radius); cache->rotation = atan2(dy, dx); } - else if(sd->brush->flag & BRUSH_RAKE) { + else if(brush->flag & BRUSH_RAKE) { int update; dx = cache->last_rake[0] - cache->mouse[0]; @@ -1284,7 +1311,7 @@ static void sculpt_update_cache_variants(Sculpt *sd, PointerRNA *ptr) } /* Find the grab delta */ - if(sd->brush->sculpt_tool == SCULPT_TOOL_GRAB) { + if(brush->sculpt_tool == SCULPT_TOOL_GRAB) { unproject(cache->mats, grab_location, cache->mouse[0], cache->mouse[1], cache->depth); if(!cache->first_time) VecSubf(cache->grab_delta, grab_location, cache->old_grab_location); @@ -1300,7 +1327,8 @@ static void sculpt_brush_stroke_init_properties(bContext *C, wmOperator *op, wmE ModifierData *md; ViewContext vc; float scale[3], clip_tolerance[3] = {0,0,0}; - int mouse[2], flag = 0; + float mouse[2]; + int flag = 0; /* Set scaling adjustment */ scale[0] = 1.0f / ob->size[0]; @@ -1327,25 +1355,26 @@ static void sculpt_brush_stroke_init_properties(bContext *C, wmOperator *op, wmE /* Initial mouse location */ mouse[0] = event->x; mouse[1] = event->y; - RNA_int_set_array(op->ptr, "initial_mouse", mouse); + RNA_float_set_array(op->ptr, "initial_mouse", mouse); /* Initial screen depth under the mouse */ view3d_set_viewcontext(C, &vc); RNA_float_set(op->ptr, "depth", read_cached_depth(&vc, event->x, event->y)); - sculpt_update_cache_invariants(sd, C, op); + sculpt_update_cache_invariants(sd, ss, C, op); } static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *event) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + SculptSession *ss = CTX_data_active_object(C)->sculpt; view3d_operator_needs_opengl(C); /* TODO: Shouldn't really have to do this at the start of every stroke, but sculpt would need some sort of notification when changes are made to the texture. */ - sculpt_update_tex(sd); + sculpt_update_tex(sd, ss); /* add modal handler */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); @@ -1353,16 +1382,16 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even return OPERATOR_RUNNING_MODAL; } -static void sculpt_restore_mesh(Sculpt *sd) +static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) { - SculptSession *ss = sd->session; StrokeCache *cache = ss->cache; + Brush *brush = paint_brush(&sd->paint); int i; /* Restore the mesh before continuing with anchored stroke */ - if((sd->brush->flag & BRUSH_ANCHORED) && cache->mesh_store) { + if((brush->flag & BRUSH_ANCHORED) && ss->mesh_co_orig) { for(i = 0; i < ss->totvert; ++i) { - VecCopyf(ss->mvert[i].co, cache->mesh_store[i]); + VecCopyf(ss->mvert[i].co, ss->mesh_co_orig[i]); ss->mvert[i].no[0] = cache->orig_norms[i][0]; ss->mvert[i].no[1] = cache->orig_norms[i][1]; ss->mvert[i].no[2] = cache->orig_norms[i][2]; @@ -1374,8 +1403,8 @@ static void sculpt_restore_mesh(Sculpt *sd) VecCopyf(fn, cache->face_norms[i]); } - if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER) - memset(cache->layer_disps, 0, sizeof(float) * ss->totvert); + if(brush->sculpt_tool == SCULPT_TOOL_LAYER) + memset(ss->layer_disps, 0, sizeof(float) * ss->totvert); } } @@ -1387,39 +1416,41 @@ static void sculpt_post_stroke_free(SculptSession *ss) static void sculpt_flush_update(bContext *C) { - Sculpt *s = CTX_data_tool_settings(C)->sculpt; + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; ARegion *ar = CTX_wm_region(C); - MultiresModifierData *mmd = s->session->multires; + MultiresModifierData *mmd = ss->multires; - calc_damaged_verts(s->session); + calc_damaged_verts(ss); if(mmd) { - if(mmd->undo_verts && mmd->undo_verts != s->session->mvert) + if(mmd->undo_verts && mmd->undo_verts != ss->mvert) MEM_freeN(mmd->undo_verts); - mmd->undo_verts = s->session->mvert; - mmd->undo_verts_tot = s->session->totvert; - multires_mark_as_modified(CTX_data_active_object(C)); + mmd->undo_verts = ss->mvert; + mmd->undo_verts_tot = ss->totvert; + multires_mark_as_modified(ob); } ED_region_tag_redraw(ar); } /* Returns zero if no sculpt changes should be made, non-zero otherwise */ -static int sculpt_smooth_stroke(Sculpt *s, int output[2], wmEvent *event) +static int sculpt_smooth_stroke(Sculpt *s, SculptSession *ss, float output[2], wmEvent *event) { + Brush *brush = paint_brush(&s->paint); + output[0] = event->x; output[1] = event->y; - if(s->brush->flag & BRUSH_SMOOTH_STROKE && s->brush->sculpt_tool != SCULPT_TOOL_GRAB) { - StrokeCache *cache = s->session->cache; - float u = .9, v = 1.0 - u; - int dx = cache->mouse[0] - event->x, dy = cache->mouse[1] - event->y; - int radius = 50; + if(brush->flag & BRUSH_SMOOTH_STROKE && brush->sculpt_tool != SCULPT_TOOL_GRAB) { + StrokeCache *cache = ss->cache; + float u = brush->smooth_stroke_factor, v = 1.0 - u; + float dx = cache->mouse[0] - event->x, dy = cache->mouse[1] - event->y; /* If the mouse is moving within the radius of the last move, don't update the mouse position. This allows sharp turns. */ - if(dx*dx + dy*dy < radius*radius) + if(dx*dx + dy*dy < brush->smooth_stroke_radius * brush->smooth_stroke_radius) return 0; output[0] = event->x * v + cache->mouse[0] * u; @@ -1432,43 +1463,53 @@ static int sculpt_smooth_stroke(Sculpt *s, int output[2], wmEvent *event) /* Returns zero if the stroke dots should not be spaced, non-zero otherwise */ int sculpt_space_stroke_enabled(Sculpt *s) { - Brush *br = s->brush; + Brush *br = paint_brush(&s->paint); return (br->flag & BRUSH_SPACE) && !(br->flag & BRUSH_ANCHORED) && (br->sculpt_tool != SCULPT_TOOL_GRAB); } /* Put the location of the next sculpt stroke dot into the stroke RNA and apply it to the mesh */ -static void sculpt_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, int mouse[2]) +static void sculpt_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse[2]) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - StrokeCache *cache = sd->session->cache; + SculptSession *ss = CTX_data_active_object(C)->sculpt; + StrokeCache *cache = ss->cache; PointerRNA itemptr; - float cur_depth; + float cur_depth, pressure = 1; float center[3]; cur_depth = read_cached_depth(&cache->vc, mouse[0], mouse[1]); - unproject(sd->session->cache->mats, center, mouse[0], mouse[1], cur_depth); + unproject(ss->cache->mats, center, mouse[0], mouse[1], cur_depth); + + /* Tablet */ + if(event->custom == EVT_DATA_TABLET) { + wmTabletData *wmtab= event->customdata; + if(wmtab->Active != EVT_TABLET_NONE) + pressure= wmtab->Pressure; + } /* Add to stroke */ RNA_collection_add(op->ptr, "stroke", &itemptr); RNA_float_set_array(&itemptr, "location", center); - RNA_int_set_array(&itemptr, "mouse", mouse); + RNA_float_set_array(&itemptr, "mouse", mouse); RNA_boolean_set(&itemptr, "flip", event->shift); - sculpt_update_cache_variants(sd, &itemptr); + RNA_float_set(&itemptr, "pressure", pressure); + sculpt_update_cache_variants(sd, ss, &itemptr); - sculpt_restore_mesh(sd); - do_symmetrical_brush_actions(sd, cache); + sculpt_restore_mesh(sd, ss); + do_symmetrical_brush_actions(sd, ss); } /* For brushes with stroke spacing enabled, moves mouse in steps towards the final mouse location. */ -static int sculpt_space_stroke(bContext *C, wmOperator *op, wmEvent *event, Sculpt *s, const int final_mouse[2]) +static int sculpt_space_stroke(bContext *C, wmOperator *op, wmEvent *event, Sculpt *s, SculptSession *ss, const float final_mouse[2]) { - StrokeCache *cache = s->session->cache; + StrokeCache *cache = ss->cache; + Brush *brush = paint_brush(&s->paint); int cnt = 0; if(sculpt_space_stroke_enabled(s)) { float vec[2] = {final_mouse[0] - cache->mouse[0], final_mouse[1] - cache->mouse[1]}; - int mouse[2] = {cache->mouse[0], cache->mouse[1]}; + float mouse[2] = {cache->mouse[0], cache->mouse[1]}; float length, scale; int steps = 0, i; @@ -1476,11 +1517,11 @@ static int sculpt_space_stroke(bContext *C, wmOperator *op, wmEvent *event, Scul length = sqrt(vec[0]*vec[0] + vec[1]*vec[1]); if(length > FLT_EPSILON) { - scale = s->brush->spacing / length; + scale = brush->spacing / length; vec[0] *= scale; vec[1] *= scale; - steps = (int)(length / s->brush->spacing); + steps = (int)(length / brush->spacing); for(i = 0; i < steps; ++i, ++cnt) { mouse[0] += vec[0]; mouse[1] += vec[1]; @@ -1495,38 +1536,39 @@ static int sculpt_space_stroke(bContext *C, wmOperator *op, wmEvent *event, Scul static int sculpt_brush_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + SculptSession *ss = CTX_data_active_object(C)->sculpt; ARegion *ar = CTX_wm_region(C); float cur_depth; sculpt_update_mesh_elements(C); - if(!sd->session->cache) { + if(!ss->cache) { ViewContext vc; view3d_set_viewcontext(C, &vc); cur_depth = read_cached_depth(&vc, event->x, event->y); /* Don't start the stroke until a valid depth is found */ if(cur_depth < 1.0 - FLT_EPSILON) { - sculpt_brush_stroke_init_properties(C, op, event, sd->session); - sculptmode_update_all_projverts(sd->session); + sculpt_brush_stroke_init_properties(C, op, event, ss); + sculptmode_update_all_projverts(ss); } ED_region_tag_redraw(ar); } - if(sd->session->cache) { - int mouse[2]; + if(ss->cache) { + float mouse[2]; - if(sculpt_smooth_stroke(sd, mouse, event)) { + if(sculpt_smooth_stroke(sd, ss, mouse, event)) { if(sculpt_space_stroke_enabled(sd)) { - if(!sculpt_space_stroke(C, op, event, sd, mouse)) + if(!sculpt_space_stroke(C, op, event, sd, ss, mouse)) ED_region_tag_redraw(ar); } else sculpt_brush_stroke_add_step(C, op, event, mouse); sculpt_flush_update(C); - sculpt_post_stroke_free(sd->session); + sculpt_post_stroke_free(ss); } else ED_region_tag_redraw(ar); @@ -1534,10 +1576,10 @@ static int sculpt_brush_stroke_modal(bContext *C, wmOperator *op, wmEvent *event /* Finished */ if(event->type == LEFTMOUSE && event->val == 0) { - if(sd->session->cache) { - request_depth_update(sd->session->cache->vc.rv3d); - sculpt_cache_free(sd->session->cache); - sd->session->cache = NULL; + if(ss->cache) { + request_depth_update(ss->cache->vc.rv3d); + sculpt_cache_free(ss->cache); + ss->cache = NULL; sculpt_undo_push(C, sd); } @@ -1550,24 +1592,25 @@ static int sculpt_brush_stroke_modal(bContext *C, wmOperator *op, wmEvent *event static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + SculptSession *ss = CTX_data_active_object(C)->sculpt; view3d_operator_needs_opengl(C); - sculpt_update_cache_invariants(sd, C, op); - sculptmode_update_all_projverts(sd->session); - sculpt_update_tex(sd); + sculpt_update_cache_invariants(sd, ss, C, op); + sculptmode_update_all_projverts(ss); + sculpt_update_tex(sd, ss); RNA_BEGIN(op->ptr, itemptr, "stroke") { - sculpt_update_cache_variants(sd, &itemptr); + sculpt_update_cache_variants(sd, ss, &itemptr); - sculpt_restore_mesh(sd); - do_symmetrical_brush_actions(sd, sd->session->cache); + sculpt_restore_mesh(sd, ss); + do_symmetrical_brush_actions(sd, ss); - sculpt_post_stroke_free(sd->session); + sculpt_post_stroke_free(ss); } RNA_END; sculpt_flush_update(C); - sculpt_cache_free(sd->session->cache); + sculpt_cache_free(ss->cache); sculpt_undo_push(C, sd); @@ -1604,46 +1647,77 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) RNA_def_float_vector(ot->srna, "clip_tolerance", 3, NULL, 0.0f, FLT_MAX, "clip_tolerance", "", 0.0f, 1000.0f); /* The initial 2D location of the mouse */ - RNA_def_int_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX); + RNA_def_float_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX); /* The initial screen depth of the mouse */ RNA_def_float(ot->srna, "depth", 0.0f, 0.0f, FLT_MAX, "depth", "", 0.0f, FLT_MAX); } +/**** Reset the copy of the mesh that is being sculpted on (currently just for the layer brush) ****/ + +static int sculpt_set_persistent_base(bContext *C, wmOperator *op) +{ + SculptSession *ss = CTX_data_active_object(C)->sculpt; + + if(ss) { + if(ss->layer_disps) + MEM_freeN(ss->layer_disps); + ss->layer_disps = NULL; + + if(ss->mesh_co_orig) + MEM_freeN(ss->mesh_co_orig); + ss->mesh_co_orig = NULL; + } + + return OPERATOR_FINISHED; +} + +static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Set Persistent Base"; + ot->idname= "SCULPT_OT_set_persistent_base"; + + /* api callbacks */ + ot->exec= sculpt_set_persistent_base; + ot->poll= sculpt_mode_poll; + + ot->flag= OPTYPE_REGISTER; +} + /**** Toggle operator for turning sculpt mode on or off ****/ static int sculpt_toggle_mode(bContext *C, wmOperator *op) { ToolSettings *ts = CTX_data_tool_settings(C); + Object *ob = CTX_data_active_object(C); - if(G.f & G_SCULPTMODE) { - multires_force_update(CTX_data_active_object(C)); + if(ob->mode & OB_MODE_SCULPT) { + multires_force_update(ob); /* Leave sculptmode */ - G.f &= ~G_SCULPTMODE; + ob->mode &= ~OB_MODE_SCULPT; - toggle_paint_cursor(C); - - sculptsession_free(ts->sculpt); + free_sculptsession(&ob->sculpt); } else { /* Enter sculptmode */ - G.f |= G_SCULPTMODE; + ob->mode |= OB_MODE_SCULPT; /* Create persistent sculpt mode data */ if(!ts->sculpt) ts->sculpt = MEM_callocN(sizeof(Sculpt), "sculpt mode data"); /* Create sculpt mode session data */ - if(ts->sculpt->session) - MEM_freeN(ts->sculpt->session); - ts->sculpt->session = MEM_callocN(sizeof(SculptSession), "sculpt session"); + if(ob->sculpt) + free_sculptsession(&ob->sculpt); + ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); - toggle_paint_cursor(C); + if(!ts->sculpt->cursor) + toggle_paint_cursor(C); - /* If there's no brush, create one */ - brush_check_exists(&ts->sculpt->brush); + paint_init(&ts->sculpt->paint, "Brush"); WM_event_add_notifier(C, NC_SCENE|ND_MODE, CTX_data_scene(C)); } @@ -1669,5 +1743,5 @@ void ED_operatortypes_sculpt() WM_operatortype_append(SCULPT_OT_radial_control); WM_operatortype_append(SCULPT_OT_brush_stroke); WM_operatortype_append(SCULPT_OT_sculptmode_toggle); - WM_operatortype_append(SCULPT_OT_brush_curve_preset); + WM_operatortype_append(SCULPT_OT_set_persistent_base); } diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 216ff3993dd..4fb22064c17 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -60,6 +60,7 @@ #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" +#include "DNA_meta_types.h" #include "DNA_userdef_types.h" #include "DNA_gpencil_types.h" #include "DNA_windowmanager_types.h" @@ -396,14 +397,14 @@ static void action_icu_buts(SpaceAction *saction) /* Channel List */ /* left hand part */ -void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar) +void draw_channel_names(bContext *C, bAnimContext *ac, SpaceAction *saction, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; View2D *v2d= &ar->v2d; - float x= 0.0f, y= 0.0f; + float y= 0.0f; int items, height; /* build list of channels to draw */ @@ -427,566 +428,48 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar) UI_view2d_sync(NULL, ac->sa, v2d, V2D_VIEWSYNC_AREA_VERTICAL); /* loop through channels, and set up drawing depending on their type */ - y= (float)ACHANNEL_FIRST; - - for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + { /* first pass: just the standard GL-drawing for backdrop + text */ + y= (float)ACHANNEL_FIRST; - /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) - { - bActionGroup *grp = NULL; - short indent= 0, offset= 0, sel= 0, group= 0; - int expand= -1, protect = -1, special= -1, mute = -1; - char name[128]; + for (ale= anim_data.first; ale; ale= ale->next) { + float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); + float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); - /* determine what needs to be drawn */ - switch (ale->type) { - case ANIMTYPE_SCENE: /* scene */ - { - Scene *sce= (Scene *)ale->data; - - group= 4; - indent= 0; - - special= ICON_SCENE_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_SCEC(sce)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_SCEC(sce); - strcpy(name, sce->id.name+2); - } - break; - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - group= 4; - indent= 0; - - /* icon depends on object-type */ - if (ob->type == OB_ARMATURE) - special= ICON_ARMATURE_DATA; - else - special= ICON_OBJECT_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_OBJC(ob)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_OBJC(base); - strcpy(name, ob->id.name+2); - } - break; - case ANIMTYPE_FILLACTD: /* action widget */ - { - bAction *act= (bAction *)ale->data; - - group = 4; - indent= 1; - special= ICON_ACTION; - - if (EXPANDED_ACTC(act)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_ACTC(act); - strcpy(name, act->id.name+2); - } - break; - case ANIMTYPE_FILLMATD: /* object materials (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_MATERIAL_DATA; - - if (FILTER_MAT_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Materials"); - } - break; - case ANIMTYPE_FILLPARTD: /* object particles (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_PARTICLE_DATA; - - if (FILTER_PART_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Particles"); - } - break; - - - case ANIMTYPE_DSMAT: /* single material (dopesheet) expand widget */ - { - Material *ma = (Material *)ale->data; - - group = 0; - indent = 0; - special = ICON_MATERIAL_DATA; - offset = 21; - - if (FILTER_MAT_OBJD(ma)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, ma->id.name+2); - } - break; - case ANIMTYPE_DSLAM: /* lamp (dopesheet) expand widget */ - { - Lamp *la = (Lamp *)ale->data; - - group = 4; - indent = 1; - special = ICON_LAMP_DATA; - - if (FILTER_LAM_OBJD(la)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, la->id.name+2); - } - break; - case ANIMTYPE_DSCAM: /* camera (dopesheet) expand widget */ - { - Camera *ca = (Camera *)ale->data; - - group = 4; - indent = 1; - special = ICON_CAMERA_DATA; - - if (FILTER_CAM_OBJD(ca)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, ca->id.name+2); - } - break; - case ANIMTYPE_DSCUR: /* curve (dopesheet) expand widget */ - { - Curve *cu = (Curve *)ale->data; - - group = 4; - indent = 1; - special = ICON_CURVE_DATA; - - if (FILTER_CUR_OBJD(cu)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, cu->id.name+2); - } - break; - case ANIMTYPE_DSSKEY: /* shapekeys (dopesheet) expand widget */ - { - Key *key= (Key *)ale->data; - - group = 4; - indent = 1; - special = ICON_SHAPEKEY_DATA; // XXX - - if (FILTER_SKE_OBJD(key)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - //sel = SEL_OBJC(base); - strcpy(name, "Shape Keys"); - } - break; - case ANIMTYPE_DSWOR: /* world (dopesheet) expand widget */ - { - World *wo= (World *)ale->data; - - group = 4; - indent = 1; - special = ICON_WORLD_DATA; - - if (FILTER_WOR_SCED(wo)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, wo->id.name+2); - } - break; - case ANIMTYPE_DSPART: /* particle (dopesheet) expand widget */ - { - ParticleSettings *part= (ParticleSettings*)ale->data; - - group = 0; - indent = 0; - special = ICON_PARTICLE_DATA; - offset = 21; - - if (FILTER_PART_OBJD(part)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, part->id.name+2); - } - break; - - - case ANIMTYPE_GROUP: /* action group */ - { - bActionGroup *agrp= (bActionGroup *)ale->data; - - group= 2; - indent= 0; - special= -1; - - if (ale->id) { - /* special exception for materials */ - if (GS(ale->id->name) == ID_MA) - offset= 25; - else - offset= 14; - } - else - offset= 0; - - /* only show expand if there are any channels */ - if (agrp->channels.first) { - if (EXPANDED_AGRP(agrp)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - } - - if (agrp->flag & AGRP_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (EDITABLE_AGRP(agrp)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - - sel = SEL_AGRP(agrp); - strcpy(name, agrp->name); - } - break; - case ANIMTYPE_FCURVE: /* F-Curve channel */ - { - FCurve *fcu = (FCurve *)ale->data; - - indent = 0; - - group= (fcu->grp) ? 1 : 0; - grp= fcu->grp; - - if (ale->id) { - /* special exception for materials and particles */ - if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) { - offset= 21; - indent= 1; - } - else - offset= 14; - } - else - offset= 0; - - if (fcu->flag & FCURVE_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (fcu->bezt) { - if (EDITABLE_FCU(fcu)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - } - else - protect = ICON_ZOOMOUT; // XXX editability is irrelevant here, but this icon is temp... - - sel = SEL_FCU(fcu); - - getname_anim_fcurve(name, ale->id, fcu); - } - break; - - case ANIMTYPE_SHAPEKEY: /* shapekey channel */ - { - KeyBlock *kb = (KeyBlock *)ale->data; - - indent = 0; - special = -1; - - offset= (ale->id) ? 21 : 0; - - if (kb->name[0] == '\0') - sprintf(name, "Key %d", ale->index); - else - strcpy(name, kb->name); - } - break; - - case ANIMTYPE_GPDATABLOCK: /* gpencil datablock */ - { - bGPdata *gpd = (bGPdata *)ale->data; - ScrArea *sa = (ScrArea *)ale->owner; - - indent = 0; - group= 3; - - /* only show expand if there are any channels */ - if (gpd->layers.first) { - if (gpd->flag & GP_DATA_EXPAND) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - } - - switch (sa->spacetype) { - case SPACE_VIEW3D: - { - /* this shouldn't cause any overflow... */ - //sprintf(name, "3DView:%s", view3d_get_name(sa->spacedata.first)); // XXX missing func.. - strcpy(name, "3dView"); - special= ICON_VIEW3D; - } - break; - case SPACE_NODE: - { - SpaceNode *snode= sa->spacedata.first; - char treetype[12]; - - if (snode->treetype == 1) - strcpy(treetype, "Composite"); - else - strcpy(treetype, "Material"); - sprintf(name, "Nodes:%s", treetype); - - special= ICON_NODE; - } - break; - case SPACE_SEQ: - { - SpaceSeq *sseq= sa->spacedata.first; - char imgpreview[10]; - - switch (sseq->mainb) { - case 1: sprintf(imgpreview, "Image..."); break; - case 2: sprintf(imgpreview, "Luma..."); break; - case 3: sprintf(imgpreview, "Chroma..."); break; - case 4: sprintf(imgpreview, "Histogram"); break; - - default: sprintf(imgpreview, "Sequence"); break; - } - sprintf(name, "Sequencer:%s", imgpreview); - - special= ICON_SEQUENCE; - } - break; - case SPACE_IMAGE: - { - SpaceImage *sima= sa->spacedata.first; - - if (sima->image) - sprintf(name, "Image:%s", sima->image->id.name+2); - else - strcpy(name, "Image:"); - - special= ICON_IMAGE_COL; - } - break; - - default: - { - sprintf(name, ""); - special= -1; - } - break; - } - } - break; - case ANIMTYPE_GPLAYER: /* gpencil layer */ - { - bGPDlayer *gpl = (bGPDlayer *)ale->data; - - indent = 0; - special = -1; - expand = -1; - group = 1; - - if (EDITABLE_GPL(gpl)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - - if (gpl->flag & GP_LAYER_HIDE) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - sel = SEL_GPL(gpl); - BLI_snprintf(name, 32, gpl->info); - } - break; - } - - /* now, start drawing based on this information */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw backing strip behind channel name */ - if (group == 4) { - /* only used in dopesheet... */ - if (ELEM(ale->type, ANIMTYPE_SCENE, ANIMTYPE_OBJECT)) { - /* object channel - darker */ - UI_ThemeColor(TH_DOPESHEET_CHANNELOB); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else { - /* sub-object folders - lighter */ - UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); - - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); - - /* clear group value, otherwise we cause errors... */ - group = 0; - } - } - else if (group == 3) { - /* only for gp-data channels */ - UI_ThemeColorShade(TH_GROUP, 20); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else if (group == 2) { - /* only for action group channels */ - if (ale->flag & AGRP_ACTIVE) - UI_ThemeColorShade(TH_GROUP_ACTIVE, 10); - else - UI_ThemeColorShade(TH_GROUP, 20); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else { - /* for normal channels - * - use 3 shades of color group/standard color for 3 indention level - * - only use group colors if allowed to, and if actually feasible - */ - if ( !(saction->flag & SACTION_NODRAWGCOLORS) && - (grp) && (grp->customCol) ) - { - char cp[3]; - - if (indent == 2) { - VECCOPY(cp, grp->cs.solid); - } - else if (indent == 1) { - VECCOPY(cp, grp->cs.select); - } - else { - VECCOPY(cp, grp->cs.active); - } - - glColor3ub(cp[0], cp[1], cp[2]); - } - else - UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); - - indent += group; - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw(ac, ale, yminc, ymaxc); } - /* draw expand/collapse triangle */ - if (expand > 0) { - UI_icon_draw(x+offset, yminc, expand); - offset += 17; + /* adjust y-position for next one */ + y -= ACHANNEL_STEP; + } + } + { /* second pass: widgets */ + uiBlock *block= uiBeginBlock(C, ar, "dopesheet channel buttons", UI_EMBOSS); + + y= (float)ACHANNEL_FIRST; + + for (ale= anim_data.first; ale; ale= ale->next) { + float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); + float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw_widgets(ac, ale, block, yminc, ymaxc); } - /* draw special icon indicating certain data-types */ - if (special > -1) { - if (ELEM(group, 3, 4)) { - /* for gpdatablock channels */ - UI_icon_draw(x+offset, yminc, special); - offset += 17; - } - else { - /* for normal channels */ - UI_icon_draw(x+offset, yminc, special); - offset += 17; - } - } - glDisable(GL_BLEND); - - /* draw name */ - if (sel) - UI_ThemeColor(TH_TEXT_HI); - else - UI_ThemeColor(TH_TEXT); - offset += 3; - UI_DrawString(x+offset, y-4, name); - - /* reset offset - for RHS of panel */ - offset = 0; - - /* set blending again, as text drawing may clear it */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw protect 'lock' */ - if (protect > -1) { - offset = 16; - UI_icon_draw((float)ACHANNEL_NAMEWIDTH-offset, yminc, protect); - } - - /* draw mute 'eye' */ - if (mute > -1) { - offset += 16; - UI_icon_draw((float)(ACHANNEL_NAMEWIDTH-offset), yminc, mute); - } - glDisable(GL_BLEND); + /* adjust y-position for next one */ + y -= ACHANNEL_STEP; } - /* adjust y-position for next one */ - y -= ACHANNEL_STEP; + uiEndBlock(C, block); + uiDrawBlock(C, block); } /* free tempolary channels */ diff --git a/source/blender/editors/space_action/action_header.c b/source/blender/editors/space_action/action_header.c index b3c3cbaca18..e4750bd0a37 100644 --- a/source/blender/editors/space_action/action_header.c +++ b/source/blender/editors/space_action/action_header.c @@ -153,7 +153,7 @@ static void act_channelmenu(bContext *C, uiLayout *layout, void *arg_unused) static void act_gplayermenu(bContext *C, uiLayout *layout, void *arg_unused) { - //uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu); + //uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu, NULL, NULL); //uiItemS(layout); //uiItemO(layout, NULL, 0, "NLAEDIT_OT_duplicate"); } @@ -210,9 +210,9 @@ static void act_edit_expomenu(bContext *C, uiLayout *layout, void *arg_unused) static void act_editmenu(bContext *C, uiLayout *layout, void *arg_unused) { - uiItemMenuF(layout, "Transform", 0, act_edit_transformmenu); - uiItemMenuF(layout, "Snap", 0, act_edit_snapmenu); - uiItemMenuF(layout, "Mirror", 0, act_edit_mirrormenu); + uiItemMenuF(layout, "Transform", 0, act_edit_transformmenu, NULL); + uiItemMenuF(layout, "Snap", 0, act_edit_snapmenu, NULL); + uiItemMenuF(layout, "Mirror", 0, act_edit_mirrormenu, NULL); uiItemS(layout); @@ -225,9 +225,9 @@ static void act_editmenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemMenuF(layout, "Handle Type", 0, act_edit_handlesmenu); - uiItemMenuF(layout, "Interpolation Mode", 0, act_edit_ipomenu); - uiItemMenuF(layout, "Extrapolation Mode", 0, act_edit_expomenu); + uiItemMenuF(layout, "Handle Type", 0, act_edit_handlesmenu, NULL); + uiItemMenuF(layout, "Interpolation Mode", 0, act_edit_ipomenu, NULL); + uiItemMenuF(layout, "Extrapolation Mode", 0, act_edit_expomenu, NULL); uiItemS(layout); @@ -386,6 +386,7 @@ void action_header_buttons(const bContext *C, ARegion *ar) uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Lamps"); uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCAM, B_REDR, ICON_CAMERA_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Cameras"); uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCUR, B_REDR, ICON_CURVE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Curves"); + uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMBA, B_REDR, ICON_META_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display MetaBalls"); uiDefIconButBitI(block, TOGN, ADS_FILTER_NOPART, B_REDR, ICON_PARTICLE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Particles"); uiBlockEndAlign(block); xco += 30; diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 26655892176..1aeeeff0c80 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -41,7 +41,7 @@ struct bAnimListElem; /* ***************************************** */ /* action_draw.c */ -void draw_channel_names(struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar); +void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar); void draw_channel_strips(struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar); struct ActKeysInc *init_aki_data(struct bAnimContext *ac, struct bAnimListElem *ale); diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 55e035cfced..275ac4ea4c1 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -243,7 +243,7 @@ static void action_channel_area_draw(const bContext *C, ARegion *ar) /* data */ if (ANIM_animdata_get_context(C, &ac)) { - draw_channel_names(&ac, saction, ar); + draw_channel_names(C, &ac, saction, ar); } /* reset view matrix */ diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 5c33b648947..041e6a09323 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -77,6 +77,7 @@ void ED_spacetypes_init(void) ED_spacetype_sequencer(); ED_spacetype_logic(); ED_spacetype_console(); + ED_spacetype_userpref(); // ... /* register operator types for screen and all spaces */ diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 614017cc4c6..530500cfafa 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -49,6 +49,7 @@ #include "BKE_global.h" #include "BKE_material.h" #include "BKE_modifier.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -304,7 +305,7 @@ static int buttons_context_path_particle(ButsContextPath *path) return 0; } -static int buttons_context_path_brush(ButsContextPath *path) +static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) { Scene *scene; ToolSettings *ts; @@ -320,14 +321,8 @@ static int buttons_context_path_brush(ButsContextPath *path) scene= path->ptr[path->len-1].data; ts= scene->toolsettings; - if(G.f & G_SCULPTMODE) - br= ts->sculpt->brush; - else if(G.f & G_VERTEXPAINT) - br= ts->vpaint->brush; - else if(G.f & G_WEIGHTPAINT) - br= ts->wpaint->brush; - else if(G.f & G_TEXTUREPAINT) - br= ts->imapaint.brush; + if(scene) + br= paint_brush(paint_get_active(scene)); if(br) { RNA_id_pointer_create(&br->id, &path->ptr[path->len]); @@ -337,11 +332,11 @@ static int buttons_context_path_brush(ButsContextPath *path) } } - /* no path to a world possible */ + /* no path to a brush possible */ return 0; } -static int buttons_context_path_texture(ButsContextPath *path) +static int buttons_context_path_texture(const bContext *C, ButsContextPath *path) { Material *ma; Lamp *la; @@ -356,7 +351,7 @@ static int buttons_context_path_texture(ButsContextPath *path) return 1; } /* try brush */ - else if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(path)) { + else if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(C, path)) { br= path->ptr[path->len-1].data; if(br) { @@ -465,7 +460,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma found= buttons_context_path_material(path); break; case BCONTEXT_TEXTURE: - found= buttons_context_path_texture(path); + found= buttons_context_path_texture(C, path); break; case BCONTEXT_BONE: found= buttons_context_path_bone(path); @@ -558,7 +553,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r "world", "object", "mesh", "armature", "lattice", "curve", "meta_ball", "lamp", "camera", "material", "material_slot", "texture", "texture_slot", "bone", "edit_bone", "particle_system", - "cloth", "soft_body", "fluid", "collision", "brush", NULL}; + "cloth", "soft_body", "fluid", "smoke", "collision", "brush", NULL}; CTX_data_dir_set(result, dir); return 1; @@ -691,6 +686,17 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } } + + else if(CTX_data_equals(member, "smoke")) { + PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + + if(ptr && ptr->data) { + Object *ob= ptr->data; + ModifierData *md= modifiers_findByType(ob, eModifierType_Smoke); + CTX_data_pointer_set(result, &ob->id, &RNA_SmokeModifier, md); + return 1; + } + } else if(CTX_data_equals(member, "collision")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index e52efe8508d..057f35a2487 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -916,7 +916,7 @@ static int toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event) uiPopupMenu *pup; uiLayout *layout; - RNA_pointer_create(&sc->id, &RNA_SpaceButtonsWindow, sbuts, &ptr); + RNA_pointer_create(&sc->id, &RNA_SpaceProperties, sbuts, &ptr); pup= uiPupMenuBegin(C, "Align", 0); layout= uiPupMenuLayout(pup); diff --git a/source/blender/editors/space_file/Makefile b/source/blender/editors/space_file/Makefile index 2f4180448e5..43b2f09ed2d 100644 --- a/source/blender/editors/space_file/Makefile +++ b/source/blender/editors/space_file/Makefile @@ -59,3 +59,7 @@ ifeq ($(WITH_OPENJPEG),true) CPPFLAGS += -DWITH_OPENJPEG endif +ifeq ($(WITH_OPENEXR), true) + CPPFLAGS += -DWITH_OPENEXR +endif + diff --git a/source/blender/editors/space_file/SConscript b/source/blender/editors/space_file/SConscript index 36e042bdaa6..e6fba38fb8f 100644 --- a/source/blender/editors/space_file/SConscript +++ b/source/blender/editors/space_file/SConscript @@ -12,5 +12,7 @@ defs = [] if env['WITH_BF_OPENJPEG']: defs.append('WITH_OPENJPEG') +if env['WITH_BF_OPENEXR']: + defs.append('WITH_OPENEXR') env.BlenderLib ( 'bf_editors_space_file', sources, Split(incs), defs, libtype=['core'], priority=[115] ) diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index f3c18859fb0..30598d39d58 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -170,23 +170,28 @@ static void file_panel_operator(const bContext *C, Panel *pa) wmOperator *op= sfile->op; int empty= 1; - RNA_STRUCT_BEGIN(op->ptr, prop) { - if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) - continue; - if(strcmp(RNA_property_identifier(prop), "filename") == 0) - continue; - if(strcmp(RNA_property_identifier(prop), "display") == 0) - continue; - if(strncmp(RNA_property_identifier(prop), "filter", 6) == 0) - continue; - - uiItemFullR(pa->layout, NULL, 0, op->ptr, prop, -1, 0, 0, 0, 0); - empty= 0; + if(op->type->ui) { + op->type->ui((bContext*)C, op->ptr, pa->layout); } - RNA_STRUCT_END; + else { + RNA_STRUCT_BEGIN(op->ptr, prop) { + if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) + continue; + if(strcmp(RNA_property_identifier(prop), "filename") == 0) + continue; + if(strcmp(RNA_property_identifier(prop), "display") == 0) + continue; + if(strncmp(RNA_property_identifier(prop), "filter", 6) == 0) + continue; - if(empty) - uiItemL(pa->layout, "No properties.", 0); + uiItemFullR(pa->layout, NULL, 0, op->ptr, prop, -1, 0, 0, 0, 0); + empty= 0; + } + RNA_STRUCT_END; + + if(empty) + uiItemL(pa->layout, "No properties.", 0); + } } void file_panels_register(ARegionType *art) diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 7ebc8c4338f..538c1e4fce7 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -840,7 +840,16 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) || BLI_testextensie(file->relname, ".mv")) { file->flags |= MOVIEFILE; } - else if(BLI_testextensie(file->relname, ".wav")) { + else if(BLI_testextensie(file->relname, ".wav") + || BLI_testextensie(file->relname, ".ogg") + || BLI_testextensie(file->relname, ".oga") + || BLI_testextensie(file->relname, ".mp3") + || BLI_testextensie(file->relname, ".mp2") + || BLI_testextensie(file->relname, ".ac3") + || BLI_testextensie(file->relname, ".aac") + || BLI_testextensie(file->relname, ".flac") + || BLI_testextensie(file->relname, ".wma") + || BLI_testextensie(file->relname, ".eac3")) { file->flags |= SOUNDFILE; } } else { // no quicktime @@ -875,7 +884,16 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) || BLI_testextensie(file->relname, ".mv")) { file->flags |= MOVIEFILE; } - else if(BLI_testextensie(file->relname, ".wav")) { + else if(BLI_testextensie(file->relname, ".wav") + || BLI_testextensie(file->relname, ".ogg") + || BLI_testextensie(file->relname, ".oga") + || BLI_testextensie(file->relname, ".mp3") + || BLI_testextensie(file->relname, ".mp2") + || BLI_testextensie(file->relname, ".ac3") + || BLI_testextensie(file->relname, ".aac") + || BLI_testextensie(file->relname, ".flac") + || BLI_testextensie(file->relname, ".wma") + || BLI_testextensie(file->relname, ".eac3")) { file->flags |= SOUNDFILE; } } diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 82babb70c53..fb995285ab7 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -160,7 +160,7 @@ static void graph_panel_properties(const bContext *C, Panel *pa) } getname_anim_fcurve(name, ale->id, fcu); - uiDefBut(block, LABEL, 1, name, 30, 180, 300, 19, NULL, 0.0, 0.0, 0, 0, "Name of Active F-Curve"); + uiDefBut(block, LABEL, 1, name, 40, 180, 300, 19, NULL, 0.0, 0.0, 0, 0, "Name of Active F-Curve"); /* TODO: the following settings could be added here * - F-Curve coloring mode - mode selector + color selector diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 105ecf23c3e..f3aa0fac42b 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -51,6 +51,7 @@ #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" +#include "DNA_meta_types.h" #include "DNA_object_types.h" #include "DNA_particle_types.h" #include "DNA_scene_types.h" @@ -876,19 +877,15 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri /* ************************************************************************* */ /* Channel List */ -// XXX quite a few of these need to be kept in sync with their counterparts in Action Editor -// as they're the same. We have 2 separate copies of this for now to make it easier to develop -// the diffences between the two editors, but one day these should be merged! - /* left hand part */ -void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) +void graph_draw_channel_names(bContext *C, bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; View2D *v2d= &ar->v2d; - float x= 0.0f, y= 0.0f, height; + float y= 0.0f, height; int items, i=0; /* build list of channels to draw */ @@ -902,521 +899,57 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) * start of list offset, and the second is as a correction for the scrollers. */ height= (float)((items*ACHANNEL_STEP) + (ACHANNEL_HEIGHT*2)); - -#if 0 - if (height > (v2d->mask.ymax - v2d->mask.ymin)) { - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) - */ - v2d->tot.ymin= (float)(-height); - } - - /* XXX I would call the below line! (ton) */ -#endif UI_view2d_totRect_set(v2d, ar->winx, height); /* loop through channels, and set up drawing depending on their type */ - y= (float)ACHANNEL_FIRST; - - for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + { /* first pass: just the standard GL-drawing for backdrop + text */ + y= (float)ACHANNEL_FIRST; - /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) - { - bActionGroup *grp = NULL; - short indent= 0, offset= 0, sel= 0, group= 0; - int expand= -1, protect = -1, special= -1, mute = -1; - char name[128]; + for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { + const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); - /* determine what needs to be drawn */ - switch (ale->type) { - case ANIMTYPE_SCENE: /* scene */ - { - Scene *sce= (Scene *)ale->data; - - group= 4; - indent= 0; - - special= ICON_SCENE_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_SCEC(sce)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_SCEC(sce); - strcpy(name, sce->id.name+2); - } - break; - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - group= 4; - indent= 0; - - /* icon depends on object-type */ - if (ob->type == OB_ARMATURE) - special= ICON_ARMATURE_DATA; - else - special= ICON_OBJECT_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_OBJC(ob)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_OBJC(base); - strcpy(name, ob->id.name+2); - } - break; - case ANIMTYPE_FILLACTD: /* action widget */ - { - bAction *act= (bAction *)ale->data; - - group = 4; - indent= 1; - special= ICON_ACTION; - - if (EXPANDED_ACTC(act)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - sel = SEL_ACTC(act); - strcpy(name, act->id.name+2); - } - break; - case ANIMTYPE_FILLDRIVERS: /* drivers widget */ - { - AnimData *adt= (AnimData *)ale->data; - - group = 4; - indent= 1; - special= ICON_ANIM_DATA; - - if (EXPANDED_DRVD(adt)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - strcpy(name, "Drivers"); - } - break; - case ANIMTYPE_FILLMATD: /* object materials (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_MATERIAL_DATA; - - if (FILTER_MAT_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Materials"); - } - break; - case ANIMTYPE_FILLPARTD: /* object particles (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_PARTICLE_DATA; - - if (FILTER_PART_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Particles"); - } - break; - - - case ANIMTYPE_DSMAT: /* single material (dopesheet) expand widget */ - { - Material *ma = (Material *)ale->data; - - group = 0; - indent = 0; - special = ICON_MATERIAL_DATA; - offset = 21; - - if (FILTER_MAT_OBJD(ma)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, ma->id.name+2); - } - break; - case ANIMTYPE_DSLAM: /* lamp (dopesheet) expand widget */ - { - Lamp *la = (Lamp *)ale->data; - - group = 4; - indent = 1; - special = ICON_LAMP_DATA; - - if (FILTER_LAM_OBJD(la)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, la->id.name+2); - } - break; - case ANIMTYPE_DSCAM: /* camera (dopesheet) expand widget */ - { - Camera *ca = (Camera *)ale->data; - - group = 4; - indent = 1; - special = ICON_CAMERA_DATA; - - if (FILTER_CAM_OBJD(ca)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, ca->id.name+2); - } - break; - case ANIMTYPE_DSCUR: /* curve (dopesheet) expand widget */ - { - Curve *cu = (Curve *)ale->data; - - group = 4; - indent = 1; - special = ICON_CURVE_DATA; - - if (FILTER_CUR_OBJD(cu)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, cu->id.name+2); - } - break; - case ANIMTYPE_DSSKEY: /* shapekeys (dopesheet) expand widget */ - { - Key *key= (Key *)ale->data; - - group = 4; - indent = 1; - special = ICON_SHAPEKEY_DATA; - - if (FILTER_SKE_OBJD(key)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - //sel = SEL_OBJC(base); - strcpy(name, "Shape Keys"); - } - break; - case ANIMTYPE_DSWOR: /* world (dopesheet) expand widget */ - { - World *wo= (World *)ale->data; - - group = 4; - indent = 1; - special = ICON_WORLD_DATA; - - if (FILTER_WOR_SCED(wo)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, wo->id.name+2); - } - break; - case ANIMTYPE_DSPART: /* particle (dopesheet) expand widget */ - { - ParticleSettings *part= (ParticleSettings*)ale->data; - - group = 0; - indent = 0; - special = ICON_PARTICLE_DATA; - offset = 21; - - if (FILTER_PART_OBJD(part)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, part->id.name+2); - } - break; - - - case ANIMTYPE_GROUP: /* action group */ - { - bActionGroup *agrp= (bActionGroup *)ale->data; - - group= 2; - indent= 0; - special= -1; - - if (ale->id) { - /* special exception for materials */ - if (GS(ale->id->name) == ID_MA) - offset= 25; - else - offset= 14; - } - else - offset= 0; - - /* only show expand if there are any channels */ - if (agrp->channels.first) { - if (EXPANDED_AGRP(agrp)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - } - - /* for now, 'special' (i.e. in front of name) is used to show visibility status */ - if (agrp->flag & AGRP_NOTVISIBLE) - special= ICON_CHECKBOX_DEHLT; - else - special= ICON_CHECKBOX_HLT; - - if (agrp->flag & AGRP_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (EDITABLE_AGRP(agrp)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - - sel = SEL_AGRP(agrp); - strcpy(name, agrp->name); - } - break; - case ANIMTYPE_FCURVE: /* F-Curve channel */ - { - FCurve *fcu = (FCurve *)ale->data; - - indent = 0; - - group= (fcu->grp) ? 1 : 0; - grp= fcu->grp; - - if (ale->id) { - /* special exception for materials and particles */ - if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) { - offset= 21; - indent= 1; - } - else - offset= 14; - } - else - offset= 0; - - /* for now, 'special' (i.e. in front of name) is used to show visibility status */ - if (fcu->flag & FCURVE_VISIBLE) - special= ICON_CHECKBOX_HLT; - else - special= ICON_CHECKBOX_DEHLT; - - if (fcu->flag & FCURVE_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (fcu->bezt) { - if (EDITABLE_FCU(fcu)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - } - else - protect = ICON_ZOOMOUT; // XXX editability is irrelevant here, but this icon is temp... - - sel = SEL_FCU(fcu); - - getname_anim_fcurve(name, ale->id, fcu); - } - break; - - case ANIMTYPE_SHAPEKEY: /* shapekey channel */ - { - KeyBlock *kb = (KeyBlock *)ale->data; - - indent = 0; - special = -1; - - offset= (ale->id) ? 21 : 0; - - if (kb->name[0] == '\0') - sprintf(name, "Key %d", ale->index); - else - strcpy(name, kb->name); - } - break; - } - - /* now, start drawing based on this information */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw backing strip behind channel name */ - if (group == 4) { - /* only used in dopesheet... */ - if (ELEM(ale->type, ANIMTYPE_SCENE, ANIMTYPE_OBJECT)) { - /* object channel - darker */ - UI_ThemeColor(TH_DOPESHEET_CHANNELOB); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else { - /* sub-object folders - lighter */ - UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); - - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); - - /* clear group value, otherwise we cause errors... */ - group = 0; - } - } - else if (group == 3) { - /* only for gp-data channels */ - UI_ThemeColorShade(TH_GROUP, 20); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else if (group == 2) { - /* only for action group channels */ - if (ale->flag & AGRP_ACTIVE) - UI_ThemeColorShade(TH_GROUP_ACTIVE, 10); - else - UI_ThemeColorShade(TH_GROUP, 20); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8); - } - else { - short shadefac= ((indent==0)?20: (indent==1)?-20: -40); - - indent += group; - offset += 7 * indent; - - /* draw channel backdrop */ - UI_ThemeColorShade(TH_HEADER, shadefac); - - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); - - /* most of the time, only F-Curves are going to be drawn here */ - if (ale->type == ANIMTYPE_FCURVE) { - /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever - * color the curve has stored - */ - FCurve *fcu= (FCurve *)ale->data; - glColor3fv(fcu->color); - - // NOTE: only enable the following line for the fading-out gradient - //glShadeModel(GL_SMOOTH); - - glBegin(GL_QUADS); - /* solid color for the area around the checkbox */ - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f(x+offset+18, ymaxc); - glVertex2f(x+offset+18, yminc); - -#if 0 // fading out gradient - /* fading out gradient for the rest of the box */ - glVertex2f(x+offset+18, yminc); - glVertex2f(x+offset+18, ymaxc); - - UI_ThemeColorShade(TH_HEADER, shadefac); // XXX does this cause any problems on some cards? - - glVertex2f(x+offset+20, ymaxc); - glVertex2f(x+offset+20, yminc); -#endif // fading out gradient - glEnd(); - - // NOTE: only enable the following line for the fading-out gradient - //glShadeModel(GL_FLAT); - } + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw(ac, ale, yminc, ymaxc); } - /* draw expand/collapse triangle */ - if (expand > 0) { - UI_icon_draw(x+offset, yminc, expand); - offset += 17; + /* adjust y-position for next one */ + y -= ACHANNEL_STEP; + } + } + { /* second pass: widgets */ + uiBlock *block= uiBeginBlock(C, ar, "graph channel buttons", UI_EMBOSS); + + y= (float)ACHANNEL_FIRST; + + /* set blending again, as may not be set in previous step */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { + const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw_widgets(ac, ale, block, yminc, ymaxc); } - /* draw special icon indicating certain data-types */ - if (special > -1) { - if (ELEM(group, 3, 4)) { - /* for gpdatablock channels */ - UI_icon_draw(x+offset, yminc, special); - offset += 17; - } - else { - /* for normal channels */ - UI_icon_draw(x+offset, yminc, special); - offset += 17; - } - } - glDisable(GL_BLEND); - - /* draw name */ - if (sel) - UI_ThemeColor(TH_TEXT_HI); - else - UI_ThemeColor(TH_TEXT); - offset += 3; - UI_DrawString(x+offset, y-4, name); - - /* reset offset - for RHS of panel */ - offset = 0; - - /* set blending again, as text drawing may clear it */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw protect 'lock' */ - if (protect > -1) { - offset = 16; - UI_icon_draw((float)ACHANNEL_NAMEWIDTH-offset, yminc, protect); - } - - /* draw mute 'eye' */ - if (mute > -1) { - offset += 16; - UI_icon_draw((float)(ACHANNEL_NAMEWIDTH-offset), yminc, mute); - } - glDisable(GL_BLEND); + /* adjust y-position for next one */ + y -= ACHANNEL_STEP; } - /* adjust y-position for next one */ - y -= ACHANNEL_STEP; + uiEndBlock(C, block); + uiDrawBlock(C, block); + + glDisable(GL_BLEND); } /* free tempolary channels */ diff --git a/source/blender/editors/space_graph/graph_header.c b/source/blender/editors/space_graph/graph_header.c index 989f1f8e0cc..c4654972dcd 100644 --- a/source/blender/editors/space_graph/graph_header.c +++ b/source/blender/editors/space_graph/graph_header.c @@ -201,9 +201,9 @@ static void graph_edit_expomenu(bContext *C, uiLayout *layout, void *arg_unused) static void graph_editmenu(bContext *C, uiLayout *layout, void *arg_unused) { - uiItemMenuF(layout, "Transform", 0, graph_edit_transformmenu); - uiItemMenuF(layout, "Snap", 0, graph_edit_snapmenu); - uiItemMenuF(layout, "Mirror", 0, graph_edit_mirrormenu); + uiItemMenuF(layout, "Transform", 0, graph_edit_transformmenu, NULL); + uiItemMenuF(layout, "Snap", 0, graph_edit_snapmenu, NULL); + uiItemMenuF(layout, "Mirror", 0, graph_edit_mirrormenu, NULL); uiItemS(layout); @@ -217,9 +217,9 @@ static void graph_editmenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemMenuF(layout, "Handle Type", 0, graph_edit_handlesmenu); - uiItemMenuF(layout, "Interpolation Mode", 0, graph_edit_ipomenu); - uiItemMenuF(layout, "Extrapolation Mode", 0, graph_edit_expomenu); + uiItemMenuF(layout, "Handle Type", 0, graph_edit_handlesmenu, NULL); + uiItemMenuF(layout, "Interpolation Mode", 0, graph_edit_ipomenu, NULL); + uiItemMenuF(layout, "Extrapolation Mode", 0, graph_edit_expomenu, NULL); uiItemS(layout); @@ -310,13 +310,14 @@ void graph_header_buttons(const bContext *C, ARegion *ar) uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display Lamps"); uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCAM, B_REDR, ICON_CAMERA_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display Cameras"); uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCUR, B_REDR, ICON_CURVE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display Curves"); + uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMBA, B_REDR, ICON_META_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display MetaBalls"); uiDefIconButBitI(block, TOGN, ADS_FILTER_NOPART, B_REDR, ICON_PARTICLE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(sipo->ads->filterflag), 0, 0, 0, 0, "Display Particles"); uiBlockEndAlign(block); xco += 30; } else { // XXX this case shouldn't happen at all... for now, just pad out same amount of space - xco += 9*XIC + 30; + xco += 10*XIC + 30; } /* auto-snap selector */ diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index 31f1c6d4301..2e8d0655d2d 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -48,7 +48,7 @@ struct ARegion *graph_has_buttons_region(struct ScrArea *sa); /* ***************************************** */ /* graph_draw.c */ -void graph_draw_channel_names(struct bAnimContext *ac, struct SpaceIpo *sipo, struct ARegion *ar); +void graph_draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct SpaceIpo *sipo, struct ARegion *ar); void graph_draw_curves(struct bAnimContext *ac, struct SpaceIpo *sipo, struct ARegion *ar, struct View2DGrid *grid, short sel); void graph_draw_ghost_curves(struct bAnimContext *ac, struct SpaceIpo *sipo, struct ARegion *ar, struct View2DGrid *grid); diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 0390586951b..3717ccc8244 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -309,7 +309,7 @@ static void graph_channel_area_draw(const bContext *C, ARegion *ar) /* draw channels */ if (ANIM_animdata_get_context(C, &ac)) { - graph_draw_channel_names(&ac, sipo, ar); + graph_draw_channel_names((bContext*)C, &ac, sipo, ar); } /* reset view matrix */ diff --git a/source/blender/editors/space_image/Makefile b/source/blender/editors/space_image/Makefile index e7e9a9b5665..af15b1d9724 100644 --- a/source/blender/editors/space_image/Makefile +++ b/source/blender/editors/space_image/Makefile @@ -53,3 +53,7 @@ CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include CPPFLAGS += -I../include +ifeq ($(WITH_OPENEXR), true) + CPPFLAGS += -DWITH_OPENEXR +endif + diff --git a/source/blender/editors/space_image/SConscript b/source/blender/editors/space_image/SConscript index e7041ef0458..874549e6949 100644 --- a/source/blender/editors/space_image/SConscript +++ b/source/blender/editors/space_image/SConscript @@ -11,5 +11,7 @@ defs = [] if env['WITH_BF_LCMS']: defs.append('WITH_LCMS') +if env['WITH_BF_OPENEXR']: + defs.append('WITH_OPENEXR') env.BlenderLib ( 'bf_editors_space_image', sources, Split(incs), defs, libtype=['core'], priority=[40] ) diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 4dcaa96caf7..ac0a5c7f53a 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -58,6 +58,7 @@ #include "BKE_mesh.h" #include "BKE_node.h" #include "BKE_packedFile.h" +#include "BKE_paint.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -450,7 +451,7 @@ void brush_buttons(const bContext *C, uiBlock *block, short fromsima, { // SpaceImage *sima= CTX_wm_space_image(C); ToolSettings *settings= CTX_data_tool_settings(C); - Brush *brush= settings->imapaint.brush; + Brush *brush= paint_brush(&settings->imapaint.paint); ID *id; int yco, xco, butw, but_idx; // short *menupoin = &(sima->menunr); // XXX : &(G.buts->menunr); @@ -472,7 +473,7 @@ void brush_buttons(const bContext *C, uiBlock *block, short fromsima, uiBlockEndAlign(block); yco -= 30; - id= (ID*)settings->imapaint.brush; + id= (ID*)brush; xco= 200; // std_libbuttons(block, 0, yco, 0, NULL, evt_browse, ID_BR, 0, id, NULL, menupoin, 0, evt_local, evt_del, 0, evt_keepdata); if(brush && !brush->id.lib) { @@ -574,7 +575,7 @@ static void image_panel_paintcolor(const bContext *C, Panel *pa) { SpaceImage *sima= CTX_wm_space_image(C); ToolSettings *settings= CTX_data_tool_settings(C); - Brush *brush= settings->imapaint.brush; + Brush *brush= paint_brush(&settings->imapaint.paint); uiBlock *block; static float hsv[3], old[3]; // used as temp mem for picker static char hexcol[128]; @@ -1318,7 +1319,7 @@ void ED_image_uiblock_panel(const bContext *C, uiBlock *block, Image **ima_pp, I } /* exception, let's do because we only use this panel 3 times in blender... but not real good code! */ - if( (FACESEL_PAINT_TEST) && sima && &sima->iuser==iuser) + if( (paint_facesel_test(CTX_data_active_object(C))) && sima && &sima->iuser==iuser) return; /* left side default per-image options, right half the additional options */ diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index ff25a2635d2..2f5fc805367 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -47,6 +47,7 @@ #include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_image.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" #include "BIF_gl.h" @@ -577,7 +578,7 @@ static void draw_image_view_tool(Scene *scene) static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *height) { - Brush *brush = scene->toolsettings->imapaint.brush; + Brush *brush = paint_brush(&scene->toolsettings->imapaint.paint); ImBuf *ibuf; unsigned int size, alpha; unsigned char *rect, *cp; @@ -615,7 +616,7 @@ static void draw_image_paint_helpers(SpaceImage *sima, ARegion *ar, Scene *scene int x, y, w, h; unsigned char *clonerect; - brush= scene->toolsettings->imapaint.brush; + brush= paint_brush(&scene->toolsettings->imapaint.paint); if(brush && (scene->toolsettings->imapaint.tool == PAINT_TOOL_CLONE)) { /* this is not very efficient, but glDrawPixels doesn't allow diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h index 519364b58d9..070b627af07 100644 --- a/source/blender/editors/space_info/info_intern.h +++ b/source/blender/editors/space_info/info_intern.h @@ -32,9 +32,6 @@ struct wmOperatorType; -/* info_header.c */ -void info_header_buttons(const bContext *C, ARegion *ar); - void FILE_OT_pack_all(struct wmOperatorType *ot); void FILE_OT_unpack_all(struct wmOperatorType *ot); void FILE_OT_make_paths_relative(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 274f5f47e43..cda79ea0764 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -708,8 +708,6 @@ static char *actuator_name(int type) return "Material"; case ACT_SOUND: return "Sound"; - case ACT_CD: - return "CD"; case ACT_PROPERTY: return "Property"; case ACT_EDIT_OBJECT: @@ -748,21 +746,21 @@ static char *actuator_pup(Object *owner) case OB_ARMATURE: return "Actuators %t|Action %x15|Motion %x0|Constraint %x9|Ipo %x1" "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Scene %x11|Random %x13|Message %x14|Game %x17" "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; break; case OB_MESH: return "Actuators %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1" "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Scene %x11|Random %x13|Message %x14|Game %x17" "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; break; default: return "Actuators %t|Motion %x0|Constraint %x9|Ipo %x1" "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" - "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Scene %x11|Random %x13|Message %x14|Game %x17" "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; } } @@ -1581,7 +1579,6 @@ static int get_col_actuator(int type) case ACT_IPO: return TH_PANEL; case ACT_PROPERTY: return TH_PANEL; case ACT_SOUND: return TH_PANEL; - case ACT_CD: return TH_PANEL; case ACT_CAMERA: return TH_PANEL; case ACT_EDIT_OBJECT: return TH_PANEL; case ACT_GROUP: return TH_PANEL; @@ -1674,7 +1671,6 @@ static void check_state_mask(bContext *C, void *arg1_but, void *arg2_mask) static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width) { bSoundActuator *sa = NULL; - bCDActuator *cda = NULL; bObjectActuator *oa = NULL; bIpoActuator *ia = NULL; bPropertyActuator *pa = NULL; @@ -1984,11 +1980,14 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh } case ACT_SOUND: { - ysize = 70; - sa = act->data; sa->sndnr = 0; + if(sa->flag & ACT_SND_3D_SOUND) + ysize = 114; + else + ysize = 92; + wval = (width-20)/2; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); @@ -2003,8 +2002,14 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4"; uiDefBut(block, TEX, B_IDNAME, "SO:",xco+30,yco-22,width-40,19, sa->sound->id.name+2, 0.0, 21.0, 0, 0, ""); uiDefButS(block, MENU, 1, dummy_str,xco+10,yco-44,width-20, 19, &sa->type, 0.0, 0.0, 0, 0, ""); - uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->sound->volume, 0.0, 1.0, 0, 0, "Sets the volume of this sound"); - uiDefButF(block, NUM, 0, "Pitch:",xco+wval+10,yco-66,wval, 19, &sa->sound->pitch,-12.0, 12.0, 0, 0, "Sets the pitch of this sound"); + uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->volume, 0.0, 1.0, 0, 0, "Sets the volume of this sound"); + uiDefButF(block, NUM, 0, "Pitch:",xco+wval+10,yco-66,wval, 19, &sa->pitch,-12.0, 12.0, 0, 0, "Sets the pitch of this sound"); + uiDefButS(block, TOG | BIT, 0, "3D Sound", xco+10, yco-88, width-20, 19, &sa->flag, 0.0, 1.0, 0.0, 0.0, "Plays the sound positioned in 3D space."); + if(sa->flag & ACT_SND_3D_SOUND) + { + uiDefButF(block, NUM, 0, "Rolloff: ", xco+10, yco-110, wval, 19, &sa->sound3D.rolloff_factor, 0.0, 5.0, 0.0, 0.0, "The rolloff factor defines the influence factor on volume depending on distance."); + uiDefButF(block, NUM, 0, "Reference distance: ", xco+wval+10, yco-110, wval, 19, &sa->sound3D.reference_distance, 0.0, 1000.0, 0.0, 0.0, "The reference distance is the distance where the sound has a gain of 1.0."); + } } MEM_freeN(str); } @@ -2014,41 +2019,6 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh yco-= ysize; - break; - } - case ACT_CD: - { - char cd_type_str[] = "Sound mode %t|Play all tracks %x0|Play one track %x1|" - "Volume %x3|Stop %x4|Pause %x5|Resume %x6"; - cda = act->data; - - if (cda) { - if (cda->track == 0) { - cda->track = 1; - cda->volume = 1; - cda->type = ACT_CD_PLAY_ALL; - } - - if (cda->type == ACT_CD_PLAY_TRACK || cda->type == ACT_CD_LOOP_TRACK) { - ysize = 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefButS(block, NUM, 0, "Track:", xco+10,yco-44,width-20, 19, &cda->track, 1, 99, 0, 0, "Select the track to be played"); - } - else if (cda->type == ACT_CD_VOLUME) { - ysize = 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-44,width-20, 19, &cda->volume, 0, 1, 0, 0, "Set the volume for CD playback"); - } - else { - ysize = 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - uiDefButS(block, MENU, B_REDR, cd_type_str,xco+10,yco-22,width-20, 19, &cda->type, 0.0, 0.0, 0, 0, ""); - } - yco-= ysize; break; } case ACT_CAMERA: diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 98dacc8ef5b..063b329b7a1 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -45,6 +45,7 @@ #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" +#include "DNA_meta_types.h" #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" #include "DNA_world_types.h" @@ -88,6 +89,7 @@ * part of the channel is relevant. * * NOTE: eventually, this should probably be phased out when many of these things are replaced with buttons + * --> Most channels are now selection only... */ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, short selectmode) @@ -117,32 +119,17 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho case ANIMTYPE_SCENE: { Scene *sce= (Scene *)ale->data; - AnimData *adt= ale->data; - if (x < 16) { - /* toggle expand */ - sce->flag ^= SCE_DS_COLLAPSED; - - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - - notifierFlags |= ND_ANIMCHAN_EDIT; + /* set selection status */ + if (selectmode == SELECT_INVERT) { + /* swap select */ + sce->flag ^= SCE_DS_SELECTED; } else { - /* set selection status */ - if (selectmode == SELECT_INVERT) { - /* swap select */ - sce->flag ^= SCE_DS_SELECTED; - } - else { - sce->flag |= SCE_DS_SELECTED; - } - - notifierFlags |= ND_ANIMCHAN_SELECT; + sce->flag |= SCE_DS_SELECTED; } + + notifierFlags |= ND_ANIMCHAN_SELECT; } break; case ANIMTYPE_OBJECT: @@ -151,20 +138,8 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho Scene *sce= (Scene *)ads->source; Base *base= (Base *)ale->data; Object *ob= base->object; - AnimData *adt= ale->adt; - if (x < 16) { - /* toggle expand */ - ob->nlaflag ^= OB_ADS_COLLAPSED; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - - notifierFlags |= ND_ANIMCHAN_EDIT; - } - else if (nlaedit_is_tweakmode_on(ac) == 0) { + if (nlaedit_is_tweakmode_on(ac) == 0) { /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ @@ -193,133 +168,6 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho } } break; - case ANIMTYPE_FILLMATD: - { - Object *ob= (Object *)ale->data; - ob->nlaflag ^= OB_ADS_SHOWMATS; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_FILLPARTD: - { - Object *ob= (Object *)ale->data; - ob->nlaflag ^= OB_ADS_SHOWPARTS; // XXX - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - - case ANIMTYPE_DSMAT: - { - Material *ma= (Material *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - ma->flag ^= MA_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSLAM: - { - Lamp *la= (Lamp *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - la->flag ^= LA_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSCAM: - { - Camera *ca= (Camera *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - ca->flag ^= CAM_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSCUR: - { - Curve *cu= (Curve *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - cu->flag ^= CU_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSSKEY: - { - Key *key= (Key *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - key->flag ^= KEYBLOCK_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSWOR: - { - World *wo= (World *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - wo->flag ^= WO_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; - case ANIMTYPE_DSPART: - { - ParticleSettings *part= (ParticleSettings *)ale->data; - AnimData *adt= ale->adt; - - if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) { - /* toggle mute */ - adt->flag ^= ADT_NLA_EVAL_OFF; - } - else { - /* toggle expand */ - part->flag ^= PART_DS_EXPAND; - } - notifierFlags |= ND_ANIMCHAN_EDIT; - } - break; case ANIMTYPE_NLATRACK: { diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 3feefcc11ab..f30954292b4 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -46,6 +46,7 @@ #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" +#include "DNA_meta_types.h" #include "DNA_particle_types.h" #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" @@ -410,7 +411,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr /* don't draw if line would end up on or after the end of the strip */ if (repeatPos < strip->end) - fdrawline(repeatPos, yminc, repeatPos, ymaxc); + fdrawline(repeatPos, yminc+4, repeatPos, ymaxc-4); } } /* or if meta-strip, draw lines delimiting extents of sub-strips (in same color as outline, if more than 1 exists) */ @@ -591,36 +592,15 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* *********************************************** */ /* Channel List */ -void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) +/* old code for drawing NLA channels using GL only */ +// TODO: depreceate this code... +static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, View2D *v2d, float y) { - ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter; - - View2D *v2d= &ar->v2d; - float x= 0.0f, y= 0.0f; - int items, height; - - /* build list of channels to draw */ - filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - - /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first - * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for - * start of list offset, and the second is as a correction for the scrollers. - */ - height= ((items*NLACHANNEL_STEP) + (NLACHANNEL_HEIGHT*2)); - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) - */ - v2d->tot.ymin= (float)(-height); + float x = 0.0f; /* loop through channels, and set up drawing depending on their type */ - y= (float)(-NLACHANNEL_HEIGHT); - - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale= anim_data->first; ale; ale= ale->next) { const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF); const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF); const float ydatac= (float)(y - 7); @@ -632,283 +612,10 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) short indent= 0, offset= 0, sel= 0, group= 0; int expand= -1, protect = -1, special= -1, mute = -1; char name[128]; + short doDraw=0; /* determine what needs to be drawn */ switch (ale->type) { - case ANIMTYPE_SCENE: /* scene */ - { - Scene *sce= (Scene *)ale->data; - AnimData *adt= ale->adt; - - group= 4; - indent= 0; - - special= ICON_SCENE_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_SCEC(sce)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - sel = SEL_SCEC(sce); - strcpy(name, sce->id.name+2); - } - break; - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - AnimData *adt= ale->adt; - - group= 4; - indent= 0; - - /* icon depends on object-type */ - if (ob->type == OB_ARMATURE) - special= ICON_ARMATURE_DATA; - else - special= ICON_OBJECT_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_OBJC(ob)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - sel = SEL_OBJC(base); - strcpy(name, ob->id.name+2); - } - break; - case ANIMTYPE_FILLMATD: /* object materials (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_MATERIAL_DATA; - - if (FILTER_MAT_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Materials"); - } - break; - case ANIMTYPE_FILLPARTD: /* object particles (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_PARTICLE_DATA; - - if (FILTER_PART_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Particles"); - } - break; - - - case ANIMTYPE_DSMAT: /* single material (dopesheet) expand widget */ - { - Material *ma = (Material *)ale->data; - AnimData *adt= ale->adt; - - group = 0; - indent = 0; - special = ICON_MATERIAL_DATA; - offset = 21; - - if (FILTER_MAT_OBJD(ma)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, ma->id.name+2); - } - break; - case ANIMTYPE_DSLAM: /* lamp (dopesheet) expand widget */ - { - Lamp *la = (Lamp *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_LAMP_DATA; - - if (FILTER_LAM_OBJD(la)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, la->id.name+2); - } - break; - case ANIMTYPE_DSCAM: /* camera (dopesheet) expand widget */ - { - Camera *ca = (Camera *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_CAMERA_DATA; - - if (FILTER_CAM_OBJD(ca)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, ca->id.name+2); - } - break; - case ANIMTYPE_DSCUR: /* curve (dopesheet) expand widget */ - { - Curve *cu = (Curve *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_CURVE_DATA; - - if (FILTER_CUR_OBJD(cu)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, cu->id.name+2); - } - break; - case ANIMTYPE_DSSKEY: /* shapekeys (dopesheet) expand widget */ - { - Key *key= (Key *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_SHAPEKEY_DATA; - - if (FILTER_SKE_OBJD(key)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - //sel = SEL_OBJC(base); - strcpy(name, "Shape Keys"); - } - break; - case ANIMTYPE_DSWOR: /* world (dopesheet) expand widget */ - { - World *wo= (World *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_WORLD_DATA; - - if (FILTER_WOR_SCED(wo)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, wo->id.name+2); - } - break; - case ANIMTYPE_DSPART: /* particle (dopesheet) expand widget */ - { - ParticleSettings *part= (ParticleSettings*)ale->data; - AnimData *adt= ale->adt; - - group = 0; - indent = 0; - special = ICON_PARTICLE_DATA; - offset = 21; - - if (FILTER_PART_OBJD(part)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, part->id.name+2); - } - break; - case ANIMTYPE_NLATRACK: /* NLA Track */ { NlaTrack *nlt= (NlaTrack *)ale->data; @@ -952,6 +659,9 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) sel = SEL_NLT(nlt); strcpy(name, nlt->name); + + // draw manually still + doDraw= 1; } break; case ANIMTYPE_NLAACTION: /* NLA Action-Line */ @@ -978,167 +688,219 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) sprintf(name, "ActAction: <%s>", act->id.name+2); else sprintf(name, ""); + + // draw manually still + doDraw= 1; } break; + + default: /* handled by standard channel-drawing API */ + // draw backdrops only... + ANIM_channel_draw(ac, ale, yminc, ymaxc); + break; } - /* now, start drawing based on this information */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw backing strip behind channel name */ - if (group == 4) { - /* only used in dopesheet... */ - if (ELEM(ale->type, ANIMTYPE_SCENE, ANIMTYPE_OBJECT)) { - /* object channel - darker */ - UI_ThemeColor(TH_DOPESHEET_CHANNELOB); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (8):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)NLACHANNEL_NAMEWIDTH, ymaxc, 10); - } - else { - /* sub-object folders - lighter */ - UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); + /* if special types, draw manually for now... */ + if (doDraw) { + /* now, start drawing based on this information */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + /* draw backing strip behind channel name */ + if (group == 5) { + /* Action Line */ + AnimData *adt= ale->adt; + + // TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now) + if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { + // greenish color (same as tweaking strip) - hardcoded for now + glColor3f(0.3f, 0.95f, 0.1f); + } + else { + if (ale->data) + glColor3f(0.8f, 0.2f, 0.0f); // reddish color - hardcoded for now + else + glColor3f(0.6f, 0.5f, 0.5f); // greyish-red color - hardcoded for now + } offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); - glEnd(); + + /* only on top two corners, to show that this channel sits on top of the preceeding ones */ + uiSetRoundBox((1|2)); + + /* draw slightly shifted up vertically to look like it has more separtion from other channels, + * but we then need to slightly shorten it so that it doesn't look like it overlaps + */ + gl_round_box(GL_POLYGON, x+offset, yminc+NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc+NLACHANNEL_SKIP-1, 8); /* clear group value, otherwise we cause errors... */ group = 0; } - } - else if (group == 5) { - /* Action Line */ - AnimData *adt= ale->adt; - - // TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now) - if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { - // greenish color (same as tweaking strip) - hardcoded for now - glColor3f(0.3f, 0.95f, 0.1f); - } else { - if (ale->data) - glColor3f(0.8f, 0.2f, 0.0f); // reddish color - hardcoded for now - else - glColor3f(0.6f, 0.5f, 0.5f); // greyish-red color - hardcoded for now + /* for normal channels + * - use 3 shades of color group/standard color for 3 indention level + */ + UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); + + indent += group; + offset += 7 * indent; + glBegin(GL_QUADS); + glVertex2f(x+offset, yminc); + glVertex2f(x+offset, ymaxc); + glVertex2f((float)v2d->cur.xmax, ymaxc); + glVertex2f((float)v2d->cur.xmax, yminc); + glEnd(); } - offset += 7 * indent; - - /* only on top two corners, to show that this channel sits on top of the preceeding ones */ - uiSetRoundBox((1|2)); - - /* draw slightly shifted up vertically to look like it has more separtion from other channels, - * but we then need to slightly shorten it so that it doesn't look like it overlaps - */ - gl_round_box(GL_POLYGON, x+offset, yminc+NLACHANNEL_SKIP, (float)NLACHANNEL_NAMEWIDTH, ymaxc+NLACHANNEL_SKIP-1, 8); - - /* clear group value, otherwise we cause errors... */ - group = 0; - } - else { - /* for normal channels - * - use 3 shades of color group/standard color for 3 indention level - */ - UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); - - indent += group; - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)NLACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)NLACHANNEL_NAMEWIDTH, yminc); - glEnd(); - } - - /* draw expand/collapse triangle */ - if (expand > 0) { - UI_icon_draw(x+offset, ydatac, expand); - offset += 17; - } - - /* draw special icon indicating certain data-types */ - if (special > -1) { - /* for normal channels */ - UI_icon_draw(x+offset, ydatac, special); - offset += 17; - } - glDisable(GL_BLEND); - - /* draw name */ - if (sel) - UI_ThemeColor(TH_TEXT_HI); - else - UI_ThemeColor(TH_TEXT); - offset += 3; - UI_DrawString(x+offset, y-4, name); - - /* reset offset - for RHS of panel */ - offset = 0; - - /* set blending again, as text drawing may clear it */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw protect 'lock' */ - if (protect > -1) { - offset = 16; - UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, protect); - } - - /* draw mute 'eye' */ - if (mute > -1) { - offset += 16; - UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, mute); - } - - /* draw NLA-action line 'status-icons' - only when there's an action */ - if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) { - AnimData *adt= ale->adt; - - offset += 16; - - /* now draw some indicator icons */ - if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) { - /* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */ - // for now, use pin icon to symbolise this - if (adt->flag & ADT_NLA_EDIT_NOMAP) - UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, ICON_PINNED); - else - UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, ICON_UNPINNED); - - fdrawline((float)(NLACHANNEL_NAMEWIDTH-offset), yminc, - (float)(NLACHANNEL_NAMEWIDTH-offset), ymaxc); - offset += 16;; - - /* 'tweaking action' indicator - not a button */ - UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_EDIT); + /* draw expand/collapse triangle */ + if (expand > 0) { + UI_icon_draw(x+offset, ydatac, expand); + offset += 17; } - else { - /* XXX firstly draw a little rect to help identify that it's different from the toggles */ - glBegin(GL_LINE_LOOP); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-offset-1, y-7); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-offset-1, y+9); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-1, y+9); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-1, y-7); - glEnd(); // GL_LINES - - /* 'push down' icon for normal active-actions */ - UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_FREEZE); + + /* draw special icon indicating certain data-types */ + if (special > -1) { + /* for normal channels */ + UI_icon_draw(x+offset, ydatac, special); + offset += 17; } + glDisable(GL_BLEND); + + /* draw name */ + if (sel) + UI_ThemeColor(TH_TEXT_HI); + else + UI_ThemeColor(TH_TEXT); + offset += 3; + UI_DrawString(x+offset, y-4, name); + + /* reset offset - for RHS of panel */ + offset = 0; + + /* set blending again, as text drawing may clear it */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + /* draw protect 'lock' */ + if (protect > -1) { + offset = 16; + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, protect); + } + + /* draw mute 'eye' */ + if (mute > -1) { + offset += 16; + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, mute); + } + + /* draw NLA-action line 'status-icons' - only when there's an action */ + if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) { + AnimData *adt= ale->adt; + + offset += 16; + + /* now draw some indicator icons */ + if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) { + /* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */ + // for now, use pin icon to symbolise this + if (adt->flag & ADT_NLA_EDIT_NOMAP) + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_PINNED); + else + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_UNPINNED); + + fdrawline((float)(v2d->cur.xmax-offset), yminc, + (float)(v2d->cur.xmax-offset), ymaxc); + offset += 16;; + + /* 'tweaking action' indicator - not a button */ + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_EDIT); + } + else { + /* XXX firstly draw a little rect to help identify that it's different from the toggles */ + glBegin(GL_LINE_LOOP); + glVertex2f((float)v2d->cur.xmax-offset-1, y-7); + glVertex2f((float)v2d->cur.xmax-offset-1, y+9); + glVertex2f((float)v2d->cur.xmax-1, y+9); + glVertex2f((float)v2d->cur.xmax-1, y-7); + glEnd(); // GL_LINES + + /* 'push down' icon for normal active-actions */ + UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_FREEZE); + } + } + + glDisable(GL_BLEND); } - - glDisable(GL_BLEND); } /* adjust y-position for next one */ y -= NLACHANNEL_STEP; } +} + +void draw_nla_channel_list (bContext *C, bAnimContext *ac, SpaceNla *snla, ARegion *ar) +{ + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + View2D *v2d= &ar->v2d; + float y= 0.0f; + int items, height; + + /* build list of channels to draw */ + filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS); + items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + + /* Update max-extent of channels here (taking into account scrollers): + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first + * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for + * start of list offset, and the second is as a correction for the scrollers. + */ + height= ((items*NLACHANNEL_STEP) + (NLACHANNEL_HEIGHT*2)); + /* don't use totrect set, as the width stays the same + * (NOTE: this is ok here, the configuration is pretty straightforward) + */ + v2d->tot.ymin= (float)(-height); + + /* draw channels */ + { /* first pass: backdrops + oldstyle drawing */ + y= (float)(-NLACHANNEL_HEIGHT); + + draw_nla_channel_list_gl(ac, &anim_data, v2d, y); + } + { /* second pass: UI widgets */ + uiBlock *block= uiBeginBlock(C, ar, "NLA channel buttons", UI_EMBOSS); + + y= (float)(-NLACHANNEL_HEIGHT); + + /* set blending again, as may not be set in previous step */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + /* loop through channels, and set up drawing depending on their type */ + for (ale= anim_data.first; ale; ale= ale->next) { + const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF); + const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF); + + /* check if visible */ + if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + { + /* draw all channels using standard channel-drawing API */ + ANIM_channel_draw_widgets(ac, ale, block, yminc, ymaxc); + } + + /* adjust y-position for next one */ + y -= NLACHANNEL_STEP; + } + + uiEndBlock(C, block); + uiDrawBlock(C, block); + + glDisable(GL_BLEND); + } /* free tempolary channels */ BLI_freelistN(&anim_data); diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index d476852ef2d..763f4116416 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -919,6 +919,58 @@ void NLA_OT_split (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/* ******************** Bake Strips Operator ***************************** */ +/* Bakes the NLA Strips for the active AnimData blocks */ + +static int nlaedit_bake_exec (bContext *C, wmOperator *op) +{ + bAnimContext ac; + + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + + /* get a list of the editable tracks being shown in the NLA */ + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + + /* for each AnimData block, bake strips to animdata... */ + for (ale= anim_data.first; ale; ale= ale->next) { + // FIXME + } + + /* free temp data */ + BLI_freelistN(&anim_data); + + /* refresh auto strip properties */ + ED_nla_postop_refresh(&ac); + + /* set notifier that things have changed */ + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL); + + /* done */ + return OPERATOR_FINISHED; +} + +void NLA_OT_bake (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Bake Strips"; + ot->idname= "NLA_OT_bake"; + ot->description= "Bake all strips of selected AnimData blocks."; + + /* api callbacks */ + ot->exec= nlaedit_bake_exec; + ot->poll= nlaop_poll_tweakmode_off; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /* *********************************************** */ /* NLA Editing Operations (Modifying) */ diff --git a/source/blender/editors/space_nla/nla_header.c b/source/blender/editors/space_nla/nla_header.c index 20343adef03..e507efb0a30 100644 --- a/source/blender/editors/space_nla/nla_header.c +++ b/source/blender/editors/space_nla/nla_header.c @@ -151,8 +151,8 @@ static void nla_editmenu(bContext *C, uiLayout *layout, void *arg_unused) { Scene *scene= CTX_data_scene(C); - uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu); - uiItemMenuF(layout, "Snap", 0, nla_edit_snapmenu); + uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu, NULL); + uiItemMenuF(layout, "Snap", 0, nla_edit_snapmenu, NULL); uiItemS(layout); @@ -261,13 +261,14 @@ void nla_header_buttons(const bContext *C, ARegion *ar) uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Lamps"); uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCAM, B_REDR, ICON_CAMERA_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Cameras"); uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCUR, B_REDR, ICON_CURVE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Curves"); + uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMBA, B_REDR, ICON_META_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display MetaBalls"); uiDefIconButBitI(block, TOGN, ADS_FILTER_NOPART, B_REDR, ICON_PARTICLE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Particles"); uiBlockEndAlign(block); xco += 15; } else { // XXX this case shouldn't happen at all... for now, just pad out same amount of space - xco += 7*XIC + 15; + xco += 10*XIC + 15; } xco += (XIC + 8); diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index 7cc09707ba7..e4557ec878f 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -45,7 +45,7 @@ void NLA_OT_properties(wmOperatorType *ot); /* nla_draw.c */ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar); -void draw_nla_channel_list(bAnimContext *ac, SpaceNla *snla, ARegion *ar); +void draw_nla_channel_list(bContext *C, bAnimContext *ac, SpaceNla *snla, ARegion *ar); /* **************************************** */ /* nla_header.c */ diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 6f377aabd4e..c4f929274c7 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -238,7 +238,7 @@ static void nla_channel_area_draw(const bContext *C, ARegion *ar) /* data */ if (ANIM_animdata_get_context(C, &ac)) { - draw_nla_channel_list(&ac, snla, ar); + draw_nla_channel_list((bContext *)C, &ac, snla, ar); } /* reset view matrix */ diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 70e2167c1e4..f3df7a29c2e 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -607,9 +607,9 @@ static void do_node_internal_buttons(bContext *C, void *node_v, int event) } WM_event_add_notifier(C, NC_SCENE|ND_NODES, CTX_data_scene(C)); } - - // else if(snode->treetype==NTREE_TEXTURE) - // texture_node_event(snode, val); + else if(snode->treetype==NTREE_TEXTURE) { + WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id); + } } } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index fe68a56dea5..e1b612d74e1 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -56,6 +56,7 @@ #include "BKE_main.h" #include "BKE_node.h" #include "BKE_material.h" +#include "BKE_paint.h" #include "BKE_texture.h" #include "BKE_scene.h" #include "BKE_utildefines.h" @@ -212,10 +213,8 @@ void snode_handle_recalc(bContext *C, SpaceNode *snode) WM_event_add_notifier(C, NC_MATERIAL|ND_NODES, snode->id); else if(snode->treetype==NTREE_COMPOSIT) WM_event_add_notifier(C, NC_SCENE|ND_NODES, snode->id); - else if(snode->treetype==NTREE_TEXTURE) { - // ntreeTexUpdatePreviews(snode->nodetree); /* XXX texture nodes should follow shader node methods (ton) */ - // XXX BIF_preview_changed(ID_TE); - } + else if(snode->treetype==NTREE_TEXTURE) + WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id); } #if 0 @@ -486,7 +485,7 @@ static void texture_node_event(SpaceNode *snode, short event) #endif /* 0 */ /* assumes nothing being done in ntree yet, sets the default in/out node */ /* called from shading buttons or header */ -void node_shader_default(Material *ma) +void ED_node_shader_default(Material *ma) { bNode *in, *out; bNodeSocket *fromsock, *tosock; @@ -516,7 +515,7 @@ void node_shader_default(Material *ma) /* assumes nothing being done in ntree yet, sets the default in/out node */ /* called from shading buttons or header */ -void node_composit_default(Scene *sce) +void ED_node_composit_default(Scene *sce) { bNode *in, *out; bNodeSocket *fromsock, *tosock; @@ -550,7 +549,7 @@ void node_composit_default(Scene *sce) /* assumes nothing being done in ntree yet, sets the default in/out node */ /* called from shading buttons or header */ -void node_texture_default(Tex *tx) +void ED_node_texture_default(Tex *tx) { bNode *in, *out; bNodeSocket *fromsock, *tosock; @@ -592,7 +591,7 @@ void snode_set_context(SpaceNode *snode, Scene *scene) if(ob) { Material *ma= give_current_material(ob, ob->actcol); if(ma) { - snode->from= material_from(ob, ob->actcol); + snode->from= &ob->id; snode->id= &ma->id; snode->nodetree= ma->nodetree; } @@ -614,7 +613,13 @@ void snode_set_context(SpaceNode *snode, Scene *scene) if(snode->texfrom==SNODE_TEX_OBJECT) { if(ob) { tx= give_current_texture(ob, ob->actcol); - snode->from= (ID *)ob; + + if(ob->type == OB_LAMP) + snode->from= (ID*)ob->data; + else + snode->from= (ID*)give_current_material(ob, ob->actcol); + + /* from is not set fully for material nodes, should be ID + Node then */ } } else if(snode->texfrom==SNODE_TEX_WORLD) { @@ -623,23 +628,20 @@ void snode_set_context(SpaceNode *snode, Scene *scene) } else { MTex *mtex= NULL; + Brush *brush= NULL; - if(G.f & G_SCULPTMODE) { - Sculpt *sd= scene->toolsettings->sculpt; - if(sd && sd->brush) - if(sd->brush->texact != -1) - mtex= sd->brush->mtex[sd->brush->texact]; - } - else { - Brush *br= scene->toolsettings->imapaint.brush; - if(br) - mtex= br->mtex[br->texact]; - } - - if(mtex) { - snode->from= (ID *)scene; + if(ob && (ob->mode & OB_MODE_SCULPT)) + brush= paint_brush(&scene->toolsettings->sculpt->paint); + else + brush= paint_brush(&scene->toolsettings->imapaint.paint); + + if(brush && brush->texact != -1) + mtex= brush->mtex[brush->texact]; + + snode->from= (ID *)brush; + + if(mtex) tx= mtex->tex; - } } if(tx) { @@ -2270,34 +2272,6 @@ void node_read_fullsamplelayers(SpaceNode *snode) WM_cursor_wait(0); } -/* called from header_info, when deleting a scene - * goes over all scenes other than the input, checks if they have - * render layer nodes referencing the to-be-deleted scene, and - * resets them to NULL. */ - -/* XXX needs to get current scene then! */ -void clear_scene_in_nodes(Scene *sce) -{ - Scene *sce1; - bNode *node; - - sce1= G.main->scene.first; - while(sce1) { - if(sce1!=sce) { - if (sce1->nodetree) { - for(node= sce1->nodetree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS) { - Scene *nodesce= (Scene *)node->id; - - if (nodesce==sce) node->id = NULL; - } - } - } - } - sce1= sce1->id.next; - } -} - void imagepaint_composite_tags(bNodeTree *ntree, Image *image, ImageUser *iuser) { bNode *node; diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 367242d1262..2abcd2f2135 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -45,6 +45,7 @@ #include "BKE_screen.h" #include "BKE_node.h" #include "BKE_main.h" +#include "BKE_utildefines.h" #include "ED_screen.h" #include "ED_types.h" @@ -62,67 +63,9 @@ #include "node_intern.h" -/* ************************ header area region *********************** */ +/* ************************ add menu *********************** */ -static void do_node_selectmenu(bContext *C, void *arg, int event) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceNode *snode= CTX_wm_space_node(C); - - /* functions in editnode.c assume there's a tree */ - if(snode->nodetree==NULL) - return; - - switch(event) { - case 1: /* border select */ - WM_operator_name_call(C, "NODE_OT_select_border", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 2: /* select/deselect all */ - // XXX node_deselectall(snode, 1); - break; - case 3: /* select linked in */ - // XXX node_select_linked(snode, 0); - break; - case 4: /* select linked out */ - // XXX node_select_linked(snode, 1); - break; - } - - ED_area_tag_redraw(curarea); -} - -static uiBlock *node_selectmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "node_selectmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_selectmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Select|B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked From|L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked To|Shift L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - -void do_node_addmenu(bContext *C, void *arg, int event) +static void do_node_add(bContext *C, void *arg, int event) { SpaceNode *snode= CTX_wm_space_node(C); bNode *node; @@ -141,311 +84,125 @@ void do_node_addmenu(bContext *C, void *arg, int event) snode_handle_recalc(C, snode); } -static void node_make_addmenu(bContext *C, int nodeclass, uiBlock *block) +static void node_auto_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) { Main *bmain= CTX_data_main(C); SpaceNode *snode= CTX_wm_space_node(C); bNodeTree *ntree; + int nodeclass= GET_INT_FROM_POINTER(arg_nodeclass); int tot= 0, a; - short yco= 0, menuwidth=120; ntree = snode->nodetree; - if(ntree) { - /* mostly taken from toolbox.c, node_add_sublevel() */ - if(ntree) { - if(nodeclass==NODE_CLASS_GROUP) { - bNodeTree *ngroup= bmain->nodetree.first; - for(; ngroup; ngroup= ngroup->id.next) - if(ngroup->type==ntree->type) - tot++; - } - else { - bNodeType *type = ntree->alltypes.first; - while(type) { - if(type->nclass == nodeclass) - tot++; - type= type->next; - } - } - } - - if(tot==0) { - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - return; - } - - if(nodeclass==NODE_CLASS_GROUP) { - bNodeTree *ngroup= bmain->nodetree.first; - for(tot=0, a=0; ngroup; ngroup= ngroup->id.next, tot++) { - if(ngroup->type==ntree->type) { - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, (ngroup->id.name+2), 0, - yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1.0f, (float)(NODE_GROUP_MENU+tot), ""); - a++; - } - } - } - else { - bNodeType *type; - int script=0; - for(a=0, type= ntree->alltypes.first; type; type=type->next) { - if( type->nclass == nodeclass && type->name) { - if(type->type == NODE_DYNAMIC) { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, type->name, 0, - yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1.0f, (float)(NODE_DYNAMIC_MENU+script), ""); - script++; - } else { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, type->name, 0, - yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1.0f, (float)(type->type), ""); - } - a++; - } - } - } - } else { - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + if(!ntree) { + uiItemS(layout); return; } -} -static uiBlock *node_add_inputmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_inputmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_INPUT, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_outputmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_outputmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OUTPUT, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_colormenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_colormenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OP_COLOR, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_vectormenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_vectormenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OP_VECTOR, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_filtermenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_filtermenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OP_FILTER, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_convertermenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_convertermenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_CONVERTOR, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_mattemenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_mattemenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_MATTE, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_distortmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_distortmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_DISTORT, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_patternmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_patternmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_PATTERN, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_texturemenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_texturemenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_TEXTURE, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} -static uiBlock *node_add_groupmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_groupmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_GROUP, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} - -static uiBlock *node_add_dynamicmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - - block= uiBeginBlock(C, ar, "node_add_dynamicmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - node_make_addmenu(C, NODE_CLASS_OP_DYNAMIC, block); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - uiEndBlock(C, block); - - return block; -} - -static uiBlock *node_addmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceNode *snode= CTX_wm_space_node(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "node_addmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_addmenu, NULL); - - if(snode->treetype==NTREE_SHADER) { - uiDefIconTextBlockBut(block, node_add_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_outputmenu, NULL, ICON_RIGHTARROW_THIN, "Output", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_colormenu, NULL, ICON_RIGHTARROW_THIN, "Color", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_vectormenu, NULL, ICON_RIGHTARROW_THIN, "Vector", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_dynamicmenu, NULL, ICON_RIGHTARROW_THIN, "Dynamic", 0, yco-=20, 120, 19, ""); - } - else if(snode->treetype==NTREE_COMPOSIT) { - uiDefIconTextBlockBut(block, node_add_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_outputmenu, NULL, ICON_RIGHTARROW_THIN, "Output", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_colormenu, NULL, ICON_RIGHTARROW_THIN, "Color", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_vectormenu, NULL, ICON_RIGHTARROW_THIN, "Vector", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_filtermenu, NULL, ICON_RIGHTARROW_THIN, "Filter", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_mattemenu, NULL, ICON_RIGHTARROW_THIN, "Matte", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_distortmenu, NULL, ICON_RIGHTARROW_THIN, "Distort", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, ""); - - } else if(snode->treetype==NTREE_TEXTURE) { - uiDefIconTextBlockBut(block, node_add_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_outputmenu, NULL, ICON_RIGHTARROW_THIN, "Output", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_colormenu, NULL, ICON_RIGHTARROW_THIN, "Color", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_patternmenu, NULL, ICON_RIGHTARROW_THIN, "Patterns", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_texturemenu, NULL, ICON_RIGHTARROW_THIN, "Textures", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_distortmenu, NULL, ICON_RIGHTARROW_THIN, "Distort", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, ""); - } - else - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); + /* mostly taken from toolbox.c, node_add_sublevel() */ + if(nodeclass==NODE_CLASS_GROUP) { + bNodeTree *ngroup= bmain->nodetree.first; + for(; ngroup; ngroup= ngroup->id.next) + if(ngroup->type==ntree->type) + tot++; } else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); + bNodeType *type = ntree->alltypes.first; + while(type) { + if(type->nclass == nodeclass) + tot++; + type= type->next; + } + } + + if(tot==0) { + uiItemS(layout); + return; } + + uiLayoutSetFunc(layout, do_node_add, NULL); - uiTextBoundsBlock(block, 50); - - return block; + if(nodeclass==NODE_CLASS_GROUP) { + bNodeTree *ngroup= bmain->nodetree.first; + + for(tot=0, a=0; ngroup; ngroup= ngroup->id.next, tot++) { + if(ngroup->type==ntree->type) { + uiItemV(layout, ngroup->id.name+2, 0, NODE_GROUP_MENU+tot); + a++; + } + } + } + else { + bNodeType *type; + int script=0; + + for(a=0, type= ntree->alltypes.first; type; type=type->next) { + if(type->nclass == nodeclass && type->name) { + if(type->type == NODE_DYNAMIC) { + uiItemV(layout, type->name, 0, NODE_DYNAMIC_MENU+script); + script++; + } + else + uiItemV(layout, type->name, 0, type->type); + + a++; + } + } + } } +static void node_menu_add(const bContext *C, Menu *menu) +{ + uiLayout *layout= menu->layout; + SpaceNode *snode= CTX_wm_space_node(C); + + if(!snode->nodetree) + uiLayoutSetActive(layout, 0); + + if(snode->treetype==NTREE_SHADER) { + uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT)); + uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT)); + uiItemMenuF(layout, "Color", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR)); + uiItemMenuF(layout, "Vector", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_VECTOR)); + uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR)); + uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP)); + uiItemMenuF(layout, "Dynamic", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_DYNAMIC)); + } + else if(snode->treetype==NTREE_COMPOSIT) { + uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT)); + uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT)); + uiItemMenuF(layout, "Color", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR)); + uiItemMenuF(layout, "Vector", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_VECTOR)); + uiItemMenuF(layout, "Filter", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_FILTER)); + uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR)); + uiItemMenuF(layout, "Matte", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_MATTE)); + uiItemMenuF(layout, "Distort", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_DISTORT)); + uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP)); + } + else if(snode->treetype==NTREE_TEXTURE) { + uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT)); + uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT)); + uiItemMenuF(layout, "Color", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR)); + uiItemMenuF(layout, "Patterns", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_PATTERN)); + uiItemMenuF(layout, "Textures", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_TEXTURE)); + uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR)); + uiItemMenuF(layout, "Distort", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_DISTORT)); + uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP)); + } +} + +void node_menus_register(ARegionType *art) +{ + MenuType *mt; + + mt= MEM_callocN(sizeof(MenuType), "spacetype node menu add"); + strcpy(mt->idname, "NODE_MT_add"); + strcpy(mt->label, "Add"); + mt->draw= node_menu_add; + BLI_addtail(&art->menutypes, mt); +} + +#if 0 static void do_node_nodemenu(bContext *C, void *arg, int event) { ScrArea *curarea= CTX_wm_area(C); @@ -571,218 +328,5 @@ static uiBlock *node_nodemenu(bContext *C, ARegion *ar, void *arg_unused) return block; } - -static void do_node_viewmenu(bContext *C, void *arg, int event) -{ -// SpaceNode *snode= CTX_wm_space_node(C); -// ARegion *ar= CTX_wm_region(C); - ScrArea *sa= CTX_wm_area(C); - - switch(event) { - case 1: /* Zoom in */ - WM_operator_name_call(C, "VIEW2D_OT_zoom_in", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 2: /* View all */ - WM_operator_name_call(C, "VIEW2D_OT_zoom_out", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 3: /* View all */ - WM_operator_name_call(C, "NODE_OT_view_all", WM_OP_EXEC_REGION_WIN, NULL); - break; - case 4: /* Grease Pencil */ - // XXX add_blockhandler(sa, NODES_HANDLER_GREASEPENCIL, UI_PNL_UNSTOW); - break; - } - ED_area_tag_redraw(sa); -} - -static uiBlock *node_viewmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceNode *snode= CTX_wm_space_node(C); - uiBlock *block; - short yco= 0, menuwidth=120; - - block= uiBeginBlock(C, ar, "node_viewmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_node_viewmenu, NULL); - - if (snode->nodetree) { - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Grease Pencil...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - } - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom In|NumPad +", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom Out|NumPad -", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - - /* XXX if (!curarea->full) - uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - else - uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - */ - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - -static void do_node_buttons(bContext *C, void *arg, int event) -{ - // NODE_FIX_ME : instead of using "current material/texture/scene", node editor can also pin context? - // note: scene context better not gets overridden, that'll clash too much (ton) - SpaceNode *snode= CTX_wm_space_node(C); - Scene *scene= CTX_data_scene(C); - Material *ma; - Tex *tx; - - switch(event) { - case B_REDR: - ED_area_tag_redraw(CTX_wm_area(C)); - break; - case B_NODE_USEMAT: - ma= (Material *)snode->id; - if(ma) { - if(ma->use_nodes && ma->nodetree==NULL) { - node_shader_default(ma); - snode_set_context(snode, scene); - } - } - ED_area_tag_redraw(CTX_wm_area(C)); - break; - - case B_NODE_USESCENE: - if(scene->use_nodes) { - if(scene->nodetree==NULL) - node_composit_default(scene); - } - snode_set_context(snode, scene); - ED_area_tag_redraw(CTX_wm_area(C)); - break; - - case B_NODE_USETEX: - tx = (Tex *)snode->id; - if(tx) { - tx->type = 0; - if(tx->use_nodes && tx->nodetree==NULL) { - node_texture_default(tx); - snode_set_context(snode, scene); - } - } - ED_area_tag_redraw(CTX_wm_area(C)); - break; - } -} - -void node_header_buttons(const bContext *C, ARegion *ar) -{ - ScrArea *sa= CTX_wm_area(C); - SpaceNode *snode= CTX_wm_space_node(C); - Scene *scene= CTX_data_scene(C); - uiBlock *block; - short xco, yco= 3; - - block= uiBeginBlock(C, ar, "header node", UI_EMBOSS); - uiBlockSetHandleFunc(block, do_node_buttons, NULL); - - xco= ED_area_header_standardbuttons(C, block, yco); - - if((sa->flag & HEADER_NO_PULLDOWN)==0) { - int xmax; - - xmax= GetButStringLength("View"); - uiDefPulldownBut(block, node_viewmenu, NULL, - "View", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Select"); - uiDefPulldownBut(block, node_selectmenu, NULL, - "Select", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Add"); - uiDefPulldownBut(block, node_addmenu, NULL, - "Add", xco, yco, xmax-3, 20, ""); - xco+= xmax; - - xmax= GetButStringLength("Node"); - uiDefPulldownBut(block, node_nodemenu, NULL, - "Node", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } - - uiBlockSetEmboss(block, UI_EMBOSS); - - uiBlockSetEmboss(block, UI_EMBOSS); - - /* main type choosing */ - uiBlockBeginAlign(block); - uiDefIconButI(block, ROW, B_REDR, ICON_MATERIAL_DATA, xco,yco,XIC,YIC-2, - &(snode->treetype), 2.0f, 0.0f, 0.0f, 0.0f, "Material Nodes"); - xco+= XIC; - uiDefIconButI(block, ROW, B_REDR, ICON_IMAGE_DATA, xco,yco,XIC,YIC-2, - &(snode->treetype), 2.0f, 1.0f, 0.0f, 0.0f, "Composite Nodes"); - xco+= XIC; - uiDefIconButI(block, ROW, B_REDR, ICON_TEXTURE_DATA, xco,yco,XIC,YIC-2, - &(snode->treetype), 2.0f, 2.0f, 0.0f, 0.0f, "Texture Nodes"); - xco+= 2*XIC; - uiBlockEndAlign(block); - - /* find and set the context */ - snode_set_context(snode, scene); - - if(snode->treetype==NTREE_SHADER) { - if(snode->from) { - /* 0, NULL -> pin */ - // XXX xco= std_libbuttons(block, xco, 0, 0, NULL, B_MATBROWSE, ID_MA, 1, snode->id, snode->from, &(snode->menunr), - // B_MATALONE, B_MATLOCAL, B_MATDELETE, B_AUTOMATNAME, B_KEEPDATA); - - if(snode->id) { - Material *ma= (Material *)snode->id; - uiDefButC(block, TOG, B_NODE_USEMAT, "Use Nodes", xco+5,yco,90,19, &ma->use_nodes, 0.0f, 0.0f, 0, 0, ""); - xco+=80; - } - } - } - else if(snode->treetype==NTREE_COMPOSIT) { - int icon; - - if(WM_jobs_test(CTX_wm_manager(C), sa)) icon= ICON_REC; else icon= ICON_BLANK1; - uiDefIconTextButS(block, TOG, B_NODE_USESCENE, icon, "Use Nodes", xco+5,yco,100,19, &scene->use_nodes, 0.0f, 0.0f, 0, 0, "Indicate this Scene will use Nodes and execute them while editing"); - xco+= 100; - uiDefButBitI(block, TOG, R_COMP_FREE, B_NOP, "Free Unused", xco+5,yco,100,19, &scene->r.scemode, 0.0f, 0.0f, 0, 0, "Free Nodes that are not used while composite"); - xco+= 100; - uiDefButBitS(block, TOG, SNODE_BACKDRAW, B_REDR, "Backdrop", xco+5,yco,90,19, &snode->flag, 0.0f, 0.0f, 0, 0, "Use active Viewer Node output as backdrop"); - xco+= 90; - } - else if(snode->treetype==NTREE_TEXTURE) { - if(snode->from) { - - // XXX xco= std_libbuttons(block, xco, 0, 0, NULL, B_TEXBROWSE, ID_TE, 1, snode->id, snode->from, &(snode->menunr), - // B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA); - - if(snode->id) { - Tex *tx= (Tex *)snode->id; - uiDefButC(block, TOG, B_NODE_USETEX, "Use Nodes", xco+5,yco,90,19, &tx->use_nodes, 0.0f, 0.0f, 0, 0, ""); - xco+=80; - } - } - } - - UI_view2d_totRect_set(&ar->v2d, xco+XIC+100, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin)); - - uiEndBlock(C, block); - uiDrawBlock(C, block); -} - +#endif diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index d6680457376..5c66c902797 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -31,6 +31,7 @@ /* internal exports only */ struct ARegion; +struct ARegionType; struct View2D; struct bContext; struct wmWindowManager; @@ -45,6 +46,7 @@ struct wmWindowManager; /* node_header.c */ void node_header_buttons(const bContext *C, ARegion *ar); +void node_menus_register(struct ARegionType *art); /* node_draw.c */ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d); @@ -75,9 +77,6 @@ void snode_make_group_editable(SpaceNode *snode, bNode *gnode); void snode_home(ScrArea *sa, ARegion *ar, SpaceNode *snode); void node_set_active(SpaceNode *snode, bNode *node); void node_deselectall(SpaceNode *snode, int swap); -void node_shader_default(Material *ma); -void node_composit_default(Scene *sce); -void node_texture_default(Tex *tx); void snode_composite_job(const struct bContext *C, ScrArea *sa); bNode *snode_get_editgroup(SpaceNode *snode); void snode_autoconnect(SpaceNode *snode, bNode *node_to, int flag); diff --git a/source/blender/editors/space_node/node_state.c b/source/blender/editors/space_node/node_state.c index 8d805490942..dcab3dc0895 100644 --- a/source/blender/editors/space_node/node_state.c +++ b/source/blender/editors/space_node/node_state.c @@ -183,7 +183,7 @@ void NODE_OT_visibility_toggle(wmOperatorType *ot) RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX); } -static int node_fit_all_exec(bContext *C, wmOperator *op) +static int node_view_all_exec(bContext *C, wmOperator *op) { ScrArea *sa= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); @@ -196,11 +196,11 @@ static int node_fit_all_exec(bContext *C, wmOperator *op) void NODE_OT_view_all(wmOperatorType *ot) { /* identifiers */ - ot->name= "Fit All"; + ot->name= "View All"; ot->idname= "NODE_OT_view_all"; /* api callbacks */ - ot->exec= node_fit_all_exec; + ot->exec= node_view_all_exec; ot->poll= ED_operator_node_active; /* flags */ diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 25e1b368ccb..cb25d29fd27 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -46,6 +46,7 @@ #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_screen.h" +#include "BKE_node.h" #include "ED_previewrender.h" #include "ED_space_api.h" @@ -152,12 +153,16 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) if(wmn->data==ND_FILEREAD) ED_area_tag_refresh(sa); break; - + + /* future: add ID checks? */ case NC_MATERIAL: - /* future: add ID check? */ if(wmn->data==ND_SHADING) ED_area_tag_refresh(sa); break; + case NC_TEXTURE: + if(wmn->data==ND_NODES) + ED_area_tag_refresh(sa); + break; } } @@ -170,13 +175,18 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) if(snode->treetype==NTREE_SHADER) { Material *ma= (Material *)snode->id; if(ma->use_nodes) - ED_preview_shader_job(C, sa, snode->id, NULL, 100, 100); + ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100); } else if(snode->treetype==NTREE_COMPOSIT) { Scene *scene= (Scene *)snode->id; if(scene->use_nodes) snode_composite_job(C, sa); } + else if(snode->treetype==NTREE_TEXTURE) { + Tex *tex= (Tex *)snode->id; + if(tex->use_nodes) + ntreeTexUpdatePreviews(tex->nodetree); + } } } @@ -244,29 +254,18 @@ static void node_main_area_draw(const bContext *C, ARegion *ar) /* add handlers, stuff you only do once or on area/region changes */ static void node_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); + ED_region_header_init(ar); } static void node_header_area_draw(const bContext *C, ARegion *ar) { - float col[3]; - - /* clear */ - if(ED_screen_area_active(C)) - UI_GetThemeColor3fv(TH_HEADER, col); - else - UI_GetThemeColor3fv(TH_HEADERDESEL, col); - - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - /* set view2d view matrix for scrolling (without scrollers) */ - UI_view2d_view_ortho(C, &ar->v2d); - - node_header_buttons(C, ar); - - /* restore view matrix? */ - UI_view2d_view_restore(C); + SpaceNode *snode= CTX_wm_space_node(C); + Scene *scene= CTX_data_scene(C); + + /* find and set the context */ + snode_set_context(snode, scene); + + ED_region_header(C, ar); } /* used for header + main area */ @@ -275,9 +274,9 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_SCENE: - ED_region_tag_redraw(ar); - break; case NC_MATERIAL: + case NC_TEXTURE: + case NC_NODE: ED_region_tag_redraw(ar); break; } @@ -344,6 +343,8 @@ void ED_spacetype_node(void) art->draw= node_header_area_draw; BLI_addhead(&st->regiontypes, art); + + node_menus_register(art); #if 0 /* regions: channels */ diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 84dea679767..762ad82344b 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -620,7 +620,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i tenla->name= "Pose"; - if(arm->edbo==NULL && (ob->flag & OB_POSEMODE)) { // channels undefined in editmode, but we want the 'tenla' pose icon itself + if(arm->edbo==NULL && (ob->mode & OB_MODE_POSE)) { // channels undefined in editmode, but we want the 'tenla' pose icon itself int a= 0, const_index= 1000; /* ensure unique id for bone constraints */ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) { @@ -887,7 +887,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i else { /* do not extend Armature when we have posemode */ tselem= TREESTORE(te->parent); - if( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->flag & OB_POSEMODE); + if( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE); else { Bone *curBone; for (curBone=arm->bonebase.first; curBone; curBone=curBone->next){ @@ -1016,7 +1016,6 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i PointerRNA pptr, propptr, *ptr= (PointerRNA*)idv; PropertyRNA *prop, *iterprop; PropertyType proptype; - PropertySubType propsubtype; int a, tot; /* we do lazy build, for speed and to avoid infinite recusion */ @@ -1096,31 +1095,20 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i } } else if(type == TSE_RNA_ARRAY_ELEM) { - /* array property element */ - static char *vectoritem[4]= {" x", " y", " z", " w"}; - static char *quatitem[4]= {" w", " x", " y", " z"}; - static char *coloritem[4]= {" r", " g", " b", " a"}; + char c; prop= parent->directdata; - proptype= RNA_property_type(prop); - propsubtype= RNA_property_subtype(prop); - tot= RNA_property_array_length(prop); te->directdata= prop; te->rnaptr= *ptr; te->index= index; - if(tot == 4 && propsubtype == PROP_ROTATION) - te->name= quatitem[index]; - else if(tot <= 4 && (propsubtype == PROP_VECTOR || propsubtype == PROP_ROTATION)) - te->name= vectoritem[index]; - else if(tot <= 4 && propsubtype == PROP_COLOR) - te->name= coloritem[index]; - else { - te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); - sprintf(te->name, " %d", index+1); - te->flag |= TE_FREE_NAME; - } + c= RNA_property_array_item_char(prop, index); + + te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); + if(c) sprintf(te->name, " %c", c); + else sprintf(te->name, " %d", index+1); + te->flag |= TE_FREE_NAME; } } else if(type == TSE_KEYMAP) { @@ -2189,13 +2177,13 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *te, if(scene->obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); - if(ob->flag & OB_POSEMODE) + if(ob->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); else ED_armature_enter_posemode(C, base); } else { - if(ob->flag & OB_POSEMODE) return 1; + if(ob->mode & OB_MODE_POSE) return 1; } return 0; } @@ -3073,10 +3061,6 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto if(scene->obedit==base->object) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); - if(base==BASACT) { - ED_view3d_exit_paint_modes(C); - } - ED_base_object_free_and_unlink(scene, base); te->directdata= NULL; tselem->id= NULL; @@ -3250,7 +3234,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); SpaceOops *soops= CTX_wm_space_outliner(C); int event; - char *str; + char *str= NULL; /* check for invalid states */ if (soops == NULL) @@ -3674,7 +3658,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle } else if(RNA_property_type(prop) == PROP_COLLECTION) { char buf[128], *name; - + temnext= (TreeElement*)(ld->next->data); tsenext= TREESTORE(temnext); @@ -3917,7 +3901,7 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add) /* add if none found */ // XXX the default settings have yet to evolve if ((add) && (ks==NULL)) { - ks= BKE_keyingset_add(&scene->keyingsets, "Keying Set", KEYINGSET_ABSOLUTE, 0); + ks= BKE_keyingset_add(&scene->keyingsets, NULL, KEYINGSET_ABSOLUTE, 0); scene->active_keyingset= BLI_countlist(&scene->keyingsets); } @@ -3942,7 +3926,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa short groupmode= KSP_GROUP_KSNAME; /* check if RNA-property described by this selected element is an animateable prop */ - if ((tselem->type == TSE_RNA_PROPERTY) && RNA_property_animateable(&te->rnaptr, te->directdata)) { + if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { /* get id + path + index info from the selected element */ tree_element_to_path(soops, te, tselem, &id, &path, &array_index, &flag, &groupmode); @@ -3979,8 +3963,6 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa /* free path, since it had to be generated */ MEM_freeN(path); } - - } /* go over sub-tree */ @@ -4178,13 +4160,13 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen case TSE_POSEGRP_BASE: UI_icon_draw(x, y, ICON_VERTEXSEL); break; case TSE_SEQUENCE: - if((te->idcode==SEQ_MOVIE) || (te->idcode==SEQ_MOVIE_AND_HD_SOUND)) + if(te->idcode==SEQ_MOVIE) UI_icon_draw(x, y, ICON_SEQUENCE); else if(te->idcode==SEQ_META) UI_icon_draw(x, y, ICON_DOT); else if(te->idcode==SEQ_SCENE) UI_icon_draw(x, y, ICON_SCENE); - else if((te->idcode==SEQ_RAM_SOUND) || (te->idcode==SEQ_HD_SOUND)) + else if(te->idcode==SEQ_SOUND) UI_icon_draw(x, y, ICON_SOUND); else if(te->idcode==SEQ_IMAGE) UI_icon_draw(x, y, ICON_IMAGE_COL); @@ -5097,6 +5079,28 @@ static char *keymap_tweak_menu(void) return string; } +static char *keymap_tweak_dir_menu(void) +{ + static char string[500]; + static char formatstr[] = "|%s %%x%d"; + char *str= string; + + str += sprintf(str, "Tweak Direction %%t"); + + str += sprintf(str, formatstr, "Any", KM_ANY); + str += sprintf(str, formatstr, "North", EVT_GESTURE_N); + str += sprintf(str, formatstr, "North-East", EVT_GESTURE_NE); + str += sprintf(str, formatstr, "East", EVT_GESTURE_E); + str += sprintf(str, formatstr, "Sout-East", EVT_GESTURE_SE); + str += sprintf(str, formatstr, "South", EVT_GESTURE_S); + str += sprintf(str, formatstr, "South-West", EVT_GESTURE_SW); + str += sprintf(str, formatstr, "West", EVT_GESTURE_W); + str += sprintf(str, formatstr, "North-West", EVT_GESTURE_NW); + + return string; +} + + static void keymap_type_cb(bContext *C, void *kmi_v, void *unused_v) { wmKeymapItem *kmi= kmi_v; @@ -5174,17 +5178,20 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo str= keymap_tweak_menu(); uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, OL_H-1, &kmi->type, 0, 0, 0, 0, "Tweak gesture"); xstart+= butw2+5; + str= keymap_tweak_dir_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, OL_H-1, &kmi->val, 0, 0, 0, 0, "Tweak gesture direction"); + xstart+= butw2+5; break; } /* modifiers */ - uiBlockBeginAlign(block); uiDefButS(block, OPTION, 0, "Shift", xstart, (int)te->ys+1, butw3+5, OL_H-1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart+= butw3+5; uiDefButS(block, OPTION, 0, "Ctrl", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart+= butw3; uiDefButS(block, OPTION, 0, "Alt", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart+= butw3; uiDefButS(block, OPTION, 0, "Cmd", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3; xstart+= 5; - uiBlockEndAlign(block); + uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->keymodifier, "Key Modifier code"); + xstart+= butw3+5; /* rna property */ if(kmi->ptr && kmi->ptr->data) diff --git a/source/blender/editors/space_outliner/outliner_header.c b/source/blender/editors/space_outliner/outliner_header.c index 0c7859ed4e2..d4eeaabd1d3 100644 --- a/source/blender/editors/space_outliner/outliner_header.c +++ b/source/blender/editors/space_outliner/outliner_header.c @@ -177,7 +177,7 @@ static void do_outliner_buttons(bContext *C, void *arg, int event) /* add a new KeyingSet if active is -1 */ if (scene->active_keyingset == -1) { // XXX the default settings have yet to evolve... need to keep this in sync with the - BKE_keyingset_add(&scene->keyingsets, "KeyingSet", KEYINGSET_ABSOLUTE, 0); + BKE_keyingset_add(&scene->keyingsets, NULL, KEYINGSET_ABSOLUTE, 0); scene->active_keyingset= BLI_countlist(&scene->keyingsets); } @@ -196,6 +196,8 @@ static void do_outliner_buttons(bContext *C, void *arg, int event) BLI_freelinkN(&scene->keyingsets, ks); scene->active_keyingset= 0; } + else + scene->active_keyingset= 0; } /* redraw regions with KeyingSet info */ diff --git a/source/blender/editors/space_sequencer/Makefile b/source/blender/editors/space_sequencer/Makefile index 7be0bc9cfef..2fb3de516b4 100644 --- a/source/blender/editors/space_sequencer/Makefile +++ b/source/blender/editors/space_sequencer/Makefile @@ -50,6 +50,7 @@ CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../python CPPFLAGS += -I../../blenfont CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include +CPPFLAGS += -I$(NAN_AUDASPACE)/include # own include diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript index ab51068a529..7a3fb6982ef 100644 --- a/source/blender/editors/space_sequencer/SConscript +++ b/source/blender/editors/space_sequencer/SConscript @@ -6,5 +6,6 @@ sources = env.Glob('*.c') incs = '../include ../../blenlib ../../blenkernel ../../blenfont ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../makesrna' +incs += ' #/intern/audaspace/intern' env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), [], libtype=['core'], priority=[100] ) diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 99a13c8d9e0..5d58ea431a9 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -89,6 +89,9 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "BKE_sound.h" +#include "AUD_C-API.h" + /* own include */ #include "sequencer_intern.h" @@ -224,24 +227,80 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME-2, "Scene Name", "Scene name to add as a strip"); } +static Sequence* sequencer_add_sound_strip(bContext *C, wmOperator *op, int start_frame, int channel, char* filename) +{ + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, TRUE); + + bSound *sound; + + Sequence *seq; /* generic strip vars */ + Strip *strip; + StripElem *se; + + AUD_SoundInfo info; + + sound = sound_new_file(CTX_data_main(C), filename); + + if (sound==NULL || sound->snd_sound == NULL) { + if(op) + BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); + return NULL; + } + + info = AUD_getInfo(sound->snd_sound); + + if (info.specs.format == AUD_FORMAT_INVALID) { + sound_delete(C, sound); + if(op) + BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); + return NULL; + } + + seq = alloc_sequence(ed->seqbasep, start_frame, channel); + + seq->type= SEQ_SOUND; + seq->sound= sound; + + /* basic defaults */ + seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); + strip->len = seq->len = (int) (info.length * FPS); + strip->us= 1; + + strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); + + BLI_split_dirfile_basic(filename, strip->dir, se->name); + + seq->sound_handle = sound_new_handle(scene, sound, start_frame, start_frame + strip->len, 0); + + calc_sequence_disp(seq); + sort_seq(scene); + + /* last active name */ + strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1); + + return seq; +} + /* add movie operator */ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, TRUE); - + struct anim *an; char filename[FILE_MAX]; - Sequence *seq; /* generic strip vars */ + Sequence *seq, *soundseq; /* generic strip vars */ Strip *strip; StripElem *se; - - int start_frame, channel; /* operator props */ - + + int start_frame, channel, sound; /* operator props */ + start_frame= RNA_int_get(op->ptr, "start_frame"); channel= RNA_int_get(op->ptr, "channel"); - + sound = RNA_boolean_get(op->ptr, "sound"); + RNA_string_get(op->ptr, "filename", filename); an = openanim(filename, IB_rect); @@ -271,10 +330,19 @@ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) calc_sequence_disp(seq); sort_seq(scene); + if(sound) + { + soundseq = sequencer_add_sound_strip(C, NULL, start_frame, channel+1, filename); + if(soundseq != NULL) + RNA_string_get(op->ptr, "name", soundseq->name); + } + if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); set_last_seq(scene, seq); seq->flag |= SELECT; + if(soundseq) + soundseq->flag |= SELECT; } ED_area_tag_redraw(CTX_wm_area(C)); @@ -310,24 +378,15 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); - RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load hd sound with the movie"); // XXX need to impliment this + RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load sound with the movie"); } - /* add sound operator */ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Editing *ed= seq_give_editing(scene, TRUE); - - bSound *sound; - char filename[FILE_MAX]; - + Scene *scene= CTX_data_scene(C); Sequence *seq; /* generic strip vars */ - Strip *strip; - StripElem *se; - int start_frame, channel; /* operator props */ start_frame= RNA_int_get(op->ptr, "start_frame"); @@ -335,47 +394,16 @@ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filename", filename); - /* XXX if(sfile->flag & FILE_STRINGCODE) { - BLI_makestringcode(G.sce, str); - }*/ + seq = sequencer_add_sound_strip(C, op, start_frame, channel, filename); -// XXX sound= sound_new_sound(filename); - sound= NULL; - - if (sound==NULL || sound->sample->type == SAMPLE_INVALID) { - BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); + if(seq == NULL) return OPERATOR_CANCELLED; - } - - if (sound==NULL || sound->sample->bits != 16) { - BKE_report(op->reports, RPT_ERROR, "Only 16 bit audio is supported"); - return OPERATOR_CANCELLED; - } - - sound->flags |= SOUND_FLAGS_SEQUENCE; -// XXX audio_makestream(sound); - - seq = alloc_sequence(ed->seqbasep, start_frame, channel); - - seq->type= SEQ_RAM_SOUND; - seq->sound= sound; - - /* basic defaults */ - seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len = (int) ( ((float)(sound->streamlen-1) / ( (float)scene->r.audio.mixrate*4.0 ))* FPS); - strip->us= 1; - - strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - - BLI_split_dirfile_basic(filename, strip->dir, se->name); RNA_string_get(op->ptr, "name", seq->name); - - calc_sequence_disp(seq); - sort_seq(scene); - - /* last active name */ - strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1); + + if (RNA_boolean_get(op->ptr, "cache")) { + sound_cache(seq->sound, 0); + } if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); @@ -416,7 +444,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); - RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Load the sound as streaming audio"); // XXX need to impliment this + RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory."); } /* add image operator */ @@ -585,7 +613,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) if(seq->plugin==NULL) { BLI_remlink(ed->seqbasep, seq); - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); BKE_reportf(op->reports, RPT_ERROR, "Sequencer plugin \"%s\" could not load.", filename); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 3b90039335e..367bfb68208 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -173,8 +173,7 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col) case SEQ_PLUGIN: UI_GetThemeColor3ubv(TH_SEQ_PLUGIN, col); break; - case SEQ_HD_SOUND: - case SEQ_RAM_SOUND: + case SEQ_SOUND: UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col); blendcol[0] = blendcol[1] = blendcol[2] = 128; if(seq->flag & SEQ_MUTE) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20); @@ -546,11 +545,8 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float else sprintf(str, "%d | %s", seq->len, give_seqname(seq)); } - else if (seq->type == SEQ_RAM_SOUND) { - sprintf(str, "%d | %s", seq->len, seq->strip->stripdata->name); - } - else if (seq->type == SEQ_HD_SOUND) { - sprintf(str, "%d | %s", seq->len, seq->strip->stripdata->name); + else if (seq->type == SEQ_SOUND) { + sprintf(str, "%d | %s", seq->len, seq->sound->name); } else if (seq->type == SEQ_MOVIE) { sprintf(str, "%d | %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name); @@ -664,7 +660,8 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence * draw_shadedstrip(seq, background_col, x1, y1, x2, y2); /* draw additional info and controls */ - if (seq->type == SEQ_RAM_SOUND) + // XXX + if(0) // (seq->type == SEQ_SOUND) drawseqwave(scene, v2d, seq, x1, y1, x2, y2, ar->winx); if (!is_single_image) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 036c0769c1e..1555784f470 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -65,6 +65,7 @@ #include "BKE_scene.h" #include "BKE_utildefines.h" #include "BKE_report.h" +#include "BKE_sound.h" #include "WM_api.h" #include "WM_types.h" @@ -166,7 +167,7 @@ Sequence *get_foreground_frame_seq(Scene *scene, int frame) if(seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame) continue; /* only use elements you can see - not */ - if (ELEM6(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE, SEQ_MOVIE_AND_HD_SOUND, SEQ_COLOR)) { + if (ELEM5(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE, SEQ_COLOR)) { if (seq->machine > best_machine) { best_seq = seq; best_machine = seq->machine; @@ -563,7 +564,7 @@ static void reload_sound_strip(Scene *scene, char *name) calc_sequence(seqact); seq->strip= 0; - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); BLI_remlink(ed->seqbasep, seq); seq= ed->seqbasep->first; @@ -603,7 +604,7 @@ static void reload_image_strip(Scene *scene, char *name) calc_sequence(seqact); seq->strip= 0; - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); BLI_remlink(ed->seqbasep, seq); update_changed_seq_and_deps(scene, seqact, 1, 1); @@ -722,7 +723,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen for(seq=ed->seqbasep->first; seq; seq=seq->next) { if(seq->flag & SELECT) { - if (seq->type == SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND) { + if (seq->type == SEQ_SOUND) { *error_str= "Can't apply effects to audio sequence strips"; return 0; } @@ -849,7 +850,6 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short deleteall) { - Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq, *seqn; Sequence *last_seq = get_last_seq(scene); @@ -857,20 +857,20 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de while(seq) { seqn= seq->next; if((seq->flag & flag) || deleteall) { - if(seq->type==SEQ_RAM_SOUND && seq->sound) + if(seq->type==SEQ_SOUND && seq->sound) seq->sound->id.us--; BLI_remlink(lb, seq); if(seq==last_seq) set_last_seq(scene, NULL); if(seq->type==SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); if(seq->ipo) seq->ipo->id.us--; - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); } seq= seqn; } } -static Sequence *dupli_seq(Sequence *seq) +static Sequence *dupli_seq(struct Scene *scene, Sequence *seq) { Sequence *seqn = MEM_dupallocN(seq); // XXX animato: ID *id; @@ -936,14 +936,13 @@ static Sequence *dupli_seq(Sequence *seq) seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); seqn->anim= 0; - } else if(seq->type == SEQ_RAM_SOUND) { - seqn->strip->stripdata = + } else if(seq->type == SEQ_SOUND) { + seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); + if(seq->sound_handle) + seqn->sound_handle = sound_new_handle(scene, seqn->sound, seq->sound_handle->startframe, seq->sound_handle->endframe, seq->sound_handle->frameskip); + seqn->sound->id.us++; - } else if(seq->type == SEQ_HD_SOUND) { - seqn->strip->stripdata = - MEM_dupallocN(seq->strip->stripdata); - seqn->hdaudio = 0; } else if(seq->type == SEQ_IMAGE) { seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); @@ -970,13 +969,13 @@ static Sequence *dupli_seq(Sequence *seq) return seqn; } -static Sequence * deep_dupli_seq(Sequence * seq) +static Sequence * deep_dupli_seq(struct Scene *scene, Sequence * seq) { - Sequence * seqn = dupli_seq(seq); + Sequence * seqn = dupli_seq(scene, seq); if (seq->type == SEQ_META) { Sequence * s; for(s= seq->seqbase.first; s; s = s->next) { - Sequence * n = deep_dupli_seq(s); + Sequence * n = deep_dupli_seq(scene, s); if (n) { BLI_addtail(&seqn->seqbase, n); } @@ -995,7 +994,7 @@ static void recurs_dupli_seq(Scene *scene, ListBase *old, ListBase *new) for(seq= old->first; seq; seq= seq->next) { seq->tmp= NULL; if(seq->flag & SELECT) { - seqn = dupli_seq(seq); + seqn = dupli_seq(scene, seq); if (seqn) { /*should never fail */ seq->flag &= SEQ_DESEL; seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL+SEQ_LOCK); @@ -1061,10 +1060,10 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) reload_sequence_new_file(scene, seq); calc_sequence(seq); - + if (!skip_dup) { /* Duplicate AFTER the first change */ - seqn = deep_dupli_seq(seq); + seqn = deep_dupli_seq(scene, seq); } if (seqn) { @@ -1150,10 +1149,10 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence * seq, int cutframe) } calc_sequence(seq); - + if (!skip_dup) { /* Duplicate AFTER the first change */ - seqn = deep_dupli_seq(seq); + seqn = deep_dupli_seq(scene, seq); } if (seqn) { @@ -1493,11 +1492,13 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) if(selected){ /* mute unselected */ if (seq->flag & SELECT) { seq->flag |= SEQ_MUTE; + seq_update_sound(seq); } } else { if ((seq->flag & SELECT)==0) { seq->flag |= SEQ_MUTE; + seq_update_sound(seq); } } } @@ -1544,11 +1545,13 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) if(selected){ /* unmute unselected */ if (seq->flag & SELECT) { seq->flag &= ~SEQ_MUTE; + seq_update_sound(seq); } } else { if ((seq->flag & SELECT)==0) { seq->flag &= ~SEQ_MUTE; + seq_update_sound(seq); } } } @@ -2007,7 +2010,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) start_ofs += step; } - seq_free_sequence(ed, seq); + seq_free_sequence(scene, seq); seq = seq->next; } else { seq = seq->next; @@ -2130,7 +2133,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) while(seq) { if(seq->flag & SELECT) { tot++; - if (seq->type == SEQ_RAM_SOUND) { + if (seq->type == SEQ_SOUND) { BKE_report(op->reports, RPT_ERROR, "Can't make Meta Strip from audio"); return OPERATOR_CANCELLED;; } @@ -2242,7 +2245,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *op) last_seq->seqbase.last= 0; BLI_remlink(ed->seqbasep, last_seq); - seq_free_sequence(ed, last_seq); + seq_free_sequence(scene, last_seq); /* emtpy meta strip, delete all effects depending on it */ for(seq=ed->seqbasep->first; seq; seq=seq->next) diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 335652235c6..dda5837e5f5 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -153,7 +153,7 @@ void select_single_seq(Scene *scene, Sequence *seq, int deselect_all) /* BRING B if(seq->strip) strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR-1); } - else if((seq->type==SEQ_HD_SOUND) || (seq->type==SEQ_RAM_SOUND)) { + else if(seq->type==SEQ_SOUND) { if(seq->strip) strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR-1); } @@ -336,7 +336,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR-1); } } else - if (seq->type == SEQ_HD_SOUND || seq->type == SEQ_RAM_SOUND) { + if (seq->type == SEQ_SOUND) { if(seq->strip) { strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR-1); } diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index c761587198f..0e2d2ce1698 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -186,12 +186,18 @@ ARegion *text_has_properties_region(ScrArea *sa) return arnew; } +void text_toggle_properties_region(bContext *C, ScrArea *sa, ARegion *ar) +{ + ar->flag ^= RGN_FLAG_HIDDEN; + ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */ + + ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); + ED_area_tag_redraw(sa); +} + static int properties_poll(bContext *C) { - SpaceText *st= CTX_wm_space_text(C); - Text *text= CTX_data_edit_text(C); - - return (st && text); + return (CTX_wm_space_text(C) != NULL); } static int properties_exec(bContext *C, wmOperator *op) @@ -199,13 +205,8 @@ static int properties_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); ARegion *ar= text_has_properties_region(sa); - if(ar) { - ar->flag ^= RGN_FLAG_HIDDEN; - ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */ - - ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); - ED_area_tag_redraw(sa); - } + if(ar) + text_toggle_properties_region(C, sa, ar); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 8445f1b47e7..784b151f909 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -270,14 +270,23 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn) /* ************************ header time area region *********************** */ +#define PY_HEADER /* add handlers, stuff you only do once or on area/region changes */ static void time_header_area_init(wmWindowManager *wm, ARegion *ar) { +#ifdef PY_HEADER + ED_region_header_init(ar); +#else UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); +#endif } static void time_header_area_draw(const bContext *C, ARegion *ar) { +#ifdef PY_HEADER + ED_region_header(C, ar); +#else + float col[3]; /* clear */ @@ -293,7 +302,8 @@ static void time_header_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(C, &ar->v2d); time_header_buttons(C, ar); - +#endif + /* restore view matrix? */ UI_view2d_view_restore(C); } diff --git a/source/blender/editors/space_time/time_header.c b/source/blender/editors/space_time/time_header.c index b4e3c087360..13265166d98 100644 --- a/source/blender/editors/space_time/time_header.c +++ b/source/blender/editors/space_time/time_header.c @@ -69,106 +69,6 @@ /* ************************ header time area region *********************** */ -/* exported for use in screen_ops.c */ -ARegion *time_top_left_3dwindow(bScreen *screen) -{ - ARegion *aret= NULL; - ScrArea *sa; - int min= 10000; - - for(sa= screen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_VIEW3D) { - ARegion *ar; - for(ar= sa->regionbase.first; ar; ar= ar->next) { - if(ar->regiontype==RGN_TYPE_WINDOW) { - if(ar->winrct.xmin - ar->winrct.ymin < min) { - aret= ar; - min= ar->winrct.xmin - ar->winrct.ymin; - } - } - } - } - } - return aret; -} - -static void do_time_redrawmenu(bContext *C, void *arg, int event) -{ - - if(event < 1001) { - bScreen *screen= CTX_wm_screen(C); - SpaceTime *stime= CTX_wm_space_time(C); - - stime->redraws ^= event; - - if(screen->animtimer) { - wmTimer *wt= screen->animtimer; - ScreenAnimData *sad= wt->customdata; - - sad->redraws= stime->redraws; - sad->ar= NULL; - if(stime->redraws & TIME_REGION) - sad->ar= time_top_left_3dwindow(screen); - } - } -} - - -static uiBlock *time_redrawmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *curarea= CTX_wm_area(C); - SpaceTime *stime= CTX_wm_space_time(C); - uiBlock *block; - short yco= 0, menuwidth=120, icon; - - block= uiBeginBlock(C, ar, "header time_redrawmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_time_redrawmenu, NULL); - - if(stime->redraws & TIME_REGION) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Top-Left 3D Window", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_REGION, ""); - - if(stime->redraws & TIME_ALL_3D_WIN) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "All 3D Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_3D_WIN, ""); - - if(stime->redraws & TIME_ALL_ANIM_WIN) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Animation Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_ANIM_WIN, ""); - - if(stime->redraws & TIME_ALL_BUTS_WIN) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Buttons Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_BUTS_WIN, ""); - - if(stime->redraws & TIME_ALL_IMAGE_WIN) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Image Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_IMAGE_WIN, ""); - - /* Add sequencer only redraw*/ - if(stime->redraws & TIME_SEQ) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Sequencer Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_SEQ, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - if(stime->redraws & TIME_CONTINUE_PHYSICS) icon= ICON_CHECKBOX_HLT; - else icon= ICON_CHECKBOX_DEHLT; - uiDefIconTextBut(block, BUTM, 1, icon, "Continue Physics", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_CONTINUE_PHYSICS, "During playblack, continue physics simulations regardless of the frame number"); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); - - return block; -} - static void do_time_viewmenu(bContext *C, void *arg, int event) { ScrArea *curarea= CTX_wm_area(C); @@ -397,7 +297,6 @@ void do_time_buttons(bContext *C, void *arg, int event) void time_header_buttons(const bContext *C, ARegion *ar) { ScrArea *sa= CTX_wm_area(C); - SpaceTime *stime= CTX_wm_space_time(C); Scene *scene= CTX_data_scene(C); wmTimer *animtimer= CTX_wm_screen(C)->animtimer; uiBlock *block; @@ -421,16 +320,11 @@ void time_header_buttons(const bContext *C, ARegion *ar) uiDefPulldownBut(block, time_framemenu, sa, "Frame", xco, yco, xmax-3, 20, ""); xco+= xmax; - - xmax= GetButStringLength("Playback"); - uiDefPulldownBut(block, time_redrawmenu, sa, - "Playback", xco, yco, xmax-3, 20, ""); - xco+= xmax; } uiBlockSetEmboss(block, UI_EMBOSS); - uiBlockBeginAlign(block); + uiDefButI(block, TOG, B_TL_PREVIEWON,"PR", xco,yco, XIC*2, YIC, @@ -439,6 +333,8 @@ void time_header_buttons(const bContext *C, ARegion *ar) xco += XIC*2; + uiBlockBeginAlign(block); + if (scene->r.psfra) { uiDefButI(block, NUM, B_REDRAWALL,"Start:", xco,yco, (int)4.5*XIC, YIC, @@ -473,11 +369,11 @@ void time_header_buttons(const bContext *C, ARegion *ar) * to facilitate easier keyframing in some situations */ uiDefButI(block, NUM, B_NEWFRAME, "", - xco,yco, (int)3.5*XIC,YIC, + xco,yco, (int)4.5*XIC,YIC, &(scene->r.cfra), MINAFRAMEF, MAXFRAMEF, 0, 0, "Displays Current Frame of animation"); - xco += (short)(3.5 * XIC); + xco += (short)(4.5 * XIC); uiBlockBeginAlign(block); @@ -514,32 +410,37 @@ void time_header_buttons(const bContext *C, ARegion *ar) xco+= XIC; uiBlockEndAlign(block); - xco+= 1.5*XIC; + xco+= (short)(0.5*XIC); uiBlockBeginAlign(block); uiDefIconButBitS(block, TOG, AUTOKEY_ON, B_REDRAWALL, ICON_REC, xco, yco, XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones"); - xco+= XIC; - + xco+= 1*XIC; if (IS_AUTOKEY_ON(scene)) { uiDefButS(block, MENU, B_REDRAWALL, - "Auto-Keying Mode %t|Add/Replace Keys%x3|Replace Keys %x5", - xco, yco, (int)5.5*XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 1, 0, 0, + "Auto-Keying Mode %t|Add/Replace%x3|Replace%x5", + xco, yco, (int)(4.25*XIC), YIC, &(scene->toolsettings->autokey_mode), 0, 1, 0, 0, "Mode of automatic keyframe insertion for Objects and Bones"); - xco+= (5.5*XIC); + xco+= (short)(4.25*XIC); if (animtimer) { uiDefButBitS(block, TOG, ANIMRECORD_FLAG_WITHNLA, B_REDRAWALL, "Layered", - xco,yco, XIC*2.5, YIC, + xco,yco, (int)(3.5*XIC), YIC, &(scene->toolsettings->autokey_flag),0, 1, 0, 0, "Add a new NLA Track + Strip for every loop/pass made over the animation to allow non-destructive tweaking."); - xco+= (3*XIC); + uiBlockEndAlign(block); + + xco+= (short)(3.5*XIC); } + + xco += XIC; + + uiBlockEndAlign(block); + } + else { + xco+= (short)(5.25*XIC); + uiBlockEndAlign(block); } - else - xco+= 6; - - uiBlockEndAlign(block); menustr= ANIM_build_keyingsets_menu(&scene->keyingsets, 0); uiDefButI(block, MENU, B_DIFF, @@ -549,6 +450,9 @@ void time_header_buttons(const bContext *C, ARegion *ar) MEM_freeN(menustr); xco+= (5.5*XIC); + /* NOTE: order of these buttons needs to be kept in sync with other occurances + * (see Outliner header for instance, also +/- stuff for filebrowser) + */ uiBlockBeginAlign(block); uiDefIconButO(block, BUT, "ANIM_OT_delete_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_DEHLT, xco,yco,XIC,YIC, "Delete Keyframes for the Active Keying Set (Alt-I)"); xco += XIC; @@ -558,8 +462,8 @@ void time_header_buttons(const bContext *C, ARegion *ar) xco+= XIC; - uiDefIconButBitI(block, TOG, TIME_WITH_SEQ_AUDIO, B_DIFF, ICON_SPEAKER, - xco, yco, XIC, YIC, &(stime->redraws), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor"); + uiDefIconButBitS(block, TOG, AUDIO_SYNC, B_DIFF, ICON_SPEAKER, + xco, yco, XIC, YIC, &(scene->r.audio.flag), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor"); /* always as last */ diff --git a/source/blender/editors/space_userpref/Makefile b/source/blender/editors/space_userpref/Makefile new file mode 100644 index 00000000000..be7206f51ce --- /dev/null +++ b/source/blender/editors/space_userpref/Makefile @@ -0,0 +1,55 @@ +# +# $Id$ +# +# ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2007 Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL LICENSE BLOCK ***** +# +# Makes module object directory and bounces make to subdirectories. + +LIBNAME = ed_userpref +DIR = $(OCGDIR)/blender/$(LIBNAME) + +include nan_compile.mk + +CFLAGS += $(LEVEL_1_C_WARNINGS) + +CPPFLAGS += -I$(NAN_GLEW)/include +CPPFLAGS += -I$(OPENGL_HEADERS) + +# not very neat.... +CPPFLAGS += -I../../windowmanager +CPPFLAGS += -I../../blenloader +CPPFLAGS += -I../../blenkernel +CPPFLAGS += -I../../blenlib +CPPFLAGS += -I../../makesdna +CPPFLAGS += -I../../makesrna +CPPFLAGS += -I../../imbuf +CPPFLAGS += -I../../python +CPPFLAGS += -I../../blenfont +CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include + +# own include + +CPPFLAGS += -I../include diff --git a/source/blender/editors/space_userpref/SConscript b/source/blender/editors/space_userpref/SConscript new file mode 100644 index 00000000000..1b808a5a7c0 --- /dev/null +++ b/source/blender/editors/space_userpref/SConscript @@ -0,0 +1,14 @@ +#!/usr/bin/python +Import ('env') + +sources = env.Glob('*.c') + +incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../makesrna ../../imbuf ../../blenfont' +incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' + +defs = [] + +if env['WITH_BF_GAMEENGINE']: + defs.append('GAMEBLENDER=1') + +env.BlenderLib ( 'bf_editors_space_userpref', sources, Split(incs), defs, libtype=['core'], priority=[70] ) diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c new file mode 100644 index 00000000000..8c9d723ce2c --- /dev/null +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -0,0 +1,188 @@ +/** + * $Id: + * + * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include + +#include "DNA_space_types.h" +#include "DNA_screen_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" + +#include "BKE_context.h" +#include "BKE_screen.h" + +#include "ED_space_api.h" +#include "ED_screen.h" + +#include "BIF_gl.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "userpref_intern.h" // own include + +/* ******************** default callbacks for userpref space ***************** */ + +static SpaceLink *userpref_new(const bContext *C) +{ + ARegion *ar; + SpaceUserPref *spref; + + spref= MEM_callocN(sizeof(SpaceUserPref), "inituserpref"); + spref->spacetype= SPACE_USERPREF; + + /* header */ + ar= MEM_callocN(sizeof(ARegion), "header for userpref"); + + BLI_addtail(&spref->regionbase, ar); + ar->regiontype= RGN_TYPE_HEADER; + ar->alignment= RGN_ALIGN_BOTTOM; + + /* main area */ + ar= MEM_callocN(sizeof(ARegion), "main area for userpref"); + + BLI_addtail(&spref->regionbase, ar); + ar->regiontype= RGN_TYPE_WINDOW; + + return (SpaceLink *)spref; +} + +/* not spacelink itself */ +static void userpref_free(SpaceLink *sl) +{ +// SpaceUserPref *spref= (SpaceUserPref*) sl; + +} + + +/* spacetype; init callback */ +static void userpref_init(struct wmWindowManager *wm, ScrArea *sa) +{ + +} + +static SpaceLink *userpref_duplicate(SpaceLink *sl) +{ + SpaceUserPref *sprefn= MEM_dupallocN(sl); + + /* clear or remove stuff from old */ + + return (SpaceLink *)sprefn; +} + + + +/* add handlers, stuff you only do once or on area/region changes */ +static void userpref_main_area_init(wmWindowManager *wm, ARegion *ar) +{ + ED_region_panels_init(wm, ar); +} + +static void userpref_main_area_draw(const bContext *C, ARegion *ar) +{ + ED_region_panels(C, ar, 1, NULL, -1); +} + +void userpref_operatortypes(void) +{ +} + +void userpref_keymap(struct wmWindowManager *wm) +{ + +} + +/* add handlers, stuff you only do once or on area/region changes */ +static void userpref_header_area_init(wmWindowManager *wm, ARegion *ar) +{ + ED_region_header_init(ar); +} + +static void userpref_header_area_draw(const bContext *C, ARegion *ar) +{ + ED_region_header(C, ar); +} + +static void userpref_main_area_listener(ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ +} + +static void userpref_header_listener(ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ + switch(wmn->category) { + default: + break; + } + +} + +/* only called once, from space/spacetypes.c */ +void ED_spacetype_userpref(void) +{ + SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype userpref"); + ARegionType *art; + + st->spaceid= SPACE_USERPREF; + + st->new= userpref_new; + st->free= userpref_free; + st->init= userpref_init; + st->duplicate= userpref_duplicate; + st->operatortypes= userpref_operatortypes; + st->keymap= userpref_keymap; + + /* regions: main window */ + art= MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); + art->regionid = RGN_TYPE_WINDOW; + art->init= userpref_main_area_init; + art->draw= userpref_main_area_draw; + art->listener= userpref_main_area_listener; + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + + BLI_addhead(&st->regiontypes, art); + + /* regions: header */ + art= MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); + art->regionid = RGN_TYPE_HEADER; + art->minsizey= HEADERY; + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->listener= userpref_header_listener; + art->init= userpref_header_area_init; + art->draw= userpref_header_area_draw; + + BLI_addhead(&st->regiontypes, art); + + + BKE_spacetype_register(st); +} + diff --git a/source/gameengine/Expressions/KX_Python_dynamic.h b/source/blender/editors/space_userpref/userpref_intern.h similarity index 71% rename from source/gameengine/Expressions/KX_Python_dynamic.h rename to source/blender/editors/space_userpref/userpref_intern.h index eb435bdf1c3..596c2675b01 100644 --- a/source/gameengine/Expressions/KX_Python_dynamic.h +++ b/source/blender/editors/space_userpref/userpref_intern.h @@ -1,12 +1,12 @@ /** - * $Id$ + * $Id: * * ***** 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. + * 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 @@ -17,20 +17,18 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. + * + * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** */ -#ifndef KX_PYTHON_H -#define KX_PYTHON_H +#ifndef ED_USERPREF_INTERN_H +#define ED_USERPREF_INTERN_H -//#define USE_DL_EXPORT -#include "Python.h" +/* internal exports only */ -#endif // KX_PYTHON_H +#endif /* ED_USERPREF_INTERN_H */ diff --git a/source/gameengine/Expressions/KX_Python_static.h b/source/blender/editors/space_userpref/userpref_ops.c similarity index 72% rename from source/gameengine/Expressions/KX_Python_static.h rename to source/blender/editors/space_userpref/userpref_ops.c index f4f31f9b058..91a6651bd92 100644 --- a/source/gameengine/Expressions/KX_Python_static.h +++ b/source/blender/editors/space_userpref/userpref_ops.c @@ -6,7 +6,7 @@ * 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. + * 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 @@ -17,20 +17,17 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. + * + * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** */ -#ifndef KX_PYTHON_H -#define KX_PYTHON_H -#define USE_DL_EXPORT -#include "Python.h" +#include +#include -#endif // KX_PYTHON_H +#include "userpref_intern.h" diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 5a9790390b7..a5718386554 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2271,7 +2271,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, RegionView3D *rv3d range= (float)(end - start); /* store values */ - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; cfrao= CFRA; flago= arm->flag; arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES); @@ -2308,7 +2308,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, RegionView3D *rv3d ob->pose= poseo; arm->flag= flago; armature_rebuild_pose(ob, ob->data); - ob->flag |= OB_POSEMODE; + ob->mode |= OB_MODE_POSE; ob->ipoflag= ipoflago; } @@ -2349,7 +2349,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, RegionView3D *rv3d, if (range == 0) return; /* store values */ - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; cfrao= CFRA; flago= arm->flag; arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES); @@ -2388,7 +2388,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, RegionView3D *rv3d, ob->pose= poseo; arm->flag= flago; armature_rebuild_pose(ob, ob->data); - ob->flag |= OB_POSEMODE; + ob->mode |= OB_MODE_POSE; } /* draw ghosts around current frame @@ -2415,7 +2415,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base range= (float)(arm->ghostep)*stepsize + 0.5f; /* plus half to make the for loop end correct */ /* store values */ - ob->flag &= ~OB_POSEMODE; + ob->mode &= ~OB_MODE_POSE; cfrao= CFRA; actframe= BKE_nla_tweakedit_remap(adt, (float)CFRA, 0); flago= arm->flag; @@ -2474,7 +2474,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base ob->pose= poseo; arm->flag= flago; armature_rebuild_pose(ob, ob->data); - ob->flag |= OB_POSEMODE; + ob->mode |= OB_MODE_POSE; } /* ********************************** Armature Drawing - Main ************************* */ @@ -2513,10 +2513,10 @@ int draw_armature(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int /* drawing posemode selection indices or colors only in these cases */ if(!(base->flag & OB_FROMDUPLI)) { if(G.f & G_PICKSEL) { - if(ob->flag & OB_POSEMODE) + if(ob->mode & OB_MODE_POSE) arm->flag |= ARM_POSEMODE; } - else if(ob->flag & OB_POSEMODE) { + else if(ob->mode & OB_MODE_POSE) { if (arm->ghosttype == ARM_GHOST_RANGE) { draw_ghost_poses_range(scene, v3d, rv3d, base); } @@ -2530,7 +2530,7 @@ int draw_armature(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int if ((flag & DRAW_SCENESET)==0) { if(ob==OBACT) arm->flag |= ARM_POSEMODE; - else if(G.f & G_WEIGHTPAINT) { + else if(ob->mode & OB_MODE_WEIGHT_PAINT) { if(OBACT && ob==modifiers_isDeformedByArmature(OBACT)) arm->flag |= ARM_POSEMODE; } @@ -2541,7 +2541,7 @@ int draw_armature(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int draw_pose_channels(scene, v3d, rv3d, base, dt); arm->flag &= ~ARM_POSEMODE; - if(ob->flag & OB_POSEMODE) + if(ob->mode & OB_MODE_POSE) UI_ThemeColor(TH_WIRE); /* restore, for extra draw stuff */ } else retval= 1; diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 1807de9efbb..da67bd8707e 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -60,6 +60,7 @@ #include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_property.h" #include "BKE_utildefines.h" @@ -297,9 +298,9 @@ static int set_draw_settings_cached(int clearcache, int textured, MTFace *texfac if (textured!=c_textured || texface!=c_texface) { if (textured ) { - c_badtex= !GPU_set_tpage(texface); + c_badtex= !GPU_set_tpage(texface, !(litob->mode & OB_MODE_TEXTURE_PAINT)); } else { - GPU_set_tpage(0); + GPU_set_tpage(NULL, 0); c_badtex= 0; } c_textured= textured; @@ -377,7 +378,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O static void draw_textured_end() { /* switch off textures */ - GPU_set_tpage(0); + GPU_set_tpage(NULL, 0); glShadeModel(GL_FLAT); glDisable(GL_CULL_FACE); @@ -482,7 +483,7 @@ void draw_mesh_text(Scene *scene, Object *ob, int glsl) if(ob == scene->obedit) return; else if(ob==OBACT) - if(FACESEL_PAINT_TEST) + if(paint_facesel_test(ob)) return; ddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); @@ -562,7 +563,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o if(ob == scene->obedit) { dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, me->edit_mesh); } else if(faceselect) { - if(G.f & G_WEIGHTPAINT) + if(ob->mode & OB_MODE_WEIGHT_PAINT) dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1); else dm->drawMappedFacesTex(dm, draw_tface_mapped__set_draw, me); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 24306fa6298..466b55ba862 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -87,9 +87,11 @@ #include "BKE_mball.h" #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_property.h" #include "BKE_smoke.h" +#include "BKE_unit.h" #include "BKE_utildefines.h" #include "smoke_API.h" @@ -211,11 +213,10 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt) return 0; if(!CHECK_OB_DRAWTEXTURE(v3d, dt)) return 0; - if(ob==OBACT && (G.f & G_WEIGHTPAINT)) + if(ob==OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return 0; - return ((G.fileflags & G_FILE_GAME_MAT) && - (G.fileflags & G_FILE_GAME_MAT_GLSL) && (dt >= OB_SHADED)); + return (scene->gm.matmode == GAME_MAT_GLSL) && (dt >= OB_SHADED); } static int check_material_alpha(Base *base, Mesh *me, int glsl) @@ -1849,7 +1850,7 @@ static void draw_em_fancy_edges(Scene *scene, View3D *v3d, Mesh *me, DerivedMesh } } -static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, EditMesh *em) +static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, EditMesh *em, UnitSettings *unit) { Mesh *me= ob->data; EditEdge *eed; @@ -1859,18 +1860,20 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E char val[32]; /* Stores the measurement display text here */ char conv_float[5]; /* Use a float conversion matching the grid size */ float area, col[3]; /* area of the face, color of the text to draw */ - + float grid= unit->system ? unit->scale_length : v3d->grid; + int do_split= unit->flag & USER_UNIT_OPT_SPLIT; if(G.f & (G_RENDER_OGL|G_RENDER_SHADOW)) return; /* make the precission of the pronted value proportionate to the gridsize */ - if ((v3d->grid) < 0.01) + + if (grid < 0.01f) strcpy(conv_float, "%.6f"); - else if ((v3d->grid) < 0.1) + else if (grid < 0.1f) strcpy(conv_float, "%.5f"); - else if ((v3d->grid) < 1.0) + else if (grid < 1.0f) strcpy(conv_float, "%.4f"); - else if ((v3d->grid) < 10.0) + else if (grid < 10.0f) strcpy(conv_float, "%.3f"); else strcpy(conv_float, "%.2f"); @@ -1879,13 +1882,13 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E if(v3d->zbuf && (v3d->flag & V3D_ZBUF_SELECT)==0) glDisable(GL_DEPTH_TEST); - if(v3d->zbuf) bglPolygonOffset(rv3d->dist, 5.0); + if(v3d->zbuf) bglPolygonOffset(rv3d->dist, 5.0f); if(me->drawflag & ME_DRAW_EDGELEN) { UI_GetThemeColor3fv(TH_TEXT, col); /* make color a bit more red */ - if(col[0]> 0.5) {col[1]*=0.7; col[2]*= 0.7;} - else col[0]= col[0]*0.7 + 0.3; + if(col[0]> 0.5f) {col[1]*=0.7f; col[2]*= 0.7f;} + else col[0]= col[0]*0.7f + 0.3f; glColor3fv(col); for(eed= em->edges.first; eed; eed= eed->next) { @@ -1894,16 +1897,19 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E VECCOPY(v1, eed->v1->co); VECCOPY(v2, eed->v2->co); - x= 0.5*(v1[0]+v2[0]); - y= 0.5*(v1[1]+v2[1]); - z= 0.5*(v1[2]+v2[2]); + x= 0.5f*(v1[0]+v2[0]); + y= 0.5f*(v1[1]+v2[1]); + z= 0.5f*(v1[2]+v2[2]); if(v3d->flag & V3D_GLOBAL_STATS) { Mat4MulVecfl(ob->obmat, v1); Mat4MulVecfl(ob->obmat, v2); } + if(unit->system) + bUnit_AsString(val, sizeof(val), VecLenf(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); + else + sprintf(val, conv_float, VecLenf(v1, v2)); - sprintf(val, conv_float, VecLenf(v1, v2)); view3d_object_text_draw_add(x, y, z, val, 0); } } @@ -1914,8 +1920,8 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E UI_GetThemeColor3fv(TH_TEXT, col); /* make color a bit more green */ - if(col[1]> 0.5) {col[0]*=0.7; col[2]*= 0.7;} - else col[1]= col[1]*0.7 + 0.3; + if(col[1]> 0.5f) {col[0]*=0.7f; col[2]*= 0.7f;} + else col[1]= col[1]*0.7f + 0.3f; glColor3fv(col); for(efa= em->faces.first; efa; efa= efa->next) { @@ -1938,7 +1944,11 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E else area = AreaT3Dfl(v1, v2, v3); - sprintf(val, conv_float, area); + if(unit->system) + bUnit_AsString(val, sizeof(val), area*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); // XXX should be B_UNIT_AREA + else + sprintf(val, conv_float, area); + view3d_object_text_draw_add(efa->cent[0], efa->cent[1], efa->cent[2], val, 0); } } @@ -1949,8 +1959,8 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E UI_GetThemeColor3fv(TH_TEXT, col); /* make color a bit more blue */ - if(col[2]> 0.5) {col[0]*=0.7; col[1]*= 0.7;} - else col[2]= col[2]*0.7 + 0.3; + if(col[2]> 0.5f) {col[0]*=0.7f; col[1]*= 0.7f;} + else col[2]= col[2]*0.7f + 0.3f; glColor3fv(col); for(efa= em->faces.first; efa; efa= efa->next) { @@ -1980,13 +1990,13 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E if( (e4->f & e1->f & SELECT) || (G.moving && (efa->v1->f & SELECT)) ) { /* Vec 1 */ sprintf(val,"%.3f", VecAngle3(v4, v1, v2)); - VecLerpf(fvec, efa->cent, efa->v1->co, 0.8); + VecLerpf(fvec, efa->cent, efa->v1->co, 0.8f); view3d_object_text_draw_add(efa->cent[0], efa->cent[1], efa->cent[2], val, 0); } if( (e1->f & e2->f & SELECT) || (G.moving && (efa->v2->f & SELECT)) ) { /* Vec 2 */ sprintf(val,"%.3f", VecAngle3(v1, v2, v3)); - VecLerpf(fvec, efa->cent, efa->v2->co, 0.8); + VecLerpf(fvec, efa->cent, efa->v2->co, 0.8f); view3d_object_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } if( (e2->f & e3->f & SELECT) || (G.moving && (efa->v3->f & SELECT)) ) { @@ -1995,14 +2005,14 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E sprintf(val,"%.3f", VecAngle3(v2, v3, v4)); else sprintf(val,"%.3f", VecAngle3(v2, v3, v1)); - VecLerpf(fvec, efa->cent, efa->v3->co, 0.8); + VecLerpf(fvec, efa->cent, efa->v3->co, 0.8f); view3d_object_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } /* Vec 4 */ if(efa->v4) { if( (e3->f & e4->f & SELECT) || (G.moving && (efa->v4->f & SELECT)) ) { sprintf(val,"%.3f", VecAngle3(v3, v4, v1)); - VecLerpf(fvec, efa->cent, efa->v4->co, 0.8); + VecLerpf(fvec, efa->cent, efa->v4->co, 0.8f); view3d_object_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } } @@ -2011,7 +2021,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E if(v3d->zbuf) { glEnable(GL_DEPTH_TEST); - bglPolygonOffset(rv3d->dist, 0.0); + bglPolygonOffset(rv3d->dist, 0.0f); } } @@ -2096,7 +2106,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object } } - if((me->drawflag & (ME_DRAWFACES)) || FACESEL_PAINT_TEST) { /* transp faces */ + if((me->drawflag & (ME_DRAWFACES)) || paint_facesel_test(ob)) { /* transp faces */ unsigned char col1[4], col2[4], col3[4]; UI_GetThemeColor4ubv(TH_FACE, (char *)col1); @@ -2184,7 +2194,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object } if(me->drawflag & (ME_DRAW_EDGELEN|ME_DRAW_FACEAREA|ME_DRAW_EDGEANG)) - draw_em_measure_stats(v3d, rv3d, ob, em); + draw_em_measure_stats(v3d, rv3d, ob, em, &scene->unit); } if(dt>OB_WIRE) { @@ -2255,7 +2265,7 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); // Unwanted combination. - if (ob==OBACT && FACESEL_PAINT_TEST) draw_wire = 0; + if (ob==OBACT && paint_facesel_test(ob)) draw_wire = 0; if(dt==OB_BOUNDBOX) { draw_bounding_volume(scene, ob); @@ -2268,12 +2278,12 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base else if(dt==OB_WIRE || totface==0) { draw_wire = 1; /* draw wire only, no depth buffer stuff */ } - else if( (ob==OBACT && (G.f & G_TEXTUREPAINT || FACESEL_PAINT_TEST)) || + else if( (ob==OBACT && (ob->mode & OB_MODE_TEXTURE_PAINT || paint_facesel_test(ob))) || CHECK_OB_DRAWTEXTURE(v3d, dt)) { - int faceselect= (ob==OBACT && FACESEL_PAINT_TEST); + int faceselect= (ob==OBACT && paint_facesel_test(ob)); - if ((v3d->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !(G.f&G_PICKSEL || FACESEL_PAINT_TEST) && !draw_wire) { + if ((v3d->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !(G.f&G_PICKSEL || paint_facesel_test(ob)) && !draw_wire) { draw_mesh_object_outline(v3d, ob, dm); } @@ -2327,7 +2337,7 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base if(ob==OBACT) { do_draw= 0; - if( (G.f & G_WEIGHTPAINT)) { + if(ob && ob->mode & OB_MODE_WEIGHT_PAINT) { /* enforce default material settings */ GPU_enable_material(0, NULL); @@ -2347,12 +2357,13 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base GPU_disable_material(); } - else if((G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) && me->mcol) { - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1); - } - else if(G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) { - glColor3f(1.0f, 1.0f, 1.0f); - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0); + else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_TEXTURE_PAINT)) { + if(me->mcol) + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1); + else { + glColor3f(1.0f, 1.0f, 1.0f); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0); + } } else do_draw= 1; } @@ -3512,7 +3523,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } if((part->draw&PART_DRAW_NUM || part->draw&PART_DRAW_HEALTH) && !(G.f & G_RENDER_SHADOW)){ - strcpy(val, ""); + val[0]= '\0'; if(part->draw&PART_DRAW_NUM) sprintf(val, " %i", a); @@ -4399,7 +4410,7 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, if(ml==NULL) return 1; /* in case solid draw, reset wire colors */ - if(mb->editelems && (ob->flag & SELECT)) { + if(ob->flag & SELECT) { if(ob==OBACT) UI_ThemeColor(TH_ACTIVE); else UI_ThemeColor(TH_SELECT); } @@ -4776,7 +4787,7 @@ static void drawSolidSelect(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base drawDispListwire(&ob->disp); } else if(ob->type==OB_ARMATURE) { - if(!(ob->flag & OB_POSEMODE)) + if(!(ob->mode & OB_MODE_POSE)) draw_armature(scene, v3d, rv3d, base, OB_WIRE, 0); } @@ -4925,7 +4936,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* xray delay? */ if((flag & DRAW_PICKING)==0 && (base->flag & OB_FROMDUPLI)==0) { /* don't do xray in particle mode, need the z-buffer */ - if(!(G.f & G_PARTICLEEDIT)) { + if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) { /* xray and transp are set when it is drawing the 2nd/3rd pass */ if(!v3d->xray && !v3d->transp && (ob->dtx & OB_DRAWXRAY) && !(ob->dtx & OB_DRAWTRANSP)) { add_view3d_after(v3d, base, V3D_XRAY, flag); @@ -5071,7 +5082,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) dtx= 0; /* faceselect exception: also draw solid when dt==wire, except in editmode */ - if(ob==OBACT && (G.f & (G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT))) { + if(ob==OBACT && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { if(ob->type==OB_MESH) { if(ob==scene->obedit); @@ -5284,7 +5295,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) for(psys=ob->particlesystem.first; psys; psys=psys->next) draw_new_particle_system(scene, v3d, rv3d, base, psys, dt); - if(G.f & G_PARTICLEEDIT && ob==OBACT) { + if(ob->mode & OB_MODE_PARTICLE_EDIT && ob==OBACT) { psys= PE_get_current(scene, ob); if(psys && !scene->obedit && psys_in_edit_mode(scene, psys)) draw_particle_edit(scene, v3d, rv3d, ob, psys, dt); @@ -5298,15 +5309,14 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } /* draw code for smoke */ - if(md = modifiers_findByType(ob, eModifierType_Smoke)) + if((md = modifiers_findByType(ob, eModifierType_Smoke))) { SmokeModifierData *smd = (SmokeModifierData *)md; // draw collision objects if((smd->type & MOD_SMOKE_TYPE_COLL) && smd->coll) { - SmokeCollSettings *scs = smd->coll; - /* + /*SmokeCollSettings *scs = smd->coll; if(scs->points) { size_t i; @@ -5349,8 +5359,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) float *buffer = NULL; int res[3]; float bigfactor = 1.0; - int big = smd->domain->flags & MOD_SMOKE_HIGHRES; + int big = (smd->domain->flags & MOD_SMOKE_HIGHRES) && (smd->domain->viewsettings & MOD_SMOKE_VIEW_USEBIG); int new = 0; + int have_lamp = 0; // GUI sent redraw event if(smd->domain->flags & MOD_SMOKE_VIEW_REDRAWNICE) @@ -5367,8 +5378,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } else { - smoke_get_bigres(smd->domain->fluid, res); - bigfactor = 1.0 / smd->domain->amplify; + smoke_turbulence_get_res(smd->domain->wt, res); + bigfactor = 1.0 / (smd->domain->amplify + 1); } wmLoadMatrix(rv3d->viewmat); @@ -5439,7 +5450,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(new > 1) { - float light[3] = {0.0,0.0,2.0}; // TODO: take real LAMP coordinates - dg + float light[3] = {0.0,0.0,0.0}; // TODO: take real LAMP coordinates - dg Base *base_tmp = NULL; for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) @@ -5451,6 +5462,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(la->type == LA_LOCAL) { VECCOPY(light, base_tmp->object->obmat[3]); + have_lamp = 1; break; } } @@ -5554,6 +5566,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) tvox = smoke_get_bigtvox(smd, index); tray = smoke_get_bigtray(smd, index); } + + if(!have_lamp) + tray = 1.0; // fill buffer with luminance and alpha // 1 - T_vox @@ -5705,7 +5720,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(G.f & G_RENDER_SHADOW) return; /* object centers, need to be drawn in viewmat space for speed, but OK for picking select */ - if(ob!=OBACT || (G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT))==0) { + if(ob!=OBACT || !(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { int do_draw_center= -1; /* defines below are zero or positive... */ if((scene->basact)==base) diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index e1f0b537241..8b719dd2d80 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -595,7 +595,7 @@ static void view3d_tools_area_init(wmWindowManager *wm, ARegion *ar) static void view3d_tools_area_draw(const bContext *C, ARegion *ar) { - ED_region_panels(C, ar, 1, view3d_context_string(C), -1); + ED_region_panels(C, ar, 1, CTX_data_mode_string(C), -1); } static int view3d_context(const bContext *C, const char *member, bContextDataResult *result) @@ -889,7 +889,7 @@ void ED_spacetype_view3d(void) /* regions: tool(bar) */ art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); art->regionid = RGN_TYPE_TOOLS; - art->minsizex= 120; // XXX + art->minsizex= 160; // XXX art->minsizey= 50; // XXX art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; art->listener= view3d_buttons_area_listener; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 4b7f7ebed29..9b05f5b25b2 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1002,6 +1002,7 @@ static void view3d_panel_transform_spaces(const bContext *C, Panel *pa) } #endif // XXX not used +#if 0 static void brush_idpoin_handle(bContext *C, ID *id, int event) { Brush **br = current_brush_source(CTX_data_scene(C)); @@ -1032,6 +1033,7 @@ static void brush_idpoin_handle(bContext *C, ID *id, int event) break; } } +#endif static void view3d_panel_object(const bContext *C, Panel *pa) { @@ -1043,7 +1045,6 @@ static void view3d_panel_object(const bContext *C, Panel *pa) Object *ob= OBACT; TransformProperties *tfp; float lim; - static char hexcol[128]; if(ob==NULL) return; @@ -1057,13 +1058,13 @@ static void view3d_panel_object(const bContext *C, Panel *pa) // XXX uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT)) { + if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) { } else { //bt= uiDefBut(block, TEX, B_IDNAME, "OB: ", 10,180,140,20, ob->id.name+2, 0.0, 21.0, 0, 0, ""); //uiButSetFunc(bt, test_idbutton_cb, ob->id.name, NULL); - if((G.f & G_PARTICLEEDIT)==0) { + if((ob->mode & OB_MODE_PARTICLE_EDIT)==0) { // uiBlockBeginAlign(block); // uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_OBJECTPANELPARENT, "Par:", 160, 180, 140, 20, &ob->parent, "Parent Object"); if((ob->parent) && (ob->partype == PARBONE)) { @@ -1084,7 +1085,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa) if(ob->type==OB_MBALL) v3d_editmetaball_buts(block, ob, lim); else v3d_editvertex_buts(C, block, v3d, ob, lim); } - else if(ob->flag & OB_POSEMODE) { + else if(ob->mode & OB_MODE_POSE) { v3d_posearmature_buts(block, v3d, ob, lim); } else { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 5e6bfe89165..3140ae76d4b 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -59,9 +59,11 @@ #include "BKE_key.h" #include "BKE_object.h" #include "BKE_global.h" +#include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "BKE_unit.h" #include "RE_pipeline.h" // make_stars @@ -234,15 +236,18 @@ static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, flo } -static void drawgrid(ARegion *ar, View3D *v3d) +#define GRID_MIN_PX 6.0f + +static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_unit) { /* extern short bgpicmode; */ RegionView3D *rv3d= ar->regiondata; float wx, wy, x, y, fw, fx, fy, dx; float vec4[4]; char col[3], col2[3]; - short sublines = v3d->gridsubdiv; + *grid_unit= NULL; + vec4[0]=vec4[1]=vec4[2]=0.0; vec4[3]= 1.0; Mat4MulVec4fl(rv3d->persmat, vec4); @@ -256,7 +261,8 @@ static void drawgrid(ARegion *ar, View3D *v3d) x= (wx)*fx/fw; y= (wy)*fy/fw; - vec4[0]=vec4[1]=v3d->grid; + vec4[0]=vec4[1]= (unit->system) ? 1.0 : v3d->grid; + vec4[2]= 0.0; vec4[3]= 1.0; Mat4MulVec4fl(rv3d->persmat, vec4); @@ -272,72 +278,115 @@ static void drawgrid(ARegion *ar, View3D *v3d) /* check zoom out */ UI_ThemeColor(TH_GRID); - if(dx<6.0) { - v3d->gridview*= sublines; - dx*= sublines; - - if(dx<6.0) { + if(unit->system) { + /* Use GRID_MIN_PX*2 for units because very very small grid + * items are less useful when dealing with units */ + void *usys; + int len, i; + double scalar; + float dx_scalar; + float blend_fac; + + bUnit_GetSystem(&usys, &len, unit->system, B_UNIT_LENGTH); + + if(usys) { + i= len; + while(i--) { + scalar= bUnit_GetScaler(usys, i); + + dx_scalar = dx * scalar * unit->scale_length; + if (dx_scalar < (GRID_MIN_PX*2)) + continue; + + /* Store the smallest drawn grid size units name so users know how big each grid cell is */ + if(*grid_unit==NULL) { + *grid_unit= bUnit_GetNameDisplay(usys, i); + v3d->gridview= (scalar * unit->scale_length); + } + blend_fac= 1-((GRID_MIN_PX*2)/dx_scalar); + + /* tweak to have the fade a bit nicer */ + blend_fac= (blend_fac * blend_fac) * 2.0f; + CLAMP(blend_fac, 0.3f, 1.0f); + + + UI_ThemeColorBlend(TH_BACK, TH_GRID, blend_fac); + + drawgrid_draw(ar, wx, wy, x, y, dx_scalar); + } + } + } + else { + short sublines = v3d->gridsubdiv; + + if(dxgridview*= sublines; dx*= sublines; - if(dx<6.0) { + if(dxgridview*= sublines; - dx*=sublines; - if(dx<6.0); - else { - UI_ThemeColor(TH_GRID); + dx*= sublines; + + if(dxgridview*= sublines; + dx*=sublines; + if(dx60.0) { // start blending in - v3d->gridview/= sublines; - dx/= sublines; - if(dx>60.0) { // start blending in + else { + if(dx>(GRID_MIN_PX*10)) { // start blending in v3d->gridview/= sublines; dx/= sublines; - if(dx>60.0) { - UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, dx); + if(dx>(GRID_MIN_PX*10)) { // start blending in + v3d->gridview/= sublines; + dx/= sublines; + if(dx>(GRID_MIN_PX*10)) { + UI_ThemeColor(TH_GRID); + drawgrid_draw(ar, wx, wy, x, y, dx); + } + else { + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); + drawgrid_draw(ar, wx, wy, x, y, dx); + UI_ThemeColor(TH_GRID); + drawgrid_draw(ar, wx, wy, x, y, dx*sublines); + } } else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx*sublines); } } else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*10)); drawgrid_draw(ar, wx, wy, x, y, dx); - UI_ThemeColor(TH_GRID); + UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx*sublines); } } - else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); - drawgrid_draw(ar, wx, wy, x, y, dx); - UI_ThemeColor(TH_GRID); - drawgrid_draw(ar, wx, wy, x, y, dx*sublines); - } } + x+= (wx); y+= (wy); UI_GetThemeColor3ubv(TH_GRID, col); @@ -361,7 +410,7 @@ static void drawgrid(ARegion *ar, View3D *v3d) glDepthMask(1); // enable write in zbuffer } - +#undef GRID_MIN_PX static void drawfloor(Scene *scene, View3D *v3d) { @@ -749,7 +798,7 @@ static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d) } } } - else if(ob->pose && (ob->flag & OB_POSEMODE)) { + else if(ob->pose && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if((pchan->bone->flag & BONE_ACTIVE) && (pchan->bone->layer & arm->layer)) { @@ -1042,7 +1091,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) { RegionView3D *rv3d= ar->regiondata; - struct Base *base; + struct Base *base = scene->basact; /*for 2.43 release, don't use glext and just define the constant. this to avoid possibly breaking platforms before release.*/ @@ -1054,9 +1103,11 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) int m; #endif - if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || (FACESEL_PAINT_TEST)); - else if((G.f & G_TEXTUREPAINT) && scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)); - else if((G.f & G_PARTICLEEDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)); + if(base && (base->object->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT) || + paint_facesel_test(base->object))); + else if((base && (base->object->mode & OB_MODE_TEXTURE_PAINT)) && + scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)); + else if((base && (base->object->mode & OB_MODE_PARTICLE_EDIT)) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)); else if(scene->obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)); else { v3d->flag &= ~V3D_NEEDBACKBUFDRAW; @@ -1101,7 +1152,6 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) G.f |= G_BACKBUFSEL; - base= (scene->basact); if(base && (base->lay & v3d->lay)) { draw_object_backbufsel(scene, v3d, rv3d, base->object); } @@ -1805,13 +1855,13 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) /* *********************** customdata **************** */ /* goes over all modes and view3d settings */ -static CustomDataMask get_viewedit_datamask(bScreen *screen) +static CustomDataMask get_viewedit_datamask(bScreen *screen, Scene *scene, Object *ob) { CustomDataMask mask = CD_MASK_BAREMESH; ScrArea *sa; /* check if we need tfaces & mcols due to face select or texture paint */ - if(FACESEL_PAINT_TEST || G.f & G_TEXTUREPAINT) + if(paint_facesel_test(ob) || (ob && ob->mode & OB_MODE_TEXTURE_PAINT)) mask |= CD_MASK_MTFACE | CD_MASK_MCOL; /* check if we need tfaces & mcols due to view mode */ @@ -1825,23 +1875,22 @@ static CustomDataMask get_viewedit_datamask(bScreen *screen) if((view->drawtype == OB_TEXTURE) || ((view->drawtype == OB_SOLID) && (view->flag2 & V3D_SOLID_TEX))) { mask |= CD_MASK_MTFACE | CD_MASK_MCOL; - if((G.fileflags & G_FILE_GAME_MAT) && - (G.fileflags & G_FILE_GAME_MAT_GLSL)) { + if(scene->gm.matmode == GAME_MAT_GLSL) mask |= CD_MASK_ORCO; - } } } } /* check if we need mcols due to vertex paint or weightpaint */ - if(G.f & G_VERTEXPAINT) - mask |= CD_MASK_MCOL; - if(G.f & G_WEIGHTPAINT) - mask |= CD_MASK_WEIGHT_MCOL; - - if(G.f & G_SCULPTMODE) - mask |= CD_MASK_MDISPS; - + if(ob) { + if(ob->mode & OB_MODE_VERTEX_PAINT) + mask |= CD_MASK_MCOL; + if(ob->mode & OB_MODE_WEIGHT_PAINT) + mask |= CD_MASK_WEIGHT_MCOL; + if(ob->mode & OB_MODE_SCULPT) + mask |= CD_MASK_MDISPS; + } + return mask; } @@ -1855,9 +1904,10 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) Object *ob; int retopo= 0, sculptparticle= 0; Object *obact = OBACT; + char *grid_unit= NULL; /* from now on all object derived meshes check this */ - v3d->customdata_mask= get_viewedit_datamask(CTX_wm_screen(C)); + v3d->customdata_mask= get_viewedit_datamask(CTX_wm_screen(C), scene, obact); /* shadow buffers, before we setup matrices */ if(draw_glsl_material(scene, NULL, v3d, v3d->drawtype)) @@ -1929,7 +1979,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } else { ED_region_pixelspace(ar); - drawgrid(ar, v3d); + drawgrid(&scene->unit, ar, v3d, &grid_unit); /* XXX make function? replaces persp(1) */ glMatrixMode(GL_PROJECTION); wmLoadMatrix(rv3d->winmat); @@ -1983,7 +2033,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } // retopo= retopo_mesh_check() || retopo_curve_check(); - sculptparticle= (G.f & (G_SCULPTMODE|G_PARTICLEEDIT)) && !scene->obedit; + sculptparticle= (obact && obact->mode & (OB_MODE_SCULPT|OB_MODE_PARTICLE_EDIT)) && !scene->obedit; if(retopo) view3d_update_depths(ar, v3d); @@ -1996,7 +2046,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } if(!retopo && sculptparticle && !(obact && (obact->dtx & OB_DRAWXRAY))) { - if(G.f & G_SCULPTMODE) + if(obact && obact->mode & OB_MODE_SCULPT) draw_sculpt_depths(scene, ar, v3d); view3d_update_depths(ar, v3d); } @@ -2012,7 +2062,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! if(!retopo && sculptparticle && (obact && (OBACT->dtx & OB_DRAWXRAY))) { - if(G.f & G_SCULPTMODE) + if(obact && obact->mode & OB_MODE_SCULPT) draw_sculpt_depths(scene, ar, v3d); view3d_update_depths(ar, v3d); } @@ -2060,19 +2110,23 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) if(U.uiflag & USER_SHOW_VIEWPORTNAME) { draw_viewport_name(ar, v3d); } - + if (grid_unit) { /* draw below the viewport name */ + UI_ThemeColor(TH_TEXT_HI); + BLF_draw_default(10, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, grid_unit); + } + ob= OBACT; if(U.uiflag & USER_DRAWVIEWINFO) draw_selected_name(scene, ob, v3d); /* XXX here was the blockhandlers for floating panels */ - if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || G.f & G_TEXTUREPAINT) { + if(ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) { v3d->flag |= V3D_NEEDBACKBUFDRAW; // XXX addafterqueue(ar->win, BACKBUFDRAW, 1); } - if((G.f & G_PARTICLEEDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)) { + if((ob && ob->mode & OB_MODE_PARTICLE_EDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)) { v3d->flag |= V3D_NEEDBACKBUFDRAW; // XXX addafterqueue(ar->win, BACKBUFDRAW, 1); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index acb3a2257dc..5ef64274e72 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -54,6 +54,7 @@ #include "BKE_depsgraph.h" #include "BKE_object.h" #include "BKE_global.h" +#include "BKE_paint.h" #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" @@ -904,6 +905,9 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2. rv3d->persp= V3D_PERSP; smooth_view(C, NULL, v3d->camera, new_ofs, NULL, &new_dist, NULL); } + else { + smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL); + } } // XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); @@ -947,14 +951,14 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with INIT_MINMAX(min, max); - if (G.f & G_WEIGHTPAINT) { + if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { /* hardcoded exception, we look for the one selected armature */ /* this is weak code this way, we should make a generic active/selection callback interface once... */ Base *base; for(base=scene->base.first; base; base= base->next) { if(TESTBASELIB(v3d, base)) { if(base->object->type==OB_ARMATURE) - if(base->object->flag & OB_POSEMODE) + if(base->object->mode & OB_MODE_POSE) break; } } @@ -966,7 +970,7 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with if(obedit) { ok = minmax_verts(obedit, min, max); /* only selected */ } - else if(ob && (ob->flag & OB_POSEMODE)) { + else if(ob && (ob->mode & OB_MODE_POSE)) { if(ob->pose) { bArmature *arm= ob->data; bPoseChannel *pchan; @@ -987,10 +991,10 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with } } } - else if (FACESEL_PAINT_TEST) { + else if (paint_facesel_test(ob)) { // XXX ok= minmax_tface(min, max); } - else if (G.f & G_PARTICLEEDIT) { + else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) { ok= PE_minmax(scene, min, max); } else { @@ -2196,7 +2200,7 @@ void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int mode) rv3d->view = 0; //printf("passing here \n"); // - if (scene->obedit==NULL && ob && !(ob->flag & OB_POSEMODE)) { + if (scene->obedit==NULL && ob && !(ob->mode & OB_MODE_POSE)) { use_sel = 1; } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 26ca5a07973..6c86c87302c 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -61,6 +61,7 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_screen.h" #include "BKE_utildefines.h" /* for VECCOPY */ @@ -79,6 +80,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -104,16 +106,6 @@ * This can be cleaned when I make some new 'mode' icons. */ -#define V3D_OBJECTMODE_SEL ICON_OBJECT_DATA -#define V3D_EDITMODE_SEL ICON_EDITMODE_HLT -#define V3D_SCULPTMODE_SEL ICON_SCULPTMODE_HLT -#define V3D_FACESELECT_SEL ICON_FACESEL_HLT /* this is not a mode anymore - just a switch */ -#define V3D_VERTEXPAINTMODE_SEL ICON_VPAINT_HLT -#define V3D_TEXTUREPAINTMODE_SEL ICON_TPAINT_HLT -#define V3D_WEIGHTPAINTMODE_SEL ICON_WPAINT_HLT -#define V3D_POSEMODE_SEL ICON_POSE_HLT -#define V3D_PARTICLEEDITMODE_SEL ICON_ANIM - #define TEST_EDITMESH if(obedit==0) return; \ if( (v3d->lay & obedit->lay)==0 ) return; @@ -134,29 +126,6 @@ static int retopo_mesh_paint_check() {return 0;} /* end XXX ************* */ - -/* well... in this file a lot of view mode manipulation happens, so let's have it defined here */ -void ED_view3d_exit_paint_modes(bContext *C) -{ - if(G.f & G_TEXTUREPAINT) - WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(G.f & G_VERTEXPAINT) - WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - else if(G.f & G_WEIGHTPAINT) - WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - - if(G.f & G_SCULPTMODE) - WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(G.f & G_PARTICLEEDIT) - WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL); - - G.f &= ~(G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT+G_SCULPTMODE+G_PARTICLEEDIT); -} - - - - - static void do_view3d_header_buttons(bContext *C, void *arg, int event); #define B_SCENELOCK 101 @@ -519,7 +488,7 @@ static void do_view3d_view_alignviewmenu(bContext *C, void *arg, int event) if ((obedit) && (obedit->type == OB_MESH)) { editmesh_align_view_to_selected(v3d, event + 1); } - else if (FACESEL_PAINT_TEST) { + else if (paint_facesel_test(CTX_data_active_object(C))) { Object *obact= OBACT; if (obact && obact->type==OB_MESH) { Mesh *me= obact->data; @@ -571,7 +540,7 @@ static uiBlock *view3d_view_alignviewmenu(bContext *C, ARegion *ar, void *arg_un uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center Cursor and View All|Shift C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align Active Camera to View|Ctrl Alt NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - if (((obedit) && (obedit->type == OB_MESH)) || (FACESEL_PAINT_TEST)) { + if (((obedit) && (obedit->type == OB_MESH)) || (paint_facesel_test(CTX_data_active_object(C)))) { uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Top)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Front)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Side)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); @@ -963,112 +932,6 @@ static uiBlock *view3d_select_object_groupedmenu(bContext *C, ARegion *ar, void #endif -static void view3d_select_objectmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, "Select/Deselect All", 0, "OBJECT_OT_select_all_toggle"); - uiItemO(layout, "Inverse", 0, "OBJECT_OT_select_inverse"); - uiItemO(layout, "Random", 0, "OBJECT_OT_select_random"); - uiItemO(layout, "Select All by Layer", 0, "OBJECT_OT_select_by_layer"); - uiItemMenuEnumO(layout, "Select All by Type", 0, "OBJECT_OT_select_by_type", "type"); - uiItemMenuEnumO(layout, "Select Grouped", 0, "OBJECT_OT_select_grouped", "type"); - -#if 0 - uiDefIconTextBlockBut(block, view3d_select_object_layermenu, NULL, ICON_RIGHTARROW_THIN, "Select All by Layer", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_select_object_typemenu, NULL, ICON_RIGHTARROW_THIN, "Select All by Type", 0, yco-=20, 120, 19, ""); - - uiItemS(layout); - - uiDefIconTextBlockBut(block, view3d_select_object_linkedmenu, NULL, ICON_RIGHTARROW_THIN, "Linked", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_select_object_groupedmenu, NULL, ICON_RIGHTARROW_THIN, "Grouped", 0, yco-=20, 120, 19, ""); -#endif -} - -static void view3d_select_meshmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, "Select/Deselect All", 0, "MESH_OT_select_all_toggle"); - uiItemO(layout, "Inverse", 0, "MESH_OT_select_inverse"); - - uiItemS(layout); - - uiItemO(layout, "Random...", 0, "MESH_OT_select_random"); // Random... - uiItemO(layout, "Sharp Edges", 0, "MESH_OT_edges_select_sharp"); - uiItemO(layout, "Linked Flat Faces", 0, "MESH_OT_faces_select_linked_flat"); - - uiItemS(layout); - - uiItemEnumO(layout, "Triangles", 0, "MESH_OT_select_by_number_vertices", "type", 3); // Ctrl Alt Shift 3 - uiItemEnumO(layout, "Quads", 0, "MESH_OT_select_by_number_vertices", "type", 4); // Ctrl Alt Shift 4 - uiItemEnumO(layout, "Loose Verts/Edges", 0, "MESH_OT_select_by_number_vertices", "type", 5); // Ctrl Alt Shift 5 - uiItemO(layout, "Similar...", 0, "MESH_OT_select_similar"); - - uiItemS(layout); - - uiItemO(layout, "Less", 0, "MESH_OT_select_more"); - uiItemO(layout, "More", 0, "MESH_OT_select_less"); - - uiItemS(layout); - - uiItemO(layout, "Linked", 0, "MESH_OT_select_linked"); - uiItemO(layout, "Vertex Path", 0, "MESH_OT_select_vertex_path"); // W, Alt 7 - uiItemO(layout, "Edge Loop", 0, "MESH_OT_loop_multi_select"); - uiItemBooleanO(layout, "Edge Ring", 0, "MESH_OT_loop_multi_select", "ring", 1); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_loop_to_region"); // Ctrl E 8 - uiItemO(layout, NULL, 0, "MESH_OT_region_to_loop"); // Ctrl E 9 -} - -static void view3d_select_curvemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Object *obedit= CTX_data_edit_object(C); - - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_circle"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "CURVE_OT_select_all_toggle"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_inverse"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_random"); // Random... - uiItemO(layout, NULL, 0, "CURVE_OT_select_every_nth"); // Every Nth.. - - uiItemS(layout); - - if(obedit->type == OB_SURF) { - uiItemO(layout, NULL, 0, "CURVE_OT_select_row"); - } - else { - uiItemO(layout, NULL, 0, "CURVE_OT_de_select_first"); - uiItemO(layout, NULL, 0, "CURVE_OT_de_select_last"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_next"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_previous"); - } - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "CURVE_OT_select_more"); - uiItemO(layout, NULL, 0, "CURVE_OT_select_less"); - - /* commented out because it seems to only like the LKEY method - based on mouse pointer position :( */ - /* uiItemO(layout, NULL, 0, "CURVE_OT_select_linked"); */ - -#if 0 - G.qual |= LR_CTRLKEY; - select_connected_nurb(); - G.qual &= ~LR_CTRLKEY; - break;*/ -#endif -} - static void view3d_select_metaballmenu(bContext *C, uiLayout *layout, void *arg_unused) { uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); @@ -1079,18 +942,19 @@ static void view3d_select_metaballmenu(bContext *C, uiLayout *layout, void *arg_ uiItemO(layout, NULL, 0, "MBALL_OT_select_random_metaelems"); } -static void view3d_select_latticemenu(bContext *C, uiLayout *layout, void *arg_unused) +/* wrapper for python layouts */ +void uiTemplate_view3d_select_metaballmenu(uiLayout *layout, bContext *C) { - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - uiItemS(layout); - uiItemO(layout, NULL, 0, "LATTICE_OT_select_all_toggle"); + void *arg_unused = NULL; + view3d_select_metaballmenu(C, layout, arg_unused); } static void view3d_select_armaturemenu(bContext *C, uiLayout *layout, void *arg_unused) { PointerRNA ptr; - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); + /* this part of the menu has been moved to python */ + /*uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); uiItemS(layout); @@ -1102,7 +966,7 @@ static void view3d_select_armaturemenu(bContext *C, uiLayout *layout, void *arg_ uiItemEnumO(layout, "Parent", 0, "ARMATURE_OT_select_hierarchy", "direction", BONE_SELECT_PARENT); uiItemEnumO(layout, "Child", 0, "ARMATURE_OT_select_hierarchy", "direction", BONE_SELECT_CHILD); - uiItemS(layout); + uiItemS(layout);*/ WM_operator_properties_create(&ptr, "ARMATURE_OT_select_hierarchy"); RNA_boolean_set(&ptr, "extend", 1); @@ -1115,25 +979,17 @@ static void view3d_select_armaturemenu(bContext *C, uiLayout *layout, void *arg_ uiItemFullO(layout, "Extend Child", 0, "ARMATURE_OT_select_hierarchy", ptr.data, WM_OP_EXEC_REGION_WIN); } +/* wrapper for python layouts */ +void uiTemplate_view3d_select_armaturemenu(uiLayout *layout, bContext *C) +{ + void *arg_unused = NULL; + view3d_select_armaturemenu(C, layout, arg_unused); +} + static void view3d_select_posemenu(bContext *C, uiLayout *layout, void *arg_unused) { PointerRNA ptr; - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, "Select/Deselect All", 0, "POSE_OT_select_all_toggle"); - uiItemO(layout, "Inverse", 0, "POSE_OT_select_inverse"); - uiItemO(layout, "Constraint Target", 0, "POSE_OT_select_constraint_target"); - - uiItemS(layout); - - uiItemEnumO(layout, "Parent", 0, "POSE_OT_select_hierarchy", "direction", BONE_SELECT_PARENT); - uiItemEnumO(layout, "Child", 0, "POSE_OT_select_hierarchy", "direction", BONE_SELECT_CHILD); - - uiItemS(layout); - WM_operator_properties_create(&ptr, "POSE_OT_select_hierarchy"); RNA_boolean_set(&ptr, "extend", 1); RNA_enum_set(&ptr, "direction", BONE_SELECT_PARENT); @@ -1145,6 +1001,13 @@ static void view3d_select_posemenu(bContext *C, uiLayout *layout, void *arg_unus uiItemFullO(layout, "Extend Child", 0, "POSE_OT_select_hierarchy", ptr.data, WM_OP_EXEC_REGION_WIN); } +/* wrapper for python layouts */ +void uiTemplate_view3d_select_posemenu(uiLayout *layout, bContext *C) +{ + void *arg_unused = NULL; + view3d_select_posemenu(C, layout, arg_unused); +} + void do_view3d_select_faceselmenu(bContext *C, void *arg, int event) { #if 0 @@ -1215,6 +1078,14 @@ static uiBlock *view3d_select_faceselmenu(bContext *C, ARegion *ar, void *arg_un return block; } +/* wrapper for python layouts */ +void uiTemplate_view3d_select_faceselmenu(uiLayout *layout, bContext *C) +{ + void *arg_unused = NULL; + ARegion *ar= CTX_wm_region(C); + view3d_select_faceselmenu(C, ar, arg_unused); +} + static void view3d_edit_snapmenu(bContext *C, uiLayout *layout, void *arg_unused) { uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_selected_to_grid"); @@ -1228,6 +1099,7 @@ static void view3d_edit_snapmenu(bContext *C, uiLayout *layout, void *arg_unused uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_cursor_to_active"); } +#if 0 void do_view3d_transform_moveaxismenu(bContext *C, void *arg, int event) { #if 0 @@ -1428,7 +1300,9 @@ static uiBlock *view3d_transform_scaleaxismenu(bContext *C, ARegion *ar, void *a uiTextBoundsBlock(block, 60); return block; } +#endif +#if 0 static void do_view3d_transformmenu(bContext *C, void *arg, int event) { #if 0 @@ -1664,6 +1538,7 @@ static uiBlock *view3d_object_mirrormenu(bContext *C, ARegion *ar, void *arg_unu return block; } #endif +#endif static void view3d_edit_object_transformmenu(bContext *C, uiLayout *layout, void *arg_unused) { @@ -1924,42 +1799,6 @@ static uiBlock *view3d_edit_object_copyattrmenu(bContext *C, ARegion *ar, void * } #endif -static void view3d_edit_object_parentmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Make Parent...", 0, "OBJECT_OT_parent_set"); - uiItemO(layout, "Clear Parent...", 0, "OBJECT_OT_parent_clear"); -} - -static void view3d_edit_object_groupmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "GROUP_OT_group_create"); - uiItemO(layout, NULL, 0, "GROUP_OT_objects_remove"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "GROUP_OT_objects_add_active"); - uiItemO(layout, NULL, 0, "GROUP_OT_objects_remove_active"); -} - -static void view3d_edit_object_trackmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Make Track...", 0, "OBJECT_OT_track_set"); - uiItemO(layout, "Clear Track...", 0, "OBJECT_OT_track_clear"); -} - -static void view3d_edit_object_constraintsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "OBJECT_OT_constraint_add_with_targets"); - uiItemO(layout, NULL, 0, "OBJECT_OT_constraints_clear"); -} - -static void view3d_edit_object_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Show Hidden", 0, "OBJECT_OT_restrictview_clear"); - uiItemO(layout, "Hide Selected", 0, "OBJECT_OT_restrictview_set"); - uiItemBooleanO(layout, "Hide Unselected", 0, "OBJECT_OT_restrictview_set", "unselected", 1); -} - #if 0 #ifndef DISABLE_PYTHON static void do_view3d_edit_object_scriptsmenu(bContext *C, void *arg, int event) @@ -2033,74 +1872,8 @@ static void do_view3d_edit_objectmenu(bContext *C, void *arg, int event) } #endif -static void view3d_edit_objectmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ #if 0 - Object *ob= CTX_data_active_object(C); - - uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_object_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); -#endif - - uiItemMenuF(layout, "Clear/Apply", 0, view3d_edit_object_transformmenu); - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - - uiItemS(layout); - - // TODO: these operators may get renamed - uiItemO(layout, NULL, 0, "ANIM_OT_insert_keyframe_menu"); - uiItemO(layout, NULL, 0, "ANIM_OT_delete_keyframe_v3d"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "OBJECT_OT_duplicate"); - uiItemBooleanO(layout, "Duplicate Linked", 0, "OBJECT_OT_duplicate", "linked", 1); - uiItemO(layout, NULL, 0, "OBJECT_OT_delete"); - - uiItemO(layout, NULL, 0, "OBJECT_OT_proxy_make"); -#if 0 - uiDefIconTextBlockBut(block, view3d_edit_object_makelinksmenu, NULL, ICON_RIGHTARROW_THIN, "Make Links", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_object_singleusermenu, NULL, ICON_RIGHTARROW_THIN, "Make Single User", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_object_makelocalmenu, NULL, ICON_RIGHTARROW_THIN, "Make Local", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, view3d_edit_object_copyattrmenu, NULL, ICON_RIGHTARROW_THIN, "Copy Attributes", 0, yco-=20, 120, 19, ""); -#endif - - uiItemS(layout); - - uiItemMenuF(layout, "Parent", 0, view3d_edit_object_parentmenu); - uiItemMenuF(layout, "Track", 0, view3d_edit_object_trackmenu); - uiItemMenuF(layout, "Group", 0, view3d_edit_object_groupmenu); - uiItemMenuF(layout, "Constraints", 0, view3d_edit_object_constraintsmenu); - -#if 0 - if(ob && ob->type == OB_MESH) { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Boolean Operation...|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); - } - - // join... (added already) - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Convert Object Type...|Alt C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, ""); -#endif - uiItemS(layout); - - uiItemO(layout, NULL, 0, "OBJECT_OT_join"); - - uiItemS(layout); - -#if 0 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Move to Layer...|M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, ""); -#endif - - uiItemMenuF(layout, "Show/Hide", 0, view3d_edit_object_showhidemenu); - -#if 0 -#ifndef DISABLE_PYTHON - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBlockBut(block, view3d_edit_object_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Scripts", 0, yco-=20, 120, 19, ""); -#endif -#endif -} - +/* visible buttons ported to python, check ifedout buttons */ static void view3d_edit_mesh_verticesmenu(bContext *C, uiLayout *layout, void *arg_unused) { uiItemO(layout, "Merge...", 0, "MESH_OT_merge"); @@ -2120,45 +1893,10 @@ static void view3d_edit_mesh_verticesmenu(bContext *C, uiLayout *layout, void *a uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Hook|Ctrl H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); // make_parent(); #endif } - -void do_view3d_edit_mesh_edgesmenu(bContext *C, void *arg, int event) -{ -#if 0 - Scene *scene= CTX_data_scene(C); - float fac; - short randfac; - - switch(event) { - case 9: /* Crease SubSurf */ - if(!multires_level1_test()) { - initTransform(TFM_CREASE, CTX_EDGE); - Transform(); - } - break; - case 12: /* Edgeslide */ - EdgeSlide(0,0.0); - break; - case 13: /* Edge Loop Delete */ - if(EdgeLoopDelete()) { - countall(); - ED_undo_push(C, "Erase Edge Loop"); - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - } - break; - case 14: /*Collapse Edges*/ - collapseEdges(); - ED_undo_push(C, "Collapse"); - break; - case 17: /* Adjust Bevel Weight */ - if(!multires_level1_test()) { - initTransform(TFM_BWEIGHT, CTX_EDGE); - Transform(); - } - break; - } #endif -} +#if 0 +/* visible buttons ported to python, check ifedout buttons */ static void view3d_edit_mesh_edgesmenu(bContext *C, uiLayout *layout, void *arg_unused) { uiItemO(layout, NULL, 0, "MESH_OT_edge_face_add"); @@ -2205,38 +1943,11 @@ static void view3d_edit_mesh_edgesmenu(bContext *C, uiLayout *layout, void *arg_ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Collapse", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 14, ""); #endif } +#endif -static void view3d_edit_mesh_facesmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "MESH_OT_edge_face_add"); - uiItemO(layout, NULL, 0, "MESH_OT_fill"); - uiItemO(layout, NULL, 0, "MESH_OT_beauty_fill"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_quads_convert_to_tris"); - uiItemO(layout, NULL, 0, "MESH_OT_tris_convert_to_quads"); - uiItemO(layout, NULL, 0, "MESH_OT_edge_flip"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_smooth"); - uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_flat"); -} - -static void view3d_edit_mesh_normalsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, "Recalculate Outside", 0, "MESH_OT_normals_make_consistent"); - uiItemBooleanO(layout, "Recalculate Inside", 0, "MESH_OT_normals_make_consistent", "inside", 1); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MESH_OT_flip_normals"); -} - +#if 0 void do_view3d_edit_mirrormenu(bContext *C, void *arg, int event) { -#if 0 float mat[3][3]; Mat3One(mat); @@ -2277,7 +1988,6 @@ void do_view3d_edit_mirrormenu(bContext *C, void *arg, int event) Transform(); break; } -#endif } static uiBlock *view3d_edit_mirrormenu(bContext *C, ARegion *ar, void *arg_unused) @@ -2306,13 +2016,7 @@ static uiBlock *view3d_edit_mirrormenu(bContext *C, ARegion *ar, void *arg_unuse uiTextBoundsBlock(block, 60); return block; } - -static void view3d_edit_mesh_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "MESH_OT_reveal"); - uiItemO(layout, NULL, 0, "MESH_OT_hide"); - uiItemBooleanO(layout, "Hide Unselected", 0, "MESH_OT_hide", "unselected", 1); -} +#endif #ifndef DISABLE_PYTHON #if 0 @@ -2363,6 +2067,8 @@ static void do_view3d_edit_meshmenu(bContext *C, void *arg, int event) } #endif +#if 0 +/* visible buttons ported to python, check ifedout buttons */ static void view3d_edit_meshmenu(bContext *C, uiLayout *layout, void *arg_unused) { Scene *scene= CTX_data_scene(C); @@ -2386,7 +2092,7 @@ static void view3d_edit_meshmenu(bContext *C, uiLayout *layout, void *arg_unused uiDefIconTextBlockBut(block, view3d_edit_snapmenu, NULL, ICON_RIGHTARROW_THIN, "Snap", 0, yco-=20, 120, 19, ""); #endif - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); + uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu, NULL); uiItemS(layout); @@ -2407,10 +2113,10 @@ static void view3d_edit_meshmenu(bContext *C, uiLayout *layout, void *arg_unused uiItemS(layout); - uiItemMenuF(layout, "Vertices", 0, view3d_edit_mesh_verticesmenu); - uiItemMenuF(layout, "Edges", 0, view3d_edit_mesh_edgesmenu); - uiItemMenuF(layout, "Faces", 0, view3d_edit_mesh_facesmenu); - uiItemMenuF(layout, "Normals", 0, view3d_edit_mesh_normalsmenu); + uiItemMenuF(layout, "Vertices", 0, view3d_edit_mesh_verticesmenu, NULL); + uiItemMenuF(layout, "Edges", 0, view3d_edit_mesh_edgesmenu, NULL); + uiItemMenuF(layout, "Faces", 0, view3d_edit_mesh_facesmenu, NULL); + uiItemMenuF(layout, "Normals", 0, view3d_edit_mesh_normalsmenu, NULL); uiItemS(layout); @@ -2420,7 +2126,7 @@ static void view3d_edit_meshmenu(bContext *C, uiLayout *layout, void *arg_unused uiItemS(layout); - uiItemMenuF(layout, "Show/Hide", 0, view3d_edit_mesh_showhidemenu); + uiItemMenuF(layout, "Show/Hide", 0, view3d_edit_mesh_showhidemenu, NULL); #if 0 #ifndef DISABLE_PYTHON @@ -2429,7 +2135,10 @@ static void view3d_edit_meshmenu(bContext *C, uiLayout *layout, void *arg_unused #endif #endif } +#endif +#if 0 +/* visible buttons ported to python, check ifedout buttons */ static void view3d_edit_curve_controlpointsmenu(bContext *C, uiLayout *layout, void *arg_unused) { Object *obedit= CTX_data_edit_object(C); @@ -2453,20 +2162,10 @@ static void view3d_edit_curve_controlpointsmenu(bContext *C, uiLayout *layout, v // XXX uiItemO(layout, NULL, 0, "OBJECT_OT_add_hook"); Add Hook| Ctrl H // add_hook_menu() } +#endif -static void view3d_edit_curve_segmentsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "CURVE_OT_subdivide"); - uiItemO(layout, NULL, 0, "CURVE_OT_switch_direction"); -} - -static void view3d_edit_curve_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "CURVE_OT_reveal"); - uiItemO(layout, NULL, 0, "CURVE_OT_hide"); - uiItemBooleanO(layout, "Hide Unselected", 0, "CURVE_OT_hide", "unselected", 1); -} - +#if 0 +/* visible buttons ported to python, check ifedout buttons */ static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unused) { Scene *scene= CTX_data_scene(C); @@ -2481,7 +2180,7 @@ static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unuse uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); #endif - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); + uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu, NULL); uiItemS(layout); @@ -2500,8 +2199,8 @@ static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unuse uiItemS(layout); - uiItemMenuF(layout, "Control Points", 0, view3d_edit_curve_controlpointsmenu); - uiItemMenuF(layout, "Segments", 0, view3d_edit_curve_segmentsmenu); + uiItemMenuF(layout, "Control Points", 0, view3d_edit_curve_controlpointsmenu, NULL); + uiItemMenuF(layout, "Segments", 0, view3d_edit_curve_segmentsmenu, NULL); uiItemS(layout); @@ -2510,85 +2209,12 @@ static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unuse uiItemS(layout); - uiItemMenuF(layout, "Show/Hide Control Points", 0, view3d_edit_curve_showhidemenu); -} - -static void view3d_edit_metaball_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "MBALL_OT_hide_metaelems"); - uiItemO(layout, NULL, 0, "MBALL_OT_reveal_metaelems"); - uiItemBooleanO(layout, "Hide Unselected", 0, "MBALL_OT_hide_metaelems", "unselected", 1); -} - -static void view3d_edit_metaballmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - Scene *scene= CTX_data_scene(C); - ToolSettings *ts= CTX_data_tool_settings(C); - PointerRNA tsptr; - - RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &tsptr); - - uiItemO(layout, "Undo Editing", 0, "ED_OT_undo"); - uiItemO(layout, "Redo Editing", 0, "ED_OT_redo"); - - uiItemS(layout); - - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "MBALL_OT_delete_metaelems"); - uiItemO(layout, NULL, 0, "MBALL_OT_duplicate_metaelems"); - - uiItemS(layout); - - uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O - uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff"); // |Shift O - - uiItemS(layout); - - uiItemMenuF(layout, "Show/Hide Control Points", 0, view3d_edit_metaball_showhidemenu); -} - -static void view3d_edit_text_charsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - /* the character codes are specified in UTF-8 */ - - uiItemStringO(layout, "Copyright|Alt C", 0, "FONT_OT_text_insert", "text", "\xC2\xA9"); - uiItemStringO(layout, "Registered Trademark|Alt R", 0, "FONT_OT_text_insert", "text", "\xC2\xAE"); - - uiItemS(layout); - - uiItemStringO(layout, "Degree Sign|Alt G", 0, "FONT_OT_text_insert", "text", "\xC2\xB0"); - uiItemStringO(layout, "Multiplication Sign|Alt x", 0, "FONT_OT_text_insert", "text", "\xC3\x97"); - uiItemStringO(layout, "Circle|Alt .", 0, "FONT_OT_text_insert", "text", "\xC2\x8A"); - uiItemStringO(layout, "Superscript 1|Alt 1", 0, "FONT_OT_text_insert", "text", "\xC2\xB9"); - uiItemStringO(layout, "Superscript 2|Alt 2", 0, "FONT_OT_text_insert", "text", "\xC2\xB2"); - uiItemStringO(layout, "Superscript 3|Alt 3", 0, "FONT_OT_text_insert", "text", "\xC2\xB3"); - uiItemStringO(layout, "Double >>|Alt >", 0, "FONT_OT_text_insert", "text", "\xC2\xBB"); - uiItemStringO(layout, "Double <<|Alt <", 0, "FONT_OT_text_insert", "text", "\xC2\xAB"); - uiItemStringO(layout, "Promillage|Alt %", 0, "FONT_OT_text_insert", "text", "\xE2\x80\xB0"); - - uiItemS(layout); - - uiItemStringO(layout, "Dutch Florin|Alt F", 0, "FONT_OT_text_insert", "text", "\xC2\xA4"); - uiItemStringO(layout, "British Pound|Alt L", 0, "FONT_OT_text_insert", "text", "\xC2\xA3"); - uiItemStringO(layout, "Japanese Yen|Alt Y", 0, "FONT_OT_text_insert", "text", "\xC2\xA5"); - - uiItemS(layout); - - uiItemStringO(layout, "German S|Alt S", 0, "FONT_OT_text_insert", "text", "\xC3\x9F"); - uiItemStringO(layout, "Spanish Question Mark|Alt ?", 0, "FONT_OT_text_insert", "text", "\xC2\xBF"); - uiItemStringO(layout, "Spanish Exclamation Mark|Alt !", 0, "FONT_OT_text_insert", "text", "\xC2\xA1"); -} - -static void view3d_edit_textmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "FONT_OT_file_paste"); - uiItemS(layout); - uiItemMenuF(layout, "Special Characters", 0, view3d_edit_text_charsmenu); + uiItemMenuF(layout, "Show/Hide Control Points", 0, view3d_edit_curve_showhidemenu, NULL); } +#endif +#if 0 +/* visible buttons ported to python, check ifedout buttons */ static void view3d_edit_latticemenu(bContext *C, uiLayout *layout, void *arg_unused) { Scene *scene= CTX_data_scene(C); @@ -2606,7 +2232,7 @@ static void view3d_edit_latticemenu(bContext *C, uiLayout *layout, void *arg_unu uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); #endif - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); + uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu, NULL); uiItemS(layout); @@ -2622,32 +2248,7 @@ static void view3d_edit_latticemenu(bContext *C, uiLayout *layout, void *arg_unu uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff"); // |Shift O } - - -static void view3d_edit_armature_parentmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "ARMATURE_OT_parent_set"); - uiItemO(layout, NULL, 0, "ARMATURE_OT_parent_clear"); -} - -static void view3d_edit_armature_rollmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - /* 0 = 'Global', 1 = 'Cursor' */ - // TODO: keep these in sync... - uiItemEnumO(layout, "Clear Roll (Z-Axis Up)", 0, "ARMATURE_OT_calculate_roll", "type", 0); - uiItemEnumO(layout, "Roll to Cursor", 0, "ARMATURE_OT_calculate_roll", "type", 1); - - uiItemS(layout); - - uiItemEnumO(layout, "Set Roll", 0, "TFM_OT_transform", "mode", TFM_BONE_ROLL); -} - -static void view3d_edit_armature_settingsmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemEnumO(layout, "Toggle a Setting", 0, "ARMATURE_OT_flags_set", "mode", 2); - uiItemEnumO(layout, "Enable a Setting", 0, "ARMATURE_OT_flags_set", "mode", 1); - uiItemEnumO(layout, "Disable a Setting", 0, "ARMATURE_OT_flags_set", "mode", 0); -} +#endif #if 0 static void do_view3d_edit_armaturemenu(bContext *C, void *arg, int event) @@ -2673,6 +2274,8 @@ static void do_view3d_edit_armaturemenu(bContext *C, void *arg, int event) } #endif +#if 0 +/* visible buttons ported to python, check ifedout buttons */ static void view3d_edit_armaturemenu(bContext *C, uiLayout *layout, void *arg_unused) { Object *obedit = CTX_data_edit_object(C); @@ -2684,8 +2287,8 @@ static void view3d_edit_armaturemenu(bContext *C, uiLayout *layout, void *arg_un uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); #endif - uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu); - uiItemMenuF(layout, "Bone Roll", 0, view3d_edit_armature_rollmenu); + uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu, NULL); + uiItemMenuF(layout, "Bone Roll", 0, view3d_edit_armature_rollmenu, NULL); if (arm->drawtype == ARM_ENVELOPE) uiItemEnumO(layout, "Scale Envelope Distance", 0, "TFM_OT_transform", "mode", TFM_BONESIZE); @@ -2722,13 +2325,13 @@ static void view3d_edit_armaturemenu(bContext *C, uiLayout *layout, void *arg_un uiItemS(layout); - uiItemMenuF(layout, "Parent", 0, view3d_edit_armature_parentmenu); + uiItemMenuF(layout, "Parent", 0, view3d_edit_armature_parentmenu, NULL); uiItemS(layout); - uiItemMenuF(layout, "Bone Settings ", 0, view3d_edit_armature_settingsmenu); + uiItemMenuF(layout, "Bone Settings ", 0, view3d_edit_armature_settingsmenu, NULL); } - +#endif static void view3d_pose_armature_transformmenu(bContext *C, uiLayout *layout, void *arg_unused) { @@ -2827,7 +2430,7 @@ static void view3d_pose_armaturemenu(bContext *C, uiLayout *layout, void *arg_un #endif if ( (arm) && ((arm->drawtype == ARM_B_BONE) || (arm->drawtype == ARM_ENVELOPE)) ) uiItemEnumO(layout, "Scale Envelope Distance", 0, "TFM_OT_transform", "mode", TFM_BONESIZE); - uiItemMenuF(layout, "Clear Transform", 0, view3d_pose_armature_transformmenu); + uiItemMenuF(layout, "Clear Transform", 0, view3d_pose_armature_transformmenu, NULL); uiItemS(layout); @@ -2850,14 +2453,14 @@ static void view3d_pose_armaturemenu(bContext *C, uiLayout *layout, void *arg_un uiItemS(layout); - uiItemMenuF(layout, "Pose Library", 0, view3d_pose_armature_poselibmenu); - uiItemMenuF(layout, "Motion Paths", 0, view3d_pose_armature_motionpathsmenu); - uiItemMenuF(layout, "Bone Groups", 0, view3d_pose_armature_groupmenu); + uiItemMenuF(layout, "Pose Library", 0, view3d_pose_armature_poselibmenu, NULL); + uiItemMenuF(layout, "Motion Paths", 0, view3d_pose_armature_motionpathsmenu, NULL); + uiItemMenuF(layout, "Bone Groups", 0, view3d_pose_armature_groupmenu, NULL); uiItemS(layout); - uiItemMenuF(layout, "Inverse Kinematics", 0, view3d_pose_armature_ikmenu); - uiItemMenuF(layout, "Constraints", 0, view3d_pose_armature_constraintsmenu); + uiItemMenuF(layout, "Inverse Kinematics", 0, view3d_pose_armature_ikmenu, NULL); + uiItemMenuF(layout, "Constraints", 0, view3d_pose_armature_constraintsmenu, NULL); uiItemS(layout); @@ -2874,8 +2477,8 @@ static void view3d_pose_armaturemenu(bContext *C, uiLayout *layout, void *arg_un uiItemS(layout); - uiItemMenuF(layout, "Show/Hide Bones", 0, view3d_pose_armature_showhidemenu); - uiItemMenuF(layout, "Bone Settings", 0, view3d_pose_armature_settingsmenu); + uiItemMenuF(layout, "Show/Hide Bones", 0, view3d_pose_armature_showhidemenu, NULL); + uiItemMenuF(layout, "Bone Settings", 0, view3d_pose_armature_settingsmenu, NULL); #if 0 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Copy Attributes...|Ctrl C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); @@ -2896,7 +2499,7 @@ static void do_view3d_vpaintmenu(bContext *C, void *arg, int event) BIF_undo(); break; case 1: /* set vertex colors/weight */ - if(FACESEL_PAINT_TEST) + if(paint_facesel_test(CTX_data_active_object(C))) clear_vpaint_selectedfaces(); else /* we know were in vertex paint mode */ clear_vpaint(); @@ -3031,7 +2634,7 @@ static uiBlock *view3d_wpaintmenu(bContext *C, ARegion *ar, void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - if (FACESEL_PAINT_TEST) { + if (paint_facesel_test(CTX_data_active_object(C))) { uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Weight|Shift K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); menunr++; @@ -3059,185 +2662,6 @@ static uiBlock *view3d_wpaintmenu(bContext *C, ARegion *ar, void *arg_unused) return block; } -void do_view3d_sculpt_inputmenu(bContext *C, void *arg, int event) -{ -#if 0 - Scene *scene= CTX_data_scene(C); - SculptData *sd= &scene->sculptdata; - short val; - - switch(event) { - case 0: - sd->flags ^= SCULPT_INPUT_SMOOTH; - ED_undo_push(C, "Smooth stroke"); - break; - case 1: - val= sd->tablet_size; - if(button(&val,0,10,"Tablet Size:")==0) return; - sd->tablet_size= val; - ED_undo_push(C, "Tablet size"); - break; - case 2: - val= sd->tablet_strength; - if(button(&val,0,10,"Tablet Strength:")==0) return; - sd->tablet_strength= val; - ED_undo_push(C, "Tablet strength"); - break; - } - -#endif -} - -void do_view3d_sculptmenu(bContext *C, void *arg, int event) -{ -#if 0 - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - SculptData *sd= &scene->sculptdata; - BrushData *br= sculptmode_brush(); - - switch(event) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - sd->brush_type= event+1; - ED_undo_push(C, "Brush type"); - break; - case 11: - if(v3d) - v3d->pivot_last= !v3d->pivot_last; - break; - case 12: - sd->flags ^= SCULPT_DRAW_FAST; - ED_undo_push(C, "Partial Redraw"); - break; - case 13: - sd->flags ^= SCULPT_DRAW_BRUSH; - ED_undo_push(C, "Draw Brush"); - break; - case 14: - add_blockhandler(sa, VIEW3D_HANDLER_OBJECT, UI_PNL_UNSTOW); - break; - case 15: - sculpt_radialcontrol_start(RADIALCONTROL_ROTATION); - break; - case 16: - sculpt_radialcontrol_start(RADIALCONTROL_STRENGTH); - break; - case 17: - sculpt_radialcontrol_start(RADIALCONTROL_SIZE); - break; -#endif -} - -uiBlock *view3d_sculpt_inputmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - uiBlock *block; - short yco= 0, menuwidth= 120; - Sculpt *sd= CTX_data_tool_settings(C)->sculpt; - - block= uiBeginBlock(C, ar, "view3d_sculpt_inputmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_sculpt_inputmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ((sd->flags & SCULPT_INPUT_SMOOTH) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Smooth Stroke|Shift S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Tablet Size Adjust", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Tablet Strength Adjust", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 50); - return block; -} - -static void view3d_sculpt_menu(bContext *C, uiLayout *layout, void *arg_unused) -{ - bScreen *sc= CTX_wm_screen(C); - Sculpt *s = CTX_data_tool_settings(C)->sculpt; - PointerRNA rna; - - RNA_pointer_create(&sc->id, &RNA_Sculpt, s, &rna); - - uiItemR(layout, NULL, 0, &rna, "symmetry_x", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "symmetry_y", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "symmetry_z", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "lock_x", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "lock_y", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "lock_z", 0, 0, 0); - - /* Brush settings */ - RNA_pointer_create(&sc->id, &RNA_Brush, s->brush, &rna); - - /* Curve */ - uiItemS(layout); - uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SHARP); - uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SMOOTH); - uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_MAX); - - uiItemS(layout); - - uiItemR(layout, NULL, 0, &rna, "airbrush", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "rake", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "anchored", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "space", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "smooth_stroke", 0, 0, 0); - - uiItemR(layout, NULL, 0, &rna, "flip_direction", 0, 0, 0); -} - -uiBlock *view3d_sculptmenu(bContext *C, ARegion *ar, void *arg_unused) -{ - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - uiBlock *block; - Sculpt *sd= CTX_data_tool_settings(C)->sculpt; -// XXX const BrushData *br= sculptmode_brush(); - short yco= 0, menuwidth= 120; - - block= uiBeginBlock(C, ar, "view3d_sculptmenu", UI_EMBOSSP); - uiBlockSetButmFunc(block, do_view3d_sculptmenu, NULL); - - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Sculpt Properties|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 14, ""); - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBlockBut(block, view3d_sculpt_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input Settings", 0, yco-=20, 120, 19, ""); - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ((sd->flags & SCULPT_DRAW_BRUSH) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Display Brush", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, ""); - uiDefIconTextBut(block, BUTM, 1, ((sd->flags & SCULPT_DRAW_FAST) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Partial Redraw", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, ""); - if(v3d) - uiDefIconTextBut(block, BUTM, 1, (v3d->pivot_last ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Pivot Last", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Scale Brush|F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 17, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Strengthen Brush|Shift F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rotate Brush|Ctrl F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, ""); - - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - /* XXX uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==FLATTEN_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Flatten|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==LAYER_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Layer|L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==GRAB_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Grab|G", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==INFLATE_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Inflate|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==PINCH_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Pinch|P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==SMOOTH_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Smooth|S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); - uiDefIconTextBut(block, BUTM, 1, (sd->brush_type==DRAW_BRUSH ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT), "Draw|D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");*/ - - - if(ar->alignment==RGN_ALIGN_TOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - uiTextBoundsBlock(block, 50); - - return block; -} - static void do_view3d_facesel_showhidemenu(bContext *C, void *arg, int event) { #if 0 @@ -3322,28 +2746,6 @@ static uiBlock *view3d_faceselmenu(bContext *C, ARegion *ar, void *arg_unused) return block; } -static void view3d_select_particlemenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - ToolSettings *ts= CTX_data_tool_settings(C); - - uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_all_toggle"); - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_linked"); - - if(ts->particle.selectmode & SCE_SELECT_POINT) { - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_last"); // |W, 4 - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_first"); // |W, 3 - } - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_more"); - uiItemO(layout, NULL, 0, "PARTICLE_OT_select_less"); -} - static void view3d_particle_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused) { uiItemO(layout, NULL, 0, "PARTICLE_OT_reveal"); @@ -3374,7 +2776,7 @@ static void view3d_particlemenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemMenuF(layout, "Show/Hide Particles", 0, view3d_particle_showhidemenu); + uiItemMenuF(layout, "Show/Hide Particles", 0, view3d_particle_showhidemenu, NULL); } static char *view3d_modeselect_pup(Scene *scene) @@ -3386,10 +2788,7 @@ static char *view3d_modeselect_pup(Scene *scene) str += sprintf(str, "Mode: %%t"); - if(ob) - str += sprintf(str, formatstr, "Object Mode", V3D_OBJECTMODE_SEL, ICON_OBJECT_DATA); - else - str += sprintf(str, formatstr, "Object Mode", V3D_OBJECTMODE_SEL, ICON_OBJECT_DATA); + str += sprintf(str, formatstr, "Object Mode", OB_MODE_OBJECT, ICON_OBJECT_DATA); if(ob==NULL) return string; @@ -3398,26 +2797,25 @@ static char *view3d_modeselect_pup(Scene *scene) || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) { - str += sprintf(str, formatstr, "Edit Mode", V3D_EDITMODE_SEL, ICON_EDITMODE_HLT); + str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT); } if (ob->type == OB_MESH) { - str += sprintf(str, formatstr, "Sculpt Mode", V3D_SCULPTMODE_SEL, ICON_SCULPTMODE_HLT); - /*str += sprintf(str, formatstr, "Face Select", V3D_FACESELECTMODE_SEL, ICON_FACESEL_HLT);*/ - str += sprintf(str, formatstr, "Vertex Paint", V3D_VERTEXPAINTMODE_SEL, ICON_VPAINT_HLT); - str += sprintf(str, formatstr, "Texture Paint", V3D_TEXTUREPAINTMODE_SEL, ICON_TPAINT_HLT); - str += sprintf(str, formatstr, "Weight Paint", V3D_WEIGHTPAINTMODE_SEL, ICON_WPAINT_HLT); + str += sprintf(str, formatstr, "Sculpt Mode", OB_MODE_SCULPT, ICON_SCULPTMODE_HLT); + str += sprintf(str, formatstr, "Vertex Paint", OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT); + str += sprintf(str, formatstr, "Texture Paint", OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT); + str += sprintf(str, formatstr, "Weight Paint", OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT); } /* if active object is an armature */ if (ob->type==OB_ARMATURE) { - str += sprintf(str, formatstr, "Pose Mode", V3D_POSEMODE_SEL, ICON_POSE_HLT); + str += sprintf(str, formatstr, "Pose Mode", OB_MODE_POSE, ICON_POSE_HLT); } if (ob->particlesystem.first) { - str += sprintf(str, formatstr, "Particle Mode", V3D_PARTICLEEDITMODE_SEL, ICON_PARTICLEMODE); + str += sprintf(str, formatstr, "Particle Mode", OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE); } return (string); @@ -3505,11 +2903,10 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event) ToolSettings *ts= CTX_data_tool_settings(C); ScrArea *sa= CTX_wm_area(C); View3D *v3d= sa->spacedata.first; - Base *basact= CTX_data_active_base(C); - Object *ob= CTX_data_active_object(C); Object *obedit = CTX_data_edit_object(C); EditMesh *em= NULL; int bit, ctrl= win->eventstate->ctrl, shift= win->eventstate->shift; + PointerRNA props_ptr; if(obedit && obedit->type==OB_MESH) { em= BKE_mesh_get_editmesh((Mesh *)obedit->data); @@ -3556,79 +2953,10 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event) // XXX start_game(); break; case B_MODESELECT: - if (v3d->modeselect == V3D_OBJECTMODE_SEL) { - - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - ED_armature_exit_posemode(C, basact); - if(obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - } - else if (v3d->modeselect == V3D_EDITMODE_SEL) { - if(!obedit) { - v3d->flag &= ~V3D_MODE; - ED_object_enter_editmode(C, EM_WAITCURSOR); - ED_undo_push(C, "Original"); /* here, because all over code enter_editmode is abused */ - } - } - else if (v3d->modeselect == V3D_SCULPTMODE_SEL) { - if (!(G.f & G_SCULPTMODE)) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) ED_object_exit_editmode(C, EM_FREEUNDO|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - else if (v3d->modeselect == V3D_VERTEXPAINTMODE_SEL) { - if (!(G.f & G_VERTEXPAINT)) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - else if (v3d->modeselect == V3D_TEXTUREPAINTMODE_SEL) { - if (!(G.f & G_TEXTUREPAINT)) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - else if (v3d->modeselect == V3D_WEIGHTPAINTMODE_SEL) { - if (!(G.f & G_WEIGHTPAINT) && (ob && ob->type == OB_MESH) ) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - else if (v3d->modeselect == V3D_POSEMODE_SEL) { - - if (ob) { - v3d->flag &= ~V3D_MODE; - if(obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - ED_armature_enter_posemode(C, basact); - } - } - else if(v3d->modeselect == V3D_PARTICLEEDITMODE_SEL){ - if (!(G.f & G_PARTICLEEDIT)) { - v3d->flag &= ~V3D_MODE; - ED_view3d_exit_paint_modes(C); - if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ - - WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL); - } - } - break; - + WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set"); + RNA_enum_set(&props_ptr, "mode", v3d->modeselect); + WM_operator_name_call(C, "OBJECT_OT_mode_set", WM_OP_EXEC_REGION_WIN, &props_ptr); + break; case B_AROUND: // XXX handle_view3d_around(); /* copies to other 3d windows */ break; @@ -3688,20 +3016,20 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event) case B_MAN_TRANS: if( shift==0 || v3d->twtype==0) { v3d->twtype= V3D_MANIP_TRANSLATE; - ED_area_tag_redraw(sa); } - break; + ED_area_tag_redraw(sa); + break; case B_MAN_ROT: if( shift==0 || v3d->twtype==0) { - v3d->twtype= V3D_MANIP_ROTATE; - ED_area_tag_redraw(sa); + v3d->twtype= V3D_MANIP_ROTATE; } + ED_area_tag_redraw(sa); break; case B_MAN_SCALE: if( shift==0 || v3d->twtype==0) { - v3d->twtype= V3D_MANIP_SCALE; - ED_area_tag_redraw(sa); + v3d->twtype= V3D_MANIP_SCALE; } + ED_area_tag_redraw(sa); break; case B_NDOF: break; @@ -3771,112 +3099,44 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o * height of the header */ xmax= GetButStringLength("Select"); - if (obedit) { - if (ob && ob->type == OB_MESH) { - uiDefMenuBut(block, view3d_select_meshmenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } else if (ob && (ob->type == OB_CURVE || ob->type == OB_SURF)) { - uiDefMenuBut(block, view3d_select_curvemenu, NULL, "Select", xco, yco, xmax-3, 20, ""); - } else if (ob && ob->type == OB_FONT) { - xmax= 0; - } else if (ob && ob->type == OB_MBALL) { - uiDefMenuBut(block, view3d_select_metaballmenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } else if (ob && ob->type == OB_LATTICE) { - uiDefMenuBut(block, view3d_select_latticemenu, NULL, "Select", xco, yco, xmax-3, 20, ""); - } else if (ob && ob->type == OB_ARMATURE) { - uiDefMenuBut(block, view3d_select_armaturemenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } - } else if (FACESEL_PAINT_TEST) { - if (ob && ob->type == OB_MESH) { - uiDefPulldownBut(block, view3d_select_faceselmenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } - } else if ((G.f & G_VERTEXPAINT) || (G.f & G_TEXTUREPAINT) || (G.f & G_WEIGHTPAINT)) { - uiDefBut(block, LABEL,0,"", xco, 0, xmax, 20, 0, 0, 0, 0, 0, ""); - } else if (G.f & G_PARTICLEEDIT) { - uiDefMenuBut(block, view3d_select_particlemenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } else { - - if (ob && (ob->flag & OB_POSEMODE)) - uiDefMenuBut(block, view3d_select_posemenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - else - uiDefMenuBut(block, view3d_select_objectmenu, NULL, "Select", xco,yco, xmax-3, 20, ""); - } + xco+= xmax; if (obedit) { - if (ob && ob->type == OB_MESH) { - xmax= GetButStringLength("Mesh"); - uiDefMenuBut(block, view3d_edit_meshmenu, NULL, "Mesh", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_CURVE) { - xmax= GetButStringLength("Curve"); - uiDefMenuBut(block, view3d_edit_curvemenu, NULL, "Curve", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_SURF) { - xmax= GetButStringLength("Surface"); - uiDefMenuBut(block, view3d_edit_curvemenu, NULL, "Surface", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_FONT) { - xmax= GetButStringLength("Text"); - uiDefMenuBut(block, view3d_edit_textmenu, NULL, "Text", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_MBALL) { - xmax= GetButStringLength("Metaball"); - uiDefMenuBut(block, view3d_edit_metaballmenu, NULL, "Metaball", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_LATTICE) { - xmax= GetButStringLength("Lattice"); - uiDefMenuBut(block, view3d_edit_latticemenu, NULL, "Lattice", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } else if (ob && ob->type == OB_ARMATURE) { - xmax= GetButStringLength("Armature"); - uiDefMenuBut(block, view3d_edit_armaturemenu, NULL, "Armature", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } - } - else if (G.f & G_WEIGHTPAINT) { + else if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { xmax= GetButStringLength("Paint"); uiDefPulldownBut(block, view3d_wpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, ""); xco+= xmax; } - else if (G.f & G_VERTEXPAINT) { + else if (ob && ob->mode & OB_MODE_VERTEX_PAINT) { xmax= GetButStringLength("Paint"); uiDefPulldownBut(block, view3d_vpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, ""); xco+= xmax; } - else if (G.f & G_TEXTUREPAINT) { + else if (ob && ob->mode & OB_MODE_TEXTURE_PAINT) { xmax= GetButStringLength("Paint"); uiDefPulldownBut(block, view3d_tpaintmenu, NULL, "Paint", xco,yco, xmax-3, 20, ""); xco+= xmax; } - else if( G.f & G_SCULPTMODE) { - xmax= GetButStringLength("Sculpt"); - uiDefMenuBut(block, view3d_sculpt_menu, NULL, "Sculpt", xco, yco, xmax-3, 20, ""); - xco+= xmax; - } - else if (FACESEL_PAINT_TEST) { + else if (paint_facesel_test(ob)) { if (ob && ob->type == OB_MESH) { xmax= GetButStringLength("Face"); uiDefPulldownBut(block, view3d_faceselmenu, NULL, "Face", xco,yco, xmax-3, 20, ""); xco+= xmax; } } - else if(G.f & G_PARTICLEEDIT) { + else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) { xmax= GetButStringLength("Particle"); uiDefMenuBut(block, view3d_particlemenu, NULL, "Particle", xco,yco, xmax-3, 20, ""); xco+= xmax; } else { - if (ob && (ob->flag & OB_POSEMODE)) { + if (ob && (ob->mode & OB_MODE_POSE)) { xmax= GetButStringLength("Pose"); uiDefMenuBut(block, view3d_pose_armaturemenu, NULL, "Pose", xco,yco, xmax-3, 20, ""); xco+= xmax; } - else { - xmax= GetButStringLength("Object"); - uiDefMenuBut(block, view3d_edit_objectmenu, NULL, "Object", xco,yco, xmax-3, 20, ""); - xco+= xmax; - } } *xcoord= xco; @@ -3905,6 +3165,20 @@ static void header_xco_step(ARegion *ar, int *xco, int *yco, int *maxco, int ste } } +/* Returns the icon associated with an object mode */ +static int object_mode_icon(int mode) +{ + EnumPropertyItem *item = object_mode_items; + + while(item->name != NULL) { + if(item->value == mode) + return item->icon; + ++item; + } + + return ICON_OBJECT_DATAMODE; +} + void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) { ARegion *ar= CTX_wm_region(C); @@ -3927,29 +3201,23 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiBlockSetEmboss(block, UI_EMBOSS); /* mode */ - v3d->modeselect = V3D_OBJECTMODE_SEL; - - if (obedit) v3d->modeselect = V3D_EDITMODE_SEL; - else if(ob && (ob->flag & OB_POSEMODE)) v3d->modeselect = V3D_POSEMODE_SEL; - else if (G.f & G_SCULPTMODE) v3d->modeselect = V3D_SCULPTMODE_SEL; - else if (G.f & G_WEIGHTPAINT) v3d->modeselect = V3D_WEIGHTPAINTMODE_SEL; - else if (G.f & G_VERTEXPAINT) v3d->modeselect = V3D_VERTEXPAINTMODE_SEL; - else if (G.f & G_TEXTUREPAINT) v3d->modeselect = V3D_TEXTUREPAINTMODE_SEL; - /*else if(G.f & G_FACESELECT) v3d->modeselect = V3D_FACESELECTMODE_SEL;*/ - else if(G.f & G_PARTICLEEDIT) v3d->modeselect = V3D_PARTICLEEDITMODE_SEL; + if(ob) + v3d->modeselect = ob->mode; + else + v3d->modeselect = OB_MODE_OBJECT; v3d->flag &= ~V3D_MODE; /* not sure what the v3d->flag is useful for now... modeselect is confusing */ if(obedit) v3d->flag |= V3D_EDITMODE; - if(ob && (ob->flag & OB_POSEMODE)) v3d->flag |= V3D_POSEMODE; - if(G.f & G_VERTEXPAINT) v3d->flag |= V3D_VERTEXPAINT; - if(G.f & G_WEIGHTPAINT) v3d->flag |= V3D_WEIGHTPAINT; - if (G.f & G_TEXTUREPAINT) v3d->flag |= V3D_TEXTUREPAINT; - if(FACESEL_PAINT_TEST) v3d->flag |= V3D_FACESELECT; - - uiDefIconTextButS(block, MENU, B_MODESELECT, (v3d->modeselect),view3d_modeselect_pup(scene) , - xco,yco,126,20, &(v3d->modeselect), 0, 0, 0, 0, "Mode (Hotkeys: Tab, V, Ctrl Tab)"); + if(ob && (ob->mode & OB_MODE_POSE)) v3d->flag |= V3D_POSEMODE; + if(ob && (ob->mode & OB_MODE_VERTEX_PAINT)) v3d->flag |= V3D_VERTEXPAINT; + if(ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) v3d->flag |= V3D_WEIGHTPAINT; + if(ob && (ob->mode & OB_MODE_TEXTURE_PAINT)) v3d->flag |= V3D_TEXTUREPAINT; + if(paint_facesel_test(ob)) v3d->flag |= V3D_FACESELECT; + + uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene) , + xco,yco,126,20, &(v3d->modeselect), 0, 0, 0, 0, "Mode (Hotkeys: Tab, V, Ctrl Tab)"); header_xco_step(ar, &xco, &yco, &maxco, 126+8); /* DRAWTYPE */ @@ -3989,7 +3257,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiBlockEndAlign(block); } } else { - if (obedit==NULL && (G.f & (G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT))) { + if (obedit==NULL && ((ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)))) { uiDefIconButBitI(block, TOG, G_FACESELECT, B_VIEW_BUTSEDIT, ICON_FACESEL_HLT,xco,yco,XIC,YIC, &G.f, 0, 0, 0, 0, "Painting Mask (FKey)"); header_xco_step(ar, &xco, &yco, &maxco, XIC+10); } else { @@ -4076,7 +3344,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } /* proportional falloff */ - if((obedit && (obedit->type == OB_MESH || obedit->type == OB_CURVE || obedit->type == OB_SURF || obedit->type == OB_LATTICE)) || G.f & G_PARTICLEEDIT) { + if((obedit && (obedit->type == OB_MESH || obedit->type == OB_CURVE || obedit->type == OB_SURF || obedit->type == OB_LATTICE)) || (ob && ob->mode & OB_MODE_PARTICLE_EDIT)) { uiBlockBeginAlign(block); uiDefIconTextButS(block, ICONTEXTROW,B_REDR, ICON_PROP_OFF, "Proportional %t|Off %x0|On %x1|Connected %x2", xco,yco,XIC+10,YIC, &(ts->proportional), 0, 1.0, 0, 0, "Proportional Edit Falloff (Hotkeys: O, Alt O) "); @@ -4137,7 +3405,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) BKE_mesh_end_editmesh(obedit->data, em); } - else if(G.f & G_PARTICLEEDIT) { + else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) { uiBlockBeginAlign(block); uiDefIconButBitI(block, TOG, SCE_SELECT_PATH, B_SEL_PATH, ICON_EDGESEL, xco,yco,XIC,YIC, &ts->particle.selectmode, 1.0, 0.0, 0, 0, "Path edit mode"); xco+= XIC; @@ -4157,7 +3425,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiDefIconBut(block, BUT, B_VIEWRENDER, ICON_SCENE, xco,yco,XIC,YIC, NULL, 0, 1.0, 0, 0, "Render this window (Ctrl Click for anim)"); - if (ob && (ob->flag & OB_POSEMODE)) { + if (ob && (ob->mode & OB_MODE_POSE)) { xco+= XIC; uiBlockBeginAlign(block); @@ -4174,9 +3442,8 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } } - - /* always as last */ - UI_view2d_totRect_set(&ar->v2d, maxco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); + + /* do not do view2d totrect set here, it's now a template */ uiEndBlock(C, block); uiDrawBlock(C, block); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 3e9382509f4..acd1c62bc17 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -140,7 +140,6 @@ void view3d_buttons_register(struct ARegionType *art); void VIEW3D_OT_toolbar(struct wmOperatorType *ot); void view3d_toolbar_register(struct ARegionType *art); void view3d_tool_props_register(struct ARegionType *art); -char *view3d_context_string(const struct bContext *C); /* view3d_snap.c */ int minmax_verts(Object *obedit, float *min, float *max); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index c1fbb676179..7743ede399b 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -59,6 +59,7 @@ #include "BKE_depsgraph.h" #include "BKE_object.h" #include "BKE_global.h" +#include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -378,7 +379,7 @@ static void do_lasso_select_objects(ViewContext *vc, short mcords[][2], short mo else ED_base_object_select(base, BA_DESELECT); base->object->flag= base->flag; } - if(base->object->flag & OB_POSEMODE) { + if(base->object->mode & OB_MODE_POSE) { do_lasso_select_pose(vc, mcords, moves, select); } } @@ -693,12 +694,14 @@ static void do_lasso_select_node(short mcords[][2], short moves, short select) void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short moves, short select) { + Object *ob = CTX_data_active_object(C); + if(vc->obedit==NULL) { - if(FACESEL_PAINT_TEST) + if(paint_facesel_test(ob)) do_lasso_select_facemode(vc, mcords, moves, select); - else if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT)) + else if(ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) ; - else if(G.f & G_PARTICLEEDIT) + else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) PE_lasso_select(C, mcords, moves, select); else do_lasso_select_objects(vc, mcords, moves, select); @@ -1109,7 +1112,7 @@ static void mouse_select(bContext *C, short *mval, short extend, short obcenter) WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, basact->object); /* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */ - if(G.f & G_WEIGHTPAINT) { + if(basact->object->mode & OB_MODE_WEIGHT_PAINT) { /* prevent activating */ basact= NULL; } @@ -1323,6 +1326,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); View3D *v3d= sa->spacedata.first; Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); rcti rect; Base *base; MetaElem *ml; @@ -1341,11 +1345,11 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) rect.xmax= RNA_int_get(op->ptr, "xmax"); rect.ymax= RNA_int_get(op->ptr, "ymax"); - if(obedit==NULL && (FACESEL_PAINT_TEST)) { + if(obedit==NULL && (paint_facesel_test(OBACT))) { // XXX face_borderselect(); return OPERATOR_FINISHED; } - else if(obedit==NULL && (G.f & G_PARTICLEEDIT)) { + else if(obedit==NULL && (obact && obact->mode & OB_MODE_PARTICLE_EDIT)) { return PE_border_select(C, &rect, (val==LEFTMOUSE)); } @@ -1453,7 +1457,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) int bone_only; int totobj= MAXPICKBUF; // XXX solve later - if((ob) && (ob->flag & OB_POSEMODE)) + if((ob) && (ob->mode & OB_MODE_POSE)) bone_only= 1; else bone_only= 0; @@ -1558,6 +1562,7 @@ void VIEW3D_OT_select_border(wmOperatorType *ot) static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); short extend= RNA_boolean_get(op->ptr, "extend"); view3d_operator_needs_opengl(C); @@ -1575,7 +1580,7 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) mouse_mball(C, event->mval, extend); } - else if(G.f & G_PARTICLEEDIT) + else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) PE_mouse_particles(C, event->mval, extend); else mouse_select(C, event->mval, extend, 0); @@ -1637,9 +1642,9 @@ static void mesh_circle_select(ViewContext *vc, int selecting, short *mval, floa { ToolSettings *ts= vc->scene->toolsettings; int bbsel; + Object *ob= vc->obact; - if(vc->obedit==NULL && (FACESEL_PAINT_TEST)) { - Object *ob= vc->obact; + if(vc->obedit==NULL && paint_facesel_test(ob)) { Mesh *me = ob?ob->data:NULL; if (me) { @@ -1778,12 +1783,13 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); Scene *scene= CTX_data_scene(C); + Object *obact= CTX_data_active_object(C); View3D *v3d= sa->spacedata.first; int x= RNA_int_get(op->ptr, "x"); int y= RNA_int_get(op->ptr, "y"); int radius= RNA_int_get(op->ptr, "radius"); - if(CTX_data_edit_object(C) || (G.f & G_PARTICLEEDIT)) { + if(CTX_data_edit_object(C) || (obact && obact->mode & OB_MODE_PARTICLE_EDIT)) { ViewContext vc; short mval[2], selecting; @@ -1794,8 +1800,10 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) mval[1]= y; selecting= LEFTMOUSE==RNA_int_get(op->ptr, "event_type"); // XXX solve - if(CTX_data_edit_object(C)) + if(CTX_data_edit_object(C)) { obedit_circle_select(&vc, selecting, mval, (float)radius); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obact); + } else return PE_circle_select(C, selecting, mval, (float)radius); } diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index fba8d13c6a5..335bc2c9e56 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -482,7 +482,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; @@ -609,7 +609,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op) else { CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; float cursp[3]; @@ -775,7 +775,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op) else { Object *ob= OBACT; - if(ob && (ob->flag & OB_POSEMODE)) { + if(ob && (ob->mode & OB_MODE_POSE)) { bArmature *arm= ob->data; bPoseChannel *pchan; for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { @@ -935,7 +935,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; @@ -1004,7 +1004,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_POSEMODE) { + if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 67d8bc3e5ee..32378a915bd 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -118,6 +118,19 @@ static void redo_cb(bContext *C, void *arg_op, void *arg2) } } +static wmOperator *view3d_last_operator(const bContext *C) +{ + wmWindowManager *wm= CTX_wm_manager(C); + wmOperator *op; + + /* only for operators that are registered and did an undo push */ + for(op= wm->operators.last; op; op= op->prev) + if((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO)) + break; + + return op; +} + static void view3d_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOperator *op) { wmWindowManager *wm= CTX_wm_manager(C); @@ -129,28 +142,32 @@ static void view3d_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOper } RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); - uiDefAutoButsRNA(C, pa->layout, &ptr, 1); - + if(op->type->ui) + op->type->ui((bContext*)C, &ptr, pa->layout); + else + uiDefAutoButsRNA(C, pa->layout, &ptr, 1); +} + +static void view3d_panel_operator_redo_header(const bContext *C, Panel *pa) +{ + wmOperator *op= view3d_last_operator(C); + + if(op) BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname)); + else BLI_strncpy(pa->drawname, "Operator", sizeof(pa->drawname)); } static void view3d_panel_operator_redo(const bContext *C, Panel *pa) { - wmWindowManager *wm= CTX_wm_manager(C); - wmOperator *op; + wmOperator *op= view3d_last_operator(C); uiBlock *block; - block= uiLayoutGetBlock(pa->layout); - - /* only for operators that are registered and did an undo push */ - for(op= wm->operators.last; op; op= op->prev) - if((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO)) - break; - if(op==NULL) return; if(op->type->poll && op->type->poll((bContext *)C)==0) return; + block= uiLayoutGetBlock(pa->layout); + uiBlockSetFunc(block, redo_cb, op, NULL); if(op->macro.first) { @@ -164,42 +181,6 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa) /* ******************* */ -char *view3d_context_string(const bContext *C) -{ - Object *obedit= CTX_data_edit_object(C); - - if(obedit) { - switch(obedit->type) { - case OB_MESH: - return "editmode_mesh"; - case OB_CURVE: - return "editmode_curve"; - case OB_SURF: - return "editmode_surface"; - case OB_FONT: - return "editmode_text"; - case OB_ARMATURE: - return "editmode_armature"; - case OB_MBALL: - return "editmode_mball"; - case OB_LATTICE: - return "editmode_lattice"; - } - } - else { - Object *ob = CTX_data_active_object(C); - - if(ob && (ob->flag & OB_POSEMODE)) return "pose_mode"; - else if (G.f & G_SCULPTMODE) return "sculpt_mode"; - else if (G.f & G_WEIGHTPAINT) return "weight_paint"; - else if (G.f & G_VERTEXPAINT) return "vertex_paint"; - else if (G.f & G_TEXTUREPAINT) return "texture_paint"; - else if(G.f & G_PARTICLEEDIT) return "particle_mode"; - } - - return "objectmode"; -} - typedef struct CustomTool { struct CustomTool *next, *prev; char opname[OP_MAX_TYPENAME]; @@ -215,7 +196,7 @@ static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) BLI_addtail(arg_listbase, ct); BLI_strncpy(ct->opname, ot->idname, OP_MAX_TYPENAME); - BLI_strncpy(ct->context, view3d_context_string(C), OP_MAX_TYPENAME); + BLI_strncpy(ct->context, CTX_data_mode_string(C), OP_MAX_TYPENAME); } } @@ -278,7 +259,7 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) SpaceLink *sl= CTX_wm_space_data(C); SpaceType *st= NULL; uiLayout *col; - const char *context= view3d_context_string(C); + const char *context= CTX_data_mode_string(C); if(sl) st= BKE_spacetype_from_id(sl->spacetype); @@ -315,7 +296,8 @@ void view3d_tool_props_register(ARegionType *art) pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel last operator"); strcpy(pt->idname, "VIEW3D_PT_last_operator"); - strcpy(pt->label, "Last Operator"); + strcpy(pt->label, "Operator"); + pt->draw_header= view3d_panel_operator_redo_header; pt->draw= view3d_panel_operator_redo; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 20e0a79f0c7..58b7a70a128 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1389,12 +1389,13 @@ static ListBase queue_back; static void SaveState(bContext *C) { wmWindow *win= CTX_wm_window(C); + Object *obact = CTX_data_active_object(C); glPushAttrib(GL_ALL_ATTRIB_BITS); GPU_state_init(); - if(G.f & G_TEXTUREPAINT) + if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) GPU_paint_set_mipmap(1); queue_back= win->queue; @@ -1407,8 +1408,9 @@ static void SaveState(bContext *C) static void RestoreState(bContext *C) { wmWindow *win= CTX_wm_window(C); + Object *obact = CTX_data_active_object(C); - if(G.f & G_TEXTUREPAINT) + if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) GPU_paint_set_mipmap(0); //XXX curarea->win_swap = 0; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 510193fdade..dd7cebdfe3f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -89,6 +89,7 @@ #include "BKE_pointcache.h" #include "BKE_utildefines.h" #include "BKE_context.h" +#include "BKE_unit.h" //#include "BSE_view.h" @@ -3039,12 +3040,22 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { applyAspectRatio(t, dvec); dist = VecLength(vec); - sprintf(&tvec[0], "%.4f", dvec[0]); - sprintf(&tvec[20], "%.4f", dvec[1]); - sprintf(&tvec[40], "%.4f", dvec[2]); + if(t->scene->unit.system) { + int i, do_split= t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1:0; + + for(i=0; i<3; i++) + bUnit_AsString(&tvec[i*20], 20, dvec[i]*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1); + } + else { + sprintf(&tvec[0], "%.4f", dvec[0]); + sprintf(&tvec[20], "%.4f", dvec[1]); + sprintf(&tvec[40], "%.4f", dvec[2]); + } } - if( dist > 1e10 || dist < -1e10 ) /* prevent string buffer overflow */ + if(t->scene->unit.system) + bUnit_AsString(distvec, sizeof(distvec), dist*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0); + else if( dist > 1e10 || dist < -1e10 ) /* prevent string buffer overflow */ sprintf(distvec, "%.4e", dist); else sprintf(distvec, "%.4f", dist); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 40e133f554f..57a77ae75b8 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -917,7 +917,7 @@ static short pose_grab_with_ik(Object *ob) Bone *bonec; short tot_ik= 0; - if ((ob==NULL) || (ob->pose==NULL) || (ob->flag & OB_POSEMODE)==0) + if ((ob==NULL) || (ob->pose==NULL) || (ob->mode & OB_MODE_POSE)==0) return 0; arm = ob->data; @@ -4898,7 +4898,7 @@ void special_aftertrans_update(TransInfo *t) // allqueue(REDRAWBUTSEDIT, 0); } - else if(G.f & G_PARTICLEEDIT) { + else if(t->scene->basact && (ob = t->scene->basact->object) && ob->mode & OB_MODE_PARTICLE_EDIT) { ; } else { @@ -4957,9 +4957,9 @@ static void createTransObject(bContext *C, TransInfo *t) set_trans_object_base_flags(C, t); /* count */ +#if 0 // TRANSFORM_FIX_ME CTX_DATA_BEGIN(C, Object*, ob, selected_objects) { -#if 0 // TRANSFORM_FIX_ME /* store ipo keys? */ if ((ob->id.lib == 0) && (ob->ipo) && (ob->ipo->showkey) && (ob->ipoflag & OB_DRAWKEY)) { elems.first= elems.last= NULL; @@ -4973,12 +4973,14 @@ static void createTransObject(bContext *C, TransInfo *t) if(elems.first==NULL) t->total++; } -#endif // else { t->total++; // } } CTX_DATA_END; +#else + t->total= CTX_DATA_COUNT(C, selected_objects); +#endif if(!t->total) { /* clear here, main transform function escapes too */ @@ -5232,18 +5234,18 @@ void createTransData(bContext *C, TransInfo *t) t->poseobj = ob; /* <- tsk tsk, this is going to give issues one day */ } } - else if (ob && (ob->flag & OB_POSEMODE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { // XXX this is currently limited to active armature only... // XXX active-layer checking isn't done as that should probably be checked through context instead createTransPose(C, t, ob); } - else if (G.f & G_WEIGHTPAINT) { + else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) { /* exception, we look for the one selected armature */ CTX_DATA_BEGIN(C, Object*, ob_armature, selected_objects) { if(ob_armature->type==OB_ARMATURE) { - if(ob_armature->flag & OB_POSEMODE) + if(ob_armature->mode & OB_MODE_POSE) { createTransPose(C, t, ob_armature); break; @@ -5252,7 +5254,7 @@ void createTransData(bContext *C, TransInfo *t) } CTX_DATA_END; } - else if (G.f & G_PARTICLEEDIT && PE_can_edit(PE_get_current(scene, ob))) { + else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_can_edit(PE_get_current(scene, ob))) { createTransParticleVerts(C, t); if(t->data && t->flag & T_PROP_EDIT) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 9e04799d77e..168a65a2e75 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -343,11 +343,11 @@ static void animrecord_check_state (Scene *scene, ID *id, wmTimer *animtimer) void recalcData(TransInfo *t) { Scene *scene = t->scene; - Base *base; + Base *base = scene->basact; if (t->obedit) { } - else if(G.f & G_PARTICLEEDIT) { + else if(base && base->object->mode & OB_MODE_PARTICLE_EDIT) { flushTransParticles(t); } if (t->spacetype==SPACE_NODE) { @@ -765,7 +765,7 @@ void recalcData(TransInfo *t) */ // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes? if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) { - short targetless_ik= (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet! + int targetless_ik= (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet! animrecord_check_state(t->scene, &ob->id, t->animtimer); autokeyframe_pose_cb_func(t->scene, (View3D *)t->view, ob, t->mode, targetless_ik); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 3366f8d72d7..37fd79e38e1 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -338,7 +338,7 @@ int calc_manipulator_stats(const bContext *C) Mat4MulVecfl(obedit->obmat, scene->twmax); } } - else if(ob && (ob->flag & OB_POSEMODE)) { + else if(ob && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan; int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed @@ -358,10 +358,10 @@ int calc_manipulator_stats(const bContext *C) Mat4MulVecfl(ob->obmat, scene->twmax); } } - else if(G.f & (G_VERTEXPAINT + G_TEXTUREPAINT + G_WEIGHTPAINT + G_SCULPTMODE)) { + else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { ; } - else if(G.f & G_PARTICLEEDIT) { + else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) { ParticleSystem *psys= PE_get_current(scene, ob); ParticleData *pa = psys->particles; ParticleEditKey *ek; @@ -412,7 +412,7 @@ int calc_manipulator_stats(const bContext *C) switch(v3d->twmode) { case V3D_MANIP_NORMAL: - if(obedit || ob->flag & OB_POSEMODE) { + if(obedit || ob->mode & OB_MODE_POSE) { float mat[3][3]; int type; @@ -1415,7 +1415,7 @@ void BIF_draw_manipulator(const bContext *C) rv3d->twmat[3][2]= (scene->twmin[2] + scene->twmax[2])/2.0f; if(v3d->around==V3D_ACTIVE && scene->obedit==NULL) { Object *ob= OBACT; - if(ob && !(ob->flag & OB_POSEMODE)) + if(ob && !(ob->mode & OB_MODE_POSE)) VECCOPY(rv3d->twmat[3], ob->obmat[3]); } break; diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 605eb6996a5..8f9d6108e37 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -87,7 +87,7 @@ void BIF_manageTransformOrientation(bContext *C, int confirm, int set) { else if (obedit->type == OB_ARMATURE) index = manageBoneSpace(C, confirm, set); } - else if (ob && (ob->flag & OB_POSEMODE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { index = manageBoneSpace(C, confirm, set); } else { @@ -487,7 +487,7 @@ void initTransformOrientation(bContext *C, TransInfo *t) break; case V3D_MANIP_NORMAL: - if(obedit || ob->flag & OB_POSEMODE) { + if(obedit || ob->mode & OB_MODE_POSE) { float mat[3][3]; int type; @@ -864,7 +864,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], Mat3MulVecfl(mat, plane); } } - else if(ob && (ob->flag & OB_POSEMODE)) + else if(ob && (ob->mode & OB_MODE_POSE)) { bArmature *arm= ob->data; bPoseChannel *pchan; @@ -894,10 +894,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], result = ORIENTATION_EDGE; } } - else if(G.f & (G_VERTEXPAINT + G_TEXTUREPAINT + G_WEIGHTPAINT + G_SCULPTMODE)) - { - } - else if(G.f & G_PARTICLEEDIT) + else if(ob && (ob->mode & (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT|OB_MODE_PARTICLE_EDIT))) { } else { diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 435f2c7ecf4..18159414cf6 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -75,14 +75,11 @@ /* ***************** generic undo system ********************* */ -/* ********* XXX **************** */ -static void sound_initialize_sounds() {} -/* ********* XXX **************** */ - void ED_undo_push(bContext *C, char *str) { wmWindowManager *wm= CTX_wm_manager(C); Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); if(obedit) { if (U.undosteps == 0) return; @@ -100,7 +97,7 @@ void ED_undo_push(bContext *C, char *str) else if (obedit->type==OB_ARMATURE) undo_push_armature(C, str); } - else if(G.f & G_PARTICLEEDIT) { + else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) { if (U.undosteps == 0) return; PE_undo_push(CTX_data_scene(C), str); @@ -119,12 +116,13 @@ void ED_undo_push(bContext *C, char *str) static int ed_undo_step(bContext *C, int step, const char *undoname) { Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); ScrArea *sa= CTX_wm_area(C); if(sa && sa->spacetype==SPACE_IMAGE) { SpaceImage *sima= (SpaceImage *)sa->spacedata.first; - if(G.f & G_TEXTUREPAINT || sima->flag & SI_DRAWTOOL) { + if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) { undo_imagepaint_step(step); WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -146,9 +144,9 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) else { int do_glob_undo= 0; - if(G.f & G_TEXTUREPAINT) + if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) undo_imagepaint_step(step); - else if(G.f & G_PARTICLEEDIT) { + else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) { if(step==1) PE_undo(CTX_data_scene(C)); else @@ -167,7 +165,6 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) BKE_undo_name(C, undoname); else BKE_undo_step(C, step); - sound_initialize_sounds(); } } @@ -214,13 +211,14 @@ static int ed_redo_exec(bContext *C, wmOperator *op) void ED_undo_menu(bContext *C) { Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); if(obedit) { //if ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE) // undo_editmode_menu(); } else { - if(G.f & G_PARTICLEEDIT) + if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) PE_undo_menu(CTX_data_scene(C), CTX_data_active_object(C)); else if(U.uiflag & USER_GLOBALUNDO) { char *menu= BKE_undo_menu_string(); @@ -229,7 +227,6 @@ void ED_undo_menu(bContext *C) MEM_freeN(menu); if(event>0) { BKE_undo_number(C, event); - sound_initialize_sounds(); } } } diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 802f30506f8..82ff51dc5ce 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -78,7 +78,7 @@ int GPU_get_material_blend_mode(void); * be drawn using one or the other * - passing NULL clears the state again */ -int GPU_set_tpage(struct MTFace *tface); +int GPU_set_tpage(struct MTFace *tface, int mipmap); /* Lights * - returns how many lights were enabled @@ -105,10 +105,10 @@ void GPU_paint_set_mipmap(int mipmap); /* Image updates and free * - these deal with images bound as opengl textures */ -void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h); +void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h, int mipmap); void GPU_update_images_framechange(void); int GPU_update_image_time(struct Image *ima, double time); -int GPU_verify_image(struct Image *ima, int tftile, int tfmode, int compare); +int GPU_verify_image(struct Image *ima, int tftile, int tfmode, int compare, int mipmap); void GPU_free_image(struct Image *ima); void GPU_free_images(void); diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index 7218b6b1328..eba585e8838 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -75,7 +75,7 @@ GPUTexture *GPU_texture_create_1D(int w, float *pixels); GPUTexture *GPU_texture_create_2D(int w, int h, float *pixels); GPUTexture *GPU_texture_create_depth(int w, int h); GPUTexture *GPU_texture_from_blender(struct Image *ima, - struct ImageUser *iuser, double time); + struct ImageUser *iuser, double time, int mipmap); void GPU_texture_free(GPUTexture *tex); void GPU_texture_ref(GPUTexture *tex); diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index 49c0dc166c1..f7318869fb3 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -124,7 +124,7 @@ void GPU_material_free(struct Material *ma); void GPU_materials_free(); -void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time); +void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap); void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4]); void GPU_material_unbind(GPUMaterial *material); int GPU_material_bound(GPUMaterial *material); diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 94c1910e3bc..c8a2d553685 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -824,7 +824,7 @@ void GPU_nodes_extract_dynamic_inputs(GPUPass *pass, ListBase *nodes) GPU_shader_unbind(shader); } -void GPU_pass_bind(GPUPass *pass, double time) +void GPU_pass_bind(GPUPass *pass, double time, int mipmap) { GPUInput *input; GPUShader *shader = pass->shader; @@ -838,7 +838,7 @@ void GPU_pass_bind(GPUPass *pass, double time) /* now bind the textures */ for (input=inputs->first; input; input=input->next) { if (input->ima) - input->tex = GPU_texture_from_blender(input->ima, input->iuser, time); + input->tex = GPU_texture_from_blender(input->ima, input->iuser, time, mipmap); if(input->tex && input->bindtex) { GPU_texture_bind(input->tex, input->texid); diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h index 53b52f24f16..f5dd956d176 100644 --- a/source/blender/gpu/intern/gpu_codegen.h +++ b/source/blender/gpu/intern/gpu_codegen.h @@ -71,7 +71,7 @@ GPUPass *GPU_generate_pass(ListBase *nodes, struct GPUNodeLink *outlink, struct GPUShader *GPU_pass_shader(GPUPass *pass); -void GPU_pass_bind(GPUPass *pass, double time); +void GPU_pass_bind(GPUPass *pass, double time, int mipmap); void GPU_pass_update_uniforms(GPUPass *pass); void GPU_pass_unbind(GPUPass *pass); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index eb834abc670..e7846a23905 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -194,8 +194,11 @@ static int smaller_pow2(int num) static int is_pow2_limit(int num) { /* take texture clamping into account */ - if (G.f & G_TEXTUREPAINT) - return 1; + + /* XXX: texturepaint not global! + if (G.f & G_TEXTUREPAINT) + return 1;*/ + if (U.glreslimit != 0 && num > U.glreslimit) return 0; @@ -204,8 +207,9 @@ static int is_pow2_limit(int num) static int smaller_pow2_limit(int num) { - if (G.f & G_TEXTUREPAINT) - return 1; + /* XXX: texturepaint not global! + if (G.f & G_TEXTUREPAINT) + return 1;*/ /* take texture clamping into account */ if (U.glreslimit != 0 && num > U.glreslimit) @@ -249,7 +253,7 @@ void GPU_set_linear_mipmap(int linear) static int gpu_get_mipmap(void) { - return GTS.domipmap && (!(G.f & G_TEXTUREPAINT)); + return GTS.domipmap; } static GLenum gpu_get_mipmap_filter(int mag) @@ -382,7 +386,7 @@ static void gpu_verify_reflection(Image *ima) } } -int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare) +int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare, int mipmap) { ImBuf *ibuf = NULL; unsigned int *bind = NULL; @@ -507,7 +511,7 @@ int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare) } /* scale if not a power of two */ - if (!is_pow2_limit(rectw) || !is_pow2_limit(recth)) { + if (!mipmap && (!is_pow2_limit(rectw) || !is_pow2_limit(recth))) { rectw= smaller_pow2_limit(rectw); recth= smaller_pow2_limit(recth); @@ -520,7 +524,7 @@ int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare) glGenTextures(1, (GLuint *)bind); glBindTexture( GL_TEXTURE_2D, *bind); - if (!gpu_get_mipmap()) { + if (!(gpu_get_mipmap() && mipmap)) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); @@ -559,7 +563,7 @@ static void gpu_verify_repeat(Image *ima) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } -int GPU_set_tpage(MTFace *tface) +int GPU_set_tpage(MTFace *tface, int mipmap) { Image *ima; @@ -575,7 +579,7 @@ int GPU_set_tpage(MTFace *tface) gpu_verify_alpha_mode(tface); gpu_verify_reflection(ima); - if(GPU_verify_image(ima, tface->tile, tface->mode, 1)) { + if(GPU_verify_image(ima, tface->tile, tface->mode, 1, mipmap)) { GTS.curtile= GTS.tile; GTS.curima= GTS.ima; GTS.curtilemode= GTS.tilemode; @@ -640,13 +644,13 @@ void GPU_paint_set_mipmap(int mipmap) } } -void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) +void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap) { ImBuf *ibuf; ibuf = BKE_image_get_ibuf(ima, NULL); - if (ima->repbind || gpu_get_mipmap() || !ima->bindcode || !ibuf || + if (ima->repbind || (gpu_get_mipmap() && mipmap) || !ima->bindcode || !ibuf || (!is_pow2(ibuf->x) || !is_pow2(ibuf->y)) || (w == 0) || (h == 0)) { /* these cases require full reload still */ @@ -988,7 +992,7 @@ int GPU_enable_material(int nr, void *attribs) gpumat = GPU_material_from_blender(GMS.gscene, mat); GPU_material_vertex_attributes(gpumat, gattribs); - GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0); + GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT)); GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col); GMS.gboundmat= mat; diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 4984e043031..467b2c4a7f4 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -312,7 +312,7 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in return tex; } -GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, double time) +GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, double time, int mipmap) { GPUTexture *tex; GLint w, h, border, lastbindcode, bindcode; @@ -320,7 +320,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, double time) glGetIntegerv(GL_TEXTURE_BINDING_2D, &lastbindcode); GPU_update_image_time(ima, time); - bindcode = GPU_verify_image(ima, 0, 0, 0); + bindcode = GPU_verify_image(ima, 0, 0, 0, mipmap); if(ima->gputexture) { ima->gputexture->bindcode = bindcode; diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 7e8b5c18d71..c0fb069fc41 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -246,7 +246,7 @@ void GPU_material_free(Material *ma) BLI_freelistN(&ma->gpumaterial); } -void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time) +void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap) { if(material->pass) { LinkData *nlink; @@ -266,7 +266,7 @@ void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double tim } } - GPU_pass_bind(material->pass, time); + GPU_pass_bind(material->pass, time, mipmap); material->bound = 1; } } @@ -500,7 +500,7 @@ static void ramp_diffuse_result(GPUShadeInput *shi, GPUNodeLink **diff) GPUMaterial *mat= shi->gpumat; GPUNodeLink *fac; - if(!(G.fileflags & G_FILE_GLSL_NO_RAMPS)) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS)) { if(ma->ramp_col) { if(ma->rampin_col==MA_RAMP_IN_RESULT) { GPU_link(mat, "ramp_rgbtobw", *diff, &fac); @@ -516,7 +516,7 @@ static void add_to_diffuse(GPUMaterial *mat, Material *ma, GPUShadeInput *shi, G { GPUNodeLink *fac, *tmp, *addcol; - if(!(G.fileflags & G_FILE_GLSL_NO_RAMPS) && + if(!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) && ma->ramp_col && (ma->mode & MA_RAMP_COL)) { /* MA_RAMP_IN_RESULT is exceptional */ if(ma->rampin_col==MA_RAMP_IN_RESULT) { @@ -556,7 +556,7 @@ static void ramp_spec_result(GPUShadeInput *shi, GPUNodeLink **spec) GPUMaterial *mat= shi->gpumat; GPUNodeLink *fac; - if(!(G.fileflags & G_FILE_GLSL_NO_RAMPS) && + if(!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) && ma->ramp_spec && ma->rampin_spec==MA_RAMP_IN_RESULT) { GPU_link(mat, "ramp_rgbtobw", *spec, &fac); @@ -644,7 +644,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la is= inp; /* Lambert */ - if(!(G.fileflags & G_FILE_GLSL_NO_SHADERS)) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) { if(ma->diff_shader==MA_DIFF_ORENNAYAR) GPU_link(mat, "shade_diffuse_oren_nayer", inp, vn, lv, view, GPU_uniform(&ma->roughness), &is); else if(ma->diff_shader==MA_DIFF_TOON) @@ -656,7 +656,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la } } - if(!(G.fileflags & G_FILE_GLSL_NO_SHADERS)) + if(!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) if(ma->shade_flag & MA_CUBIC) GPU_link(mat, "shade_cubic", is, &is); @@ -671,7 +671,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la // done in shade_visifac now, GPU_link(mat, "mtex_value_clamp_positive", i, &i); if((ma->mode & MA_SHADOW) && GPU_lamp_has_shadow_buffer(lamp)) { - if(!(G.fileflags & G_FILE_GLSL_NO_SHADOWS)) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS)) { mat->dynproperty |= DYN_LAMP_PERSMAT; GPU_link(mat, "test_shadowbuf", @@ -700,7 +700,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la GPU_link(mat, "math_multiply", i, shadfac, &i); } } - else if((G.fileflags & G_FILE_GLSL_NO_SHADOWS) && (lamp->mode & LA_ONLYSHADOW)) { + else if((mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS) && (lamp->mode & LA_ONLYSHADOW)) { add_user_list(&mat->lamps, lamp); add_user_list(&lamp->materials, shi->gpumat->ma); return; @@ -716,7 +716,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la } } - if(G.fileflags & G_FILE_GLSL_NO_SHADERS); + if(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS); else if(!(lamp->mode & LA_NO_SPEC) && !(lamp->mode & LA_ONLYSHADOW) && (GPU_link_changed(shi->spec) || ma->spec != 0.0f)) { if(lamp->type == LA_HEMI) { @@ -1015,11 +1015,11 @@ static void do_material_tex(GPUShadeInput *shi) if(mtex->mapto & MAP_COL) texture_rgb_blend(mat, tcol, shi->rgb, tin, colfac, mtex->blendtype, &shi->rgb); - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_COLSPEC)) + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_COLSPEC)) texture_rgb_blend(mat, tcol, shi->specrgb, tin, colfac, mtex->blendtype, &shi->specrgb); } - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) { if(mtex->maptoneg & MAP_NORM) tex->norfac= -mtex->norfac; else tex->norfac= mtex->norfac; @@ -1065,22 +1065,22 @@ static void do_material_tex(GPUShadeInput *shi) GPU_link(mat, "mtex_rgbtoint", trgb, &tin); } - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_REF) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_REF) { int flip= mtex->maptoneg & MAP_REF; texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->refl, tin, varfac, mtex->blendtype, flip, &shi->refl); GPU_link(mat, "mtex_value_clamp_positive", shi->refl, &shi->refl); } - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_SPEC) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_SPEC) { int flip= mtex->maptoneg & MAP_SPEC; texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->spec, tin, varfac, mtex->blendtype, flip, &shi->spec); GPU_link(mat, "mtex_value_clamp_positive", shi->spec, &shi->spec); } - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_EMIT) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_EMIT) { int flip= mtex->maptoneg & MAP_EMIT; texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->emit, tin, varfac, mtex->blendtype, flip, &shi->emit); GPU_link(mat, "mtex_value_clamp_positive", shi->emit, &shi->emit); } - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_HAR) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_HAR) { int flip= mtex->maptoneg & MAP_HAR; GPU_link(mat, "mtex_har_divide", shi->har, &shi->har); texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->har, tin, varfac, mtex->blendtype, flip, &shi->har); @@ -1091,7 +1091,7 @@ static void do_material_tex(GPUShadeInput *shi) texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->alpha, tin, varfac, mtex->blendtype, flip, &shi->alpha); GPU_link(mat, "mtex_value_clamp", shi->alpha, &shi->alpha); } - if(!(G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_AMB) { + if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_AMB) { int flip= mtex->maptoneg & MAP_AMB; texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->amb, tin, varfac, mtex->blendtype, flip, &shi->amb); GPU_link(mat, "mtex_value_clamp", shi->amb, &shi->amb); @@ -1139,10 +1139,10 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) do_material_tex(shi); - if(ma->mode & MA_ZTRA) + if((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) GPU_material_enable_alpha(mat); - if((G.fileflags & G_FILE_GLSL_NO_LIGHTS) || (ma->mode & MA_SHLESS)) { + if((mat->scene->gm.flag & GAME_GLSL_NO_LIGHTS) || (ma->mode & MA_SHLESS)) { shr->combined = shi->rgb; shr->alpha = shi->alpha; GPU_link(mat, "set_rgb", shi->rgb, &shr->diff); @@ -1213,7 +1213,7 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) GPU_uniform(&world->horr), &shr->combined); } - if(!(ma->mode & MA_ZTRA)) { + if(!((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP))) { if(world && (GPU_link_changed(shr->alpha) || ma->alpha != 1.0f)) GPU_link(mat, "shade_world_mix", GPU_uniform(&world->horr), shr->combined, &shr->combined); @@ -1251,7 +1251,7 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma) mat = GPU_material_construct_begin(ma); mat->scene = scene; - if(!(G.fileflags & G_FILE_GLSL_NO_NODES) && ma->nodetree && ma->use_nodes) { + if(!(scene->gm.flag & GAME_GLSL_NO_NODES) && ma->nodetree && ma->use_nodes) { ntreeGPUMaterialNodes(ma->nodetree, mat); } else { @@ -1458,8 +1458,8 @@ void GPU_lamp_free(Object *ob) int GPU_lamp_has_shadow_buffer(GPULamp *lamp) { - return (!(G.fileflags & G_FILE_GLSL_NO_SHADOWS) && - !(G.fileflags & G_FILE_GLSL_NO_LIGHTS) && + return (!(lamp->scene->gm.flag & GAME_GLSL_NO_SHADOWS) && + !(lamp->scene->gm.flag & GAME_GLSL_NO_LIGHTS) && lamp->tex && lamp->fb); } diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 0c6c04273e3..6f097ea3882 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -313,6 +313,7 @@ typedef enum DOPESHEET_FILTERFLAG { ADS_FILTER_NOWOR = (1<<14), ADS_FILTER_NOSCE = (1<<15), ADS_FILTER_NOPART = (1<<16), + ADS_FILTER_NOMBA = (1<<17), /* NLA-specific filters */ ADS_FILTER_NLA_NOACT = (1<<20), /* if the AnimData block has no NLA data, don't include to just show Action-line */ diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index c3f668ff622..278da27faf9 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -37,6 +37,9 @@ struct Scene; struct Group; struct Text; +// for Sound3D +#include "DNA_sound_types.h" + /* ****************** ACTUATORS ********************* */ /* unused now, moved to editobjectactuator in 2.02. Still needed for dna */ @@ -62,18 +65,13 @@ typedef struct bSoundActuator { short flag, sndnr; int sta, end; short pad1[2]; + float volume, pitch; struct bSound *sound; + struct Sound3D sound3D; short type, makecopy; short copymade, pad2[1]; } bSoundActuator; -typedef struct bCDActuator { - short flag, sndnr; - int sta, end; - short type, track; - float volume; -} bCDActuator; - typedef struct bEditObjectActuator { int time; short type, flag; @@ -291,7 +289,6 @@ typedef struct FreeCamera { #define ACT_RANDOM 13 #define ACT_MESSAGE 14 #define ACT_ACTION 15 /* __ NLA */ -#define ACT_CD 16 #define ACT_GAME 17 #define ACT_VISIBILITY 18 #define ACT_2DFILTER 19 @@ -432,6 +429,9 @@ typedef struct FreeCamera { #define ACT_RANDOM_FLOAT_NORMAL 8 #define ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL 9 +/* SoundActuator->flag */ +#define ACT_SND_3D_SOUND 1 + /* SoundActuator->type */ #define ACT_SND_PLAY_STOP_SOUND 0 #define ACT_SND_PLAY_END_SOUND 1 @@ -444,15 +444,6 @@ typedef struct FreeCamera { #define ACT_MESG_MESG 0 #define ACT_MESG_PROP 1 -/* cdactuator->type */ -#define ACT_CD_PLAY_ALL 0 -#define ACT_CD_PLAY_TRACK 1 -#define ACT_CD_LOOP_TRACK 2 -#define ACT_CD_VOLUME 3 -#define ACT_CD_STOP 4 -#define ACT_CD_PAUSE 5 -#define ACT_CD_RESUME 6 - /* gameactuator->type */ #define ACT_GAME_LOAD 0 #define ACT_GAME_START 1 diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index f88d3b68ebf..52ea298c110 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -58,18 +58,17 @@ typedef struct Brush { int size; /* brush diameter */ float innerradius; /* inner radius after which the falloff starts */ float spacing; /* spacing of paint operations */ + int smooth_stroke_radius; /* turning radius (in pixels) for smooth stroke */ + float smooth_stroke_factor; /* higher values limit fast changes in the stroke direction */ float rate; /* paint operations / second (airbrush) */ float rgb[3]; /* color */ float alpha; /* opacity */ - float rot; /* rotation in radians */ - short texact; /* active texture */ char sculpt_tool; /* active tool */ - char tex_mode; - char pad[4]; + char pad[1]; } Brush; /* Brush.flag */ @@ -85,6 +84,7 @@ typedef struct Brush { #define BRUSH_DIR_IN 512 #define BRUSH_SPACE 1024 #define BRUSH_SMOOTH_STROKE 2048 +#define BRUSH_PERSISTENT 4096 /* Brush.blend */ #define BRUSH_BLEND_MIX 0 @@ -96,11 +96,6 @@ typedef struct Brush { #define BRUSH_BLEND_ERASE_ALPHA 6 #define BRUSH_BLEND_ADD_ALPHA 7 -/* Brush.tex_mode */ -#define BRUSH_TEX_DRAG 0 -#define BRUSH_TEX_TILE 1 -#define BRUSH_TEX_3D 2 - /* Brush.sculpt_tool */ #define SCULPT_TOOL_DRAW 1 #define SCULPT_TOOL_SMOOTH 2 diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 5b566a244b4..f7b3273c2e1 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -164,7 +164,7 @@ typedef struct Material { #define MA_VERTEXCOL 16 #define MA_HALO_SOFT 16 #define MA_HALO 32 /* deprecated */ -#define MA_ZTRA 64 +#define MA_ZTRANSP 64 #define MA_VERTEXCOLP 128 #define MA_ZINV 256 #define MA_HALO_RINGS 256 @@ -180,7 +180,7 @@ typedef struct Material { #define MA_NOMIST 0x4000 #define MA_HALO_SHADE 0x4000 #define MA_HALO_FLARE 0x8000 -#define MA_RADIO 0x10000 +#define MA_TRANSP 0x10000 #define MA_RAYTRANSP 0x20000 #define MA_RAYMIRROR 0x40000 #define MA_SHADOW_TRA 0x80000 @@ -224,7 +224,7 @@ typedef struct Material { #define MA_SPEC_WARDISO 4 /* dynamode */ -#define MA_DRAW_DYNABUTS 1 +#define MA_DRAW_DYNABUTS 1 /* deprecated */ #define MA_FH_NOR 2 /* ramps */ diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 3ecfe416c79..f7f1d3b53bd 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -139,7 +139,7 @@ typedef struct TFace { #define ME_DRAWCREASES (1 << 6) #define ME_DRAWSEAMS (1 << 7) #define ME_DRAWSHARP (1 << 8) -#define ME_DRAWBWEIGHTS (1 << 8) +#define ME_DRAWBWEIGHTS (1 << 9) #define ME_DRAW_EDGELEN (1 << 10) #define ME_DRAW_FACEAREA (1 << 11) diff --git a/source/blender/makesdna/DNA_meta_types.h b/source/blender/makesdna/DNA_meta_types.h index 897368fd5df..8b61405b851 100644 --- a/source/blender/makesdna/DNA_meta_types.h +++ b/source/blender/makesdna/DNA_meta_types.h @@ -35,6 +35,7 @@ #include "DNA_ID.h" struct BoundBox; +struct AnimData; struct Ipo; struct Material; @@ -62,18 +63,20 @@ typedef struct MetaElem { typedef struct MetaBall { ID id; + struct AnimData *adt; struct BoundBox *bb; ListBase elems; ListBase disp; ListBase *editelems; /* not saved in files, note we use pointer for editmode check */ - struct Ipo *ipo; + struct Ipo *ipo; // XXX... depreceated (old animation system) /* material of the mother ball will define the material used of all others */ struct Material **mat; - short flag, totcol; + char flag, flag2; /* flag is enum for updates, flag2 is bitflags for settings */ + short totcol; int texflag; /* used to store MB_AUTOSPACE */ /* texture space, copied as one block in editobject.c */ @@ -104,6 +107,10 @@ typedef struct MetaBall { #define MB_UPDATE_FAST 2 #define MB_UPDATE_NEVER 3 +/* mb->flag2 */ +#define MB_DS_EXPAND (1<<0) + + /* ml->type */ #define MB_BALL 0 #define MB_TUBEX 1 /* depercated */ diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 3f504848d77..9d1707599b9 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -420,6 +420,7 @@ typedef struct ClothModifierData { struct ClothSimSettings *sim_parms; /* definition is in DNA_cloth_types.h */ struct ClothCollSettings *coll_parms; /* definition is in DNA_cloth_types.h */ struct PointCache *point_cache; /* definition is in DNA_object_force.h */ + struct ListBase ptcaches; } ClothModifierData; typedef struct CollisionModifierData { diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index b5b33610bfe..625864c4888 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -74,14 +74,36 @@ typedef struct PartDeflect { int seed; /* wind noise random seed */ } PartDeflect; +/* Point cache file data types: + * - used as (1<recalc (flag bits!) */ #define OB_RECALC_OB 1 @@ -513,6 +519,16 @@ extern Object workob; #define OB_LOCK_SCALEZ 256 #define OB_LOCK_SCALE 448 +/* ob->mode */ +#define OB_MODE_OBJECT 0 +#define OB_MODE_EDIT 1 +#define OB_MODE_SCULPT 2 +#define OB_MODE_VERTEX_PAINT 4 +#define OB_MODE_WEIGHT_PAINT 8 +#define OB_MODE_TEXTURE_PAINT 16 +#define OB_MODE_PARTICLE_EDIT 32 +#define OB_MODE_POSE 64 + /* ob->softflag in DNA_object_force.h */ #ifdef __cplusplus diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index b71d390db5a..925fd31328d 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -229,6 +229,7 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in /* point cache */ struct PointCache *pointcache; + struct ListBase ptcaches; struct KDTree *tree; /* used for interactions with self and other systems */ }ParticleSystem; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 752f756401c..4a3d555ca33 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -387,7 +387,7 @@ typedef struct GameData { * bit 3: (gameengine): Activity culling is enabled. * bit 5: (gameengine) : enable Bullet DBVT tree for view frustrum culling */ - short mode, pad11; + short mode, flag, matmode, pad[3]; short occlusionRes; /* resolution of occlusion Z buffer in pixel */ short physicsEngine; short ticrate, maxlogicstep, physubstep, maxphystep; @@ -401,6 +401,7 @@ typedef struct GameData { struct GameDome dome; short stereoflag, stereomode, xsch, ysch; //xsch and ysch can be deleted !!! } GameData; + #define STEREO_NOSTEREO 1 #define STEREO_ENABLED 2 #define STEREO_DOME 3 @@ -422,6 +423,25 @@ typedef struct GameData { #define WOPHY_ODE 4 #define WOPHY_BULLET 5 +/* GameData.flag */ +#define GAME_ENABLE_ALL_FRAMES (1 << 1) +#define GAME_SHOW_DEBUG_PROPS (1 << 2) +#define GAME_SHOW_FRAMERATE (1 << 3) +#define GAME_SHOW_PHYSICS (1 << 4) +#define GAME_DISPLAY_LISTS (1 << 5) +#define GAME_GLSL_NO_LIGHTS (1 << 6) +#define GAME_GLSL_NO_SHADERS (1 << 7) +#define GAME_GLSL_NO_SHADOWS (1 << 8) +#define GAME_GLSL_NO_RAMPS (1 << 9) +#define GAME_GLSL_NO_NODES (1 << 10) +#define GAME_GLSL_NO_EXTRA_TEX (1 << 11) +#define GAME_IGNORE_DEPRECATION_WARNINGS (1 << 12) + +/* GameData.matmode */ +#define GAME_MAT_TEXFACE 0 +#define GAME_MAT_MULTITEX 1 +#define GAME_MAT_GLSL 2 + typedef struct TimeMarker { struct TimeMarker *next, *prev; int frame; @@ -429,8 +449,18 @@ typedef struct TimeMarker { unsigned int flag; } TimeMarker; +typedef struct Paint { + /* Array of brushes selected for use in this paint mode */ + Brush **brushes; + int active_brush_index, brush_count; + + /* WM handle */ + void *paint_cursor; +} Paint; + typedef struct ImagePaintSettings { - struct Brush *brush; + Paint paint; + short flag, tool; /* for projection painting only */ @@ -465,26 +495,23 @@ typedef struct TransformOrientation { float mat[3][3]; } TransformOrientation; -struct SculptSession; -typedef struct Sculpt -{ - /* Note! a deep copy of this struct must be done header_info.c's copy_scene function */ - /* Data stored only from entering sculptmode until exiting sculptmode */ - struct SculptSession *session; - struct Brush *brush; +typedef struct Sculpt { + Paint paint; + + /* WM handle */ + void *cursor; /* For rotating around a pivot point */ float pivot[3]; int flags; - /* For the Brush Shape */ - char texsep; + /* Control tablet input */ char tablet_size, tablet_strength; - char pad[5]; + char pad[6]; } Sculpt; typedef struct VPaint { - struct Brush *brush; + Paint paint; float gamma, mul; /* should become part of struct Brush? */ short mode, flag; @@ -622,6 +649,12 @@ typedef struct bStats { int totvert, totface; } bStats; +typedef struct UnitSettings { + /* Display/Editing unit options for each scene */ + float scale_length; /* maybe have other unit conversions? */ + short system; + short flag; /* imperial, metric etc */ +} UnitSettings; typedef struct Scene { ID id; @@ -642,7 +675,7 @@ typedef struct Scene { float twmin[3], twmax[3]; /* boundbox of selection for transform widget */ unsigned int lay; - + short flag; /* various settings */ short use_nodes; @@ -662,6 +695,7 @@ typedef struct Scene { ListBase markers; ListBase transform_spaces; + ListBase sound_handles; /* none of the dependancy graph vars is mean to be saved */ struct DagForest *theDag; @@ -680,6 +714,10 @@ typedef struct Scene { /* Game Settings */ struct GameFraming framing; // XXX deprecated since 2.5 struct GameData gm; + + /* Units */ + struct UnitSettings unit; + } Scene; @@ -1071,6 +1109,15 @@ typedef enum SculptFlags { #define SK_RETARGET_ROLL_VIEW 1 #define SK_RETARGET_ROLL_JOINT 2 +/* UnitSettings */ + +/* UnitSettings->system */ +#define USER_UNIT_NONE 0 +#define USER_UNIT_METRIC 1 +#define USER_UNIT_IMPERIAL 2 +/* UnitSettings->flag */ +#define USER_UNIT_OPT_SPLIT 1 + #ifdef __cplusplus } diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 39e72c34adf..6d455d20f59 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -147,7 +147,7 @@ typedef struct Sequence { Strip *strip; - struct Ipo *ipo; + struct Ipo *ipo; // xxx depreceated... old animation system struct Scene *scene; struct anim *anim; float facf0, facf1; @@ -160,7 +160,7 @@ typedef struct Sequence { ListBase seqbase; /* list of strips for metastrips */ struct bSound *sound; /* the linked "bSound" object */ - struct hdaudio *hdaudio; /* external hdaudio object */ + struct SoundHandle *sound_handle; float level, pan; /* level in dB (0=full), pan -1..1 */ int scenenr; /* for scene selection */ float strobe; @@ -281,7 +281,7 @@ typedef struct SpeedControlVars { #define SEQ_MOVIE 3 #define SEQ_RAM_SOUND 4 #define SEQ_HD_SOUND 5 -#define SEQ_MOVIE_AND_HD_SOUND 6 /* helper for add_sequence */ +#define SEQ_SOUND 4 #define SEQ_EFFECT 8 #define SEQ_CROSS 8 diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h index 0c93b5eb56e..c7f49d3ddd2 100644 --- a/source/blender/makesdna/DNA_smoke_types.h +++ b/source/blender/makesdna/DNA_smoke_types.h @@ -30,7 +30,10 @@ #define DNA_SMOKE_TYPES_H /* flags */ -#define MOD_SMOKE_HIGHRES (1<<1) +#define MOD_SMOKE_HIGHRES (1<<1) /* compute high resolution */ +#define MOD_SMOKE_DISSOLVE (1<<2) /* let smoke dissolve */ +#define MOD_SMOKE_DISSOLVE_LOG (1<<3) /* using 1/x for dissolve */ + /* noise */ #define MOD_SMOKE_NOISEWAVE (1<<0) #define MOD_SMOKE_NOISEFFT (1<<1) @@ -44,6 +47,7 @@ #define MOD_SMOKE_VIEW_CHANGETOBIG (1<<5) #define MOD_SMOKE_VIEW_REDRAWNICE (1<<6) #define MOD_SMOKE_VIEW_REDRAWALL (1<<7) +#define MOD_SMOKE_VIEW_USEBIG (1<<8) typedef struct SmokeDomainSettings { struct SmokeModifierData *smd; /* for fast RNA access */ @@ -74,11 +78,10 @@ typedef struct SmokeDomainSettings { int viewsettings; int max_textures; short noise; /* noise type: wave, curl, anisotropic */ - short pad2; - int prev_res[3]; - int prev_maxres; - int render_res[3]; - int render_maxres; + short diss_percent; + int diss_speed;/* in frames */ + float strength; + struct WTURBULENCE *wt; // WTURBULENCE object, if active } SmokeDomainSettings; @@ -101,9 +104,17 @@ typedef struct SmokeFlowSettings { int pad; } SmokeFlowSettings; +/* + struct BVHTreeFromMesh *bvh; + float mat[4][4]; + float mat_old[4][4]; + */ + /* collision objects (filled with smoke) */ typedef struct SmokeCollSettings { struct SmokeModifierData *smd; /* for fast RNA access */ + struct BVHTree *bvhtree; /* bounding volume hierarchy for this cloth object */ + struct DerivedMesh *dm; float *points; float *points_old; float *vel; diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h index 5dedd20e1e4..5f6ebf60865 100644 --- a/source/blender/makesdna/DNA_sound_types.h +++ b/source/blender/makesdna/DNA_sound_types.h @@ -37,45 +37,46 @@ /* stupid... could easily be solved */ #include "DNA_view2d_types.h" -/* extern int noaudio; * defined in sound.c . also not very nice */ -/* extern ListBase *samples; don't do this in DNA, but in BKE_... instead */ - -struct bSample; struct Ipo; struct PackedFile; struct SpaceLink; -/* should not be here! */ -# -# -typedef struct bSample { - ID id; - void *data; - void *snd_sample; - short type, bits; - short channels; - int len, rate; -// int buffer; - int alindex; - char fakedata[16]; - int flags; - char name[160]; - struct PackedFile * packedfile; - short us; -} bSample; - +// runtime only - no saving +typedef struct SoundHandle { + struct SoundHandle *next, *prev; + struct bSound *source; + void *handle; + int state; + int startframe; + int endframe; + int frameskip; + int mute; + int changed; + float volume; + float pad; +} SoundHandle; +typedef struct Sound3D +{ + float min_gain; + float max_gain; + float reference_distance; + float max_distance; + float rolloff_factor; + float cone_inner_angle; + float cone_outer_angle; + float cone_outer_gain; +} Sound3D; typedef struct bSound { ID id; char name[160]; - struct bSample *sample; - void *stream; + void *stream; // AUD_XXX deprecated struct PackedFile *packedfile; - struct PackedFile *newpackedfile; - void *snd_sound; - struct Ipo *ipo; - float volume, panning; + struct PackedFile *newpackedfile; // AUD_XXX deprecated + void *snd_sound; // AUD_XXX used for AUD_Sound now + struct Ipo *ipo; // AUD_XXX deprecated + float volume, panning; // AUD_XXX deprecated /** * Sets the rollofffactor. The rollofffactor is a per-Source parameter * the application can use to increase or decrease the range of a source @@ -84,47 +85,42 @@ typedef struct bSound { * value of 0, which indicates that the application does not wish any * distance attenuation on the respective Source. */ - float attenuation; - float pitch; + float attenuation; // AUD_XXX deprecated + float pitch; // AUD_XXX deprecated /** * min_gain indicates the minimal gain which is always guaranteed for this sound */ - float min_gain; + float min_gain; // AUD_XXX deprecated /** * max_gain indicates the maximal gain which is always guaranteed for this sound */ - float max_gain; + float max_gain; // AUD_XXX deprecated /** * Sets the referencedistance at which the listener will experience gain. */ - float distance; - int flags; - int streamlen; - char channels; - char highprio; - char pad[10]; + float distance; // AUD_XXX deprecated + int flags; // AUD_XXX deprecated + int streamlen; // AUD_XXX deprecated + char channels; // AUD_XXX deprecated + char highprio; // AUD_XXX deprecated + char pad[10]; // AUD_XXX deprecated + + // AUD_XXX NEW + int type; + int changed; + struct bSound *child_sound; + void *cache; + + // SOUND_TYPE_LIMITER + float start, end; } bSound; -typedef struct bSoundListener { - ID id; - /** - * Overall gain - */ - float gain; - /** - * Sets a scaling to exaggerate or deemphasize the Doppler (pitch) shift - * resulting from the calculation. - */ - float dopplerfactor; - /** - * Sets the value of the propagation speed relative to which the source - * velocities are interpreted. - */ - float dopplervelocity; - short numsoundsblender; - short numsoundsgameengine; - -} bSoundListener; +typedef enum eSound_Type { + SOUND_TYPE_INVALID = -1, + SOUND_TYPE_FILE = 0, + SOUND_TYPE_BUFFER, + SOUND_TYPE_LIMITER +} eSound_Type; /* spacesound->flag */ #define SND_DRAWFRAMES 1 @@ -147,20 +143,6 @@ typedef struct SpaceSound { } SpaceSound; -enum SAMPLE_FileTypes { - SAMPLE_INVALID = -1, // must be negative - SAMPLE_UNKNOWN = 0, - SAMPLE_RAW, - SAMPLE_WAV, - SAMPLE_MP2, - SAMPLE_MP3, - SAMPLE_OGG_VORBIS, - SAMPLE_WMA, - SAMPLE_ASF, - SAMPLE_AIFF -}; - - #define SOUND_CHANNELS_STEREO 0 #define SOUND_CHANNELS_LEFT 1 #define SOUND_CHANNELS_RIGHT 2 @@ -173,8 +155,6 @@ enum SAMPLE_FileTypes { #define SOUND_FLAGS_PRIORITY (1 << 5) #define SOUND_FLAGS_SEQUENCE (1 << 6) -#define SAMPLE_NEEDS_SAVE (1 << 0) - /* to DNA_sound_types.h*/ #endif diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index d24d9af4177..37f28cfeaa6 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -508,6 +508,13 @@ typedef struct SpaceConsole { } SpaceConsole; +typedef struct SpaceUserPref { + SpaceLink *next, *prev; + ListBase regionbase; /* storage of regions for inactive spaces */ + int spacetype; + + int pad; +} SpaceUserPref; /* view3d Now in DNA_view3d_types.h */ @@ -821,7 +828,7 @@ enum { #define TIME_ALL_3D_WIN 2 #define TIME_ALL_ANIM_WIN 4 #define TIME_ALL_BUTS_WIN 8 -#define TIME_WITH_SEQ_AUDIO 16 +#define TIME_WITH_SEQ_AUDIO 16 // deprecated #define TIME_SEQ 32 #define TIME_ALL_IMAGE_WIN 64 #define TIME_CONTINUE_PHYSICS 128 @@ -861,7 +868,8 @@ enum { SPACE_NODE, SPACE_LOGIC, SPACE_CONSOLE, - SPACEICONMAX = SPACE_CONSOLE + SPACE_USERPREF, + SPACEICONMAX = SPACE_USERPREF }; #endif diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 7325181ee14..0054e885a21 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -53,17 +53,17 @@ typedef struct MTex { char uvname[32]; char projx, projy, projz, mapping; - float ofs[3], size[3]; + float ofs[3], size[3], rot; short texflag, colormodel, pmapto, pmaptoneg; - short normapspace, which_output, pad[2]; + short normapspace, which_output; + char brush_map_mode, pad[7]; float r, g, b, k; float def_var, rt; float colfac, norfac, varfac; float dispfac; float warpfac; - } MTex; #ifndef DNA_USHORT_FIX @@ -143,7 +143,11 @@ typedef struct Tex { float dist_amount, ns_outscale; /* newnoise: voronoi nearest neighbour weights, minkovsky exponent, distance metric & color type */ - float vn_w1, vn_w2, vn_w3, vn_w4, vn_mexp; + float vn_w1; + float vn_w2; + float vn_w3; + float vn_w4; + float vn_mexp; short vn_distm, vn_coltype; short noisedepth, noisetype; @@ -392,6 +396,11 @@ typedef struct TexMapping { #define MTEX_BLEND_COLOR 13 #define MTEX_NUM_BLENDTYPES 14 +/* brush_map_mode */ +#define MTEX_MAP_MODE_FIXED 0 +#define MTEX_MAP_MODE_TILED 1 +#define MTEX_MAP_MODE_3D 2 + /* **************** EnvMap ********************* */ /* type */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index f61b4b2904d..c2314e1e3a2 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -260,6 +260,7 @@ typedef struct bTheme { ThemeSpace ttime; ThemeSpace tnode; ThemeSpace tlogic; + ThemeSpace tuserpref; /* 20 sets of bone colors for this theme */ ThemeWireColor tarm[20]; @@ -293,6 +294,11 @@ typedef struct UserDef { short userpref, viewzoom; int mixbufsize; + int audiodevice; + int audiorate; + int audioformat; + int audiochannels; + int scrollback; /* console scrollback limit */ int dpi; /* range 48-128? */ short encoding; @@ -411,7 +417,6 @@ extern UserDef U; /* from blenkernel blender.c */ /* toolsettings->autokey_flag */ #define ANIMRECORD_FLAG_WITHNLA (1<<10) - /* transopts */ #define USER_TR_TOOLTIPS (1 << 0) #define USER_TR_BUTTONS (1 << 1) diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index b6a2b4c0544..7d03bbec1ee 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -54,6 +54,7 @@ struct StructRNA; struct PointerRNA; struct ReportList; struct Report; +struct uiLayout; #define OP_MAX_TYPENAME 64 #define KMAP_MAX_NAME 64 @@ -208,8 +209,8 @@ typedef struct wmOperatorType { * that the operator might still fail to execute even if this return true */ int (*poll)(struct bContext *); - /* panel for redo and repeat */ - void *(*uiBlock)(struct wmOperator *); + /* optional panel for redo and repeat, autogenerated if not set */ + void (*ui)(struct bContext *, struct PointerRNA *, struct uiLayout *); /* rna for properties */ struct StructRNA *srna; diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h index 200ff6d9324..64ff23dd1a8 100644 --- a/source/blender/makesdna/DNA_world_types.h +++ b/source/blender/makesdna/DNA_world_types.h @@ -71,12 +71,12 @@ typedef struct World { /** * Gravitation constant for the game world */ - float gravity; // moved to scene->gamedata in 2.5 + float gravity; // XXX moved to scene->gamedata in 2.5 /** * Radius of the activity bubble, in Manhattan length. Objects * outside the box are activity-culled. */ - float activityBoxRadius; // moved to scene->gamedata in 2.5 + float activityBoxRadius; // XXX moved to scene->gamedata in 2.5 short skytype; /** @@ -89,9 +89,9 @@ typedef struct World { * bit 5: (gameengine) : enable Bullet DBVT tree for view frustrum culling */ short mode; // partially moved to scene->gamedata in 2.5 - short occlusionRes; /* resolution of occlusion Z buffer in pixel */ // moved to scene->gamedata in 2.5 - short physicsEngine; /* here it's aligned */ // moved to scene->gamedata in 2.5 - short ticrate, maxlogicstep, physubstep, maxphystep; // moved to scene->gamedata in 2.5 + short occlusionRes; /* resolution of occlusion Z buffer in pixel */ // XXX moved to scene->gamedata in 2.5 + short physicsEngine; /* here it's aligned */ // XXX moved to scene->gamedata in 2.5 + short ticrate, maxlogicstep, physubstep, maxphystep; // XXX moved to scene->gamedata in 2.5 float misi, miststa, mistdist, misthi; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 1b3175d7f55..e08bc734242 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -252,6 +252,7 @@ extern StructRNA RNA_MarbleTexture; extern StructRNA RNA_MaskModifier; extern StructRNA RNA_Material; extern StructRNA RNA_MaterialHalo; +extern StructRNA RNA_MaterialPhysics; extern StructRNA RNA_MaterialRaytraceMirror; extern StructRNA RNA_MaterialRaytraceTransparency; extern StructRNA RNA_MaterialSlot; @@ -304,8 +305,11 @@ extern StructRNA RNA_OperatorStrokeElement; extern StructRNA RNA_OrController; extern StructRNA RNA_OutflowFluidSettings; extern StructRNA RNA_PackedFile; +extern StructRNA RNA_Paint; extern StructRNA RNA_Panel; extern StructRNA RNA_Particle; +extern StructRNA RNA_ParticleBrush; +extern StructRNA RNA_ParticleEdit; extern StructRNA RNA_ParticleFluidSettings; extern StructRNA RNA_ParticleHairKey; extern StructRNA RNA_ParticleInstanceModifier; @@ -328,6 +332,7 @@ extern StructRNA RNA_RadarSensor; extern StructRNA RNA_RandomSensor; extern StructRNA RNA_RaySensor; extern StructRNA RNA_Region; +extern StructRNA RNA_RenderEngine; extern StructRNA RNA_RenderLayer; extern StructRNA RNA_RenderPass; extern StructRNA RNA_RenderResult; @@ -378,6 +383,9 @@ extern StructRNA RNA_ShapeKeyPoint; extern StructRNA RNA_ShrinkwrapConstraint; extern StructRNA RNA_ShrinkwrapModifier; extern StructRNA RNA_SimpleDeformModifier; +extern StructRNA RNA_SmokeCollSettings; +extern StructRNA RNA_SmokeDomainSettings; +extern StructRNA RNA_SmokeFlowSettings; extern StructRNA RNA_SmokeModifier; extern StructRNA RNA_SmoothModifier; extern StructRNA RNA_SoftBodyModifier; @@ -386,17 +394,22 @@ extern StructRNA RNA_Sound; extern StructRNA RNA_SoundSequence; extern StructRNA RNA_Space; extern StructRNA RNA_Space3DView; -extern StructRNA RNA_SpaceButtonsWindow; extern StructRNA RNA_SpaceConsole; extern StructRNA RNA_SpaceDopeSheetEditor; extern StructRNA RNA_SpaceFileBrowser; extern StructRNA RNA_SpaceGraphEditor; extern StructRNA RNA_SpaceImageEditor; +extern StructRNA RNA_SpaceInfo; +extern StructRNA RNA_SpaceLogicEditor; extern StructRNA RNA_SpaceNLA; +extern StructRNA RNA_SpaceNodeEditor; extern StructRNA RNA_SpaceOutliner; +extern StructRNA RNA_SpaceProperties; extern StructRNA RNA_SpaceSequenceEditor; extern StructRNA RNA_SpaceTextEditor; +extern StructRNA RNA_SpaceTimeline; extern StructRNA RNA_SpaceUVEditor; +extern StructRNA RNA_SpaceUserPreferences; extern StructRNA RNA_SpeedControlSequence; extern StructRNA RNA_SpotLamp; extern StructRNA RNA_StretchToConstraint; @@ -442,16 +455,17 @@ extern StructRNA RNA_TextureSlot; extern StructRNA RNA_Theme; extern StructRNA RNA_ThemeAudioWindow; extern StructRNA RNA_ThemeBoneColorSet; -extern StructRNA RNA_ThemeButtonsWindow; extern StructRNA RNA_ThemeDopeSheet; extern StructRNA RNA_ThemeFileBrowser; extern StructRNA RNA_ThemeFontStyle; extern StructRNA RNA_ThemeGraphEditor; extern StructRNA RNA_ThemeImageEditor; +extern StructRNA RNA_ThemeInfo; extern StructRNA RNA_ThemeLogicEditor; extern StructRNA RNA_ThemeNLAEditor; extern StructRNA RNA_ThemeNodeEditor; extern StructRNA RNA_ThemeOutliner; +extern StructRNA RNA_ThemeProperties; extern StructRNA RNA_ThemeSequenceEditor; extern StructRNA RNA_ThemeStyle; extern StructRNA RNA_ThemeTextEditor; @@ -470,19 +484,19 @@ extern StructRNA RNA_TransformSequence; extern StructRNA RNA_UILayout; extern StructRNA RNA_UIListItem; extern StructRNA RNA_UVProjectModifier; +extern StructRNA RNA_UnitSettings; extern StructRNA RNA_UnknownType; extern StructRNA RNA_UserPreferences; -extern StructRNA RNA_UserPreferencesAutosave; extern StructRNA RNA_UserPreferencesEdit; extern StructRNA RNA_UserPreferencesFilePaths; extern StructRNA RNA_UserPreferencesLanguage; extern StructRNA RNA_UserPreferencesSystem; extern StructRNA RNA_UserPreferencesView; extern StructRNA RNA_UserSolidLight; -extern StructRNA RNA_VertexPaint; extern StructRNA RNA_VectorFont; extern StructRNA RNA_VertexGroup; extern StructRNA RNA_VertexGroupElement; +extern StructRNA RNA_VertexPaint; extern StructRNA RNA_VoronoiTexture; extern StructRNA RNA_WaveModifier; extern StructRNA RNA_Window; @@ -559,9 +573,11 @@ char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen); const char *RNA_property_identifier(PropertyRNA *prop); PropertyType RNA_property_type(PropertyRNA *prop); PropertySubType RNA_property_subtype(PropertyRNA *prop); +PropertyUnit RNA_property_unit(PropertyRNA *prop); int RNA_property_flag(PropertyRNA *prop); int RNA_property_array_length(PropertyRNA *prop); +char RNA_property_array_item_char(PropertyRNA *prop, int index); int RNA_property_string_maxlength(PropertyRNA *prop); @@ -645,7 +661,7 @@ RawPropertyType RNA_property_raw_type(PropertyRNA *prop); void RNA_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop); void RNA_property_pointer_remove(PointerRNA *ptr, PropertyRNA *prop); void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr); -void RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key); +int RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key); void RNA_property_collection_clear(PointerRNA *ptr, PropertyRNA *prop); /* Path @@ -763,7 +779,7 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name); int RNA_property_is_set(PointerRNA *ptr, const char *name); /* python compatible string representation of this property, (must be freed!) */ -char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop); +char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop); char *RNA_pointer_as_string(PointerRNA *ptr); /* Function */ diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index ae9eaba8646..33f5d7137b8 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -63,6 +63,7 @@ void RNA_def_struct_path_func(StructRNA *srna, const char *path); void RNA_def_struct_identifier(StructRNA *srna, const char *identifier); void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description); void RNA_def_struct_ui_icon(StructRNA *srna, int icon); +void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext); void RNA_struct_free(BlenderRNA *brna, StructRNA *srna); /* Compact Property Definitions */ diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 78e65e8fc06..46d8c50caa6 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -29,6 +29,8 @@ /* Types */ +extern EnumPropertyItem object_mode_items[]; + extern EnumPropertyItem prop_mode_items[]; extern EnumPropertyItem space_type_items[]; extern EnumPropertyItem region_type_items[]; @@ -47,6 +49,8 @@ extern EnumPropertyItem nla_mode_blend_items[]; extern EnumPropertyItem event_value_items[]; extern EnumPropertyItem event_type_items[]; +extern EnumPropertyItem brush_sculpt_tool_items[]; + #endif /* RNA_ENUM_TYPES */ diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 3355e684358..51c3645fb03 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -66,17 +66,51 @@ typedef enum PropertyType { PROP_COLLECTION = 6 } PropertyType; +/* also update rna_property_subtype_unit when you change this */ +typedef enum PropertyUnit { + PROP_UNIT_NONE = (0<<16), + PROP_UNIT_LENGTH = (1<<16), /* m */ + PROP_UNIT_AREA = (2<<16), /* m^2 */ + PROP_UNIT_VOLUME = (3<<16), /* m^3 */ + PROP_UNIT_MASS = (4<<16), /* kg */ + PROP_UNIT_ROTATION = (5<<16), /* rad */ + PROP_UNIT_TIME = (6<<16), /* frame */ + PROP_UNIT_VELOCITY = (7<<16), /* m/s */ + PROP_UNIT_ACCELERATION = (8<<16) /* m/(s^2) */ +} PropertyUnit; + +#define RNA_SUBTYPE_UNIT(subtype) (subtype & 0x00FF0000) +#define RNA_SUBTYPE_UNIT_VALUE(subtype) (subtype>>16) + +/* also update rna_property_subtypename when you change this */ typedef enum PropertySubType { PROP_NONE = 0, - PROP_UNSIGNED = 1, - PROP_FILEPATH = 2, - PROP_DIRPATH = 3, - PROP_COLOR = 4, - PROP_VECTOR = 5, - PROP_MATRIX = 6, - PROP_ROTATION = 7, - PROP_NEVER_NULL = 8, - PROP_PERCENTAGE = 9 + + /* strings */ + PROP_FILEPATH = 1, + PROP_DIRPATH = 2, + + /* numbers */ + PROP_UNSIGNED = 13, + PROP_PERCENTAGE = 14, + PROP_ANGLE = 15|PROP_UNIT_ROTATION, + PROP_TIME = 16|PROP_UNIT_TIME, + PROP_DISTANCE = 17|PROP_UNIT_LENGTH, + + /* number arrays */ + PROP_COLOR = 20, + PROP_TRANSLATION = 21|PROP_UNIT_LENGTH, + PROP_DIRECTION = 22, + PROP_VELOCITY = 23|PROP_UNIT_VELOCITY, + PROP_ACCELERATION = 24|PROP_UNIT_ACCELERATION, + PROP_MATRIX = 25, + PROP_EULER = 26|PROP_UNIT_ROTATION, + PROP_QUATERNION = 27, + PROP_XYZ = 28, + PROP_RGB = 29, + + /* pointers */ + PROP_NEVER_NULL = 30, } PropertySubType; typedef enum PropertyFlag { @@ -232,7 +266,7 @@ typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_ typedef int (*StructCallbackFunc)(struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list); typedef void (*StructFreeFunc)(void *data); typedef struct StructRNA *(*StructRegisterFunc)(const struct bContext *C, struct ReportList *reports, void *data, - StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); + const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); typedef void (*StructUnregisterFunc)(const struct bContext *C, struct StructRNA *type); typedef struct StructRNA StructRNA; diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 2aa0fcc79ff..152f4031b91 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -42,6 +42,10 @@ SET(SRC INCLUDE_DIRECTORIES(../../../../intern/guardedalloc .. ../../makesdna ../../blenkernel ../../blenlib ../../windowmanager ../../editors/include ../../imbuf ../../render/extern/include .) FILE(GLOB INC_FILES ../*.h ../../makesdna/*.h) +IF(WITH_GAMEENGINE) + ADD_DEFINITIONS(-DGAMEBLENDER) +ENDIF(WITH_GAMEENGINE) + IF(WITH_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) @@ -67,6 +71,10 @@ IF(NOT WITH_ELBEEM) ADD_DEFINITIONS(-DDISABLE_ELBEEM) ENDIF(NOT WITH_ELBEEM) +IF(WITH_FFTW3) + ADD_DEFINITIONS(-DFFTW3=1) +ENDIF(WITH_FFTW3) + # Build makesrna executable ADD_EXECUTABLE(makesrna ${SRC} ${INC_FILES}) TARGET_LINK_LIBRARIES(makesrna bf_dna) diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index 6c8038bd509..1a3687af51e 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -58,6 +58,9 @@ if env['WITH_BF_LCMS']: if env['WITH_BF_GAMEENGINE']: defs.append('GAMEBLENDER=1') + +if env['WITH_BF_FFTW3']: + defs.append('FFTW3=1') makesrna_tool.Append(CPPDEFINES=defs) diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index b467c2d20c2..baf820e7249 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1381,15 +1381,48 @@ static const char *rna_property_subtypename(PropertyType type) { switch(type) { case PROP_NONE: return "PROP_NONE"; - case PROP_UNSIGNED: return "PROP_UNSIGNED"; case PROP_FILEPATH: return "PROP_FILEPATH"; case PROP_DIRPATH: return "PROP_DIRPATH"; - case PROP_COLOR: return "PROP_COLOR"; - case PROP_VECTOR: return "PROP_VECTOR"; - case PROP_MATRIX: return "PROP_MATRIX"; - case PROP_ROTATION: return "PROP_ROTATION"; - case PROP_NEVER_NULL: return "PROP_NEVER_NULL"; + case PROP_UNSIGNED: return "PROP_UNSIGNED"; case PROP_PERCENTAGE: return "PROP_PERCENTAGE"; + case PROP_ANGLE: return "PROP_ANGLE"; + case PROP_TIME: return "PROP_TIME"; + case PROP_DISTANCE: return "PROP_DISTANCE"; + case PROP_COLOR: return "PROP_COLOR"; + case PROP_TRANSLATION: return "PROP_TRANSLATION"; + case PROP_DIRECTION: return "PROP_DIRECTION"; + case PROP_MATRIX: return "PROP_MATRIX"; + case PROP_EULER: return "PROP_EULER"; + case PROP_QUATERNION: return "PROP_QUATERNION"; + case PROP_VELOCITY: return "PROP_VELOCITY"; + case PROP_ACCELERATION: return "PROP_ACCELERATION"; + case PROP_XYZ: return "PROP_XYZ"; + case PROP_RGB: return "PROP_RGB"; + case PROP_NEVER_NULL: return "PROP_NEVER_NULL"; + default: { + /* incase we dont have a type preset that includes the subtype */ + if(RNA_SUBTYPE_UNIT(type)) { + return rna_property_subtypename(type & ~RNA_SUBTYPE_UNIT(type)); + } + else { + return "PROP_SUBTYPE_UNKNOWN"; + } + } + } +} + +static const char *rna_property_subtype_unit(PropertyType type) +{ + switch(RNA_SUBTYPE_UNIT(type)) { + case PROP_UNIT_NONE: return "PROP_UNIT_NONE"; + case PROP_UNIT_LENGTH: return "PROP_UNIT_LENGTH"; + case PROP_UNIT_AREA: return "PROP_UNIT_AREA"; + case PROP_UNIT_VOLUME: return "PROP_UNIT_VOLUME"; + case PROP_UNIT_MASS: return "PROP_UNIT_MASS"; + case PROP_UNIT_ROTATION: return "PROP_UNIT_ROTATION"; + case PROP_UNIT_TIME: return "PROP_UNIT_TIME"; + case PROP_UNIT_VELOCITY: return "PROP_UNIT_VELOCITY"; + case PROP_UNIT_ACCELERATION:return "PROP_UNIT_ACCELERATION"; default: return "PROP_UNKNOWN"; } } @@ -1702,7 +1735,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr rna_print_c_string(f, prop->name); fprintf(f, ",\n\t"); rna_print_c_string(f, prop->description); fprintf(f, ",\n\t"); fprintf(f, "%d,\n", prop->icon); - fprintf(f, "\t%s, %s, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), prop->arraylength); + fprintf(f, "\t%s, %s|%s, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), rna_property_subtype_unit(prop->subtype), prop->arraylength); fprintf(f, "\t%s, %d, %s,\n", rna_function_string(prop->update), prop->noteflag, rna_function_string(prop->editable)); if(prop->flag & PROP_RAW_ACCESS) rna_set_raw_offset(f, srna, prop); @@ -2212,7 +2245,7 @@ static void rna_generate_header_cpp(BlenderRNA *brna, FILE *f) fprintf(f, "#include \"RNA_blender.h\"\n"); fprintf(f, "#include \"RNA_types.h\"\n"); - fprintf(f, cpp_classes); + fprintf(f, "%s", cpp_classes); fprintf(f, "/**************** Declarations ****************/\n\n"); diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index cf3d59f78a0..f6e0a2468c4 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -152,6 +152,30 @@ IDProperty *rna_IDPropertyGroup_idproperties(PointerRNA *ptr, int create) return ptr->data; } +void rna_IDPropertyGroup_unregister(const bContext *C, StructRNA *type) +{ + RNA_struct_free(&BLENDER_RNA, type); +} + +StructRNA *rna_IDPropertyGroup_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +{ + PointerRNA dummyptr; + + /* create dummy pointer */ + RNA_pointer_create(NULL, &RNA_IDPropertyGroup, NULL, &dummyptr); + + /* validate the python class */ + if(validate(&dummyptr, data, NULL) != 0) + return NULL; + + return RNA_def_struct(&BLENDER_RNA, identifier, "IDPropertyGroup"); // XXX +} + +StructRNA* rna_IDPropertyGroup_refine(PointerRNA *ptr) +{ + return ptr->type; +} + #else static void rna_def_ID_properties(BlenderRNA *brna) @@ -210,6 +234,8 @@ static void rna_def_ID_properties(BlenderRNA *brna) srna= RNA_def_struct(brna, "IDPropertyGroup", NULL); RNA_def_struct_ui_text(srna, "ID Property Group", "Group of ID properties."); RNA_def_struct_idproperties_func(srna, "rna_IDPropertyGroup_idproperties"); + RNA_def_struct_register_funcs(srna, "rna_IDPropertyGroup_register", "rna_IDPropertyGroup_unregister"); + RNA_def_struct_refine_func(srna, "rna_IDPropertyGroup_refine"); } static void rna_def_ID(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index c141efc7ac6..7b8edb6c341 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -539,6 +539,11 @@ PropertySubType RNA_property_subtype(PropertyRNA *prop) return rna_ensure_property(prop)->subtype; } +PropertyUnit RNA_property_unit(PropertyRNA *prop) +{ + return RNA_SUBTYPE_UNIT(rna_ensure_property(prop)->subtype); +} + int RNA_property_flag(PropertyRNA *prop) { return rna_ensure_property(prop)->flag; @@ -549,6 +554,24 @@ int RNA_property_array_length(PropertyRNA *prop) return rna_ensure_property_array_length(prop); } +char RNA_property_array_item_char(PropertyRNA *prop, int index) +{ + const char *vectoritem= "XYZW"; + const char *quatitem= "WXYZ"; + const char *coloritem= "RGBA"; + PropertySubType subtype= rna_ensure_property(prop)->subtype; + + /* get string to use for array index */ + if ((index < 4) && (subtype == PROP_QUATERNION)) + return quatitem[index]; + else if((index < 4) && ELEM6(subtype, PROP_TRANSLATION, PROP_DIRECTION, PROP_XYZ, PROP_EULER, PROP_VELOCITY, PROP_ACCELERATION)) + return vectoritem[index]; + else if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_RGB)) + return coloritem[index]; + else + return '\0'; +} + void RNA_property_int_range(PointerRNA *ptr, PropertyRNA *prop, int *hardmin, int *hardmax) { IntPropertyRNA *iprop= (IntPropertyRNA*)rna_ensure_property(prop); @@ -1236,8 +1259,15 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop) else if(pprop->get) { return pprop->get(ptr); } + else if(prop->flag & PROP_IDPROPERTY) { + /* XXX temporary hack to add it automatically, reading should + never do any write ops, to ensure thread safety etc .. */ + RNA_property_pointer_add(ptr, prop); + return RNA_property_pointer_get(ptr, prop); + } else { PointerRNA result; + memset(&result, 0, sizeof(result)); return result; } @@ -1375,7 +1405,7 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop) void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr) { IDProperty *idprop; - //CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; + CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; if((idprop=rna_idproperty_check(&prop, ptr))) { IDPropertyTemplate val = {0}; @@ -1401,7 +1431,6 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA MEM_freeN(item); } } -#if 0 else if(cprop->add){ if(!(cprop->add->flag & FUNC_USE_CONTEXT)) { /* XXX check for this somewhere else */ ParameterList params; @@ -1410,9 +1439,8 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA RNA_parameter_list_free(¶ms); } } -#endif - else - printf("RNA_property_collection_add %s.%s: not implemented for this property.\n", ptr->type->identifier, prop->identifier); + /*else + printf("RNA_property_collection_add %s.%s: not implemented for this property.\n", ptr->type->identifier, prop->identifier);*/ if(r_ptr) { if(idprop) { @@ -1427,10 +1455,10 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA } } -void RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) +int RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) { IDProperty *idprop; - //CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; + CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; if((idprop=rna_idproperty_check(&prop, ptr))) { IDProperty tmp, *array; @@ -1449,20 +1477,25 @@ void RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) IDP_ResizeIDPArray(idprop, len-1); } + + return 1; } - else if(prop->flag & PROP_IDPROPERTY); -#if 0 + else if(prop->flag & PROP_IDPROPERTY) + return 1; else if(cprop->remove){ if(!(cprop->remove->flag & FUNC_USE_CONTEXT)) { /* XXX check for this somewhere else */ ParameterList params; - RNA_parameter_list_create(&ptr, cprop->remove); + RNA_parameter_list_create(¶ms, ptr, cprop->remove); RNA_function_call(NULL, NULL, ptr, cprop->remove, ¶ms); RNA_parameter_list_free(¶ms); } + + return 0; } -#endif - else - printf("RNA_property_collection_remove %s.%s: only supported for id properties.\n", ptr->type->identifier, prop->identifier); + /*else + printf("RNA_property_collection_remove %s.%s: only supported for id properties.\n", ptr->type->identifier, prop->identifier);*/ + + return 0; } void RNA_property_collection_clear(PointerRNA *ptr, PropertyRNA *prop) @@ -1966,9 +1999,10 @@ void rna_iterator_array_end(CollectionPropertyIterator *iter) { ArrayIterator *internal= iter->internal; - if(internal->free_ptr) + if(internal->free_ptr) { MEM_freeN(internal->free_ptr); - + internal->free_ptr= NULL; + } MEM_freeN(iter->internal); iter->internal= NULL; } @@ -2624,7 +2658,7 @@ char *RNA_pointer_as_string(PointerRNA *ptr) BLI_dynstr_append(dynstr, ", "); first_time= 0; - cstring = RNA_property_as_string(ptr, prop); + cstring = RNA_property_as_string(NULL, ptr, prop); BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring); MEM_freeN(cstring); } @@ -2638,7 +2672,7 @@ char *RNA_pointer_as_string(PointerRNA *ptr) return cstring; } -char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop) +char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop) { int type = RNA_property_type(prop); int len = RNA_property_array_length(prop); @@ -2707,7 +2741,7 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop) const char *identifier; int val = RNA_property_enum_get(ptr, prop); - if(RNA_property_enum_identifier(NULL, ptr, prop, val, &identifier)) { + if(RNA_property_enum_identifier(C, ptr, prop, val, &identifier)) { BLI_dynstr_appendf(dynstr, "'%s'", identifier); } else { @@ -2810,8 +2844,10 @@ const struct ListBase *RNA_function_defined_parameters(FunctionRNA *func) ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *ptr, FunctionRNA *func) { PropertyRNA *parm; - int tot= 0; + void *data; + int tot= 0, size; + /* allocate data */ for(parm= func->cont.properties.first; parm; parm= parm->next) tot+= rna_parameter_size(parm); @@ -2819,6 +2855,44 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *ptr, parms->func= func; parms->tot= tot; + /* set default values */ + data= parms->data; + + for(parm= func->cont.properties.first; parm; parm= parm->next) { + size= rna_parameter_size(parm); + + if(!(parm->flag & PROP_REQUIRED)) { + switch(parm->type) { + case PROP_BOOLEAN: + if(parm->arraylength) memcpy(data, &((BooleanPropertyRNA*)parm)->defaultarray, size); + else memcpy(data, &((BooleanPropertyRNA*)parm)->defaultvalue, size); + break; + case PROP_INT: + if(parm->arraylength) memcpy(data, &((IntPropertyRNA*)parm)->defaultarray, size); + else memcpy(data, &((IntPropertyRNA*)parm)->defaultvalue, size); + break; + case PROP_FLOAT: + if(parm->arraylength) memcpy(data, &((FloatPropertyRNA*)parm)->defaultarray, size); + else memcpy(data, &((FloatPropertyRNA*)parm)->defaultvalue, size); + break; + case PROP_ENUM: + memcpy(data, &((EnumPropertyRNA*)parm)->defaultvalue, size); + break; + case PROP_STRING: { + const char *defvalue= ((StringPropertyRNA*)parm)->defaultvalue; + if(defvalue && defvalue[0]) + memcpy(data, &defvalue, size); + break; + } + case PROP_POINTER: + case PROP_COLLECTION: + break; + } + } + + data= ((char*)data) + size; + } + return parms; } diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 3eb88e706e9..473e726db60 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -51,8 +51,7 @@ void RNA_def_actuator(BlenderRNA *brna) {ACT_SCENE, "SCENE", 0, "Scene", ""}, {ACT_RANDOM, "RANDOM", 0, "Random", ""}, {ACT_MESSAGE, "MESSAGE", 0, "Message", ""}, - {ACT_ACTION, "ACTION", 0, "Action", ""}, - {ACT_CD, "CD", 0, "CD", ""}, + {ACT_ACTION, "ACTION", 0, "Action", ""}, {ACT_GAME, "GAME", 0, "Game", ""}, {ACT_VISIBILITY, "VISIBILITY", 0, "Visibility", ""}, {ACT_2DFILTER, "FILTER_2D", 0, "2D Filter", ""}, diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 45a833e0b29..7bc09b052ee 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -481,22 +481,22 @@ static void rna_def_bone(BlenderRNA *brna) RNA_def_property_array(prop, 16); RNA_def_property_ui_text(prop, "Bone Armature-Relative Matrix", "4x4 bone matrix relative to armature."); - prop= RNA_def_property(srna, "tail", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "tail", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "tail"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Tail", "Location of tail end of the bone."); - prop= RNA_def_property(srna, "armature_tail", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "armature_tail", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "arm_tail"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Armature-Relative Tail", "Location of tail end of the bone relative to armature."); - prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "head"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Head", "Location of head end of the bone."); - prop= RNA_def_property(srna, "armature_head", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "armature_head", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "arm_head"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Armature-Relative Head", "Location of head end of the bone relative to armature."); @@ -526,13 +526,13 @@ static void rna_def_edit_bone(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Roll", "Bone rotation around head-tail axis."); RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); - prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "head"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Head", "Location of head end of the bone."); RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); - prop= RNA_def_property(srna, "tail", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "tail", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "tail"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Tail", "Location of tail end of the bone."); @@ -739,13 +739,13 @@ void rna_def_armature(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Ghosting Frame Step", "Frame step for Ghosts (not for 'On Keyframes' Onion-skining method)."); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - prop= RNA_def_property(srna, "ghost_start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "ghost_start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "ghostsf"); RNA_def_property_int_funcs(prop, NULL, "rna_Armature_ghost_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Ghosting Start Frame", "Starting frame of range of Ghosts to display (not for 'Around Current Frame' Onion-skinning method)."); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - prop= RNA_def_property(srna, "ghost_end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "ghost_end_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "ghostef"); RNA_def_property_int_funcs(prop, NULL, "rna_Armature_ghost_end_frame_set", NULL); RNA_def_property_ui_text(prop, "Ghosting End Frame", "End frame of range of Ghosts to display (not for 'Around Current Frame' Onion-skinning method)."); @@ -758,13 +758,13 @@ void rna_def_armature(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Paths Frame Step", "Number of frames between 'dots' on Bone Paths (when drawing)."); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - prop= RNA_def_property(srna, "path_start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "path_start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "pathsf"); RNA_def_property_int_funcs(prop, NULL, "rna_Armature_path_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Paths Calculation Start Frame", "Starting frame of range of frames to use for Bone Path calculations."); RNA_def_property_update(prop, 0, "rna_Armature_update_data"); - prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "pathef"); RNA_def_property_int_funcs(prop, NULL, "rna_Armature_path_end_frame_set", NULL); RNA_def_property_ui_text(prop, "Paths Calculation End Frame", "End frame of range of frames to use for Bone Path calculations."); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 2bb4333365b..03b5a44f52b 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -32,6 +32,17 @@ #include "DNA_brush_types.h" #include "DNA_texture_types.h" +EnumPropertyItem brush_sculpt_tool_items[] = { + {SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""}, + {SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", ""}, + {SCULPT_TOOL_INFLATE, "INFLATE", 0, "Inflate", ""}, + {SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", ""}, + {SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""}, + {SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""}, + {SCULPT_TOOL_CLAY, "CLAY", 0, "Clay", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME #include "MEM_guardedalloc.h" @@ -74,26 +85,13 @@ static void rna_Brush_active_texture_set(PointerRNA *ptr, PointerRNA value) } } -static float rna_Brush_rotation_get(PointerRNA *ptr) -{ - Brush *brush= (Brush*)ptr->data; - const float conv = 57.295779506; - return brush->rot * conv; -} - -static void rna_Brush_rotation_set(PointerRNA *ptr, float v) -{ - Brush *brush= (Brush*)ptr->data; - const float conv = 0.017453293; - brush->rot = v * conv; -} - #else void rna_def_brush(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem prop_blend_items[] = { {BRUSH_BLEND_MIX, "MIX", 0, "Mix", "Use mix blending mode while painting."}, {BRUSH_BLEND_ADD, "ADD", 0, "Add", "Use add blending mode while painting."}, @@ -104,22 +102,7 @@ void rna_def_brush(BlenderRNA *brna) {BRUSH_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting."}, {BRUSH_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting."}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem prop_texture_mode_items[] = { - {BRUSH_TEX_DRAG, "TEX_DRAG", 0, "Drag", ""}, - {BRUSH_TEX_TILE, "TEX_TILE", 0, "Tile", ""}, - {BRUSH_TEX_3D, "TEX_3D", 0, "3D", ""}, - {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem prop_sculpt_tool_items[] = { - {SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""}, - {SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""}, - {SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", ""}, - {SCULPT_TOOL_INFLATE, "INFLATE", 0, "Inflate", ""}, - {SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", ""}, - {SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""}, - {SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""}, - {SCULPT_TOOL_CLAY, "CLAY", 0, "Clay", ""}, - {0, NULL, 0, NULL, NULL}}; - + srna= RNA_def_struct(brna, "Brush", "ID"); RNA_def_struct_ui_text(srna, "Brush", "Brush datablock for storing brush settings for painting and sculpting."); RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA); @@ -129,13 +112,8 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_blend_items); RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode."); - prop= RNA_def_property(srna, "texture_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "tex_mode"); - RNA_def_property_enum_items(prop, prop_texture_mode_items); - RNA_def_property_ui_text(prop, "Texture Mode", ""); - prop= RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_sculpt_tool_items); + RNA_def_property_enum_items(prop, brush_sculpt_tool_items); RNA_def_property_ui_text(prop, "Sculpt Tool", ""); /* number values */ @@ -152,6 +130,14 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "spacing"); RNA_def_property_range(prop, 1.0f, 100.0f); RNA_def_property_ui_text(prop, "Spacing", "Spacing between brush stamps."); + + prop= RNA_def_property(srna, "smooth_stroke_radius", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 10, 200); + RNA_def_property_ui_text(prop, "Smooth Stroke Radius", "Minimum distance from last point before stroke continues."); + + prop= RNA_def_property(srna, "smooth_stroke_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.5, 0.99); + RNA_def_property_ui_text(prop, "Smooth Stroke Factor", "Higher values give a smoother stroke."); prop= RNA_def_property(srna, "rate", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rate"); @@ -167,12 +153,6 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Strength", "The amount of pressure on the brush."); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "rot"); - RNA_def_property_range(prop, 0, 360); - RNA_def_property_float_funcs(prop, "rna_Brush_rotation_get", "rna_Brush_rotation_set", NULL); - RNA_def_property_ui_text(prop, "Rotation", "Angle of the brush texture."); - /* flag */ prop= RNA_def_property(srna, "airbrush", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH); @@ -182,9 +162,9 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_TORUS); RNA_def_property_ui_text(prop, "Wrap", "Enable torus wrapping while painting."); - prop= RNA_def_property(srna, "opacity_pressure", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "strength_pressure", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ALPHA_PRESSURE); - RNA_def_property_ui_text(prop, "Opacity Pressure", "Enable tablet pressure sensitivity for opacity."); + RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength."); prop= RNA_def_property(srna, "size_pressure", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SIZE_PRESSURE); @@ -217,6 +197,10 @@ void rna_def_brush(BlenderRNA *brna) prop= RNA_def_property(srna, "smooth_stroke", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SMOOTH_STROKE); RNA_def_property_ui_text(prop, "Smooth Stroke", "Brush lags behind mouse and follows a smoother path."); + + prop= RNA_def_property(srna, "persistent", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_PERSISTENT); + RNA_def_property_ui_text(prop, "Persistent", "Sculpts on a persistent layer of the mesh."); /* not exposed in the interface yet prop= RNA_def_property(srna, "fixed_tex", PROP_BOOLEAN, PROP_NONE); @@ -241,7 +225,7 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Clone Opacity", "Opacity of clone image display."); - prop= RNA_def_property(srna, "clone_offset", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "clone_offset", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "clone.offset"); RNA_def_property_ui_text(prop, "Clone Offset", ""); RNA_def_property_ui_range(prop, -1.0f , 1.0f, 10.0f, 3); @@ -266,12 +250,12 @@ static void rna_def_operator_stroke_element(BlenderRNA *brna) srna= RNA_def_struct(brna, "OperatorStrokeElement", "IDPropertyGroup"); RNA_def_struct_ui_text(srna, "Operator Stroke Element", ""); - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ); RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Location", ""); - prop= RNA_def_property(srna, "mouse", PROP_INT, PROP_VECTOR); + prop= RNA_def_property(srna, "mouse", PROP_FLOAT, PROP_XYZ); RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_array(prop, 2); RNA_def_property_ui_text(prop, "Mouse", ""); diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index 11443ddfde1..9096bfc2844 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -218,7 +218,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mass Vertex Group", "Vertex Group for pinning of vertices."); RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_cloth_update"); - prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -100.0, 100.0); RNA_def_property_float_funcs(prop, "rna_ClothSettings_gravity_get", "rna_ClothSettings_gravity_set", NULL); diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index f4248d18db3..420add2622a 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -130,7 +130,7 @@ static void rna_def_curvemappoint(BlenderRNA *brna) /* not editable for now, need to have CurveMapping to do curvemapping_changed */ - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "x"); RNA_def_property_array(prop, 2); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index d08e59c11dc..a8dc0454cef 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -416,7 +416,7 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Pole Sub-Target", ""); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); - prop= RNA_def_property(srna, "pole_angle", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "pole_angle", PROP_FLOAT, PROP_ANGLE); // XXX - todo, convert to rad RNA_def_property_float_sdna(prop, NULL, "poleangle"); RNA_def_property_range(prop, 0.0, 180.f); RNA_def_property_ui_text(prop, "Pole Angle", "Pole rotation offset."); @@ -676,7 +676,7 @@ static void rna_def_constraint_minmax(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Rotation", "Use the target's rotation to determine floor."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Offset", "Offset of floor from object center."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); @@ -768,13 +768,13 @@ static void rna_def_constraint_action(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "start"); RNA_def_property_range(prop, MINAFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "Start Frame", "First frame of the Action to use."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "end"); RNA_def_property_range(prop, MINAFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "End Frame", "Last frame of the Action to use."); @@ -871,7 +871,7 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); - prop= RNA_def_property(srna, "offset", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "offset", PROP_INT, PROP_TIME); RNA_def_property_range(prop, -300000.0, 300000.f); RNA_def_property_ui_text(prop, "Offset", "Offset from the position corresponding to the time frame."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); @@ -938,7 +938,7 @@ static void rna_def_constraint_stretch_to(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Keep Axis", "Axis to maintain during stretch."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "original_length", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "original_length", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "orglength"); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Original Length", "Length at rest position."); @@ -983,37 +983,37 @@ static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Pivot Type", ""); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "pivot_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "pivot_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "pivX"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Pivot X", "Offset pivot on X."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "pivot_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "pivot_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "pivY"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Pivot Y", "Offset pivot on Y."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "pivot_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "pivot_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "pivZ"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Pivot Z", "Offset pivot on Z."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_ANGLE); // XXX - convert to radians RNA_def_property_float_sdna(prop, NULL, "axX"); RNA_def_property_range(prop, -360.0, 360.f); RNA_def_property_ui_text(prop, "Axis X", "Rotate pivot on X axis in degrees."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_ANGLE); // XXX - convert to radians RNA_def_property_float_sdna(prop, NULL, "axY"); RNA_def_property_range(prop, -360.0, 360.f); RNA_def_property_ui_text(prop, "Axis Y", "Rotate pivot on Y axis in degrees."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_ANGLE); // XXX - convert to radians RNA_def_property_float_sdna(prop, NULL, "axZ"); RNA_def_property_range(prop, -360.0, 360.f); RNA_def_property_ui_text(prop, "Axis Z", "Rotate pivot on Z axis in degrees."); @@ -1135,73 +1135,73 @@ static void rna_def_constraint_transform(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Extrapolate Motion", "Extrapolate ranges."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_min_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_min_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_min[0]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Minimum X", "Bottom range of X axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_min_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_min_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_min[1]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Minimum Y", "Bottom range of Y axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_min_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_min_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_min[2]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Minimum Z", "Bottom range of Z axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_max_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_max_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_max[0]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Maximum X", "Top range of X axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_max_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_max_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_max[1]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Maximum Y", "Top range of Y axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_max_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_max_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_max[2]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Maximum Z", "Top range of Z axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_min_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_min_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_min[0]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Minimum X", "Bottom range of X axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_min_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_min_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_min[1]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Minimum Y", "Bottom range of Y axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_min_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_min_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_min[2]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Minimum Z", "Bottom range of Z axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_max_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_max_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_max[0]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Maximum X", "Top range of X axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_max_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_max_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_max[1]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Maximum Y", "Top range of Y axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_max_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_max_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_max[2]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion."); @@ -1247,37 +1247,37 @@ static void rna_def_constraint_location_limit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Maximum Z", "Use the maximum Z value."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "xmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "ymin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "zmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "xmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "ymax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "zmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow."); @@ -1313,37 +1313,37 @@ static void rna_def_constraint_rotation_limit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Limit Z", "Use the minimum Z value."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "xmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "ymin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "zmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "xmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "ymax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "zmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow."); @@ -1462,7 +1462,7 @@ static void rna_def_constraint_distance_limit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Sub-Target", ""); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); - prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist"); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Distance", "Radius of limiting sphere."); @@ -1502,7 +1502,7 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shrinkwrap Type", "Selects type of shrinkwrap algorithm for target position"); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist"); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Distance", "Distance to Target."); diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index 5e164c6525f..7239fc1ff3d 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -31,10 +31,10 @@ #include "RNA_define.h" #include "RNA_types.h" -#ifdef RNA_RUNTIME - #include "BKE_context.h" +#ifdef RNA_RUNTIME + static PointerRNA rna_Context_manager_get(PointerRNA *ptr) { bContext *C= (bContext*)ptr->data; @@ -110,6 +110,12 @@ static PointerRNA rna_Context_user_preferences_get(PointerRNA *ptr) return newptr; } +static int rna_Context_mode_get(PointerRNA *ptr) +{ + bContext *C= (bContext*)ptr->data; + return CTX_data_mode_enum(C); +} + #else void RNA_def_context(BlenderRNA *brna) @@ -117,6 +123,23 @@ void RNA_def_context(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem mode_items[] = { + {CTX_MODE_EDIT_MESH, "EDIT_MESH", 0, "Mesh Edit", ""}, + {CTX_MODE_EDIT_CURVE, "EDIT_CURVE", 0, "Curve Edit", ""}, + {CTX_MODE_EDIT_SURFACE, "EDIT_SURFACE", 0, "Surface Edit", ""}, + {CTX_MODE_EDIT_TEXT, "EDIT_TEXT", 0, "Edit Edit", ""}, + {CTX_MODE_EDIT_ARMATURE, "EDIT_ARMATURE", 0, "Armature Edit", ""}, // PARSKEL reuse will give issues + {CTX_MODE_EDIT_METABALL, "EDIT_METABALL", 0, "Metaball Edit", ""}, + {CTX_MODE_EDIT_LATTICE, "EDIT_LATTICE", 0, "Lattice Edit", ""}, + {CTX_MODE_POSE, "POSE", 0, "Pose ", ""}, + {CTX_MODE_SCULPT, "SCULPT", 0, "Sculpt", ""}, + {CTX_MODE_PAINT_WEIGHT, "PAINT_WEIGHT", 0, "Weight Paint", ""}, + {CTX_MODE_PAINT_VERTEX, "PAINT_VERTEX", 0, "Vertex Paint", ""}, + {CTX_MODE_PAINT_TEXTURE, "PAINT_TEXTURE", 0, "Texture Paint", ""}, + {CTX_MODE_PARTICLE, "PARTICLE", 0, "Particle", ""}, + {CTX_MODE_OBJECT, "OBJECT", 0, "Object", ""}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "Context", NULL); RNA_def_struct_ui_text(srna, "Context", "Current windowmanager and data context."); RNA_def_struct_sdna(srna, "bContext"); @@ -177,6 +200,11 @@ void RNA_def_context(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "UserPreferences"); RNA_def_property_pointer_funcs(prop, "rna_Context_user_preferences_get", NULL, NULL); + + prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_enum_funcs(prop, "rna_Context_mode_get", NULL, NULL); } #endif diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index faf6c3a1f75..1dd3d0e63c5 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -33,6 +33,8 @@ #include "DNA_material_types.h" #include "DNA_scene_types.h" +#include "BKE_font.h" + EnumPropertyItem beztriple_handle_type_items[] = { {HD_FREE, "FREE", 0, "Free", ""}, {HD_AUTO, "AUTO", 0, "Auto", ""}, @@ -52,6 +54,11 @@ EnumPropertyItem beztriple_interpolation_mode_items[] = { #include "DNA_object_types.h" #include "BKE_curve.h" +#include "BKE_depsgraph.h" +#include "BKE_main.h" + +#include "WM_api.h" +#include "WM_types.h" StructRNA *rna_Curve_refine(PointerRNA *ptr) { @@ -142,6 +149,22 @@ static void rna_BPoint_array_begin(CollectionPropertyIterator *iter, PointerRNA rna_iterator_array_begin(iter, (void*)nu->bp, sizeof(BPoint*), nu->pntsv>0 ? nu->pntsu*nu->pntsv : nu->pntsu, 0, NULL); } +static void rna_Curve_update_data(bContext *C, PointerRNA *ptr) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + Curve *cu= ptr->id.data; + Object *ob; + + for(ob=bmain->object.first; ob; ob= ob->id.next) { + if(ob->data == cu) { + /* XXX this will loop over all objects again (slow) */ + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + } + } +} + #else static void rna_def_bpoint(BlenderRNA *brna) @@ -157,32 +180,38 @@ static void rna_def_bpoint(BlenderRNA *brna) prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f1", 0); RNA_def_property_ui_text(prop, "Selected", "Selection status"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "hide", 0); RNA_def_property_ui_text(prop, "Hidden", "Visibility status"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Vector value */ - prop= RNA_def_property(srna, "point", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "point", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 4); RNA_def_property_float_sdna(prop, NULL, "vec"); RNA_def_property_ui_text(prop, "Point", "Point coordinates"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Number values */ prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "alfa"); /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/ RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3d View"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01f, 100.0f); RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "bevel_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "radius"); /*RNA_def_property_range(prop, 0.0f, 1.0f);*/ RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_beztriple(BlenderRNA *brna) @@ -198,67 +227,80 @@ static void rna_def_beztriple(BlenderRNA *brna) prop= RNA_def_property(srna, "selected_handle1", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f1", 0); RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "selected_handle2", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f3", 0); RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "selected_control_point", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f2", 0); RNA_def_property_ui_text(prop, "Control Point selected", "Control point selection status"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "hide", 0); RNA_def_property_ui_text(prop, "Hidden", "Visibility status"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Enums */ prop= RNA_def_property(srna, "handle1_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "h1"); RNA_def_property_enum_items(prop, beztriple_handle_type_items); RNA_def_property_ui_text(prop, "Handle 1 Type", "Handle types"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "handle2_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "h2"); RNA_def_property_enum_items(prop, beztriple_handle_type_items); RNA_def_property_ui_text(prop, "Handle 2 Type", "Handle types"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "ipo"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_items(prop, beztriple_interpolation_mode_items); RNA_def_property_ui_text(prop, "Interpolation", "(For F-Curves Only) Interpolation to use for segment of curve starting from current BezTriple."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Vector values */ - prop= RNA_def_property(srna, "handle1", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "handle1", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_BezTriple_handle1_get", "rna_BezTriple_handle1_set", NULL); RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "control_point", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "control_point", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_BezTriple_ctrlpoint_get", "rna_BezTriple_ctrlpoint_set", NULL); RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "handle2", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "handle2", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_BezTriple_handle2_get", "rna_BezTriple_handle2_set", NULL); RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Number values */ prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "alfa"); /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/ RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3d View"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01f, 100.0f); RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "bevel_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "radius"); /*RNA_def_property_range(prop, 0.0f, 1.0f);*/ RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_path(BlenderRNA *brna, StructRNA *srna) @@ -270,23 +312,28 @@ static void rna_def_path(BlenderRNA *brna, StructRNA *srna) RNA_def_property_int_sdna(prop, NULL, "pathlen"); RNA_def_property_range(prop, 1, 32767); RNA_def_property_ui_text(prop, "Path Length", "If no speed IPO was set, the length of path in frames."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* flags */ prop= RNA_def_property(srna, "path", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_PATH); RNA_def_property_ui_text(prop, "Path", "Enable the curve to become a translation path."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "follow", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FOLLOW); RNA_def_property_ui_text(prop, "Follow", "Make curve path children to rotate along the path."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "stretch", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STRETCH); RNA_def_property_ui_text(prop, "Stretch", "Option for curve-deform: makes deformed child to stretch along entire path."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "offset_path_distance", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_OFFS_PATHDIST); RNA_def_property_ui_text(prop, "Offset Path Distance", "Children will use TimeOffs value as path distance offset."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna) @@ -297,10 +344,12 @@ static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "uv_orco", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO); RNA_def_property_ui_text(prop, "UV Orco", "Forces to use UV coordinates for texture mapping 'orco'."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "vertex_normal_flip", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CU_NOPUNOFLIP); RNA_def_property_ui_text(prop, "Vertex Normal Flip", "Flip vertex normals towards the camera during render"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_font(BlenderRNA *brna, StructRNA *srna) @@ -319,62 +368,74 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "spacemode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_align_items); RNA_def_property_ui_text(prop, "Text Align", "Text align from the object center."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* number values */ prop= RNA_def_property(srna, "text_size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fsize"); RNA_def_property_range(prop, 0.1f, 10.0f); RNA_def_property_ui_text(prop, "Font size", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "line_dist", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "linedist"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Distance between lines of text", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "word_spacing", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "wordspace"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Spacing between words", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "spacing", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "spacing"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Global spacing between characters", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "shear", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "shear"); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_ui_text(prop, "Shear", "Italic angle of the characters"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "x_offset", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xof"); RNA_def_property_range(prop, -50.0f, 50.0f); RNA_def_property_ui_text(prop, "X Offset", "Horizontal offset from the object center"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "y_offset", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "yof"); RNA_def_property_range(prop, -50.0f, 50.0f); RNA_def_property_ui_text(prop, "Y Offset", "Vertical offset from the object center"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "ul_position", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ulpos"); RNA_def_property_range(prop, -0.2f, 0.8f); RNA_def_property_ui_text(prop, "Underline position", "Vertical position of underline"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "ul_height", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ulheight"); RNA_def_property_range(prop, -0.2f, 0.8f); RNA_def_property_ui_text(prop, "Underline thickness", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "active_textbox", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "actbox"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "The active text box", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* strings */ prop= RNA_def_property(srna, "family", PROP_STRING, PROP_NONE); RNA_def_property_string_maxlength(prop, 21); RNA_def_property_ui_text(prop, "Family", "Blender uses font from selfmade objects."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "str", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "str"); @@ -388,23 +449,28 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) RNA_def_property_pointer_sdna(prop, NULL, "textoncurve"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Text on Curve", "Curve deforming text object."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "font", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "vfont"); RNA_def_property_ui_text(prop, "Font", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "textbox", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tb"); RNA_def_property_ui_text(prop, "Textbox", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "edit_format", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "curinfo"); RNA_def_property_ui_text(prop, "Edit Format", "Editing settings character formatting."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* flags */ prop= RNA_def_property(srna, "fast", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FAST); RNA_def_property_ui_text(prop, "Fast", "Don't fill polygons while editing."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_textbox(BlenderRNA *brna) @@ -420,21 +486,25 @@ static void rna_def_textbox(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "x"); RNA_def_property_range(prop, -50.0f, 50.0f); RNA_def_property_ui_text(prop, "Textbox X Offset", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "y"); RNA_def_property_range(prop, -50.0f, 50.0f); RNA_def_property_ui_text(prop, "Textbox Y Offset", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "width", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "w"); RNA_def_property_range(prop, 0.0f, 50.0f); RNA_def_property_ui_text(prop, "Textbox Width", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "h"); RNA_def_property_range(prop, 0.0f, 50.0f); RNA_def_property_ui_text(prop, "Textbox Height", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_charinfo(BlenderRNA *brna) @@ -450,22 +520,27 @@ static void rna_def_charinfo(BlenderRNA *brna) prop= RNA_def_property(srna, "style", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STYLE); RNA_def_property_ui_text(prop, "Style", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "bold", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_BOLD); RNA_def_property_ui_text(prop, "Bold", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "italic", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_ITALIC); RNA_def_property_ui_text(prop, "Italic", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "underline", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UNDERLINE); RNA_def_property_ui_text(prop, "Underline", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_WRAP); RNA_def_property_ui_text(prop, "Wrap", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_surface(BlenderRNA *brna) @@ -523,31 +598,37 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_range(prop, 0, 32); RNA_def_property_ui_range(prop, 0, 32, 1.0, 0); RNA_def_property_ui_text(prop, "Bevel Resolution", "Bevel resolution when depth is non-zero and no specific bevel object has been defined."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "width", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "width"); RNA_def_property_ui_range(prop, 0, 2.0, 0.1, 0); RNA_def_property_ui_text(prop, "Width", "Scale the original width (1.0) based on given factor."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "extrude", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ext1"); RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 0); RNA_def_property_ui_text(prop, "Extrude", "Amount of curve extrusion when not using a bevel object."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "bevel_depth", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ext2"); RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 0); RNA_def_property_ui_text(prop, "Bevel Depth", "Bevel depth when not using a bevel object."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolu"); RNA_def_property_ui_range(prop, 1, 1024, 1, 0); RNA_def_property_ui_text(prop, "Resolution U", "Surface resolution in U direction."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolv"); RNA_def_property_ui_range(prop, 1, 1024, 1, 0); RNA_def_property_ui_text(prop, "Resolution V", "Surface resolution in V direction."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "render_resolution_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolu_ren"); @@ -563,34 +644,41 @@ static void rna_def_curve(BlenderRNA *brna) prop= RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ctime"); RNA_def_property_ui_text(prop, "Evaluation Time", "Parametric position along the length of the curve that Objects 'following' it should be at."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* pointers */ prop= RNA_def_property(srna, "bevel_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "bevobj"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bevel Object", "Curve object name that defines the bevel shape."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "taper_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "taperobj"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Taper Object", "Curve object name that defines the taper (width)."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Flags */ prop= RNA_def_property(srna, "curve_2d", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CU_3D); RNA_def_property_ui_text(prop, "2D Curve", "Define curve in two dimensions only. Note that fill only works when this is enabled."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "front", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FRONT); RNA_def_property_ui_text(prop, "Front", "Draw filled front for extruded/beveled curves."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "back", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_BACK); RNA_def_property_ui_text(prop, "Back", "Draw filled back for extruded/beveled curves."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "retopo", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_RETOPO); RNA_def_property_ui_text(prop, "Retopo", "Turn on the re-topology tool."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_curve_nurb(BlenderRNA *brna) @@ -624,89 +712,107 @@ static void rna_def_curve_nurb(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "tilt_interp"); RNA_def_property_enum_items(prop, spline_interpolation_items); RNA_def_property_ui_text(prop, "Tilt Interpolation", "The type of tilt interpolation for 3D, Bezier curves."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "radius_interpolation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "radius_interp"); RNA_def_property_enum_items(prop, spline_interpolation_items); RNA_def_property_ui_text(prop, "Radius Interpolation", "The type of radius interpolation for Bezier curves."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "point_count_u", PROP_INT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/ RNA_def_property_int_sdna(prop, NULL, "pntsu"); RNA_def_property_ui_text(prop, "Points U", "Total number points for the curve or surface in the U direction"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "point_count_v", PROP_INT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/ RNA_def_property_int_sdna(prop, NULL, "pntsv"); RNA_def_property_ui_text(prop, "Points V", "Total number points for the surface on the V direction"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "order_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "orderu"); RNA_def_property_range(prop, 2, 6); RNA_def_property_ui_text(prop, "Order U", "Nurbs order in the U direction (For curves and surfaces), Higher values let points influence a greater area"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "order_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "orderv"); RNA_def_property_range(prop, 2, 6); RNA_def_property_ui_text(prop, "Order V", "Nurbs order in the V direction (For surfaces only), Higher values let points influence a greater area"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolu"); RNA_def_property_range(prop, 1, 1024); RNA_def_property_ui_text(prop, "Resolution U", "Curve or Surface subdivisions per segment"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolv"); RNA_def_property_range(prop, 1, 1024); RNA_def_property_ui_text(prop, "Resolution V", "Surface subdivisions per segment"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "cyclic_u", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_CYCLIC); RNA_def_property_ui_text(prop, "Cyclic U", "Make this curve or surface a closed loop in the U direction."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "cyclic_v", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_CYCLIC); RNA_def_property_ui_text(prop, "Cyclic V", "Make this surface a closed loop in the V direction."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Note, endpoint and bezier flags should never be on at the same time! */ prop= RNA_def_property(srna, "endpoint_u", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagu", 2); RNA_def_property_ui_text(prop, "Endpoint U", "Make this nurbs curve or surface meet the endpoints in the U direction (Cyclic U must be disabled)."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "endpoint_v", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagv", 2); RNA_def_property_ui_text(prop, "Endpoint V", "Make this nurbs surface meet the endpoints in the V direction (Cyclic V must be disabled)."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "bezier_u", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagu", 4); RNA_def_property_ui_text(prop, "Bezier U", "Make this nurbs curve or surface act like a bezier spline in the U direction (Order U must be 3 or 4, Cyclic U must be disabled)."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "bezier_v", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flagv", 4); RNA_def_property_ui_text(prop, "Bezier V", "Make this nurbs surface act like a bezier spline in the V direction (Order V must be 3 or 4, Cyclic V must be disabled)."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "smooth", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_SMOOTH); RNA_def_property_ui_text(prop, "Smooth", "Smooth the normals of the surface or beveled curve."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "hide", 1); RNA_def_property_ui_text(prop, "Hide", "Hide this curve in editmode."); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "mat_nr"); RNA_def_property_ui_text(prop, "Material Index", ""); RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Curve_material_index_range"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "character_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "charidx"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/ - RNA_def_property_ui_text(prop, "Character Index", "the location of this character in the text data (only for text curves)"); + RNA_def_property_ui_text(prop, "Character Index", "Location of this character in the text data (only for text curves)"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } void RNA_def_curve(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 76e17d835ba..f22fd594d8d 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -77,6 +77,20 @@ void rna_remlink(ListBase *listbase, void *vlink) if (listbase->first == link) listbase->first = link->next; } +PropertyDefRNA *rna_findlink(ListBase *listbase, const char *identifier) +{ + Link *link; + + for(link=listbase->first; link; link=link->next) { + PropertyRNA *prop= ((PropertyDefRNA *)link)->prop; + if(prop && (strcmp(prop->identifier, identifier)==0)) { + return (PropertyDefRNA *)link; + } + } + + return NULL; +} + void rna_freelinkN(ListBase *listbase, void *vlink) { rna_remlink(listbase, vlink); @@ -444,6 +458,15 @@ void RNA_define_verify_sdna(int verify) DefRNA.verify= verify; } +void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext) +{ +#ifdef RNA_RUNTIME + ext->free(ext->data); /* decref's the PyObject that the srna owns */ + RNA_struct_blender_type_set(srna, NULL); /* this gets accessed again - XXX fixme */ + RNA_struct_py_type_set(srna, NULL); /* NULL the srna's value so RNA_struct_free wont complain of a leak */ +#endif +} + void RNA_struct_free(BlenderRNA *brna, StructRNA *srna) { #ifdef RNA_RUNTIME @@ -451,6 +474,12 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna) PropertyRNA *prop, *nextprop; PropertyRNA *parm, *nextparm; + if(srna->flag & STRUCT_RUNTIME) { + if(RNA_struct_py_type_get(srna)) { + fprintf(stderr, "StructRNA \"%s\" freed while holdng a python reference\n", srna->name); + } + } + for(prop=srna->cont.properties.first; prop; prop=nextprop) { nextprop= prop->next; @@ -482,6 +511,7 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna) if(srna->flag & STRUCT_RUNTIME) rna_freelinkN(&brna->structs, srna); + #endif } @@ -821,6 +851,13 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier } dcont= rna_find_container_def(cont); + + /* XXX - toto, detect supertype collisions */ + if(rna_findlink(&dcont->properties, identifier)) { + fprintf(stderr, "RNA_def_property: duplicate identifier \"%s\"\n", identifier); + DefRNA.error= 1; + } + dprop= MEM_callocN(sizeof(PropertyDefRNA), "PropertyDefRNA"); rna_addtail(&dcont->properties, dprop); } @@ -1066,7 +1103,7 @@ void RNA_def_property_struct_type(PropertyRNA *prop, const char *type) StructRNA *srna= DefRNA.laststruct; if(!DefRNA.preprocess) { - fprintf(stderr, "RNA_def_property_struct_type: only during preprocessing.\n"); + fprintf(stderr, "RNA_def_property_struct_type %s.%s: only during preprocessing.\n", srna->identifier, prop->identifier); return; } @@ -1877,7 +1914,7 @@ PropertyRNA *RNA_def_boolean_vector(StructOrFunctionRNA *cont_, const char *iden ContainerRNA *cont= cont_; PropertyRNA *prop; - prop= RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_XYZ); // XXX if(len != 0) RNA_def_property_array(prop, len); if(default_value) RNA_def_property_boolean_array_default(prop, default_value); RNA_def_property_ui_text(prop, ui_name, ui_description); @@ -1906,7 +1943,7 @@ PropertyRNA *RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifi ContainerRNA *cont= cont_; PropertyRNA *prop; - prop= RNA_def_property(cont, identifier, PROP_INT, PROP_VECTOR); + prop= RNA_def_property(cont, identifier, PROP_INT, PROP_XYZ); // XXX if(len != 0) RNA_def_property_array(prop, len); if(default_value) RNA_def_property_int_array_default(prop, default_value); if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax); @@ -2015,7 +2052,7 @@ PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identi ContainerRNA *cont= cont_; PropertyRNA *prop; - prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_XYZ); if(len != 0) RNA_def_property_array(prop, len); if(default_value) RNA_def_property_float_array_default(prop, default_value); if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax); @@ -2064,7 +2101,7 @@ PropertyRNA *RNA_def_float_rotation(StructOrFunctionRNA *cont_, const char *iden ContainerRNA *cont= cont_; PropertyRNA *prop; - prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_EULER); // XXX if(len != 0) RNA_def_property_array(prop, len); if(default_value) RNA_def_property_float_array_default(prop, default_value); if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax); @@ -2384,6 +2421,7 @@ void RNA_def_property_duplicate_pointers(PropertyRNA *prop) EnumPropertyItem *earray; float *farray; int *iarray; + int a; if(prop->identifier) prop->identifier= BLI_strdup(prop->identifier); if(prop->name) prop->name= BLI_strdup(prop->name); @@ -2417,7 +2455,14 @@ void RNA_def_property_duplicate_pointers(PropertyRNA *prop) earray= MEM_callocN(sizeof(EnumPropertyItem)*(eprop->totitem+1), "RNA_def_property_store"), memcpy(earray, eprop->item, sizeof(EnumPropertyItem)*(eprop->totitem+1)); eprop->item= earray; + + for(a=0; atotitem; a++) { + if(eprop->item[a].identifier) eprop->item[a].identifier= BLI_strdup(eprop->item[a].identifier); + if(eprop->item[a].name) eprop->item[a].name= BLI_strdup(eprop->item[a].name); + if(eprop->item[a].description) eprop->item[a].description= BLI_strdup(eprop->item[a].description); + } } + break; } case PROP_FLOAT: { FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop; @@ -2444,6 +2489,8 @@ void RNA_def_property_duplicate_pointers(PropertyRNA *prop) void RNA_def_property_free_pointers(PropertyRNA *prop) { if(prop->flag & PROP_FREE_POINTERS) { + int a; + if(prop->identifier) MEM_freeN((void*)prop->identifier); if(prop->name) MEM_freeN((void*)prop->name); if(prop->description) MEM_freeN((void*)prop->description); @@ -2467,6 +2514,13 @@ void RNA_def_property_free_pointers(PropertyRNA *prop) case PROP_ENUM: { EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop; if(eprop->item) MEM_freeN((void*)eprop->item); + + for(a=0; atotitem; a++) { + if(eprop->item[a].identifier) MEM_freeN((void*)eprop->item[a].identifier); + if(eprop->item[a].name) MEM_freeN((void*)eprop->item[a].name); + if(eprop->item[a].description) MEM_freeN((void*)eprop->item[a].description); + } + break; } case PROP_STRING: { StringPropertyRNA *sprop= (StringPropertyRNA*)prop; diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index ceef84b92df..fa6eea5f8a9 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -255,7 +255,7 @@ static void rna_def_fmodifier_envelope_ctrl(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Maximum Value", "Upper bound of envelope at this control-point."); /* Frame */ - prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "time"); RNA_def_property_ui_text(prop, "Frame", "Frame this control-point occurs on."); @@ -548,7 +548,7 @@ static void rna_def_fpoint(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Selected", "Selection status"); /* Vector value */ - prop= RNA_def_property(srna, "point", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "point", PROP_FLOAT, PROP_XYZ); RNA_def_property_array(prop, 2); RNA_def_property_float_sdna(prop, NULL, "vec"); RNA_def_property_ui_text(prop, "Point", "Point coordinates"); diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index ea4deae08e7..936e1700ed7 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -98,7 +98,7 @@ static void rna_FluidSettings_update_type(bContext *C, PointerRNA *ptr) part->type= PART_FLUID; psys->part= part; - psys->pointcache= BKE_ptcache_add(); + psys->pointcache= BKE_ptcache_add(&psys->ptcaches); psys->flag |= PSYS_ENABLED; BLI_addtail(&ob->particlesystem,psys); @@ -202,12 +202,12 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) RNA_def_property_range(prop, 1, 100); RNA_def_property_ui_text(prop, "Preview Resolution", "Preview resolution in X,Y and Z direction."); - prop= RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "animStart"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Start Time", "Simulation time of the first blender frame."); - prop= RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "animEnd"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "End Time", "Simulation time of the last blender frame."); @@ -240,7 +240,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) /* advanced settings */ - prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_float_sdna(prop, NULL, "gravx"); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -1000.1, 1000.1); @@ -338,7 +338,7 @@ static void rna_def_fluidsim_fluid(BlenderRNA *brna) rna_def_fluidsim_volume(srna); - prop= RNA_def_property(srna, "initial_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "initial_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "iniVelx"); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -1000.1, 1000.1); @@ -374,7 +374,7 @@ static void rna_def_fluidsim_inflow(BlenderRNA *brna) rna_def_fluidsim_volume(srna); - prop= RNA_def_property(srna, "inflow_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "inflow_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "iniVelx"); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -1000.1, 1000.1); @@ -443,12 +443,12 @@ static void rna_def_fluidsim_control(BlenderRNA *brna) RNA_def_struct_sdna(srna, "FluidsimSettings"); RNA_def_struct_ui_text(srna, "Control Fluid Simulation Settings", "Fluid simulation settings for objects controlling the motion of fluid in the simulation."); - prop= RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "cpsTimeStart"); RNA_def_property_range(prop, 0.0, 100.0); RNA_def_property_ui_text(prop, "Start Time", "Specifies time when the control particles are activated."); - prop= RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "cpsTimeEnd"); RNA_def_property_range(prop, 0.0, 100.0); RNA_def_property_ui_text(prop, "End Time", "Specifies time when the control particles are deactivated."); diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index 1406ad1ae60..18c04fbfb50 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -52,7 +52,7 @@ void RNA_def_group(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Group", "Group of Object datablocks."); RNA_def_struct_ui_icon(srna, ICON_GROUP); - prop= RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "dupli_ofs"); RNA_def_property_ui_text(prop, "Dupli Offset", "Offset from the center to use when instancing as DupliGroup."); RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 5366296a6b8..c96b1265126 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -116,7 +116,7 @@ static void rna_def_imageuser(BlenderRNA *brna) RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Offset", "Offsets the number of the frame to use in the animation."); - prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "sfra"); RNA_def_property_range(prop, 1.0f, MAXFRAMEF); RNA_def_property_ui_text(prop, "Start Frame", "Sets the global starting frame of the movie."); @@ -242,7 +242,7 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mapping", "Mapping type to use for this image in the game engine."); RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); - prop= RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "aspx"); RNA_def_property_array(prop, 2); RNA_def_property_range(prop, 0.1f, 5000.0f); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 8eb4fc9cde2..cff77fbb34b 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -181,6 +181,9 @@ struct StructRNA *rna_ID_refine(struct PointerRNA *ptr); struct IDProperty *rna_ID_idproperties(struct PointerRNA *ptr, int create); void rna_ID_fake_user_set(struct PointerRNA *ptr, int value); struct IDProperty *rna_IDPropertyGroup_idproperties(struct PointerRNA *ptr, int create); +void rna_IDPropertyGroup_unregister(const struct bContext *C, struct StructRNA *type); +struct StructRNA *rna_IDPropertyGroup_register(const struct bContext *C, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); +struct StructRNA* rna_IDPropertyGroup_refine(struct PointerRNA *ptr); void rna_object_vgroup_name_index_get(struct PointerRNA *ptr, char *value, int index); int rna_object_vgroup_name_index_length(struct PointerRNA *ptr, int index); @@ -261,6 +264,7 @@ void rna_iterator_array_end(struct CollectionPropertyIterator *iter); void rna_addtail(struct ListBase *listbase, void *vlink); void rna_freelinkN(struct ListBase *listbase, void *vlink); void rna_freelistN(struct ListBase *listbase); +PropertyDefRNA *rna_findlink(ListBase *listbase, const char *identifier); StructDefRNA *rna_find_struct_def(StructRNA *srna); FunctionDefRNA *rna_find_function_def(FunctionRNA *func); diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 216a1d05079..88047cda12b 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -282,7 +282,7 @@ static void rna_def_keydata(BlenderRNA *brna) srna= RNA_def_struct(brna, "ShapeKeyPoint", NULL); RNA_def_struct_ui_text(srna, "Shape Key Point", "Point in a shape key."); - prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", NULL); RNA_def_property_ui_text(prop, "Location", ""); @@ -291,7 +291,7 @@ static void rna_def_keydata(BlenderRNA *brna) srna= RNA_def_struct(brna, "ShapeKeyCurvePoint", NULL); RNA_def_struct_ui_text(srna, "Shape Key Curve Point", "Point in a shape key for curves."); - prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", NULL); RNA_def_property_ui_text(prop, "Location", ""); @@ -305,19 +305,19 @@ static void rna_def_keydata(BlenderRNA *brna) srna= RNA_def_struct(brna, "ShapeKeyBezierPoint", NULL); RNA_def_struct_ui_text(srna, "Shape Key Bezier Point", "Point in a shape key for bezier curves."); - prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_co_get", "rna_ShapeKeyBezierPoint_co_set", NULL); RNA_def_property_ui_text(prop, "Location", ""); RNA_def_property_update(prop, 0, "rna_Key_update_data"); - prop= RNA_def_property(srna, "handle_1_co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "handle_1_co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_handle_1_co_get", "rna_ShapeKeyBezierPoint_handle_1_co_set", NULL); RNA_def_property_ui_text(prop, "Handle 1 Location", ""); RNA_def_property_update(prop, 0, "rna_Key_update_data"); - prop= RNA_def_property(srna, "handle_2_co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "handle_2_co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_handle_2_co_get", "rna_ShapeKeyBezierPoint_handle_2_co_set", NULL); RNA_def_property_ui_text(prop, "Handle 2 Location", ""); @@ -351,7 +351,7 @@ static void rna_def_keyblock(BlenderRNA *brna) RNA_def_struct_name_property(srna, prop); /* keys need to be sorted to edit this */ - prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_float_sdna(prop, NULL, "pos"); RNA_def_property_ui_text(prop, "Frame", "Frame for absolute keys."); diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 299bd37496b..57aa1ba2736 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -151,13 +151,13 @@ static void rna_def_lamp_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shadow", "Lets the texture affect the shadow color of the lamp."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Color Factor", "Amount texture affects color values."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "shadow_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "shadow_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Shadow Factor", "Amount texture affects shadow."); @@ -314,7 +314,7 @@ static void rna_def_lamp(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Type", "Type of Lamp."); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL); - prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist"); RNA_def_property_ui_range(prop, 0, 1000, 1.0, 2); RNA_def_property_ui_text(prop, "Distance", "Falloff distance - the light is at half the original intensity at this point."); @@ -465,7 +465,7 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area) RNA_def_property_ui_text(prop, "Shadow Adaptive Threshold", "Threshold for Adaptive Sampling (Raytraced shadows)."); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL); - prop= RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "soft"); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Shadow Soft Size", "Light size for ray shadow sampling (Raytraced shadows)."); @@ -526,13 +526,13 @@ static void rna_def_area_lamp(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shape", "Shape of the area lamp."); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL); - prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "area_size"); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Size", "Size of the area of the area Lamp, X direction size for Rectangle shapes."); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL); - prop= RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "area_sizey"); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Size Y", "Size of the area of the area Lamp in the Y direction for Rectangle shapes."); @@ -628,13 +628,13 @@ static void rna_def_spot_lamp(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Spot Size", "Angle of the spotlight beam in degrees."); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL); - prop= RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipsta"); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Clip Start", "Shadow map clip start: objects closer will not generate shadows"); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL); - prop= RNA_def_property(srna, "shadow_buffer_clip_end", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "shadow_buffer_clip_end", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipend"); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Clip End", "Shadow map clip end beyond which objects will not generate shadows."); diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index 03a1dc9ec8f..b53a0589ba6 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -178,13 +178,13 @@ static void rna_def_latticepoint(BlenderRNA *brna) RNA_def_struct_sdna(srna, "BPoint"); RNA_def_struct_ui_text(srna, "LatticePoint", "Point in the lattice grid."); - prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_float_funcs(prop, "rna_LatticePoint_co_get", NULL, NULL); RNA_def_property_ui_text(prop, "Location", ""); - prop= RNA_def_property(srna, "deformed_co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "deformed_co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "vec"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Deformed Location", ""); diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 26fc3c2941e..4a24027f7e9 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -220,34 +220,34 @@ void RNA_def_main(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - const char *lists[][5]= { - {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks."}, - {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks."}, - {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks."}, - {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks."}, - {"nodetrees", "NodeTree", "rna_Main_nodetree_begin", "Node Trees", "Nodetree datablocks."}, - {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks."}, - {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks."}, - {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks."}, - {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks."}, - {"windowmanagers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks."}, - {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks."}, - {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks."}, - {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks."}, - {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks."}, - {"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks."}, - {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks."}, - {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks."}, - {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks."}, - {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks."}, - {"keys", "ID", "rna_Main_key_begin", "Keys", "Key datablocks."}, - {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks."}, - {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks."}, - {"sounds", "ID", "rna_Main_sound_begin", "Sounds", "Sound datablocks."}, - {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks."}, - {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks."}, - {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks."}, - {NULL, NULL, NULL, NULL, NULL}}; + const char *lists[][7]= { + {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks.", NULL, NULL}, + {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks.", NULL, NULL}, + {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks.", NULL, NULL}, + {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks.", NULL, NULL}, + {"nodegroups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks.", NULL, NULL}, + {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks.", "add_mesh", "remove_mesh"}, + {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks.", NULL, NULL}, + {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks.", NULL, NULL}, + {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks.", NULL, NULL}, + {"windowmanagers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks.", NULL, NULL}, + {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks.", NULL, NULL}, + {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks.", NULL, NULL}, + {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks.", NULL, NULL} , + {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks.", NULL, NULL}, + {"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks.", NULL, NULL}, + {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks.", NULL, NULL}, + {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks.", NULL, NULL}, + {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks.", NULL, NULL}, + {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks.", NULL, NULL}, + {"keys", "ID", "rna_Main_key_begin", "Keys", "Key datablocks.", NULL, NULL}, + {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks.", NULL, NULL}, + {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks.", NULL, NULL}, + {"sounds", "ID", "rna_Main_sound_begin", "Sounds", "Sound datablocks.", NULL, NULL}, + {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks.", NULL, NULL}, + {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks.", NULL, NULL}, + {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks.", NULL, NULL}, + {NULL, NULL, NULL, NULL, NULL, NULL, NULL}}; int i; srna= RNA_def_struct(brna, "Main", NULL); @@ -264,7 +264,7 @@ void RNA_def_main(BlenderRNA *brna) { prop= RNA_def_property(srna, lists[i][0], PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, lists[i][1]); - RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, lists[i][5], lists[i][6]); RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]); } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index fb79ec88c4c..93d6b0283bd 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -41,6 +41,8 @@ #include "BKE_texture.h" +#include "ED_node.h" + static PointerRNA rna_Material_mirror_get(PointerRNA *ptr) { return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceMirror, ptr->id.data); @@ -66,6 +68,11 @@ static PointerRNA rna_Material_strand_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_MaterialStrand, ptr->id.data); } +static PointerRNA rna_Material_physics_get(PointerRNA *ptr) +{ + return rna_pointer_inherit_refine(ptr, &RNA_MaterialPhysics, ptr->id.data); +} + static void rna_Material_type_set(PointerRNA *ptr, int value) { Material *ma= (Material*)ptr->data; @@ -191,6 +198,15 @@ static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, int value) ma->ramp_spec= add_colorband(0); } +void rna_Material_use_nodes_set(PointerRNA *ptr, int value) +{ + Material *ma= (Material*)ptr->data; + + ma->use_nodes= value; + if(ma->use_nodes && ma->nodetree==NULL) + ED_node_shader_default(ma); +} + #else static void rna_def_material_mtex(BlenderRNA *brna) @@ -403,7 +419,7 @@ static void rna_def_material_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Specular Color Factor", "Amount texture affects specular color."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "colordiff_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "colordiff_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Diffuse Color Factor", "Amount texture affects diffuse color."); @@ -522,10 +538,16 @@ static void rna_def_material_colors(StructRNA *srna) RNA_def_property_ui_text(prop, "Mirror Color", "Mirror color of the material."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Alpha", "Alpha transparency of the material."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL); + + prop= RNA_def_property(srna, "specular_alpha", PROP_FLOAT, PROP_PERCENTAGE); + RNA_def_property_float_sdna(prop, NULL, "spectra"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Specular Alpha", "Alpha transparency for specular areas."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); /* Color bands */ prop= RNA_def_property(srna, "use_diffuse_ramp", PROP_BOOLEAN, PROP_NONE); @@ -594,7 +616,7 @@ static void rna_def_material_diffuse(StructRNA *srna) RNA_def_property_ui_text(prop, "Diffuse Shader Model", ""); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "diffuse_reflection", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "diffuse_reflection", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "ref"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Diffuse Reflection", "Amount of diffuse reflection."); @@ -611,7 +633,7 @@ static void rna_def_material_diffuse(StructRNA *srna) RNA_def_property_ui_text(prop, "Diffuse Toon Size", "Size of diffuse toon area."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "diffuse_toon_smooth", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "diffuse_toon_smooth", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "param[1]"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Diffuse Toon Smooth", "Smoothness of diffuse toon area."); @@ -655,7 +677,7 @@ static void rna_def_material_raymirror(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Enabled", "Enable raytraced reflections."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "reflect", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "reflect", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "ray_mirror"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Reflect", "Sets the amount mirror reflection for raytrace."); @@ -667,19 +689,19 @@ static void rna_def_material_raymirror(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Fresnel", "Power of Fresnel for mirror reflection."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "fresnel_fac", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "fresnel_factor", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "fresnel_mir_i"); RNA_def_property_range(prop, 0.0f, 5.0f); RNA_def_property_ui_text(prop, "Fresnel Factor", "Blending factor for Fresnel."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "gloss", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gloss", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "gloss_mir"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Gloss", "The shininess of the reflection. Values < 1.0 give diffuse, blurry reflections."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "gloss_anisotropic", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gloss_anisotropic", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "aniso_gloss_mir"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Gloss Anisotropy", "The shape of the reflection, from 0.0 (circular) to 1.0 (fully stretched along the tangent."); @@ -691,7 +713,7 @@ static void rna_def_material_raymirror(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Gloss Samples", "Number of cone samples averaged for blurry reflections."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "adapt_thresh_mir"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Gloss Threshold", "Threshold for adaptive sampling. If a sample contributes less than this amount (as a percentage), sampling is stopped."); @@ -703,7 +725,7 @@ static void rna_def_material_raymirror(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Depth", "Maximum allowed number of light inter-reflections."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist_mir"); RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_ui_text(prop, "Maximum Distance", "Maximum distance of reflected rays. Reflections further than this range fade to sky color or material color."); @@ -726,11 +748,6 @@ static void rna_def_material_raytra(BlenderRNA *brna) RNA_def_struct_nested(brna, srna, "Material"); RNA_def_struct_ui_text(srna, "Material Raytrace Transparency", "Raytraced refraction settings for a Material datablock."); - prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAYTRANSP); /* use bitflags */ - RNA_def_property_ui_text(prop, "Enabled", "Enables raytracing for transparent refraction rendering."); - RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "ior", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ang"); RNA_def_property_range(prop, 1.0f, 3.0f); @@ -743,13 +760,13 @@ static void rna_def_material_raytra(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Fresnel", "Power of Fresnel for transparency (Ray or ZTransp)."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "fresnel_fac", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "fresnel_factor", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "fresnel_tra_i"); RNA_def_property_range(prop, 1.0f, 5.0f); RNA_def_property_ui_text(prop, "Fresnel Factor", "Blending factor for Fresnel."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "gloss", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gloss", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "gloss_tra"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Gloss", "The clarity of the refraction. Values < 1.0 give diffuse, blurry refractions."); @@ -761,7 +778,7 @@ static void rna_def_material_raytra(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Gloss Samples", "Number of cone samples averaged for blurry refractions."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "adapt_thresh_tra"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Gloss Threshold", "Threshold for adaptive sampling. If a sample contributes less than this amount (as a percentage), sampling is stopped."); @@ -773,13 +790,13 @@ static void rna_def_material_raytra(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Depth", "Maximum allowed number of light inter-refractions."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "filter", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "filter", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "filter"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Filter", "Amount to blend in the material's diffuse color in raytraced transparency (simulating absorption)."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "limit", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "limit", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "tx_limit"); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Limit", "Maximum depth for light to travel through the transparent material before becoming fully filtered (0.0 is disabled)."); @@ -790,12 +807,6 @@ static void rna_def_material_raytra(BlenderRNA *brna) RNA_def_property_range(prop, 0.1f, 10.0f); RNA_def_property_ui_text(prop, "Falloff", "Falloff power for transmissivity filter effect (1.0 is linear)."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - - prop= RNA_def_property(srna, "specular_opacity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "spectra"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Specular Opacity", "Makes specular areas opaque on transparent materials."); - RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); } static void rna_def_material_halo(BlenderRNA *brna) @@ -820,7 +831,7 @@ static void rna_def_material_halo(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Hardness", "Sets the hardness of the halo."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "add", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "add", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "add"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Add", "Sets the strength of the add effect."); @@ -936,7 +947,7 @@ static void rna_def_material_sss(BlenderRNA *brna) RNA_def_struct_nested(brna, srna, "Material"); RNA_def_struct_ui_text(srna, "Material Subsurface Scattering", "Diffuse subsurface scattering settings for a Material datablock."); - prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_RGB|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "sss_radius"); RNA_def_property_range(prop, 0.001, FLT_MAX); RNA_def_property_ui_range(prop, 0.001, 10000, 1, 3); @@ -966,13 +977,13 @@ static void rna_def_material_sss(BlenderRNA *brna) RNA_def_property_ui_text(prop, "IOR", "Index of refraction (higher values are denser)."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "sss_colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Color Factor", "Blend factor for SSS colors."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "texture_factor", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "texture_factor", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "sss_texfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Texture Factor", "Texture scatting blend factor."); @@ -1014,7 +1025,7 @@ void rna_def_material_specularity(StructRNA *srna) RNA_def_property_ui_text(prop, "Specular Shader Model", ""); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "specular_reflection", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "specular_reflection", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "spec"); RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Specularity Intensity", ""); @@ -1043,7 +1054,7 @@ void rna_def_material_specularity(StructRNA *srna) RNA_def_property_ui_text(prop, "Specular Toon Size", "Size of specular toon area."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "specular_toon_smooth", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "specular_toon_smooth", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "param[3]"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Specular Toon Smooth", "Ssmoothness of specular toon area."); @@ -1076,10 +1087,10 @@ void rna_def_material_strand(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Surface Diffuse", "Make diffuse shading more similar to shading the surface."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "blend_distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "blend_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "strand_surfnor"); RNA_def_property_range(prop, 0, 10); - RNA_def_property_ui_text(prop, "Blend Distance", "Distance in Blender units over which to blend in the surface normal."); + RNA_def_property_ui_text(prop, "Blend Distance", "Worldspace distance over which to blend in the surface normal."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "blender_units", PROP_BOOLEAN, PROP_NONE); @@ -1123,6 +1134,46 @@ void rna_def_material_strand(BlenderRNA *brna) RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); } +void rna_def_material_physics(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "MaterialPhysics", NULL); + RNA_def_struct_sdna(srna, "Material"); + RNA_def_struct_nested(brna, srna, "Material"); + RNA_def_struct_ui_text(srna, "Material Physics", "Physics settings for a Material datablock."); + + prop= RNA_def_property(srna, "align_to_normal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FH_NOR); + RNA_def_property_ui_text(prop, "Align to Normal", "Align dynamic game objects along the surface normal, when inside the physics distance area"); + + prop= RNA_def_property(srna, "friction", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "friction"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Friction", "Coulomb friction coeffecient, when inside the physics distance area"); + + prop= RNA_def_property(srna, "force", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fh"); + RNA_def_property_range(prop, 0, 1); + RNA_def_property_ui_text(prop, "Force", "Upward spring force, when inside the physics distance area"); + + prop= RNA_def_property(srna, "elasticity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "reflect"); + RNA_def_property_range(prop, 0, 1); + RNA_def_property_ui_text(prop, "Elasticity", "Elasticity of collisions"); + + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fhdist"); + RNA_def_property_range(prop, 0, 20); + RNA_def_property_ui_text(prop, "Distance", "Distance of the physics area"); + + prop= RNA_def_property(srna, "damp", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "xyfrict"); + RNA_def_property_range(prop, 0, 1); + RNA_def_property_ui_text(prop, "Damping", "Damping of the spring force, when inside the physics distance area"); +} + void RNA_def_material(BlenderRNA *brna) { StructRNA *srna; @@ -1134,6 +1185,10 @@ void RNA_def_material(BlenderRNA *brna) // {MA_TYPE_VOLUME, "VOLUME", 0, "Volume", "Render object as a volume."}, {MA_TYPE_HALO, "HALO", 0, "Halo", "Render object as halo particles."}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem transparency_items[] = { + {MA_ZTRANSP, "Z_TRANSPARENCY", 0, "Z Transparency", "Use alpha buffer for transparent faces."}, + {MA_RAYTRANSP, "RAYTRACE", 0, "Raytrace", "Use raytracing for transparent refraction rendering."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Material", "ID"); RNA_def_struct_ui_text(srna, "Material", "Material datablock to defined the appearance of geometric objects for rendering."); @@ -1145,19 +1200,31 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Type", "Material type defining how the object is rendered."); RNA_def_property_enum_funcs(prop, NULL, "rna_Material_type_set", NULL); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL); + + prop= RNA_def_property(srna, "transparency", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRANSP); + RNA_def_property_ui_text(prop, "Transparency", "Render material as transparent."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "transparency_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, transparency_items); + RNA_def_property_ui_text(prop, "Transparency Method", "Method to use for rendering transparency."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "amb"); RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Ambient", "Amount of global ambient color the material receives."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "emit", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0, 2); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_range(prop, 0, 2.0f, 10, 2); RNA_def_property_ui_text(prop, "Emit", "Amount of light to emit."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "translucency", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "translucency", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Translucency", "Amount of diffuse shading on the back side."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); @@ -1182,7 +1249,7 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_range(prop, 0, 10); RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Factor to multiply shadow buffer bias with (0 is ignore.)"); - prop= RNA_def_property(srna, "shadow_casting_alpha", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "shadow_casting_alpha", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "shad_alpha"); RNA_def_property_range(prop, 0.001, 1); RNA_def_property_ui_text(prop, "Shadow Casting Alpha", "Shadow casting alpha, only in use for Irregular Shadowbuffer."); @@ -1217,11 +1284,6 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shadeless", "Makes this material insensitive to light or shadow."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "z_transparency", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ZTRA); - RNA_def_property_ui_text(prop, "Z Transparency", "Enable alpha buffer for transparent faces."); - RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "vertex_color_light", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_VERTEXCOL); RNA_def_property_ui_text(prop, "Vertex Color Light", "Add vertex colors as additional lighting."); @@ -1267,11 +1329,6 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Exclude Mist", "Excludes this material from mist effects (in world settings)"); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "radiosity", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RADIO); - RNA_def_property_ui_text(prop, "Radiosity", "Include this material in radiosity calculations"); - RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "transparent_shadows", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADOW_TRA); RNA_def_property_ui_text(prop, "Transparent Shadows", "Allow this object to receive transparent shadows casted through other objects"); @@ -1322,12 +1379,23 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_struct_type(prop, "MaterialStrand"); RNA_def_property_pointer_funcs(prop, "rna_Material_strand_get", NULL, NULL); RNA_def_property_ui_text(prop, "Strand", "Strand settings for the material."); + + prop= RNA_def_property(srna, "physics", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "MaterialPhysics"); + RNA_def_property_pointer_funcs(prop, "rna_Material_physics_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Physics", "Game physics settings."); /* nodetree */ prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based materials."); + prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_nodes_set"); + RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material."); + RNA_def_property_update(prop, NC_MATERIAL, NULL); + /* common */ rna_def_animdata_common(srna); rna_def_mtex_common(srna, "rna_Material_mtex_begin", "rna_Material_active_texture_get", @@ -1344,6 +1412,7 @@ void RNA_def_material(BlenderRNA *brna) rna_def_material_sss(brna); rna_def_material_mtex(brna); rna_def_material_strand(brna); + rna_def_material_physics(brna); RNA_api_material(srna); } diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index dc953f80804..6918e71cd54 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -805,10 +805,10 @@ static void rna_def_mvert(BlenderRNA *brna) RNA_def_struct_path_func(srna, "rna_MeshVertex_path"); RNA_def_struct_ui_icon(srna, ICON_VERTEXSEL); - prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_ui_text(prop, "Location", ""); - prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_float_sdna(prop, NULL, "no"); RNA_def_property_float_funcs(prop, "rna_MeshVertex_normal_get", NULL, NULL); RNA_def_property_ui_text(prop, "Normal", "Vertex Normal"); @@ -918,7 +918,7 @@ static void rna_def_mface(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SMOOTH); RNA_def_property_ui_text(prop, "Smooth", ""); - prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -1035,22 +1035,22 @@ static void rna_def_mtface(BlenderRNA *brna) RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "UV Pinned", ""); - prop= RNA_def_property(srna, "uv1", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "uv1", PROP_FLOAT, PROP_XYZ); RNA_def_property_array(prop, 2); RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv1_get", "rna_MeshTextureFace_uv1_set", NULL); RNA_def_property_ui_text(prop, "UV 1", ""); - prop= RNA_def_property(srna, "uv2", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "uv2", PROP_FLOAT, PROP_XYZ); RNA_def_property_array(prop, 2); RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv2_get", "rna_MeshTextureFace_uv2_set", NULL); RNA_def_property_ui_text(prop, "UV 2", ""); - prop= RNA_def_property(srna, "uv3", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "uv3", PROP_FLOAT, PROP_XYZ); RNA_def_property_array(prop, 2); RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv3_get", "rna_MeshTextureFace_uv3_set", NULL); RNA_def_property_ui_text(prop, "UV 3", ""); - prop= RNA_def_property(srna, "uv4", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "uv4", PROP_FLOAT, PROP_XYZ); RNA_def_property_array(prop, 2); RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv4_get", "rna_MeshTextureFace_uv4_set", NULL); RNA_def_property_ui_text(prop, "UV 4", ""); @@ -1066,7 +1066,7 @@ static void rna_def_msticky(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Mesh Vertex Sticky Texture Coordinate", "Stricky texture coordinate."); RNA_def_struct_path_func(srna, "rna_MeshSticky_path"); - prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_XYZ); RNA_def_property_ui_text(prop, "Location", "Sticky texture coordinate location."); } @@ -1216,18 +1216,18 @@ void rna_def_texmat_common(StructRNA *srna, const char *texspace_editable) RNA_def_property_boolean_sdna(prop, NULL, "texflag", AUTOSPACE); RNA_def_property_ui_text(prop, "Auto Texture Space", "Adjusts active object's texture space automatically when transforming object."); - prop= RNA_def_property(srna, "texspace_loc", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "texspace_loc", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_ui_text(prop, "Texure Space Location", "Texture space location."); RNA_def_property_editable_func(prop, texspace_editable); - prop= RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size."); RNA_def_property_editable_func(prop, texspace_editable); /* not supported yet - prop= RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_EULER); RNA_def_property_float(prop, NULL, "rot"); RNA_def_property_ui_text(prop, "Texture Space Rotation", "Texture space rotation"); RNA_def_property_editable_func(prop, texspace_editable);*/ @@ -1352,6 +1352,64 @@ static void rna_def_mesh(BlenderRNA *brna) prop= RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "key"); RNA_def_property_ui_text(prop, "Shape Keys", ""); + + /* Mesh Draw Options for Edit Mode*/ + + prop= RNA_def_property(srna, "draw_edges", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEDGES); + RNA_def_property_ui_text(prop, "Draw Edges", "Displays selected edges using hilights in the 3d view and UV editor"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_faces", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWFACES); + RNA_def_property_ui_text(prop, "Draw Faces", "Displays all faces as shades in the 3d view and UV editor"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_normals", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWNORMALS); + RNA_def_property_ui_text(prop, "Draw Normals", "Displays face normals as lines"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_vertex_normals", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_VNORMALS); + RNA_def_property_ui_text(prop, "Draw Vertex Normals", "Displays vertex normals as lines"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_creases", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWCREASES); + RNA_def_property_ui_text(prop, "Draw Creases", "Displays creases created for subsurf weighting"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_bevel_weights", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWBWEIGHTS); + RNA_def_property_ui_text(prop, "Draw Bevel Weights", "Displays weights created for the Bevel modifier"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_seams", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWSEAMS); + RNA_def_property_ui_text(prop, "Draw Seams", "Displays UV unwrapping seams"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_sharp", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWSHARP); + RNA_def_property_ui_text(prop, "Draw Sharp", "Displays sharp edges, used with the EdgeSplit modifier"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + + prop= RNA_def_property(srna, "draw_edge_lenght", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_EDGELEN); + RNA_def_property_ui_text(prop, "Edge Length", "Displays selected edge lengths"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_edge_angle", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_EDGEANG); + RNA_def_property_ui_text(prop, "Edge Angles", "Displays the angles in the selected edges in degrees"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "draw_face_area", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_FACEAREA); + RNA_def_property_ui_text(prop, "Face Area", "Displays the area of selected faces"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); rna_def_texmat_common(srna, "rna_Mesh_texspace_editable"); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index df26e6b8121..7b14a7a4712 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -37,7 +37,9 @@ #include "DNA_scene_types.h" #include "DNA_object_types.h" +#include "BKE_mball.h" #include "BKE_depsgraph.h" +#include "BKE_main.h" #include "WM_types.h" #include "WM_api.h" @@ -50,11 +52,19 @@ static int rna_Meta_texspace_editable(PointerRNA *ptr) static void rna_MetaBall_update_data(bContext *C, PointerRNA *ptr) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); - DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + MetaBall *mb= ptr->id.data; + Object *ob; + + for(ob=bmain->object.first; ob; ob= ob->id.next) { + if(ob->data == mb) { + copy_mball_properties(scene, ob); + /* XXX this will loop over all objects again (slow) */ + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + } + } } #else @@ -83,35 +93,35 @@ void rna_def_metaelement(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); /* number values */ - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "x"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Location", ""); RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "quat"); RNA_def_property_ui_text(prop, "Rotation", ""); RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); - prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_UNSIGNED); + prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_UNSIGNED|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "rad"); RNA_def_property_ui_text(prop, "Radius", ""); RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); - prop= RNA_def_property(srna, "sizex", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "size_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "expx"); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_text(prop, "Size X", "Size of element, use of components depends on element type."); RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); - prop= RNA_def_property(srna, "sizey", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "expy"); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_text(prop, "Size Y", "Size of element, use of components depends on element type."); RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); - prop= RNA_def_property(srna, "sizez", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "size_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "expz"); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_text(prop, "Size Z", "Size of element, use of components depends on element type."); @@ -155,7 +165,7 @@ void rna_def_metaball(BlenderRNA *brna) RNA_def_property_struct_type(prop, "MetaElement"); RNA_def_property_ui_text(prop, "Elements", "Meta elements."); - prop= RNA_def_property(srna, "last_selected_element", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "active_element", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "lastelem"); RNA_def_property_ui_text(prop, "Last selected element.", "Last selected element."); @@ -166,16 +176,17 @@ void rna_def_metaball(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); /* number values */ - prop= RNA_def_property(srna, "wire_size", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "wire_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "wiresize"); RNA_def_property_range(prop, 0.050f, 1.0f); RNA_def_property_ui_text(prop, "Wire Size", "Polygonization resolution in the 3D viewport."); RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); - prop= RNA_def_property(srna, "render_size", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "render_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "rendersize"); RNA_def_property_range(prop, 0.050f, 1.0f); RNA_def_property_ui_text(prop, "Render Size", "Polygonization resolution in rendering."); + RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); prop= RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "thresh"); @@ -185,6 +196,9 @@ void rna_def_metaball(BlenderRNA *brna) /* materials, textures */ rna_def_texmat_common(srna, "rna_Meta_texspace_editable"); + + /* anim */ + rna_def_animdata_common(srna); } void RNA_def_meta(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 80bc46bb2f0..837158b9ec8 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -62,15 +62,15 @@ EnumPropertyItem modifier_type_items[] ={ {eModifierType_Mask, "MASK", ICON_MOD_MASK, "Mask", ""}, {eModifierType_MeshDeform, "MESH_DEFORM", ICON_MOD_MESHDEFORM, "Mesh Deform", ""}, {eModifierType_Mirror, "MIRROR", ICON_MOD_MIRROR, "Mirror", ""}, - {eModifierType_Multires, "MULTIRES", ICON_MOD_MULTIRES, "Multires", ""}, + {eModifierType_Multires, "MULTIRES", ICON_MOD_MULTIRES, "Multiresolution", ""}, {eModifierType_ParticleInstance, "PARTICLE_INSTANCE", ICON_MOD_PARTICLES, "Particle Instance", ""}, {eModifierType_ParticleSystem, "PARTICLE_SYSTEM", ICON_MOD_PARTICLES, "Particle System", ""}, {eModifierType_Shrinkwrap, "SHRINKWRAP", ICON_MOD_SHRINKWRAP, "Shrinkwrap", ""}, {eModifierType_SimpleDeform, "SIMPLE_DEFORM", ICON_MOD_SIMPLEDEFORM, "Simple Deform", ""}, {eModifierType_Smoke, "SMOKE", 0, "Smoke", ""}, {eModifierType_Smooth, "SMOOTH", ICON_MOD_SMOOTH, "Smooth", ""}, - {eModifierType_Softbody, "SOFTBODY", ICON_MOD_SOFT, "Soft Body", ""}, - {eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subsurf", ""}, + {eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""}, + {eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""}, {eModifierType_Surface, "SURFACE", ICON_MOD_PHYSICS, "Surface", ""}, {eModifierType_UVProject, "UV_PROJECT", ICON_MOD_UVPROJECT, "UV Project", ""}, {eModifierType_Wave, "WAVE", ICON_MOD_WAVE, "Wave", ""}, @@ -538,12 +538,12 @@ static void rna_def_modifier_build(BlenderRNA *brna) RNA_def_struct_sdna(srna, "BuildModifierData"); RNA_def_struct_ui_icon(srna, ICON_MOD_BUILD); - prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_TIME); RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Start", "Specify the start frame of the effect."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "length", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "length", PROP_FLOAT, PROP_TIME); RNA_def_property_range(prop, 1, MAXFRAMEF); RNA_def_property_ui_text(prop, "Length", "Specify the total time the build effect requires"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); @@ -697,32 +697,32 @@ static void rna_def_modifier_wave(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Time Offset", "Either the starting frame (for positive speed) or ending frame (for negative speed.)"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_TIME); RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Lifetime", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "damping_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "damping_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "damp"); RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Damping Time", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "falloff"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 100, 2); RNA_def_property_ui_text(prop, "Falloff Radius", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "start_position_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start_position_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "startx"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -100, 100, 100, 2); RNA_def_property_ui_text(prop, "Start Position X", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "start_position_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start_position_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "starty"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -100, 100, 100, 2); @@ -853,7 +853,7 @@ static void rna_def_modifier_hook(BlenderRNA *brna) RNA_def_struct_sdna(srna, "HookModifierData"); RNA_def_struct_ui_icon(srna, ICON_HOOK); - prop= RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 100, 2); RNA_def_property_ui_text(prop, "Falloff", "If not zero, the distance from the hook where influence ends."); @@ -953,7 +953,7 @@ static void rna_def_modifier_array(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Count", "Number of duplicates to make."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "length", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "length", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_range(prop, 0, INT_MAX); RNA_def_property_ui_range(prop, 0, 10000, 10, 2); RNA_def_property_ui_text(prop, "Length", "Length to fit array within."); @@ -967,22 +967,22 @@ static void rna_def_modifier_array(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); /* Offset parameters */ - prop= RNA_def_property(srna, "constant_offset", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "constant_offset", PROP_BOOLEAN, PROP_TRANSLATION); RNA_def_property_boolean_sdna(prop, NULL, "offset_type", MOD_ARR_OFF_CONST); RNA_def_property_ui_text(prop, "Constant Offset", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "constant_offset_displacement", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "constant_offset_displacement", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "offset"); RNA_def_property_ui_text(prop, "Constant Offset Displacement", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "relative_offset", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "relative_offset", PROP_BOOLEAN, PROP_TRANSLATION); RNA_def_property_boolean_sdna(prop, NULL, "offset_type", MOD_ARR_OFF_RELATIVE); RNA_def_property_ui_text(prop, "Relative Offset", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "relative_offset_displacement", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "relative_offset_displacement", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "scale"); RNA_def_property_ui_text(prop, "Relative Offset Displacement", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); @@ -998,7 +998,7 @@ static void rna_def_modifier_array(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Merge Vertices", "Merge vertices in first and last duplicates."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "merge_distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "merge_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "merge_dist"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 1, 1, 4); @@ -1280,7 +1280,7 @@ static void rna_def_modifier_cast(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Factor", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 10, 2); RNA_def_property_ui_text(prop, "Radius", "Only deform vertices within this distance from the center of the effect (leave as 0 for infinite.)"); @@ -1860,7 +1860,7 @@ void RNA_def_modifier(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Realtime); RNA_def_property_ui_text(prop, "Realtime", "Realtime display of a modifier."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); - RNA_def_property_ui_icon(prop, ICON_VIEW3D, 0); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 0); prop= RNA_def_property(srna, "render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Render); diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 3b55da046b8..98c72b7ee74 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -297,12 +297,12 @@ void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Blending", "Method used for combining strip's result with accumulated result."); /* Strip extents */ - prop= RNA_def_property(srna, "start_frame", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start_frame", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "start"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Start Frame", ""); - prop= RNA_def_property(srna, "end_frame", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "end_frame", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "end"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_end_frame_set", NULL); RNA_def_property_ui_text(prop, "End Frame", ""); @@ -328,12 +328,12 @@ void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Action", "Action referenced by this strip."); /* Action extents */ - prop= RNA_def_property(srna, "action_start_frame", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "action_start_frame", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "actstart"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_action_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Action Start Frame", ""); - prop= RNA_def_property(srna, "action_end_frame", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "action_end_frame", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "actend"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_action_end_frame_set", NULL); RNA_def_property_ui_text(prop, "Action End Frame", ""); @@ -371,7 +371,7 @@ void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Influence", "Amount the strip contributes to the current result."); - prop= RNA_def_property(srna, "strip_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "strip_time", PROP_FLOAT, PROP_TIME); RNA_def_property_ui_text(prop, "Strip Time", "Frame of referenced Action to evaluate."); // TODO: should the animated_influence/time settings be animatable themselves? diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index a03b59556e1..23e79831292 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1354,7 +1354,7 @@ static void rna_def_node(BlenderRNA *brna) RNA_def_struct_sdna(srna, "bNode"); RNA_def_struct_refine_func(srna, "rna_Node_refine"); - prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "locx"); RNA_def_property_array(prop, 2); RNA_def_property_range(prop, -10000.0f, 10000.0f); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 32307709387..0b77390095e 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -41,6 +41,18 @@ #include "WM_types.h" + +EnumPropertyItem object_mode_items[] = { + {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object", ""}, + {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit", ""}, + {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""}, + {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""}, + {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""}, + {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""}, + {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""}, + {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose", ""}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem parent_type_items[] = { {PAROBJECT, "OBJECT", 0, "Object", ""}, {PARCURVE, "CURVE", 0, "Curve", ""}, @@ -57,6 +69,7 @@ static EnumPropertyItem parent_type_items[] = { #include "DNA_key_types.h" #include "BKE_armature.h" +#include "BKE_bullet.h" #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_depsgraph.h" @@ -485,6 +498,86 @@ static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str) strcpy(str, ""); } +/* why does this have to be so complicated?, can't all this crap be + * moved to in BGE conversion function? - Campbell * + * + * logic from check_body_type() + * */ +static int rna_GameObjectSettings_physics_type_get(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + + /* determine the body_type setting based on flags */ + if (!(ob->gameflag & OB_COLLISION)) { + if (ob->gameflag & OB_OCCLUDER) { + ob->body_type = OB_BODY_TYPE_OCCLUDER; + } else { + ob->body_type = OB_BODY_TYPE_NO_COLLISION; + } + } else if (ob->gameflag & OB_SENSOR) { + ob->body_type = OB_BODY_TYPE_SENSOR; + } else if (!(ob->gameflag & OB_DYNAMIC)) { + ob->body_type = OB_BODY_TYPE_STATIC; + } else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY))) { + ob->body_type = OB_BODY_TYPE_DYNAMIC; + } else if (ob->gameflag & OB_RIGID_BODY) { + ob->body_type = OB_BODY_TYPE_RIGID; + } else { + ob->body_type = OB_BODY_TYPE_SOFT; + /* create the structure here because we display soft body buttons in the main panel */ + if (!ob->bsoft) + ob->bsoft = bsbNew(); + } + + return ob->body_type; +} + +static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value) +{ + Object *ob= (Object*)ptr->id.data; + ob->body_type= value; + + switch (ob->body_type) { + case OB_BODY_TYPE_SENSOR: + ob->gameflag |= OB_SENSOR|OB_COLLISION|OB_GHOST; + ob->gameflag &= ~(OB_OCCLUDER|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_ACTOR|OB_ANISOTROPIC_FRICTION|OB_DO_FH|OB_ROT_FH|OB_COLLISION_RESPONSE); + break; + case OB_BODY_TYPE_OCCLUDER: + ob->gameflag |= OB_OCCLUDER; + ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_DYNAMIC); + break; + case OB_BODY_TYPE_NO_COLLISION: + ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_OCCLUDER|OB_DYNAMIC); + break; + case OB_BODY_TYPE_STATIC: + ob->gameflag |= OB_COLLISION; + ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR); + break; + case OB_BODY_TYPE_DYNAMIC: + ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_ACTOR; + ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR); + break; + case OB_BODY_TYPE_RIGID: + ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_RIGID_BODY|OB_ACTOR; + ob->gameflag &= ~(OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR); + break; + default: + case OB_BODY_TYPE_SOFT: + ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_SOFT_BODY|OB_ACTOR; + ob->gameflag &= ~(OB_RIGID_BODY|OB_OCCLUDER|OB_SENSOR); + + /* assume triangle mesh, if no bounds chosen for soft body */ + if ((ob->gameflag & OB_BOUNDS) && (ob->boundtypeboundtype=OB_BOUND_POLYH; + } + /* create a BulletSoftBody structure if not already existing */ + if (!ob->bsoft) + ob->bsoft = bsbNew(); + break; + } +} + static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr) { Object *ob= (Object*)ptr->id.data; @@ -683,11 +776,13 @@ static void rna_def_object_game_settings(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem body_type_items[] = { - {OB_BODY_TYPE_NO_COLLISION, "NO_COLLISION", 0, "No Collision", ""}, - {OB_BODY_TYPE_STATIC, "STATIC", 0, "Static", ""}, - {OB_BODY_TYPE_DYNAMIC, "DYNAMIC", 0, "Dynamic", ""}, - {OB_BODY_TYPE_RIGID, "RIGID_BODY", 0, "Rigid Body", ""}, - {OB_BODY_TYPE_SOFT, "SOFT_BODY", 0, "Soft Body", ""}, + {OB_BODY_TYPE_NO_COLLISION, "NO_COLLISION", 0, "No Collision", "Disable colision for this object"}, + {OB_BODY_TYPE_STATIC, "STATIC", 0, "Static", "Stationary object"}, + {OB_BODY_TYPE_DYNAMIC, "DYNAMIC", 0, "Dynamic", "Linear physics"}, + {OB_BODY_TYPE_RIGID, "RIGID_BODY", 0, "Rigid Body", "Linear and angular physics"}, + {OB_BODY_TYPE_SOFT, "SOFT_BODY", 0, "Soft Body", "Soft body"}, + {OB_BODY_TYPE_OCCLUDER, "OCCLUDE", 0, "Occlude", "Occluder for optimizing scene rendering"}, + {OB_BODY_TYPE_SENSOR, "SENSOR", 0, "Sensor", "Collision Sensor, detects static and dynamic objects but not the other collision sensor objects"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem collision_bounds_items[] = { @@ -742,7 +837,7 @@ static void rna_def_object_game_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "physics_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "body_type"); RNA_def_property_enum_items(prop, body_type_items); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // this controls various gameflags + RNA_def_property_enum_funcs(prop, "rna_GameObjectSettings_physics_type_get", "rna_GameObjectSettings_physics_type_set", NULL); RNA_def_property_ui_text(prop, "Physics Type", "Selects the type of physical representation."); prop= RNA_def_property(srna, "actor", PROP_BOOLEAN, PROP_NONE); @@ -757,10 +852,10 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0.01, 10000.0); RNA_def_property_ui_text(prop, "Mass", "Mass of the object."); - prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "inertia"); RNA_def_property_range(prop, 0.01, 10.0); - RNA_def_property_ui_text(prop, "Radius", "Radius for Bounding sphere and Fh/Fh Rot."); + RNA_def_property_ui_text(prop, "Radius", "Radius of bounding sphere and material physics"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); prop= RNA_def_property(srna, "no_sleeping", PROP_BOOLEAN, PROP_NONE); @@ -820,13 +915,13 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis."); - prop= RNA_def_property(srna, "do_fh", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "material_physics", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_DO_FH); - RNA_def_property_ui_text(prop, "Do Fh", "Use Fh settings in materials."); + RNA_def_property_ui_text(prop, "Use Material Physics", "Use physics settings in materials."); - prop= RNA_def_property(srna, "rotation_fh", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "rotate_from_normal", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ROT_FH); - RNA_def_property_ui_text(prop, "Rotation Fh", "Use face normal to rotate Object"); + RNA_def_property_ui_text(prop, "Rotate From Normal", "Use face normal to rotate object, so that it points away from the surface"); prop= RNA_def_property(srna, "form_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "formfactor"); @@ -837,7 +932,7 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ANISOTROPIC_FRICTION); RNA_def_property_ui_text(prop, "Anisotropic Friction", "Enable anisotropic friction."); - prop= RNA_def_property(srna, "friction_coefficients", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "friction_coefficients", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "anisotropicFriction"); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_ui_text(prop, "Friction Coefficients", "Relative friction coefficient in the in the X, Y and Z directions, when anisotropic friction is enabled."); @@ -855,7 +950,7 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_CHILD); RNA_def_property_ui_text(prop, "Collison Compound", "Add children to form a compound collision object."); - prop= RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "margin"); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_ui_text(prop, "Collision Margin", "Extra margin around object for collision detection, small amount required for stability."); @@ -969,6 +1064,12 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Type", "Type of Object."); + prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, object_mode_items); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Mode", "Object interaction mode."); + prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); RNA_def_property_array(prop, 20); @@ -1057,47 +1158,47 @@ static void rna_def_object(BlenderRNA *brna) /* transform */ - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_ui_text(prop, "Location", "Location of the object."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); - prop= RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "dloc"); RNA_def_property_ui_text(prop, "Delta Location", "Extra added translation to object location."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "rot"); RNA_def_property_ui_text(prop, "Rotation", "Rotation of the object."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); - prop= RNA_def_property(srna, "delta_rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "delta_rotation", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "drot"); RNA_def_property_ui_text(prop, "Delta Rotation", "Extra added rotation to the rotation of the object."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); - prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_ui_text(prop, "Scale", "Scaling of the object."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); - prop= RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "dsize"); RNA_def_property_ui_text(prop, "Delta Scale", "Extra added scaling to the scale of the object."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); - prop= RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface."); - prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface."); - prop= RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface."); @@ -1152,7 +1253,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Empty Draw Type", "Viewport display style for empties."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); - prop= RNA_def_property(srna, "empty_draw_size", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "empty_draw_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "empty_drawsize"); RNA_def_property_range(prop, 0.01, 10.0); RNA_def_property_ui_text(prop, "Empty Draw Size", "Size of of display for empties in the viewport."); @@ -1278,25 +1379,25 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Dupli Group", "Instance an existing group."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); - prop= RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE|PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupsta"); RNA_def_property_range(prop, 1, 32767); RNA_def_property_ui_text(prop, "Dupli Frames Start", "Start frame for DupliFrames."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); - prop= RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE|PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupend"); RNA_def_property_range(prop, 1, 32767); RNA_def_property_ui_text(prop, "Dupli Frames End", "End frame for DupliFrames."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); - prop= RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE|PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupon"); RNA_def_property_range(prop, 1, 1500); RNA_def_property_ui_text(prop, "Dupli Frames On", "Number of frames to use between DupOff frames."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); - prop= RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE|PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupoff"); RNA_def_property_range(prop, 0, 1500); RNA_def_property_ui_text(prop, "Dupli Frames Off", "Recurring frames to exclude from the Dupliframes."); @@ -1310,7 +1411,7 @@ static void rna_def_object(BlenderRNA *brna) /* time offset */ - prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE|PROP_UNIT_TIME); RNA_def_property_float_sdna(prop, NULL, "sf"); RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Time Offset", "Animation offset in frames for IPO's and dupligroup instances."); @@ -1395,11 +1496,6 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Pose"); RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures."); - prop= RNA_def_property(srna, "pose_mode", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_POSEMODE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Pose Mode", "Object with armature data is in pose mode."); - /* shape keys */ prop= RNA_def_property(srna, "shape_key_lock", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index e229afedc62..932bef9969d 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -148,6 +148,7 @@ static void rna_Cache_idname_change(bContext *C, PointerRNA *ptr) if(new_name) { if(pid2 && cache->flag & PTCACHE_DISK_CACHE) { + /* TODO: change to simple file rename */ strcpy(name, cache->name); strcpy(cache->name, cache->prev_name); @@ -169,6 +170,87 @@ static void rna_Cache_idname_change(bContext *C, PointerRNA *ptr) BLI_freelistN(&pidlist); } +static void rna_Cache_list_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Object *ob = ptr->id.data; + PointCache *cache= ptr->data; + PTCacheID *pid; + ListBase pidlist; + + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + rna_iterator_listbase_begin(iter, pid->ptcaches, NULL); + break; + } + } + + BLI_freelistN(&pidlist); +} +static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min, int *max) +{ + Object *ob = ptr->id.data; + PointCache *cache= ptr->data; + PTCacheID *pid; + ListBase pidlist; + + BKE_ptcache_ids_from_object(&pidlist, ob); + + *min= 0; + *max= 0; + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + *max= BLI_countlist(pid->ptcaches)-1; + *max= MAX2(0, *max); + break; + } + } + + BLI_freelistN(&pidlist); +} + +static int rna_Cache_active_point_cache_index_get(PointerRNA *ptr) +{ + Object *ob = ptr->id.data; + PointCache *cache= ptr->data; + PTCacheID *pid; + ListBase pidlist; + int num = 0; + + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + num = BLI_findindex(pid->ptcaches, cache); + break; + } + } + + BLI_freelistN(&pidlist); + + return num; +} + +static void rna_Cache_active_point_cache_index_set(struct PointerRNA *ptr, int value) +{ + Object *ob = ptr->id.data; + PointCache *cache= ptr->data; + PTCacheID *pid; + ListBase pidlist; + + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache == cache) { + *(pid->cache_ptr) = BLI_findlink(pid->ptcaches, value); + break; + } + } + + BLI_freelistN(&pidlist); +} static int rna_SoftBodySettings_use_edges_get(PointerRNA *ptr) { Object *data= (Object*)(ptr->id.data); @@ -371,13 +453,14 @@ static void rna_def_pointcache(BlenderRNA *brna) srna= RNA_def_struct(brna, "PointCache", NULL); RNA_def_struct_ui_text(srna, "Point Cache", "Point cache for physics simulations."); + RNA_def_struct_ui_icon(srna, ICON_PHYSICS); - prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "startframe"); RNA_def_property_range(prop, 1, 300000); RNA_def_property_ui_text(prop, "Start", "Frame on which the simulation starts."); - prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "endframe"); RNA_def_property_range(prop, 1, 300000); RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops."); @@ -420,6 +503,7 @@ static void rna_def_pointcache(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Name", "Cache name"); RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); + RNA_def_struct_name_property(srna, prop); prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_DIRPATH); RNA_def_property_string_sdna(prop, NULL, "path"); @@ -440,6 +524,16 @@ static void rna_def_pointcache(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_EXTERNAL); RNA_def_property_ui_text(prop, "External", "Read cache from an external location"); RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); + + prop= RNA_def_property(srna, "point_cache_list", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_funcs(prop, "rna_Cache_list_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); + RNA_def_property_struct_type(prop, "PointCache"); + RNA_def_property_ui_text(prop, "Point Cache List", "Point cache list"); + + prop= RNA_def_property(srna, "active_point_cache_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_funcs(prop, "rna_Cache_active_point_cache_index_get", "rna_Cache_active_point_cache_index_set", "rna_Cache_active_point_cache_index_range"); + RNA_def_property_ui_text(prop, "Active Point Cache Index", ""); + RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change"); } static void rna_def_collision(BlenderRNA *brna) @@ -770,13 +864,13 @@ static void rna_def_game_softbody(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_BSB_BENDING_CONSTRAINTS); RNA_def_property_ui_text(prop, "Bending Const", "Enable bending constraints"); - prop= RNA_def_property(srna, "enable_rs_collision", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "cluster_rigid_to_softbody", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "collisionflags", OB_BSB_COL_CL_RS); - RNA_def_property_ui_text(prop, "Cluster Collision RS", "Enable cluster collision between soft and rigid body"); + RNA_def_property_ui_text(prop, "Rigid to Soft Body", "Enable cluster collision between soft and rigid body"); - prop= RNA_def_property(srna, "enable_ss_collision", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "cluster_soft_to_softbody", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "collisionflags", OB_BSB_COL_CL_SS); - RNA_def_property_ui_text(prop, "Cluster Collision SS", "Enable cluster collision between soft and soft body"); + RNA_def_property_ui_text(prop, "Soft to Soft Body", "Enable cluster collision between soft and soft body"); } static void rna_def_softbody(BlenderRNA *brna) @@ -810,7 +904,7 @@ static void rna_def_softbody(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mass", ""); RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); - prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_float_sdna(prop, NULL, "grav"); RNA_def_property_range(prop, -10.0f, 10.0f); RNA_def_property_ui_text(prop, "Gravitation", "Apply gravitation to point movement"); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 3ebdd61ca50..e0dbc232e06 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -536,7 +536,7 @@ static void rna_def_particle_hair_key(BlenderRNA *brna) RNA_def_struct_sdna(srna, "HairKey"); RNA_def_struct_ui_text(srna, "Particle Hair Key", "Particle key for hair particle system."); - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "co"); RNA_def_property_ui_text(prop, "Location", "Key location."); @@ -555,19 +555,19 @@ static void rna_def_particle_key(BlenderRNA *brna) srna = RNA_def_struct(brna, "ParticleKey", NULL); RNA_def_struct_ui_text(srna, "Particle Key", "Key location for a particle over time."); - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "co"); RNA_def_property_ui_text(prop, "Location", "Key location."); - prop= RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "vel"); RNA_def_property_ui_text(prop, "Velocity", "Key velocity"); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "rot"); RNA_def_property_ui_text(prop, "Rotation", "Key rotation quaterion."); - prop= RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "ave"); RNA_def_property_ui_text(prop, "Angular Velocity", "Key angular velocity."); @@ -616,35 +616,35 @@ static void rna_def_particle(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Stick Object", "Object that particle sticks to when dead"); /* Particle State & Previous State */ - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "state.co"); RNA_def_property_ui_text(prop, "Particle Location", ""); - prop= RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "state.vel"); RNA_def_property_ui_text(prop, "Particle Velocity", ""); - prop= RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "state.ave"); RNA_def_property_ui_text(prop, "Angular Velocity", ""); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "state.rot"); RNA_def_property_ui_text(prop, "Rotation", ""); - prop= RNA_def_property(srna, "prev_location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "prev_location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "prev_state.co"); RNA_def_property_ui_text(prop, "Previous Particle Location", ""); - prop= RNA_def_property(srna, "prev_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "prev_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "prev_state.vel"); RNA_def_property_ui_text(prop, "Previous Particle Velocity", ""); - prop= RNA_def_property(srna, "prev_angular_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "prev_angular_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "prev_state.ave"); RNA_def_property_ui_text(prop, "Previous Angular Velocity", ""); - prop= RNA_def_property(srna, "prev_rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "prev_rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "prev_state.rot"); RNA_def_property_ui_text(prop, "Previous Rotation", ""); @@ -662,17 +662,17 @@ static void rna_def_particle(BlenderRNA *brna) /* Random variables */ - prop= RNA_def_property(srna, "random_rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "random_rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "r_rot"); // RNA_def_property_range(prop, lowerLimitf, upperLimitf); RNA_def_property_ui_text(prop, "Random Rotation", ""); - prop= RNA_def_property(srna, "random_a_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "random_a_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "r_ave"); // RNA_def_property_range(prop, lowerLimitf, upperLimitf); RNA_def_property_ui_text(prop, "Random Angular Velocity", ""); - prop= RNA_def_property(srna, "random_velocity", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "random_velocity", PROP_FLOAT, PROP_VELOCITY); RNA_def_property_float_sdna(prop, NULL, "r_ve"); // RNA_def_property_range(prop, lowerLimitf, upperLimitf); RNA_def_property_ui_text(prop, "Random Velocity", ""); @@ -681,16 +681,16 @@ static void rna_def_particle(BlenderRNA *brna) // float fuv[4], foffset; /* coordinates on face/edge number "num" and depth along*/ // /* face normal for volume emission */ - prop= RNA_def_property(srna, "birthtime", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "birthtime", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "time"); // RNA_def_property_range(prop, lowerLimitf, upperLimitf); RNA_def_property_ui_text(prop, "Birth Time", ""); - prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_TIME); // RNA_def_property_range(prop, lowerLimitf, upperLimitf); RNA_def_property_ui_text(prop, "Lifetime", ""); - prop= RNA_def_property(srna, "die_time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "die_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "dietime"); // RNA_def_property_range(prop, lowerLimitf, upperLimitf); RNA_def_property_ui_text(prop, "Die Time", ""); @@ -1261,7 +1261,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Random Tilt", "Random tilt of the billboards"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); - prop= RNA_def_property(srna, "billboard_offset", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "billboard_offset", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "bb_offset"); RNA_def_property_array(prop, 2); RNA_def_property_range(prop, -100.0f, 100.0f); @@ -1312,7 +1312,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "End", "Frame # to stop emitting particles."); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); - prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_TIME); RNA_def_property_range(prop, 1.0f, MAXFRAMEF); RNA_def_property_ui_text(prop, "Lifetime", "Specify the life span of the particles"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); @@ -1465,14 +1465,14 @@ static void rna_def_particle_settings(BlenderRNA *brna) /* global physical properties */ - prop= RNA_def_property(srna, "acceleration", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "acceleration", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_float_sdna(prop, NULL, "acc"); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -200.0f, 200.0f); RNA_def_property_ui_text(prop, "Acceleration", "Constant acceleration"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); - prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_float_sdna(prop, NULL, "acc[2]"); RNA_def_property_range(prop, -200.0f, 200.0f); RNA_def_property_ui_text(prop, "Gravity", "Constant acceleration in global Z axis direction"); @@ -1837,7 +1837,7 @@ static void rna_def_particle_target(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Target Particle System", "The index of particle system on the target object."); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_target_reset"); - prop= RNA_def_property(srna, "time", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "time"); RNA_def_property_range(prop, 0.0, 30000.0f); //TODO: replace 30000 with MAXFRAMEF when available in 2.5 RNA_def_property_ui_text(prop, "Time", ""); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 48637829741..9e4af513062 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -358,13 +358,13 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "agrp_index"); RNA_def_property_ui_text(prop, "Bone Group Index", "Bone Group this pose channel belongs to (0=no group)."); - prop= RNA_def_property(srna, "path_start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "path_start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "pathsf"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bone Paths Calculation Start Frame", "Starting frame of range of frames to use for Bone Path calculations."); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "pathef"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bone Paths Calculation End Frame", "End frame of range of frames to use for Bone Path calculations."); @@ -385,22 +385,22 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Child", "Child of this pose channel."); - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_ui_text(prop, "Location", ""); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_ui_text(prop, "Scale", ""); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "quat"); RNA_def_property_ui_text(prop, "Rotation", "Rotation in Quaternions."); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "euler_rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "euler_rotation", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "eul"); RNA_def_property_float_funcs(prop, "rna_PoseChannel_euler_rotation_get", "rna_PoseChannel_euler_rotation_set", NULL); RNA_def_property_ui_text(prop, "Rotation (Euler)", "Rotation in Eulers."); @@ -433,45 +433,45 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Constraint Inverse Matrix", "4x4 matrix, defines transform from final position to unconstrained position."); */ - prop= RNA_def_property(srna, "pose_head", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "pose_head", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Pose Head Position", "Location of head of the channel's bone."); - prop= RNA_def_property(srna, "pose_tail", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "pose_tail", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Pose Tail Position", "Location of tail of the channel's bone."); - prop= RNA_def_property(srna, "ik_min_x", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "ik_min_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmin[0]"); RNA_def_property_range(prop, -180.0f, 0.0f); RNA_def_property_ui_text(prop, "IK X Minimum", "Minimum angles for IK Limit"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "ik_max_x", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "ik_max_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmax[0]"); RNA_def_property_range(prop, 0.0f, 180.0f); RNA_def_property_ui_text(prop, "IK X Maximum", "Maximum angles for IK Limit"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "ik_min_y", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "ik_min_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmin[1]"); RNA_def_property_range(prop, -180.0f, 0.0f); RNA_def_property_ui_text(prop, "IK Y Minimum", "Minimum angles for IK Limit"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "ik_max_y", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "ik_max_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmax[1]"); RNA_def_property_range(prop, 0.0f, 180.0f); RNA_def_property_ui_text(prop, "IK Y Maximum", "Maximum angles for IK Limit"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "ik_min_z", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "ik_min_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmin[2]"); RNA_def_property_range(prop, -180.0f, 0.0f); RNA_def_property_ui_text(prop, "IK Z Minimum", "Minimum angles for IK Limit"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "ik_max_z", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "ik_max_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmax[2]"); RNA_def_property_range(prop, 0.0f, 180.0f); RNA_def_property_ui_text(prop, "IK Z Maximum", "Maximum angles for IK Limit"); @@ -505,17 +505,17 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Custom Object", "Object that defines custom draw type for this bone."); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); - prop= RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface."); - prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface."); - prop= RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_VECTOR); + prop= RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface."); diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 7268d560282..9137e596da1 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -106,11 +106,12 @@ static void rna_RenderEngine_unregister(const bContext *C, StructRNA *type) if(!et) return; + RNA_struct_free_extension(type, &et->ext); BLI_freelinkN(&R_engines, et); RNA_struct_free(&BLENDER_RNA, type); } -static StructRNA *rna_RenderEngine_register(const bContext *C, ReportList *reports, void *data, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_RenderEngine_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { RenderEngineType *et, dummyet = {0}; RenderEngine dummyengine= {0}; @@ -272,10 +273,17 @@ static void rna_def_render_result(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + FunctionRNA *func; srna= RNA_def_struct(brna, "RenderResult", NULL); RNA_def_struct_ui_text(srna, "Render Result", "Result of rendering, including all layers and passes."); + func= RNA_def_function(srna, "load_from_file", "RE_result_load_from_file"); + RNA_def_function_ui_description(func, "Copies the pixels of this render result from an image file."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + prop= RNA_def_string(func, "filename", "", 0, "Filename", "Filename to load into this render tile, must be no smaller then the render result"); + RNA_def_property_flag(prop, PROP_REQUIRED); + RNA_define_verify_sdna(0); prop= RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE); @@ -302,15 +310,11 @@ static void rna_def_render_layer(BlenderRNA *brna) srna= RNA_def_struct(brna, "RenderLayer", NULL); RNA_def_struct_ui_text(srna, "Render Layer", ""); - func= RNA_def_function(srna, "rect_from_file", "RE_layer_rect_from_file"); + func= RNA_def_function(srna, "load_from_file", "RE_layer_load_from_file"); RNA_def_function_ui_description(func, "Copies the pixels of this renderlayer from an image file."); RNA_def_function_flag(func, FUNC_USE_REPORTS); prop= RNA_def_string(func, "filename", "", 0, "Filename", "Filename to load into this render tile, must be no smaller then the renderlayer"); RNA_def_property_flag(prop, PROP_REQUIRED); - prop= RNA_def_int(func, "x", 0, 0, INT_MAX, "Offset X", "Offset the position to copy from if the image is larger then the render layer", 0, INT_MAX); - RNA_def_property_flag(prop, PROP_REQUIRED); - prop= RNA_def_int(func, "y", 0, 0, INT_MAX, "Offset Y", "Offset the position to copy from if the image is larger then the render layer", 0, INT_MAX); - RNA_def_property_flag(prop, PROP_REQUIRED); RNA_define_verify_sdna(0); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 385c7f5b2b1..57ed5ccef39 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -407,12 +407,25 @@ static int rna_Property_subtype_get(PointerRNA *ptr) return prop->subtype; } +static int rna_Property_unit_get(PointerRNA *ptr) +{ + PropertyRNA *prop= (PropertyRNA*)ptr->data; + rna_idproperty_check(&prop, ptr); + return RNA_SUBTYPE_UNIT(prop->subtype); +} + static int rna_Property_editable_get(PointerRNA *ptr) { PropertyRNA *prop= (PropertyRNA*)ptr->data; return RNA_property_editable(ptr, prop); } +static int rna_Property_use_return_get(PointerRNA *ptr) +{ + PropertyRNA *prop= (PropertyRNA*)ptr->data; + return prop->flag & PROP_RETURN ? 1:0; +} + static int rna_Property_array_length_get(PointerRNA *ptr) { PropertyRNA *prop= (PropertyRNA*)ptr->data; @@ -769,15 +782,32 @@ static void rna_def_property(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem subtype_items[] = { {PROP_NONE, "NONE", 0, "None", ""}, - {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned Number", ""}, {PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""}, {PROP_DIRPATH, "DIRECTORY_PATH", 0, "Directory Path", ""}, - {PROP_COLOR, "COLOR", 0, "Color", ""}, - {PROP_VECTOR, "VECTOR", 0, "Vector", ""}, - {PROP_MATRIX, "MATRIX", 0, "Matrix", ""}, - {PROP_ROTATION, "ROTATION", 0, "Rotation", ""}, - {PROP_NEVER_NULL, "NEVER_NULL", 0, "Never Null", ""}, + {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned Number", ""}, {PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""}, + {PROP_ANGLE, "ANGLE", 0, "Angle", ""}, + {PROP_TIME, "TIME", 0, "Time", ""}, + {PROP_DISTANCE, "DISTANCE", 0, "Distance", ""}, + {PROP_COLOR, "COLOR", 0, "Color", ""}, + {PROP_TRANSLATION, "TRANSLATION", 0, "Translation", ""}, + {PROP_DIRECTION, "DIRECTION", 0, "Direction", ""}, + {PROP_MATRIX, "MATRIX", 0, "Matrix", ""}, + {PROP_EULER, "EULER", 0, "Euler", ""}, + {PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""}, + {PROP_XYZ, "XYZ", 0, "XYZ", ""}, + {PROP_RGB, "RGB", 0, "RGB", ""}, + {PROP_NEVER_NULL, "NEVER_NULL", 0, "Never Null", ""}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem unit_items[] = { + {PROP_UNIT_NONE, "NONE", 0, "None", ""}, + {PROP_UNIT_LENGTH, "LENGTH", 0, "Length", ""}, + {PROP_UNIT_AREA, "AREA", 0, "Area", ""}, + {PROP_UNIT_VOLUME, "VOLUME", 0, "Volume", ""}, + {PROP_UNIT_ROTATION, "ROTATION", 0, "Rotation", ""}, + {PROP_UNIT_TIME, "TIME", 0, "Time", ""}, + {PROP_UNIT_VELOCITY, "VELOCITY", 0, "Velocity", ""}, + {PROP_UNIT_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Property", NULL); @@ -813,11 +843,22 @@ static void rna_def_property(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, "rna_Property_subtype_get", NULL, NULL); RNA_def_property_ui_text(prop, "Subtype", "Semantic interpretation of the property."); + prop= RNA_def_property(srna, "unit", PROP_ENUM, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_enum_items(prop, unit_items); + RNA_def_property_enum_funcs(prop, "rna_Property_unit_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Unit", "Type of units for this property."); + prop= RNA_def_property(srna, "editable", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Property_editable_get", NULL); RNA_def_property_ui_text(prop, "Editable", "Property is editable through RNA."); + prop= RNA_def_property(srna, "use_return", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Property_use_return_get", NULL); + RNA_def_property_ui_text(prop, "Return", "True when this property is a return value from an rna function.."); + prop= RNA_def_property(srna, "registered", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Property_registered_get", NULL); @@ -875,15 +916,17 @@ static void rna_def_number_property(StructRNA *srna, PropertyType type) RNA_def_property_ui_text(prop, "Default", "Default value for this number"); switch(type) { - case PROP_BOOLEAN: - RNA_def_property_boolean_funcs(prop, "rna_BoolProperty_default_get", NULL); - break; - case PROP_INT: - RNA_def_property_int_funcs(prop, "rna_IntProperty_default_get", NULL, NULL); - break; - case PROP_FLOAT: - RNA_def_property_float_funcs(prop, "rna_FloatProperty_default_get", NULL, NULL); - break; + case PROP_BOOLEAN: + RNA_def_property_boolean_funcs(prop, "rna_BoolProperty_default_get", NULL); + break; + case PROP_INT: + RNA_def_property_int_funcs(prop, "rna_IntProperty_default_get", NULL, NULL); + break; + case PROP_FLOAT: + RNA_def_property_float_funcs(prop, "rna_FloatProperty_default_get", NULL, NULL); + break; + default: + break; } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 6e12ceb37db..60071efb0a8 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -30,6 +30,7 @@ #include "rna_internal.h" #include "DNA_scene_types.h" +#include "DNA_userdef_types.h" #ifdef WITH_FFMPEG #include "BKE_writeffmpeg.h" @@ -52,6 +53,7 @@ EnumPropertyItem prop_mode_items[] ={ #ifdef RNA_RUNTIME +#include "DNA_anim_types.h" #include "DNA_node_types.h" #include "BKE_context.h" @@ -60,6 +62,8 @@ EnumPropertyItem prop_mode_items[] ={ #include "BLI_threads.h" +#include "ED_node.h" + #include "RE_pipeline.h" PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter) @@ -174,6 +178,54 @@ static void rna_Scene_frame_update(bContext *C, PointerRNA *ptr) //ED_update_for_newframe(C); } +static int rna_Scene_active_keying_set_editable(PointerRNA *ptr) +{ + Scene *scene= (Scene *)ptr->data; + + /* only editable if there are some Keying Sets to change to */ + return (scene->keyingsets.first != NULL); +} + +static PointerRNA rna_Scene_active_keying_set_get(PointerRNA *ptr) +{ + Scene *scene= (Scene *)ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_KeyingSet, BLI_findlink(&scene->keyingsets, scene->active_keyingset-1)); +} + +static void rna_Scene_active_keying_set_set(PointerRNA *ptr, PointerRNA value) +{ + Scene *scene= (Scene *)ptr->data; + KeyingSet *ks= (KeyingSet*)value.data; + scene->active_keyingset= BLI_findindex(&scene->keyingsets, ks) + 1; +} + +static int rna_Scene_active_keying_set_index_get(PointerRNA *ptr) +{ + Scene *scene= (Scene *)ptr->data; + return MAX2(scene->active_keyingset-1, 0); +} + +static void rna_Scene_active_keying_set_index_set(PointerRNA *ptr, int value) +{ + Scene *scene= (Scene *)ptr->data; + scene->active_keyingset= value+1; +} + +static void rna_Scene_active_keying_set_index_range(PointerRNA *ptr, int *min, int *max) +{ + Scene *scene= (Scene *)ptr->data; + + *min= 0; + *max= BLI_countlist(&scene->keyingsets)-1; + *max= MAX2(0, *max); +} + + +static char *rna_SceneRenderData_path(PointerRNA *ptr) +{ + return BLI_sprintfN("render_data"); +} + static int rna_SceneRenderData_threads_get(PointerRNA *ptr) { RenderData *rd= (RenderData*)ptr->data; @@ -321,6 +373,15 @@ static void rna_SceneRenderLayer_pass_update(bContext *C, PointerRNA *ptr) ntreeCompositForceHidden(scene->nodetree, scene); } +void rna_Scene_use_nodes_set(PointerRNA *ptr, int value) +{ + Scene *scene= (Scene*)ptr->data; + + scene->use_nodes= value; + if(scene->use_nodes && scene->nodetree==NULL) + ED_node_composit_default(scene); +} + #else static void rna_def_tool_settings(BlenderRNA *brna) @@ -354,6 +415,11 @@ static void rna_def_tool_settings(BlenderRNA *brna) {SCE_SNAP_TARGET_MEDIAN, "MEDIAN", 0, "Median", "Snap median onto target."}, {SCE_SNAP_TARGET_ACTIVE, "ACTIVE", 0, "Active", "Snap active onto target."}, {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem auto_key_items[] = { + {AUTOKEY_MODE_NORMAL, "ADD_REPLACE_KEYS", 0, "Add/Replace", ""}, + {AUTOKEY_MODE_EDITKEYS, "REPLACE_KEYS", 0, "Replace", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ToolSettings", NULL); RNA_def_struct_ui_text(srna, "Tool Settings", ""); @@ -416,6 +482,20 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PEEL_OBJECT); RNA_def_property_ui_text(prop, "Snap Peel Object", "Consider objects as whole when finding volume center."); RNA_def_property_ui_icon(prop, ICON_SNAP_PEEL_OBJECT, 0); + + /* Auto Keying */ + prop= RNA_def_property(srna, "enable_auto_key", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "autokey_mode", AUTOKEY_ON); + RNA_def_property_ui_text(prop, "Auto Keying", "Automatic keyframe insertion for Objects and Bones"); + + prop= RNA_def_property(srna, "autokey_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "autokey_mode"); + RNA_def_property_enum_items(prop, auto_key_items); + RNA_def_property_ui_text(prop, "Auto-Keying Mode", "Mode of automatic keyframe insertion for Objects and Bones"); + + prop= RNA_def_property(srna, "record_with_nla", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", ANIMRECORD_FLAG_WITHNLA); + RNA_def_property_ui_text(prop, "Layered", "Add a new NLA Track + Strip for every loop/pass made over the animation to allow non-destructive tweaking."); /* UV */ prop= RNA_def_property(srna, "uv_selection_mode", PROP_ENUM, PROP_NONE); @@ -443,6 +523,40 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Vertex Group Weight", "Weight to assign in vertex groups."); } + +static void rna_def_unit_settings(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem unit_systems[] = { + {USER_UNIT_NONE, "NONE", 0, "None", ""}, + {USER_UNIT_METRIC, "METRIC", 0, "Metric", ""}, + {USER_UNIT_IMPERIAL, "IMPERIAL", 0, "Imperial", ""}, + {0, NULL, 0, NULL, NULL}}; + + srna= RNA_def_struct(brna, "UnitSettings", NULL); + RNA_def_struct_ui_text(srna, "Unit Settings", ""); + + /* Units */ + prop= RNA_def_property(srna, "system", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, unit_systems); + RNA_def_property_ui_text(prop, "Unit System", "The unit system to use for button display."); + RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop= RNA_def_property(srna, "scale_length", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_ui_text(prop, "Unit Scale", "Scale to use when converting between blender units and dimensions."); + RNA_def_property_range(prop, 0.00001, 100000.0); + RNA_def_property_ui_range(prop, 0.001, 100.0, 0.1, 3); + RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop= RNA_def_property(srna, "use_separate", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_UNIT_OPT_SPLIT); + RNA_def_property_ui_text(prop, "Separate Units", "Display units in pairs."); + RNA_def_property_update(prop, NC_WINDOW, NULL); +} + + void rna_def_render_layer_common(StructRNA *srna, int scene) { PropertyRNA *prop; @@ -673,9 +787,9 @@ void rna_def_scene_game_data(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem framing_types_items[] ={ - {SCE_GAMEFRAMING_BARS, "BARS", 0, "Stretch", ""}, - {SCE_GAMEFRAMING_EXTEND, "EXTEND", 0, "Extend", ""}, - {SCE_GAMEFRAMING_SCALE, "SCALE", 0, "Scale", ""}, + {SCE_GAMEFRAMING_BARS, "LETTERBOX", 0, "Letterbox", "Show the entire viewport in the display window, using bar horizontally or vertically"}, + {SCE_GAMEFRAMING_EXTEND, "EXTEND", 0, "Extend", "Show the entire viewport in the display window, viewing more horizontally or vertically"}, + {SCE_GAMEFRAMING_SCALE, "SCALE", 0, "Scale", "Stretch or squeeze the viewport to fill the display window"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem dome_modes_items[] ={ @@ -698,7 +812,7 @@ void rna_def_scene_game_data(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem stereo_items[] ={ - {STEREO_NOSTEREO, "NO_STEREO", 0, "No Stereo", ""}, + {STEREO_NOSTEREO, "NONE", 0, "None", ""}, {STEREO_ENABLED, "STEREO", 0, "Stereo", ""}, {STEREO_DOME, "DOME", 0, "Dome", ""}, {0, NULL, 0, NULL, NULL}}; @@ -712,6 +826,12 @@ void rna_def_scene_game_data(BlenderRNA *brna) {WOPHY_BULLET, "BULLET", 0, "Bullet", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem material_items[] ={ + {GAME_MAT_TEXFACE, "TEXTURE_FACE", 0, "Texture Face", "Single texture face materials."}, + {GAME_MAT_MULTITEX, "MULTITEXTURE", 0, "Multitexture", "Multitexture materials."}, + {GAME_MAT_GLSL, "GLSL", 0, "GLSL", "OpenGL shading language shaders."}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "SceneGameData", NULL); RNA_def_struct_sdna(srna, "GameData"); RNA_def_struct_nested(brna, srna, "Scene"); @@ -818,7 +938,7 @@ void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Physics Engine", "Physics engine used for physics simulation in the game engine."); RNA_def_property_update(prop, NC_SCENE, NULL); - prop= RNA_def_property(srna, "physics_gravity", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "physics_gravity", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_float_sdna(prop, NULL, "gravity"); RNA_def_property_range(prop, 0.0, 25.0); RNA_def_property_ui_text(prop, "Physics Gravity", "Gravitational constant used for physics simulation in the game engine."); @@ -876,6 +996,74 @@ void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_range(prop, 0.0, 1000.0); RNA_def_property_ui_text(prop, "box radius", "Radius of the activity bubble, in Manhattan length. Objects outside the box are activity-culled"); RNA_def_property_update(prop, NC_SCENE, NULL); + + /* booleans */ + prop= RNA_def_property(srna, "all_frames", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_ENABLE_ALL_FRAMES); + RNA_def_property_ui_text(prop, "All Frames", "Render as many frames as possible, rather than respecting framerate."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "show_debug_properties", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_DEBUG_PROPS); + RNA_def_property_ui_text(prop, "Show Debug Properties", "Show properties marked for debugging while the game runs."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "show_framerate_profile", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_FRAMERATE); + RNA_def_property_ui_text(prop, "Show Framerate and Profile", "Show framerate and profiling information while the game runs."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "show_physics_visualization", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_PHYSICS); + RNA_def_property_ui_text(prop, "Show Physics Visualization", "Show a visualization of physics bounds and interactions."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "display_lists", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_DISPLAY_LISTS); + RNA_def_property_ui_text(prop, "Display Lists", "Use display lists to speed up rendering by keeping geometry on the GPU."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "deprecation_warnings", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_IGNORE_DEPRECATION_WARNINGS); + RNA_def_property_ui_text(prop, "Deprecation Warnings", "Print warnings when using deprecated features in the python API."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + /* materials */ + prop= RNA_def_property(srna, "material_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "matmode"); + RNA_def_property_enum_items(prop, material_items); + RNA_def_property_ui_text(prop, "Material Mode", "Material mode to use for rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "glsl_lights", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_LIGHTS); + RNA_def_property_ui_text(prop, "GLSL Lights", "Use lights for GLSL rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "glsl_shaders", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_SHADERS); + RNA_def_property_ui_text(prop, "GLSL Shaders", "Use shaders for GLSL rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "glsl_shadows", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_SHADOWS); + RNA_def_property_ui_text(prop, "GLSL Shadows", "Use shadows for GLSL rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "glsl_ramps", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_RAMPS); + RNA_def_property_ui_text(prop, "GLSL Ramps", "Use ramps for GLSL rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "glsl_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_NODES); + RNA_def_property_ui_text(prop, "GLSL Nodes", "Use nodes for GLSL rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "glsl_extra_textures", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_EXTRA_TEX); + RNA_def_property_ui_text(prop, "GLSL Extra Textures", "Use extra textures like normal or specular maps for GLSL rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); } static void rna_def_scene_render_layer(BlenderRNA *brna) @@ -1081,6 +1269,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) srna= RNA_def_struct(brna, "SceneRenderData", NULL); RNA_def_struct_sdna(srna, "RenderData"); RNA_def_struct_nested(brna, srna, "Scene"); + RNA_def_struct_path_func(srna, "rna_SceneRenderData_path"); RNA_def_struct_ui_text(srna, "Render Data", "Rendering settings for a Scene datablock."); prop= RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE); @@ -1365,6 +1554,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Fields Still", "Disable the time difference between fields."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + prop= RNA_def_property(srna, "sync_audio", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "audio.flag", AUDIO_SYNC); + RNA_def_property_ui_text(prop, "Sync Audio", "Play back and sync with audio from Sequence Editor"); + RNA_def_property_update(prop, NC_SCENE, NULL); + prop= RNA_def_property(srna, "render_shadows", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SHADOW); RNA_def_property_ui_text(prop, "Render Shadows", "Calculate shadows while rendering."); @@ -1480,7 +1674,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FREE_IMAGE); RNA_def_property_ui_text(prop, "Free Image Textures", "Free all image texture from memory after render, to save memory before compositing."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - + + prop= RNA_def_property(srna, "free_unused_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FREE_IMAGE); + RNA_def_property_ui_text(prop, "Free Unused Nodes", "Free Nodes that are not used while compositing, to save memory."); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + prop= RNA_def_property(srna, "save_buffers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_EXR_TILE_FILE); RNA_def_property_boolean_funcs(prop, "rna_SceneRenderData_save_buffers_get", NULL); @@ -1641,7 +1840,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "World", "World used for rendering the scene."); RNA_def_property_update(prop, NC_WORLD, NULL); - prop= RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "cursor"); RNA_def_property_ui_text(prop, "Cursor Location", "3D cursor location."); RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4); @@ -1663,28 +1862,28 @@ void RNA_def_scene(BlenderRNA *brna) /* Frame Range Stuff */ - prop= RNA_def_property(srna, "current_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "current_frame", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "r.cfra"); RNA_def_property_range(prop, MINAFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "Current Frame", ""); RNA_def_property_update(prop, NC_SCENE|ND_FRAME, "rna_Scene_frame_update"); - prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "r.sfra"); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Start Frame", ""); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "r.efra"); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_end_frame_set", NULL); RNA_def_property_ui_text(prop, "End Frame", ""); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - prop= RNA_def_property(srna, "frame_step", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "frame_step", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "frame_step"); RNA_def_property_ui_text(prop, "Frame Step", "Number of frames to skip forward while rendering/playing back each frame"); @@ -1697,14 +1896,14 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Preview Range", ""); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - prop= RNA_def_property(srna, "preview_range_start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "preview_range_start_frame", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "r.psfra"); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_preview_range_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Preview Range Start Frame", ""); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - prop= RNA_def_property(srna, "preview_range_end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "preview_range_end_frame", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "r.pefra"); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_preview_range_end_frame_set", NULL); @@ -1720,6 +1919,12 @@ void RNA_def_scene(BlenderRNA *brna) /* Nodes (Compositing) */ prop= RNA_def_property(srna, "nodetree", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Node Tree", "Compositing node tree."); + + prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_use_nodes_set"); + RNA_def_property_ui_text(prop, "Use Nodes", "Enable the compositing node tree."); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); /* Sequencer */ prop= RNA_def_property(srna, "sequence_editor", PROP_POINTER, PROP_NONE); @@ -1728,24 +1933,40 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Sequence Editor", ""); /* Keying Sets */ - // TODO: hide the fact that active keyingset is an int? - prop= RNA_def_property(srna, "keyingsets", PROP_COLLECTION, PROP_NONE); + prop= RNA_def_property(srna, "keying_sets", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "keyingsets", NULL); RNA_def_property_struct_type(prop, "KeyingSet"); RNA_def_property_ui_text(prop, "Keying Sets", "Keying Sets for this Scene."); + RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL); - prop= RNA_def_property(srna, "active_keyingset", PROP_INT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Active Keying Set", "Current Keying Set index."); + prop= RNA_def_property(srna, "active_keying_set", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "KeyingSet"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_editable_func(prop, "rna_Scene_active_keying_set_editable"); + RNA_def_property_pointer_funcs(prop, "rna_Scene_active_keying_set_get", "rna_Scene_active_keying_set_set", NULL); + RNA_def_property_ui_text(prop, "Active Keying Set", "Active Keying Set used to insert/delete keyframes."); + RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL); + + prop= RNA_def_property(srna, "active_keying_set_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "active_keyingset"); + RNA_def_property_int_funcs(prop, "rna_Scene_active_keying_set_index_get", "rna_Scene_active_keying_set_index_set", "rna_Scene_active_keying_set_index_range"); + RNA_def_property_ui_text(prop, "Active Keying Set Index", "Current Keying Set index."); + RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL); /* Tool Settings */ - prop= RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "toolsettings"); RNA_def_property_struct_type(prop, "ToolSettings"); RNA_def_property_ui_text(prop, "Tool Settings", ""); + + /* Unit Settings */ + prop= RNA_def_property(srna, "unit_settings", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "unit"); + RNA_def_property_struct_type(prop, "UnitSettings"); + RNA_def_property_ui_text(prop, "Unit Settings", "Unit editing settings"); /* Render Data */ - prop= RNA_def_property(srna, "render_data", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "render_data", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "r"); RNA_def_property_struct_type(prop, "SceneRenderData"); RNA_def_property_ui_text(prop, "Render Data", ""); @@ -1757,12 +1978,13 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Timeline Markers", "Markers used in all timelines for the current scene."); /* Game Settings */ - prop= RNA_def_property(srna, "game_data", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "game_data", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "gm"); RNA_def_property_struct_type(prop, "SceneGameData"); RNA_def_property_ui_text(prop, "Game Data", ""); rna_def_tool_settings(brna); + rna_def_unit_settings(brna); rna_def_scene_render_data(brna); rna_def_scene_game_data(brna); rna_def_scene_render_layer(brna); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index e3171d38932..7a243327bd1 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -71,9 +71,15 @@ static void rna_Screen_scene_update(bContext *C, PointerRNA *ptr) } } +static int rna_Screen_animation_playing_get(PointerRNA *ptr) +{ + bScreen *sc= (bScreen*)ptr->data; + return (sc->animtimer != NULL); +} + #else -static void rna_def_scrarea(BlenderRNA *brna) +static void rna_def_area(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -119,7 +125,7 @@ static void rna_def_region(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Region ID", "Uniqute ID for this region."); } -static void rna_def_bscreen(BlenderRNA *brna) +static void rna_def_screen(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -139,12 +145,17 @@ static void rna_def_bscreen(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "areabase", NULL); RNA_def_property_struct_type(prop, "Area"); RNA_def_property_ui_text(prop, "Areas", "Areas the screen is subdivided into."); + + prop= RNA_def_property(srna, "animation_playing", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Screen_animation_playing_get", NULL); + RNA_def_property_ui_text(prop, "Animation Playing", "Animation playback is active."); } void RNA_def_screen(BlenderRNA *brna) { - rna_def_bscreen(brna); - rna_def_scrarea(brna); + rna_def_screen(brna); + rna_def_area(brna); rna_def_region(brna); } diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 1e512d8f9bb..c2c906e38f2 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -31,6 +31,8 @@ #include "DNA_scene_types.h" +#include "BKE_paint.h" + #ifdef RNA_RUNTIME static PointerRNA rna_ParticleEdit_brush_get(PointerRNA *ptr) @@ -49,20 +51,67 @@ static PointerRNA rna_ParticleBrush_curve_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_CurveMapping, NULL); } +static void rna_Paint_brushes_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Paint *p= (Paint*)ptr->data; + rna_iterator_array_begin(iter, (void*)p->brushes, sizeof(Brush*), p->brush_count, 0, NULL); +} + +static int rna_Paint_brushes_length(PointerRNA *ptr) +{ + Paint *p= (Paint*)ptr->data; + + return p->brush_count; +} + +static PointerRNA rna_Paint_active_brush_get(PointerRNA *ptr) +{ + return rna_pointer_inherit_refine(ptr, &RNA_Brush, paint_brush(ptr->data)); +} + +static void rna_Paint_active_brush_set(PointerRNA *ptr, PointerRNA value) +{ + paint_brush_set(ptr->data, value.data); +} + #else +static void rna_def_paint(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "Paint", NULL); + RNA_def_struct_ui_text(srna, "Paint", ""); + + prop= RNA_def_property(srna, "brushes", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "Brush"); + RNA_def_property_collection_funcs(prop, "rna_Paint_brushes_begin", + "rna_iterator_array_next", + "rna_iterator_array_end", + "rna_iterator_array_dereference_get", + "rna_Paint_brushes_length", 0, 0, 0, 0); + RNA_def_property_ui_text(prop, "Brushes", "Brushes selected for this paint mode."); + + prop= RNA_def_property(srna, "active_brush_index", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, INT_MAX); + + /* Fake property to get active brush directly, rather than integer index */ + prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Brush"); + RNA_def_property_pointer_funcs(prop, "rna_Paint_active_brush_get", "rna_Paint_active_brush_set", NULL); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Brush", "Active paint brush."); +} + static void rna_def_sculpt(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna= RNA_def_struct(brna, "Sculpt", NULL); + srna= RNA_def_struct(brna, "Sculpt", "Paint"); RNA_def_struct_ui_text(srna, "Sculpt", ""); - prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Brush"); - RNA_def_property_ui_text(prop, "Brush", ""); - prop= RNA_def_property(srna, "symmetry_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_X); RNA_def_property_ui_text(prop, "Symmetry X", "Mirror brush across the X axis."); @@ -110,14 +159,10 @@ static void rna_def_vertex_paint(BlenderRNA *brna) {6, "DARKEN", 0, "Darken", "Use darken blending mode while painting."}, {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "VertexPaint", NULL); + srna= RNA_def_struct(brna, "VertexPaint", "Paint"); RNA_def_struct_sdna(srna, "VPaint"); RNA_def_struct_ui_text(srna, "Vertex Paint", "Properties of vertex and weight paint mode."); - prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Brush"); - RNA_def_property_ui_text(prop, "Brush", ""); - prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_mode_items); RNA_def_property_ui_text(prop, "Brush Mode", "Mode in which color is painted."); @@ -159,14 +204,10 @@ static void rna_def_image_paint(BlenderRNA *brna) {PAINT_TOOL_CLONE, "CLONE", 0, "Clone", ""}, {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "ImagePaint", NULL); + srna= RNA_def_struct(brna, "ImagePaint", "Paint"); RNA_def_struct_sdna(srna, "ImagePaintSettings"); RNA_def_struct_ui_text(srna, "Image Paint", "Properties of image and texture painting mode."); - prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Brush"); - RNA_def_property_ui_text(prop, "Brush", ""); - prop= RNA_def_property(srna, "tool", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, tool_items); RNA_def_property_ui_text(prop, "Tool", ""); @@ -353,6 +394,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) void RNA_def_sculpt_paint(BlenderRNA *brna) { + rna_def_paint(brna); rna_def_sculpt(brna); rna_def_vertex_paint(brna); rna_def_image_paint(brna); diff --git a/source/blender/makesrna/intern/rna_sequence.c b/source/blender/makesrna/intern/rna_sequence.c index 8ca023dc57c..470909f4eff 100644 --- a/source/blender/makesrna/intern/rna_sequence.c +++ b/source/blender/makesrna/intern/rna_sequence.c @@ -192,10 +192,8 @@ static StructRNA* rna_Sequence_refine(struct PointerRNA *ptr) case SEQ_SCENE: return &RNA_SceneSequence; case SEQ_MOVIE: - case SEQ_MOVIE_AND_HD_SOUND: return &RNA_MovieSequence; - case SEQ_RAM_SOUND: - case SEQ_HD_SOUND: + case SEQ_SOUND: return &RNA_SoundSequence; case SEQ_CROSS: case SEQ_ADD: @@ -362,9 +360,7 @@ static void rna_def_sequence(BlenderRNA *brna) {SEQ_META, "META", 0, "Meta", ""}, {SEQ_SCENE, "SCENE", 0, "Scene", ""}, {SEQ_MOVIE, "MOVIE", 0, "Movie", ""}, - {SEQ_RAM_SOUND, "RAM_SOUND", 0, "Ram Sound", ""}, - {SEQ_HD_SOUND, "HD_SOUND", 0, "HD Sound", ""}, - {SEQ_MOVIE_AND_HD_SOUND, "MOVIE_AND_HD_SOUND", 0, "Movie and HD Sound", ""}, + {SEQ_SOUND, "_SOUND", 0, "Sound", ""}, {SEQ_EFFECT, "REPLACE", 0, "Replace", ""}, {SEQ_CROSS, "CROSS", 0, "Cross", ""}, {SEQ_ADD, "ADD", 0, "Add", ""}, @@ -442,38 +438,39 @@ static void rna_def_sequence(BlenderRNA *brna) /* strip positioning */ - prop= RNA_def_property(srna, "length", PROP_INT, PROP_UNSIGNED); + prop= RNA_def_property(srna, "length", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "len"); RNA_def_property_range(prop, 1, MAXFRAME); RNA_def_property_ui_text(prop, "Length", "The length of the contents of this strip before the handles are applied"); RNA_def_property_int_funcs(prop, "rna_SequenceEditor_length_get", "rna_SequenceEditor_length_set",NULL); - - prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_UNSIGNED); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); + + prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "start"); RNA_def_property_ui_text(prop, "Start Frame", ""); RNA_def_property_int_funcs(prop, NULL, "rna_SequenceEditor_start_frame_set",NULL); // overlap tests and calc_seq_disp RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); - prop= RNA_def_property(srna, "start_offset", PROP_INT, PROP_UNSIGNED); + prop= RNA_def_property(srna, "start_offset", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "startofs"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_ui_text(prop, "Start Offset", ""); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); - prop= RNA_def_property(srna, "end_offset", PROP_INT, PROP_UNSIGNED); + prop= RNA_def_property(srna, "end_offset", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "endofs"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_ui_text(prop, "End offset", ""); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); - prop= RNA_def_property(srna, "start_still", PROP_INT, PROP_UNSIGNED); + prop= RNA_def_property(srna, "start_still", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "startstill"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_range(prop, 0, MAXFRAME); RNA_def_property_ui_text(prop, "Start Still", ""); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); - prop= RNA_def_property(srna, "end_still", PROP_INT, PROP_UNSIGNED); + prop= RNA_def_property(srna, "end_still", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "endstill"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_range(prop, 0, MAXFRAME); @@ -616,21 +613,6 @@ static void rna_def_filter_video(StructRNA *srna) RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } -static void rna_def_filter_sound(StructRNA *srna) -{ - PropertyRNA *prop; - - prop= RNA_def_property(srna, "sound_gain", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "level"); - RNA_def_property_range(prop, -96.0f, 6.0f); - RNA_def_property_ui_text(prop, "Sound Gain", "Sound level in dB (0 = full volume)."); - - prop= RNA_def_property(srna, "sound_pan", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "pan"); - RNA_def_property_range(prop, -1.0f, 1.0f); - RNA_def_property_ui_text(prop, "Sound Pan", "Stereo sound balance."); -} - static void rna_def_proxy(StructRNA *srna) { PropertyRNA *prop; @@ -657,11 +639,13 @@ static void rna_def_input(StructRNA *srna) RNA_def_property_int_sdna(prop, NULL, "anim_startofs"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap test RNA_def_property_ui_text(prop, "Animation Start Offset", "Animation start offset (trim start)."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "animation_end_offset", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "anim_endofs"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap test RNA_def_property_ui_text(prop, "Animation End Offset", "Animation end offset (trim end)."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } static void rna_def_image(BlenderRNA *brna) @@ -761,7 +745,7 @@ static void rna_def_sound(BlenderRNA *brna) RNA_def_struct_sdna(srna, "Sequence"); prop= RNA_def_property(srna, "sound", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "UnknownType"); + RNA_def_property_struct_type(prop, "Sound"); RNA_def_property_ui_text(prop, "Sound", "Sound datablock used by this sequence (RAM audio only)."); prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); @@ -772,7 +756,6 @@ static void rna_def_sound(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "strip->dir"); RNA_def_property_ui_text(prop, "Directory", ""); - rna_def_filter_sound(srna); rna_def_input(srna); } @@ -833,21 +816,25 @@ static void rna_def_wipe(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "edgeWidth"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Blur Width", "Width of the blur edge, in percentage relative to the image size."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "angle"); RNA_def_property_range(prop, -90.0f, 90.0f); RNA_def_property_ui_text(prop, "Angle", "Edge angle."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "forward"); RNA_def_property_enum_items(prop, wipe_direction_items); RNA_def_property_ui_text(prop, "Direction", "Wipe direction."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "transition_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "wipetype"); RNA_def_property_enum_items(prop, wipe_type_items); RNA_def_property_ui_text(prop, "Transition Type", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } static void rna_def_glow(BlenderRNA *brna) @@ -863,30 +850,36 @@ static void rna_def_glow(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "fMini"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Threshold", "Minimum intensity to trigger a glow"); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "clamp", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fClamp"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Clamp", "rightness limit of intensity."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "boost_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fBoost"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Boost Factor", "Brightness multiplier."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "blur_distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "dDist"); RNA_def_property_range(prop, 0.5f, 20.0f); RNA_def_property_ui_text(prop, "Blur Distance", "Radius of glow effect."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "quality", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "dQuality"); RNA_def_property_range(prop, 1, 5); RNA_def_property_ui_text(prop, "Quality", "Accuracy of the blur effect."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "only_boost", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "bNoComp", 0); RNA_def_property_ui_text(prop, "Only Boost", "Show the glow buffer only."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } static void rna_def_transform(BlenderRNA *brna) @@ -915,60 +908,72 @@ static void rna_def_transform(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "ScalexIni"); RNA_def_property_ui_text(prop, "Scale Start X", ""); RNA_def_property_ui_range(prop, 0, 10, 3, 10); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "scale_start_y", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "ScaleyIni"); RNA_def_property_ui_text(prop, "Scale Start Y", ""); RNA_def_property_ui_range(prop, 0, 10, 3, 10); - + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); + prop= RNA_def_property(srna, "scale_end_x", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "ScalexFin"); RNA_def_property_ui_text(prop, "Scale End X", ""); RNA_def_property_ui_range(prop, 0, 10, 3, 10); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "scale_end_y", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "ScaleyFin"); RNA_def_property_ui_text(prop, "Scale End Y", ""); RNA_def_property_ui_range(prop, 0, 10, 3, 10); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "translate_start_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xIni"); RNA_def_property_ui_text(prop, "Translate Start X", ""); RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 10); - + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); + prop= RNA_def_property(srna, "translate_start_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "yIni"); RNA_def_property_ui_text(prop, "Translate Start Y", ""); RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 10); - + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); + prop= RNA_def_property(srna, "translate_end_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xFin"); RNA_def_property_ui_text(prop, "Translate End X", ""); RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 10); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "translate_end_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "yFin"); RNA_def_property_ui_text(prop, "Translate End Y", ""); RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 10); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "rotation_start", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rotIni"); RNA_def_property_range(prop, 0.0f, 360.0f); RNA_def_property_ui_text(prop, "Rotation Start", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "rotation_end", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rotFin"); RNA_def_property_range(prop, 0.0f, 360.0f); RNA_def_property_ui_text(prop, "Rotation End", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "translation_unit", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "percent"); RNA_def_property_enum_items(prop, translation_unit_items); RNA_def_property_ui_text(prop, "Translation Unit", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, interpolation_items); RNA_def_property_ui_text(prop, "Interpolation", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } static void rna_def_solid_color(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index cedbc992dde..6f1babb495a 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -118,7 +118,9 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) static EnumPropertyItem prop_noise_type_items[] = { {MOD_SMOKE_NOISEWAVE, "NOISEWAVE", 0, "Wavelet", ""}, - /* {MOD_SMOKE_NOISEFFT, "NOISEFFT", 0, "FFT", ""}, */ +#if FFTW3 == 1 + {MOD_SMOKE_NOISEFFT, "NOISEFFT", 0, "FFT", ""}, +#endif /* {MOD_SMOKE_NOISECURL, "NOISECURL", 0, "Curl", ""}, */ {0, NULL, 0, NULL, NULL}}; @@ -150,8 +152,13 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "highres", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGHRES); - RNA_def_property_ui_text(prop, "High res", "Show high resolution (using amplification)."); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + RNA_def_property_ui_text(prop, "High res", "Enable high resolution (using amplification)."); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); + + prop= RNA_def_property(srna, "viewhighres", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "viewsettings", MOD_SMOKE_VIEW_USEBIG); + RNA_def_property_ui_text(prop, "Show High Resolution", "Show high resolution (using amplification)."); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_redraw"); prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "noise"); @@ -171,14 +178,14 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_range(prop, -5.0, 5.0); RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5); RNA_def_property_ui_text(prop, "Gravity", "Higher value results in sinking smoke"); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); prop= RNA_def_property(srna, "beta", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "beta"); RNA_def_property_range(prop, -5.0, 5.0); RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5); RNA_def_property_ui_text(prop, "Heat", "Higher value results in faster rising smoke."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); prop= RNA_def_property(srna, "coll_group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "coll_group"); @@ -200,6 +207,30 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Effector Group", "Limit effectors to this group."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset_dependancy"); + + prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "strength"); + RNA_def_property_range(prop, 1.0, 10.0); + RNA_def_property_ui_range(prop, 1.0, 10.0, 1, 2); + RNA_def_property_ui_text(prop, "Strength", "Strength of wavelet noise"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); + + prop= RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "diss_speed"); + RNA_def_property_range(prop, 1.0, 100.0); + RNA_def_property_ui_range(prop, 1.0, 1000.0, 1, 0); + RNA_def_property_ui_text(prop, "Dissolve Speed", "Dissolve Speed"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); + + prop= RNA_def_property(srna, "dissolve_smoke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE); + RNA_def_property_ui_text(prop, "Dissolve Smoke", "Enable smoke to disappear over time."); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); + + prop= RNA_def_property(srna, "dissolve_smoke_log", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE_LOG); + RNA_def_property_ui_text(prop, "Logarithmic dissolve", "Using 1/x "); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); } static void rna_def_smoke_flow_settings(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index 363a5595b43..a029ef85544 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -36,96 +36,6 @@ #else -/* sample and listener are internal .. */ - -#if 0 -static void rna_def_sample(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - /* sound types */ - static EnumPropertyItem prop_sample_type_items[] = { - {SAMPLE_INVALID, "INVALID", 0, "Invalid", ""}, - {SAMPLE_UNKNOWN, "UNKNOWN", 0, "Unknown", ""}, - {SAMPLE_RAW, "RAW", 0, "Raw", ""}, - {SAMPLE_WAV, "WAV", 0, "WAV", "Uncompressed"}, - {SAMPLE_MP2, "MP2", 0, "MP2", "MPEG-1 Audio Layer 2"}, - {SAMPLE_MP3, "MP3", 0, "MP3", "MPEG-1 Audio Layer 3"}, - {SAMPLE_OGG_VORBIS, "OGG_VORBIS", 0, "Ogg Vorbis", ""}, - {SAMPLE_WMA, "WMA", 0, "WMA", "Windows Media Audio"}, - {SAMPLE_ASF, "ASF", 0, "ASF", "Windows Advanced Systems Format"}, - {SAMPLE_AIFF, "AIFF", 0, "AIFF", "Audio Interchange File Format"}, - {0, NULL, 0, NULL, NULL}}; - - srna= RNA_def_struct(brna, "SoundSample", "ID"); - RNA_def_struct_sdna(srna, "bSample"); - RNA_def_struct_ui_text(srna, "SoundSample", "Sound data loaded from a sound datablock."); - - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_sample_type_items); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Types", ""); - - prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); - RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Filename", "Full path filename of the sample"); - - prop= RNA_def_property(srna, "length", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "len"); - RNA_def_property_ui_text(prop, "Length", "The length of sample in seconds"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop= RNA_def_property(srna, "rate", PROP_INT, PROP_UNSIGNED); - RNA_def_property_ui_text(prop, "Rate", "Sample rate in kHz"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop= RNA_def_property(srna, "bits", PROP_INT, PROP_UNSIGNED); - RNA_def_property_ui_text(prop, "Bits", "Bit-depth of sample"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop= RNA_def_property(srna, "channels", PROP_INT, PROP_UNSIGNED); - RNA_def_property_ui_text(prop, "Channels", "Number of channels (mono=1; stereo=2)"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); -} - -static void rna_def_soundlistener(BlenderRNA *brna) -{ - - StructRNA *srna; - PropertyRNA *prop; - - srna= RNA_def_struct(brna, "SoundListener", "ID"); - RNA_def_struct_sdna(srna, "bSoundListener"); - RNA_def_struct_ui_text(srna, "Sound Listener", "Sound listener defining parameters about how sounds are played."); - - prop= RNA_def_property(srna, "gain", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_text(prop, "Gain", "Overall volume for Game Engine sound."); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 4); - - prop= RNA_def_property(srna, "doppler_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dopplerfactor"); - RNA_def_property_ui_text(prop, "Doppler Factor", "Amount of Doppler effect in Game Engine sound."); - RNA_def_property_ui_range(prop, 0.0, 10.0, 1, 4); - - prop= RNA_def_property(srna, "doppler_velocity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dopplervelocity"); - RNA_def_property_ui_text(prop, "Doppler Velocity", "The speed of sound in the Game Engine."); - RNA_def_property_ui_range(prop, 0.0, 10000.0, 0.1, 4); - - prop= RNA_def_property(srna, "num_sounds_blender", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "numsoundsblender"); - RNA_def_property_ui_text(prop, "Total Sounds in Blender", "The total number of sounds currently linked and available."); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop= RNA_def_property(srna, "num_sounds_gameengine", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "numsoundsgameengine"); - RNA_def_property_ui_text(prop, "Total Sounds in Game Engine", "The total number of sounds in the Game Engine."); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); -} -#endif - static void rna_def_sound(BlenderRNA *brna) { StructRNA *srna; @@ -138,10 +48,6 @@ static void rna_def_sound(BlenderRNA *brna) //rna_def_ipo_common(srna); - /*prop= RNA_def_property(srna, "sample", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "SoundSample"); - RNA_def_property_ui_text(prop, "Sample", "Sound sample.");*/ - prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Filename", "Sound sample file used by this Sound datablock."); @@ -149,77 +55,10 @@ static void rna_def_sound(BlenderRNA *brna) prop= RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "packedfile"); RNA_def_property_ui_text(prop, "Packed File", ""); - - /* game engine settings */ - prop= RNA_def_property(srna, "volume", PROP_FLOAT, PROP_UNSIGNED); - RNA_def_property_float_sdna(prop, NULL, "volume"); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 4); - RNA_def_property_ui_text(prop, "Volume", "Game engine only: volume for this sound."); - - prop= RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "pitch"); - RNA_def_property_ui_range(prop, -12.0, 12.0, 10, 4); - RNA_def_property_ui_text(prop, "Pitch", "Game engine only: set the pitch of this sound."); - - prop= RNA_def_property(srna, "loop", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_LOOP); - RNA_def_property_ui_text(prop, "Sound Loop", "Game engine only: toggle between looping on/off."); - - prop= RNA_def_property(srna, "ping_pong", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_BIDIRECTIONAL_LOOP); - RNA_def_property_ui_text(prop, "Ping Pong", "Game engine only: Toggle between A->B and A->B->A looping."); - - prop= RNA_def_property(srna, "sound_3d", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_3D); - RNA_def_property_ui_text(prop, "3D Sound", "Game engine only: turns 3D sound on."); - - prop= RNA_def_property(srna, "attenuation", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "attenuation"); - RNA_def_property_range(prop, 0.0, 5.0); - RNA_def_property_ui_text(prop, "Attenuation", "Game engine only: sets the surround scaling factor for 3D sound."); - - /* gain */ - prop= RNA_def_property(srna, "min_gain", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "min_gain"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Min Gain", "Minimal gain which is always guaranteed for this sound."); - - prop= RNA_def_property(srna, "max_gain", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "max_gain"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Max Gain", "Maximal gain which is always guaranteed for this sound."); - - prop= RNA_def_property(srna, "reference_distance", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "distance"); - RNA_def_property_ui_text(prop, "Reference Distance", "Reference distance at which the listener will experience gain."); - RNA_def_property_ui_range(prop, 0.0, 1000.0, 10, 4); /* NOT used anywhere */ - - /* unused - prop= RNA_def_property(srna, "panning", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "panning"); - RNA_def_property_ui_range(prop, -1.0, 1.0, 10, 4); - RNA_def_property_ui_text(prop, "Panning", "Pan the sound from left to right"); */ - - /* unused - prop= RNA_def_property(srna, "fixed_volume", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_FIXED_VOLUME); - RNA_def_property_ui_text(prop, "Fixed Volume", "Constraint sound to fixed volume."); */ - - /* unused - prop= RNA_def_property(srna, "fixed_panning", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_FIXED_PANNING); - RNA_def_property_ui_text(prop, "Fixed Panning", "Constraint sound to fixed panning."); */ - - /* unused - prop= RNA_def_property(srna, "priority", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_PRIORITY); - RNA_def_property_ui_text(prop, "Priority", "Make sound higher priority."); */ } void RNA_def_sound(BlenderRNA *brna) { - //rna_def_sample(brna); - //rna_def_soundlistener(brna); rna_def_sound(brna); } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 793970dea49..be0707390c4 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -33,10 +33,13 @@ #include "rna_internal.h" #include "DNA_action_types.h" +#include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" +#include "BKE_paint.h" + #include "WM_types.h" EnumPropertyItem space_type_items[] = { @@ -44,10 +47,10 @@ EnumPropertyItem space_type_items[] = { {SPACE_VIEW3D, "VIEW_3D", 0, "3D View", ""}, {SPACE_IPO, "GRAPH_EDITOR", 0, "Graph Editor", ""}, {SPACE_OUTLINER, "OUTLINER", 0, "Outliner", ""}, - {SPACE_BUTS, "BUTTONS_WINDOW", 0, "Buttons Window", ""}, + {SPACE_BUTS, "PROPERTIES", 0, "Properties", ""}, {SPACE_FILE, "FILE_BROWSER", 0, "File Browser", ""}, {SPACE_IMAGE, "IMAGE_EDITOR", 0, "Image Editor", ""}, - {SPACE_INFO, "USER_PREFERENCES", 0, "User Preferences", ""}, + {SPACE_INFO, "INFO", 0, "Info", ""}, {SPACE_SEQ, "SEQUENCE_EDITOR", 0, "Sequence Editor", ""}, {SPACE_TEXT, "TEXT_EDITOR", 0, "Text Editor", ""}, //{SPACE_IMASEL, "IMAGE_BROWSER", 0, "Image Browser", ""}, @@ -59,6 +62,7 @@ EnumPropertyItem space_type_items[] = { {SPACE_NODE, "NODE_EDITOR", 0, "Node Editor", ""}, {SPACE_LOGIC, "LOGIC_EDITOR", 0, "Logic Editor", ""}, {SPACE_CONSOLE, "CONSOLE", 0, "Console", ""}, + {SPACE_USERPREF, "USER_PREFERENCES", 0, "User Preferences", ""}, {0, NULL, 0, NULL, NULL}}; #define DC_RGB {0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors."} @@ -83,6 +87,7 @@ static EnumPropertyItem dc_all_items[] = {DC_RGB, DC_RGBA, DC_ALPHA, DC_Z, DC_LC #include "BKE_context.h" #include "ED_image.h" +#include "ED_screen.h" #include "IMB_imbuf_types.h" @@ -98,13 +103,13 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr) case SPACE_OUTLINER: return &RNA_SpaceOutliner; case SPACE_BUTS: - return &RNA_SpaceButtonsWindow; + return &RNA_SpaceProperties; case SPACE_FILE: return &RNA_SpaceFileBrowser; case SPACE_IMAGE: return &RNA_SpaceImageEditor; - /*case SPACE_INFO: - return &RNA_SpaceUserPreferences;*/ + case SPACE_INFO: + return &RNA_SpaceInfo; case SPACE_SEQ: return &RNA_SpaceSequenceEditor; case SPACE_TEXT: @@ -118,15 +123,17 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr) case SPACE_NLA: return &RNA_SpaceNLA; /*case SPACE_SCRIPT: - return &RNA_SpaceScriptsWindow; + return &RNA_SpaceScriptsWindow;*/ case SPACE_TIME: return &RNA_SpaceTimeline; case SPACE_NODE: return &RNA_SpaceNodeEditor; case SPACE_LOGIC: - return &RNA_SpaceLogicEditor;*/ + return &RNA_SpaceLogicEditor; case SPACE_CONSOLE: return &RNA_SpaceConsole; + case SPACE_USERPREF: + return &RNA_SpaceUserPreferences; default: return &RNA_Space; } @@ -144,7 +151,7 @@ static void rna_SpaceImageEditor_paint_update(bContext *C, PointerRNA *ptr) Scene *scene= CTX_data_scene(C); if(scene) - brush_check_exists(&scene->toolsettings->imapaint.brush); + paint_init(&scene->toolsettings->imapaint.paint, "Brush"); } static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr) @@ -227,9 +234,9 @@ void rna_SpaceFileBrowser_params_set(PointerRNA *ptr, PointerRNA value) sfile->params= value.data; } -/* Space Buttons */ +/* Space Properties */ -StructRNA *rna_SpaceButtonsWindow_pin_id_typef(PointerRNA *ptr) +StructRNA *rna_SpaceProperties_pin_id_typef(PointerRNA *ptr) { SpaceButs *sbuts= (SpaceButs*)(ptr->data); @@ -239,7 +246,7 @@ StructRNA *rna_SpaceButtonsWindow_pin_id_typef(PointerRNA *ptr) return &RNA_ID; } -void rna_SpaceButtonsWindow_align_set(PointerRNA *ptr, int value) +void rna_SpaceProperties_align_set(PointerRNA *ptr, int value) { SpaceButs *sbuts= (SpaceButs*)(ptr->data); @@ -303,6 +310,13 @@ static void rna_View3D_display_background_image_set(PointerRNA *ptr, int value) } } +/* Space Time */ +static void rna_SpaceTime_redraw_update(bContext *C, PointerRNA *ptr) +{ + SpaceTime *st= (SpaceTime*)ptr->data; + ED_screen_animation_timer_update(C, st->redraws); +} + #else static void rna_def_space(BlenderRNA *brna) @@ -509,11 +523,11 @@ static void rna_def_space_3dview(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem viewport_shading_items[] = { - {OB_BOUNDBOX, "BOUNDBOX", 0, "Bounding Box", "Display the object's local bounding boxes only"}, - {OB_WIRE, "WIREFRAME", 0, "Wireframe", "Display the object as wire edges"}, - {OB_SOLID, "SOLID", 0, "Solid", "Display the object solid, lit with default OpenGL lights"}, - {OB_SHADED, "SHADED", 0, "Shaded", "Display the object solid, with preview shading interpolated at vertices"}, - {OB_TEXTURE, "TEXTURED", 0, "Textured", "Display the object solid, with face-assigned textures"}, + {OB_BOUNDBOX, "BOUNDBOX", ICON_BBOX, "Bounding Box", "Display the object's local bounding boxes only"}, + {OB_WIRE, "WIREFRAME", ICON_WIRE, "Wireframe", "Display the object as wire edges"}, + {OB_SOLID, "SOLID", ICON_SOLID, "Solid", "Display the object solid, lit with default OpenGL lights"}, + {OB_SHADED, "SHADED", ICON_SMOOTH, "Shaded", "Display the object solid, with preview shading interpolated at vertices"}, + {OB_TEXTURE, "TEXTURED", ICON_POTATO, "Textured", "Display the object solid, with face-assigned textures"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem pivot_items[] = { @@ -564,19 +578,19 @@ static void rna_def_space_3dview(BlenderRNA *brna) RNA_def_property_range(prop, 1.0f, 250.0f); RNA_def_property_update(prop, NC_WINDOW, NULL); - prop= RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "near"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Clip Start", "3D View near clipping distance."); RNA_def_property_update(prop, NC_WINDOW, NULL); - prop= RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "far"); RNA_def_property_range(prop, 1.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Clip End", "3D View far clipping distance."); RNA_def_property_update(prop, NC_WINDOW, NULL); - prop= RNA_def_property(srna, "grid_spacing", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "grid_spacing", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "grid"); RNA_def_property_ui_text(prop, "Grid Spacing", "The distance between 3D View grid lines."); RNA_def_property_range(prop, 0.0f, FLT_MAX); @@ -708,9 +722,9 @@ static void rna_def_space_buttons(BlenderRNA *brna) {BUT_VERTICAL, "VERTICAL", 0, "Vertical", ""}, {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "SpaceButtonsWindow", "Space"); + srna= RNA_def_struct(brna, "SpaceProperties", "Space"); RNA_def_struct_sdna(srna, "SpaceButs"); - RNA_def_struct_ui_text(srna, "Buttons Space", "Buttons Window space data"); + RNA_def_struct_ui_text(srna, "Properties Space", "Properties space data"); prop= RNA_def_property(srna, "context", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mainb"); @@ -721,7 +735,7 @@ static void rna_def_space_buttons(BlenderRNA *brna) prop= RNA_def_property(srna, "align", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "align"); RNA_def_property_enum_items(prop, align_items); - RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceButtonsWindow_align_set", NULL); + RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceProperties_align_set", NULL); RNA_def_property_ui_text(prop, "Align", "Arrangement of the panels."); RNA_def_property_update(prop, NC_WINDOW, NULL); @@ -734,7 +748,7 @@ static void rna_def_space_buttons(BlenderRNA *brna) prop= RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "pinid"); RNA_def_property_struct_type(prop, "ID"); - RNA_def_property_pointer_funcs(prop, NULL, NULL, "rna_SpaceButtonsWindow_pin_id_typef"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, "rna_SpaceProperties_pin_id_typef"); RNA_def_property_flag(prop, PROP_EDITABLE); } @@ -836,11 +850,11 @@ static void rna_def_space_sequencer(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem display_mode_items[] = { - {SEQ_DRAW_SEQUENCE, "SEQUENCER", 0, "Sequencer", ""}, - {SEQ_DRAW_IMG_IMBUF, "IMAGE", 0, "Image Preview", ""}, - {SEQ_DRAW_IMG_WAVEFORM, "WAVEFORM", 0, "Luma Waveform", ""}, - {SEQ_DRAW_IMG_VECTORSCOPE, "VECTOR_SCOPE", 0, "Chroma Vectorscope", ""}, - {SEQ_DRAW_IMG_HISTOGRAM, "HISTOGRAM", 0, "Histogram", ""}, + {SEQ_DRAW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""}, + {SEQ_DRAW_IMG_IMBUF, "IMAGE", ICON_SEQ_PREVIEW, "Image Preview", ""}, + {SEQ_DRAW_IMG_WAVEFORM, "WAVEFORM", ICON_SEQ_LUMA_WAVEFORM, "Luma Waveform", ""}, + {SEQ_DRAW_IMG_VECTORSCOPE, "VECTOR_SCOPE", ICON_SEQ_CHROMA_SCOPE, "Chroma Vectorscope", ""}, + {SEQ_DRAW_IMG_HISTOGRAM, "HISTOGRAM", ICON_SEQ_HISTOGRAM, "Histogram", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpaceSequenceEditor", "Space"); @@ -1104,6 +1118,59 @@ static void rna_def_space_nla(BlenderRNA *brna) // TODO... autosnap, dopesheet? } +static void rna_def_space_time(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "SpaceTimeline", "Space"); + RNA_def_struct_sdna(srna, "SpaceTime"); + RNA_def_struct_ui_text(srna, "Space Timeline Editor", "Timeline editor space data."); + + /* Define Anim Playback Areas */ + + prop= RNA_def_property(srna, "play_top_left", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_REGION); + RNA_def_property_ui_text(prop, "Top-Left 3D Window", ""); + RNA_def_property_update(prop, 0, "rna_SpaceTime_redraw_update"); + + prop= RNA_def_property(srna, "play_all_3d", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_ALL_3D_WIN); + RNA_def_property_ui_text(prop, "All 3D Windows", ""); + RNA_def_property_update(prop, 0, "rna_SpaceTime_redraw_update"); + + prop= RNA_def_property(srna, "play_anim", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_ALL_ANIM_WIN); + RNA_def_property_ui_text(prop, "Animation Windows", ""); + RNA_def_property_update(prop, 0, "rna_SpaceTime_redraw_update"); + + prop= RNA_def_property(srna, "play_buttons", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_ALL_BUTS_WIN); + RNA_def_property_ui_text(prop, "Properties Windows", ""); + RNA_def_property_update(prop, 0, "rna_SpaceTime_redraw_update"); + + prop= RNA_def_property(srna, "play_image", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_ALL_IMAGE_WIN); + RNA_def_property_ui_text(prop, "Image Windows", ""); + RNA_def_property_update(prop, 0, "rna_SpaceTime_redraw_update"); + + prop= RNA_def_property(srna, "play_sequencer", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_SEQ); + RNA_def_property_ui_text(prop, "Sequencer Windows", ""); + RNA_def_property_update(prop, 0, "rna_SpaceTime_redraw_update"); + + /* Other options */ + + prop= RNA_def_property(srna, "continue_physics", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_CONTINUE_PHYSICS); + RNA_def_property_ui_text(prop, "Continue Physics", "During playblack, continue physics simulations regardless of the frame number"); + + prop= RNA_def_property(srna, "only_selected", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_ONLYACTSEL); + RNA_def_property_ui_text(prop, "Only Selected channels", "Show keyframes only from active/selected channels."); + RNA_def_property_update(prop, NC_WINDOW, NULL); +} + static void rna_def_console_line(BlenderRNA *brna) { StructRNA *srna; @@ -1314,7 +1381,85 @@ static void rna_def_space_filebrowser(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "params"); RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceFileBrowser_params_set", NULL); RNA_def_property_ui_text(prop, "Filebrowser Parameter", "Parameters and Settings for the Filebrowser."); +} +static void rna_def_space_info(BlenderRNA *brna) +{ + StructRNA *srna; + + srna= RNA_def_struct(brna, "SpaceInfo", "Space"); + RNA_def_struct_sdna(srna, "SpaceInfo"); + RNA_def_struct_ui_text(srna, "Space Info", "Info space data."); +} + +static void rna_def_space_userpref(BlenderRNA *brna) +{ + StructRNA *srna; + + srna= RNA_def_struct(brna, "SpaceUserPreferences", "Space"); + RNA_def_struct_sdna(srna, "SpaceUserPref"); + RNA_def_struct_ui_text(srna, "Space User Preferences", "User preferences space data."); +} + +static void rna_def_space_node(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem tree_type_items[] = { + {NTREE_SHADER, "MATERIAL", ICON_MATERIAL, "Material", "Material nodes."}, + {NTREE_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture nodes."}, + {NTREE_COMPOSIT, "COMPOSITING", ICON_RENDER_RESULT, "Compositing", "Compositing nodes."}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem texture_type_items[] = { + {SNODE_TEX_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Edit texture nodes from Object."}, + {SNODE_TEX_WORLD, "WORLD", ICON_WORLD_DATA, "World", "Edit texture nodes from World."}, + {SNODE_TEX_BRUSH, "BRUSH", ICON_BRUSH_DATA, "Brush", "Edit texture nodes from Brush."}, + {0, NULL, 0, NULL, NULL}}; + + srna= RNA_def_struct(brna, "SpaceNodeEditor", "Space"); + RNA_def_struct_sdna(srna, "SpaceNode"); + RNA_def_struct_ui_text(srna, "Space Node Editor", "Node editor space data."); + + prop= RNA_def_property(srna, "tree_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "treetype"); + RNA_def_property_enum_items(prop, tree_type_items); + RNA_def_property_ui_text(prop, "Tree Type", "Node tree type to display and edit."); + RNA_def_property_update(prop, NC_NODE, NULL); + + prop= RNA_def_property(srna, "texture_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "texfrom"); + RNA_def_property_enum_items(prop, texture_type_items); + RNA_def_property_ui_text(prop, "Texture Type", "Type of data to take texture from."); + RNA_def_property_update(prop, NC_NODE, NULL); + + prop= RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "ID", "Datablock whose nodes are being edited."); + + prop= RNA_def_property(srna, "id_from", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "from"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "ID From", "Datablock from which the edited datablock is linked."); + + prop= RNA_def_property(srna, "nodetree", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Node Tree", "Node tree being displayed and edited."); + + prop= RNA_def_property(srna, "backdrop", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_BACKDRAW); + RNA_def_property_ui_text(prop, "Backdrop", "Use active Viewer Node output as backdrop for compositing nodes."); + RNA_def_property_update(prop, NC_NODE, NULL); +} + +static void rna_def_space_logic(BlenderRNA *brna) +{ + StructRNA *srna; + + srna= RNA_def_struct(brna, "SpaceLogicEditor", "Space"); + RNA_def_struct_sdna(srna, "SpaceLogic"); + RNA_def_struct_ui_text(srna, "Space Logic Editor", "Logic editor space data."); } void RNA_def_space(BlenderRNA *brna) @@ -1332,8 +1477,13 @@ void RNA_def_space(BlenderRNA *brna) rna_def_space_dopesheet(brna); rna_def_space_graph(brna); rna_def_space_nla(brna); + rna_def_space_time(brna); rna_def_space_console(brna); rna_def_console_line(brna); + rna_def_space_info(brna); + rna_def_space_userpref(brna); + rna_def_space_node(brna); + rna_def_space_logic(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 694f980e5e9..b7403ab1178 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -36,6 +36,9 @@ #include "DNA_material_types.h" #include "DNA_texture_types.h" #include "DNA_world_types.h" +#include "DNA_node_types.h" + +#include "BKE_node.h" #include "WM_types.h" @@ -50,6 +53,7 @@ static EnumPropertyItem texture_filter_items[] = { #ifdef RNA_RUNTIME #include "BKE_texture.h" +#include "ED_node.h" StructRNA *rna_Texture_refine(struct PointerRNA *ptr) { @@ -107,6 +111,65 @@ static void rna_TextureSlot_name_get(PointerRNA *ptr, char *str) strcpy(str, ""); } +static int rna_TextureSlot_output_node_get(PointerRNA *ptr) +{ + MTex *mtex= ptr->data; + Tex *tex= mtex->tex; + int cur= mtex->which_output; + + if(tex) { + bNodeTree *ntree= tex->nodetree; + bNode *node; + if(ntree) { + for(node= ntree->nodes.first; node; node= node->next) { + if(node->type == TEX_NODE_OUTPUT) { + if(cur == node->custom1) + return cur; + } + } + } + } + + mtex->which_output= 0; + return 0; +} + + +static EnumPropertyItem *rna_TextureSlot_output_node_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + MTex *mtex= ptr->data; + Tex *tex= mtex->tex; + EnumPropertyItem *item= NULL; + int totitem= 0; + + if(tex) { + bNodeTree *ntree= tex->nodetree; + if(ntree) { + EnumPropertyItem tmp= {0, "", 0, "", ""}; + bNode *node; + + tmp.value = 0; + tmp.name = "Not Specified"; + tmp.identifier = "NOT_SPECIFIED"; + RNA_enum_item_add(&item, &totitem, &tmp); + + for(node= ntree->nodes.first; node; node= node->next) { + if(node->type == TEX_NODE_OUTPUT) { + tmp.value= node->custom1; + tmp.name= ((TexNodeOutput*)node->storage)->name; + tmp.identifier = tmp.name; + RNA_enum_item_add(&item, &totitem, &tmp); + } + } + } + } + + RNA_enum_item_end(&item, &totitem); + + *free = 1; + return item; +} + static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, int value) { Tex *tex= (Tex*)ptr->data; @@ -118,6 +181,17 @@ static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, int value) tex->coba= add_colorband(0); } +void rna_Texture_use_nodes_set(PointerRNA *ptr, int v) +{ + Tex *tex= (Tex*)ptr->data; + + tex->use_nodes = v; + tex->type = 0; + + if(v && tex->nodetree==NULL) + ED_node_texture_default(tex); +} + static void rna_ImageTexture_mipmap_set(PointerRNA *ptr, int value) { Tex *tex= (Tex*)ptr->data; @@ -147,6 +221,20 @@ static EnumPropertyItem *rna_ImageTexture_filter_itemf(bContext *C, PointerRNA * return item; } +static float rna_TextureSlot_angle_get(PointerRNA *ptr) +{ + MTex *tex= (MTex*)ptr->data; + const float conv = 57.295779506; + return tex->rot * conv; +} + +static void rna_TextureSlot_angle_set(PointerRNA *ptr, float v) +{ + MTex *tex= (MTex*)ptr->data; + const float conv = 0.017453293; + tex->rot = v * conv; +} + #else static void rna_def_color_ramp_element(BlenderRNA *brna) @@ -209,27 +297,27 @@ static void rna_def_texmapping(BlenderRNA *brna) srna= RNA_def_struct(brna, "TexMapping", NULL); RNA_def_struct_ui_text(srna, "Texture Mapping", "Mapping settings"); - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_ui_text(prop, "Location", ""); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ROTATION); + prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "rot"); RNA_def_property_ui_text(prop, "Rotation", ""); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_ui_text(prop, "Scale", ""); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "minimum", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "minimum", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "min"); RNA_def_property_ui_text(prop, "Minimum", "Minimum value for clipping"); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "maximum", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "maximum", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "max"); RNA_def_property_ui_text(prop, "Maximum", "Maximum value for clipping"); RNA_def_property_update(prop, NC_TEXTURE, NULL); @@ -267,6 +355,16 @@ static void rna_def_mtex(BlenderRNA *brna) {MTEX_BLEND_COLOR, "COLOR", 0, "Color", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem prop_map_mode_items[] = { + {MTEX_MAP_MODE_FIXED, "FIXED", 0, "Fixed", ""}, + {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""}, + {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem output_node_items[] = { + {0, "DUMMY", 0, "Dummy", ""}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "TextureSlot", NULL); RNA_def_struct_sdna(srna, "MTex"); RNA_def_struct_ui_text(srna, "Texture Slot", "Texture slot defining the mapping and influence of a texture."); @@ -287,13 +385,13 @@ static void rna_def_mtex(BlenderRNA *brna) RNA_def_property_update(prop, NC_TEXTURE, NULL); /* mapping */ - prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "ofs"); RNA_def_property_ui_range(prop, -10, 10, 10, 2); RNA_def_property_ui_text(prop, "Offset", "Fine tunes texture mapping X, Y and Z locations."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_XYZ); RNA_def_property_ui_range(prop, -100, 100, 10, 2); RNA_def_property_ui_text(prop, "Size", "Sets scaling for the texture's X, Y and Z sizes."); RNA_def_property_update(prop, NC_TEXTURE, NULL); @@ -325,23 +423,41 @@ static void rna_def_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "RGB to Intensity", "Converts texture RGB values to intensity (gray) values."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "rot"); + RNA_def_property_range(prop, 0, 360); + RNA_def_property_float_funcs(prop, "rna_TextureSlot_angle_get", "rna_TextureSlot_angle_set", NULL); + RNA_def_property_ui_text(prop, "Angle", "Defines brush texture rotation."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "brush_map_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_map_mode_items); + RNA_def_property_ui_text(prop, "Mode", ""); + + prop= RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "def_var"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Default Value", "Value to use for Ref, Spec, Amb, Emit, Alpha, RayMir, TransLu and Hard."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "variable_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "variable_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "varfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Variable Factor", "Amount texture affects other values."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "norfac"); RNA_def_property_ui_range(prop, 0, 5, 10, 3); RNA_def_property_ui_text(prop, "Normal Factor", "Amount texture affects normal values."); RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "output_node", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "which_output"); + RNA_def_property_enum_items(prop, output_node_items); + RNA_def_property_enum_funcs(prop, "rna_TextureSlot_output_node_get", NULL, "rna_TextureSlot_output_node_itemf"); + RNA_def_property_ui_text(prop, "Output Node", "Which output node to use, for node-based textures."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); } static void rna_def_filter_size_common(StructRNA *srna) @@ -1085,17 +1201,34 @@ static void rna_def_texture_voronoi(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Voronoi", "Procedural voronoi texture."); RNA_def_struct_sdna(srna, "Tex"); - prop= RNA_def_property(srna, "feature_weights", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "weight_1", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "vn_w1"); - RNA_def_property_array(prop, 4); RNA_def_property_range(prop, -2, 2); - RNA_def_property_ui_text(prop, "Feature Weights", ""); + RNA_def_property_ui_text(prop, "Weight 1", "Voronoi feature weight 1"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "weight_2", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vn_w2"); + RNA_def_property_range(prop, -2, 2); + RNA_def_property_ui_text(prop, "Weight 2", "Voronoi feature weight 2"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "weight_3", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vn_w3"); + RNA_def_property_range(prop, -2, 2); + RNA_def_property_ui_text(prop, "Weight 3", "Voronoi feature weight 3"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "weight_4", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vn_w4"); + RNA_def_property_range(prop, -2, 2); + RNA_def_property_ui_text(prop, "Weight 4", "Voronoi feature weight 4"); RNA_def_property_update(prop, NC_TEXTURE, NULL); prop= RNA_def_property(srna, "minkovsky_exponent", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "vn_mexp"); RNA_def_property_range(prop, 0.01, 10); - RNA_def_property_ui_text(prop, "Minkovsky Exponent", ""); + RNA_def_property_ui_text(prop, "Minkovsky Exponent", "Minkovsky exponent"); RNA_def_property_update(prop, NC_TEXTURE, NULL); prop= RNA_def_property(srna, "distance_metric", PROP_ENUM, PROP_NONE); @@ -1237,7 +1370,19 @@ static void rna_def_texture(BlenderRNA *brna) RNA_def_property_range(prop, 0, 2); RNA_def_property_ui_text(prop, "RGB Factor", ""); RNA_def_property_update(prop, NC_TEXTURE, NULL); - + + /* nodetree */ + prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Texture_use_nodes_set"); + RNA_def_property_ui_text(prop, "Use Nodes", "Make this a node-based texture"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); + RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node-based textures"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + rna_def_animdata_common(srna); /* specific types */ diff --git a/source/blender/makesrna/intern/rna_timeline.c b/source/blender/makesrna/intern/rna_timeline.c index d42603e1952..5e20fca15f0 100644 --- a/source/blender/makesrna/intern/rna_timeline.c +++ b/source/blender/makesrna/intern/rna_timeline.c @@ -49,7 +49,7 @@ static void rna_def_timeline_marker(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Name", ""); RNA_def_struct_name_property(srna, prop); - prop= RNA_def_property(srna, "frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "frame", PROP_INT, PROP_TIME); RNA_def_property_ui_text(prop, "Frame", "The frame on which the timeline marker appears."); } diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 590f85fedd7..f16180451a7 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -138,6 +138,8 @@ static void rna_Panel_unregister(const bContext *C, StructRNA *type) if(!(art=region_type_find(NULL, pt->space_type, pt->region_type))) return; + RNA_struct_free_extension(type, &pt->ext); + BLI_freelinkN(&art->paneltypes, pt); RNA_struct_free(&BLENDER_RNA, type); @@ -146,7 +148,7 @@ static void rna_Panel_unregister(const bContext *C, StructRNA *type) WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } -static StructRNA *rna_Panel_register(const bContext *C, ReportList *reports, void *data, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Panel_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { ARegionType *art; PanelType *pt, dummypt = {0}; @@ -233,6 +235,8 @@ static void rna_Header_unregister(const bContext *C, StructRNA *type) if(!(art=region_type_find(NULL, ht->space_type, RGN_TYPE_HEADER))) return; + RNA_struct_free_extension(type, &ht->ext); + BLI_freelinkN(&art->headertypes, ht); RNA_struct_free(&BLENDER_RNA, type); @@ -241,7 +245,7 @@ static void rna_Header_unregister(const bContext *C, StructRNA *type) WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } -static StructRNA *rna_Header_register(const bContext *C, ReportList *reports, void *data, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Header_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { ARegionType *art; HeaderType *ht, dummyht = {0}; @@ -347,6 +351,8 @@ static void rna_Menu_unregister(const bContext *C, StructRNA *type) if(!(art=region_type_find(NULL, mt->space_type, RGN_TYPE_HEADER))) return; + RNA_struct_free_extension(type, &mt->ext); + BLI_freelinkN(&art->menutypes, mt); RNA_struct_free(&BLENDER_RNA, type); @@ -355,7 +361,7 @@ static void rna_Menu_unregister(const bContext *C, StructRNA *type) WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } -static StructRNA *rna_Menu_register(const bContext *C, ReportList *reports, void *data, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Menu_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { ARegionType *art; MenuType *mt, dummymt = {0}; diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 67ade9998ed..82694098e69 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -119,7 +119,7 @@ void RNA_api_ui_layout(StructRNA *srna) func= RNA_def_function(srna, "split", "uiLayoutSplit"); parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); RNA_def_function_return(func, parm); - RNA_def_float(func, "percentage", 0.5f, 0.0f, 1.0f, "Percentage", "Percentage of width to split at.", 0.0f, 1.0f); + RNA_def_float(func, "percentage", 0.0f, 0.0f, 1.0f, "Percentage", "Percentage of width to split at.", 0.0f, 1.0f); /* items */ func= RNA_def_function(srna, "itemR", "uiItemR"); @@ -220,6 +220,7 @@ void RNA_api_ui_layout(StructRNA *srna) /* templates */ func= RNA_def_function(srna, "template_header", "uiTemplateHeader"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_boolean(func, "menus", 1, "", "The header has menus, and should show menu expander."); func= RNA_def_function(srna, "template_ID", "uiTemplateID"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); @@ -243,11 +244,13 @@ void RNA_api_ui_layout(StructRNA *srna) parm= RNA_def_pointer(func, "id", "ID", "", "ID datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); parm= RNA_def_pointer(func, "parent", "ID", "", "ID datablock."); + parm= RNA_def_pointer(func, "slot", "TextureSlot", "", "Texture slot."); func= RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping"); parm= RNA_def_pointer(func, "curvemap", "CurveMapping", "", "Curve mapping pointer."); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display."); + RNA_def_boolean(func, "compact", 0, "", "Use more compact curve mapping."); func= RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp"); parm= RNA_def_pointer(func, "ramp", "ColorRamp", "", "Color ramp pointer."); @@ -287,6 +290,15 @@ void RNA_api_ui_layout(StructRNA *srna) func= RNA_def_function(srna, "template_header_3D", "uiTemplateHeader3D"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); + func= RNA_def_function(srna, "view3d_select_metaballmenu", "uiTemplate_view3d_select_metaballmenu"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + func= RNA_def_function(srna, "view3d_select_armaturemenu", "uiTemplate_view3d_select_armaturemenu"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + func= RNA_def_function(srna, "view3d_select_posemenu", "uiTemplate_view3d_select_posemenu"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + func= RNA_def_function(srna, "view3d_select_faceselmenu", "uiTemplate_view3d_select_faceselmenu"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + func= RNA_def_function(srna, "template_texture_image", "uiTemplateTextureImage"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm= RNA_def_pointer(func, "texture", "Texture", "", ""); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index f1fd11a0094..d1245528100 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -37,6 +37,8 @@ #include "BKE_utildefines.h" +#include "BKE_sound.h" + #ifdef RNA_RUNTIME static void rna_userdef_lmb_select_set(struct PointerRNA *ptr,int value) @@ -116,6 +118,11 @@ static PointerRNA rna_UserDef_system_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_UserPreferencesSystem, ptr->data); } +static void rna_UserDef_audio_update(bContext *C, PointerRNA *ptr) +{ + sound_init(C); +} + #else static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) @@ -683,7 +690,7 @@ static void rna_def_userdef_theme_space_graph(BlenderRNA *brna) srna= RNA_def_struct(brna, "ThemeGraphEditor", NULL); RNA_def_struct_sdna(srna, "ThemeSpace"); - RNA_def_struct_ui_text(srna, "Theme Graph Editor", "Theme settings for the Ipo Editor."); + RNA_def_struct_ui_text(srna, "Theme Graph Editor", "Theme settings for the graph editor."); rna_def_userdef_theme_spaces_main(srna, SPACE_IPO); @@ -820,19 +827,33 @@ static void rna_def_userdef_theme_space_outliner(BlenderRNA *brna) rna_def_userdef_theme_spaces_main(srna, SPACE_OUTLINER); } +static void rna_def_userdef_theme_space_userpref(BlenderRNA *brna) +{ + StructRNA *srna; + + /* space_userpref */ + + srna= RNA_def_struct(brna, "ThemeUserPreferences", NULL); + RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_ui_text(srna, "Theme User Preferences", "Theme settings for the User Preferences."); + + rna_def_userdef_theme_spaces_main(srna, SPACE_USERPREF); +} + static void rna_def_userdef_theme_space_info(BlenderRNA *brna) { StructRNA *srna; /* space_info */ - srna= RNA_def_struct(brna, "ThemeUserPreferences", NULL); + srna= RNA_def_struct(brna, "ThemeInfo", NULL); RNA_def_struct_sdna(srna, "ThemeSpace"); - RNA_def_struct_ui_text(srna, "Theme User Preferences", "Theme settings for the User Preferences."); + RNA_def_struct_ui_text(srna, "Theme Info", "Theme settings for Info."); rna_def_userdef_theme_spaces_main(srna, SPACE_INFO); } + static void rna_def_userdef_theme_space_text(BlenderRNA *brna) { StructRNA *srna; @@ -990,9 +1011,9 @@ static void rna_def_userdef_theme_space_buts(BlenderRNA *brna) /* space_buts */ - srna= RNA_def_struct(brna, "ThemeButtonsWindow", NULL); + srna= RNA_def_struct(brna, "ThemeProperties", NULL); RNA_def_struct_sdna(srna, "ThemeSpace"); - RNA_def_struct_ui_text(srna, "Theme Buttons Window", "Theme settings for the Buttons Window."); + RNA_def_struct_ui_text(srna, "Theme Properties", "Theme settings for the Properties."); rna_def_userdef_theme_spaces_main(srna, SPACE_BUTS); @@ -1393,10 +1414,10 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_struct_type(prop, "ThemeSequenceEditor"); RNA_def_property_ui_text(prop, "Sequence Editor", ""); - prop= RNA_def_property(srna, "buttons_window", PROP_POINTER, PROP_NEVER_NULL); + prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "tbuts"); - RNA_def_property_struct_type(prop, "ThemeButtonsWindow"); - RNA_def_property_ui_text(prop, "Buttons Window", ""); + RNA_def_property_struct_type(prop, "ThemeProperties"); + RNA_def_property_ui_text(prop, "Properties", ""); prop= RNA_def_property(srna, "text_editor", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "text"); @@ -1423,8 +1444,13 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_struct_type(prop, "ThemeOutliner"); RNA_def_property_ui_text(prop, "Outliner", ""); - prop= RNA_def_property(srna, "user_preferences", PROP_POINTER, PROP_NEVER_NULL); + prop= RNA_def_property(srna, "info", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "tinfo"); + RNA_def_property_struct_type(prop, "ThemeInfo"); + RNA_def_property_ui_text(prop, "Info", ""); + + prop= RNA_def_property(srna, "user_preferences", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "tuserpref"); RNA_def_property_struct_type(prop, "ThemeUserPreferences"); RNA_def_property_ui_text(prop, "User Preferences", ""); @@ -1453,6 +1479,7 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna) rna_def_userdef_theme_space_node(brna); rna_def_userdef_theme_space_outliner(brna); rna_def_userdef_theme_space_info(brna); + rna_def_userdef_theme_space_userpref(brna); rna_def_userdef_theme_space_sound(brna); rna_def_userdef_theme_space_logic(brna); rna_def_userdef_theme_colorset(brna); @@ -1472,7 +1499,7 @@ static void rna_def_userdef_solidlight(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", 1); RNA_def_property_ui_text(prop, "Enabled", "Enable this OpenGL light in solid draw mode."); - prop= RNA_def_property(srna, "direction", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "direction", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_float_sdna(prop, NULL, "vec"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Direction", "The direction that the OpenGL light is shining."); @@ -1819,11 +1846,9 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "gp_settings", GP_PAINT_DOSMOOTH); RNA_def_property_ui_text(prop, "Grease Pencil Smooth Stroke", "Smooth the final stroke."); -#if 0 prop= RNA_def_property(srna, "grease_pencil_simplify_stroke", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gp_settings", GP_PAINT_DOSIMPLIFY); RNA_def_property_ui_text(prop, "Grease Pencil Simplify Stroke", "Simplify the final stroke."); -#endif prop= RNA_def_property(srna, "grease_pencil_eraser_radius", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gp_eraser"); @@ -1977,6 +2002,47 @@ static void rna_def_userdef_system(BlenderRNA *brna) {512, "AUDIO_SAMPLES_512", 0, "512", "Set audio mixing buffer size to 512 samples"}, {1024, "AUDIO_SAMPLES_1024", 0, "1024", "Set audio mixing buffer size to 1024 samples"}, {2048, "AUDIO_SAMPLES_2048", 0, "2048", "Set audio mixing buffer size to 2048 samples"}, + {4096, "AUDIO_SAMPLES_4096", 0, "4096", "Set audio mixing buffer size to 4096 samples"}, + {8192, "AUDIO_SAMPLES_8192", 0, "8192", "Set audio mixing buffer size to 8192 samples"}, + {16384, "AUDIO_SAMPLES_16384", 0, "16384", "Set audio mixing buffer size to 16384 samples"}, + {32768, "AUDIO_SAMPLES_32768", 0, "32768", "Set audio mixing buffer size to 32768 samples"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem audio_device_items[] = { + {0, "AUDIO_DEVICE_NULL", 0, "No Audio", "Null device - there will be no audio output."}, + {1, "AUDIO_DEVICE_SDL", 0, "SDL", "SDL device - simple direct media layer, recommended for sequencer usage."}, + {2, "AUDIO_DEVICE_OPENAL", 0, "OpenAL", "OpenAL device - supports 3D audio, recommended for game engine usage."}, + {3, "AUDIO_DEVICE_JACK", 0, "Jack", "Jack device - open source pro audio, recommended for pro audio users."}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem audio_rate_items[] = { +// {8000, "AUDIO_RATE_8000", 0, "8 kHz", "Set audio sampling rate to 8000 samples per second."}, +// {11025, "AUDIO_RATE_11025", 0, "11.025 kHz", "Set audio sampling rate to 11025 samples per second."}, +// {16000, "AUDIO_RATE_16000", 0, "16 kHz", "Set audio sampling rate to 16000 samples per second."}, +// {22050, "AUDIO_RATE_22050", 0, "22.05 kHz", "Set audio sampling rate to 22050 samples per second."}, +// {32000, "AUDIO_RATE_32000", 0, "32 kHz", "Set audio sampling rate to 32000 samples per second."}, + {44100, "AUDIO_RATE_44100", 0, "44.1 kHz", "Set audio sampling rate to 44100 samples per second."}, + {48000, "AUDIO_RATE_48000", 0, "48 kHz", "Set audio sampling rate to 48000 samples per second."}, +// {88200, "AUDIO_RATE_88200", 0, "88.2 kHz", "Set audio sampling rate to 88200 samples per second."}, + {96000, "AUDIO_RATE_96000", 0, "96 kHz", "Set audio sampling rate to 96000 samples per second."}, + {192000, "AUDIO_RATE_192000", 0, "192 kHz", "Set audio sampling rate to 192000 samples per second."}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem audio_format_items[] = { + {0x01, "AUDIO_FORMAT_U8", 0, "8-bit Unsigned", "Set audio sample format to 8 bit unsigned integer."}, + {0x12, "AUDIO_FORMAT_S16", 0, "16-bit Signed", "Set audio sample format to 16 bit signed integer."}, + {0x13, "AUDIO_FORMAT_S24", 0, "24-bit Signed", "Set audio sample format to 24 bit signed integer."}, + {0x14, "AUDIO_FORMAT_S32", 0, "32-bit Signed", "Set audio sample format to 32 bit signed integer."}, + {0x24, "AUDIO_FORMAT_FLOAT", 0, "32-bit Float", "Set audio sample format to 32 bit float."}, + {0x28, "AUDIO_FORMAT_DOUBLE", 0, "64-bit Float", "Set audio sample format to 64 bit float."}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem audio_channel_items[] = { + {1, "AUDIO_CHANNELS_MONO", 0, "Mono", "Set audio channels to mono."}, + {2, "AUDIO_CHANNELS_STEREO", 0, "Stereo", "Set audio channels to stereo."}, + {4, "AUDIO_CHANNELS_SURROUND4", 0, "4 Channels", "Set audio channels to 4 channels."}, + {6, "AUDIO_CHANNELS_SURROUND51", 0, "5.1 Surround", "Set audio channels to 5.1 surround sound."}, + {8, "AUDIO_CHANNELS_SURROUND71", 0, "7.1 Surround", "Set audio channels to 7.1 surround sound."}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem draw_method_items[] = { @@ -2078,6 +2144,31 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "mixbufsize"); RNA_def_property_enum_items(prop, audio_mixing_samples_items); RNA_def_property_ui_text(prop, "Audio Mixing Buffer", "Sets the number of samples used by the audio mixing buffer."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); + + prop= RNA_def_property(srna, "audio_device", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "audiodevice"); + RNA_def_property_enum_items(prop, audio_device_items); + RNA_def_property_ui_text(prop, "Audio Device", "Sets the audio output device."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); + + prop= RNA_def_property(srna, "audio_sample_rate", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "audiorate"); + RNA_def_property_enum_items(prop, audio_rate_items); + RNA_def_property_ui_text(prop, "Audio Sample Rate", "Sets the audio sample rate."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); + + prop= RNA_def_property(srna, "audio_sample_format", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "audioformat"); + RNA_def_property_enum_items(prop, audio_format_items); + RNA_def_property_ui_text(prop, "Audio Sample Format", "Sets the audio sample format."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); + + prop= RNA_def_property(srna, "audio_channels", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "audiochannels"); + RNA_def_property_enum_items(prop, audio_channel_items); + RNA_def_property_ui_text(prop, "Audio Channels", "Sets the audio channel count."); + RNA_def_property_update(prop, 0, "rna_UserDef_audio_update"); #if 0 prop= RNA_def_property(srna, "verse_master", PROP_STRING, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 4a2154bc3cf..eaed0100386 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -297,7 +297,7 @@ static void rna_def_operator_utils(BlenderRNA *brna) srna= RNA_def_struct(brna, "OperatorMousePath", "IDPropertyGroup"); RNA_def_struct_ui_text(srna, "Operator Mouse Path", "Mouse path values for operators that record such paths."); - prop= RNA_def_property(srna, "loc", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "loc", PROP_FLOAT, PROP_XYZ); RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_array(prop, 2); RNA_def_property_ui_text(prop, "Location", "Mouse location."); diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index f23b893539d..525a4446932 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -154,25 +154,25 @@ static void rna_def_world_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "blend_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "blend_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "varfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Blend Factor", "Amount texture affects color progression of the background."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "horizon_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "horizon_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Horizon Factor", "Amount texture affects color of the horizon."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "zenith_up_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "zenith_up_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Zenith Up Factor", "Amount texture affects color of the zenith above."); RNA_def_property_update(prop, NC_TEXTURE, NULL); - prop= RNA_def_property(srna, "zenith_down_factor", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "zenith_down_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colfac"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Zenith Down Factor", "Amount texture affects color of the zenith below."); @@ -216,7 +216,7 @@ static void rna_def_ambient_occlusion(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_AMB_OCC); RNA_def_property_ui_text(prop, "Enabled", "Use Ambient Occlusion to add light based on distance between elements, creating the illusion of omnipresent light"); - prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "aodist"); RNA_def_property_ui_text(prop, "Distance", "Length of rays, defines how far away other faces give occlusion effect."); @@ -319,19 +319,19 @@ static void rna_def_world_mist(BlenderRNA *brna) RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Intensity", "Intensity of the mist effect."); - prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "miststa"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 10000, 10, 2); RNA_def_property_ui_text(prop, "Start", "Starting distance of the mist, measured from the camera"); - prop= RNA_def_property(srna, "depth", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "depth", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "mistdist"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 10000, 10, 2); RNA_def_property_ui_text(prop, "Depth", "The distance over which the mist effect fades in"); - prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "misthi"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Height", "Control how much mist density decreases with height"); @@ -363,7 +363,7 @@ static void rna_def_world_stars(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Size", "Average screen dimension of stars."); RNA_def_property_update(prop, NC_WORLD, NULL); - prop= RNA_def_property(srna, "min_distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "min_distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "starmindist"); RNA_def_property_range(prop, 0, 1000); RNA_def_property_ui_text(prop, "Minimum Distance", "Minimum distance to the camera for stars."); diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 664aacf11ab..ca21ba592a8 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -31,7 +31,6 @@ SET(INC ../imbuf ../avi ../../../intern/elbeem/extern ../../../intern/iksolver/extern ../blenloader ../quicktime ../blenkernel ../../../extern/glew/include ../gpu - ${SDL_INC} ${ZLIB_INC} ) diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c index fbc56dfcc83..693a20b5b0f 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c @@ -34,9 +34,7 @@ #endif /* TODO, support python3.x */ -#if PY_VERSION_HEX >= 0x03000000 #define DISABLE_PYTHON 1 -#endif #include "DNA_text_types.h" #include "BKE_text.h" diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_at.c b/source/blender/nodes/intern/TEX_nodes/TEX_at.c index 80f232ccd0c..4d714d91130 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_at.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_at.c @@ -38,12 +38,14 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { + TexParams np = *p; float new_coord[3]; + np.coord = new_coord; - tex_input_vec(new_coord, in[1], coord, thread); - tex_input_rgba(out, in[0], new_coord, thread); + tex_input_vec(new_coord, in[1], p, thread); + tex_input_rgba(out, in[0], &np, thread); } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c index 80cbd6188ee..f1f3b0919ae 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -57,8 +57,10 @@ static float noise(int n) /* fast integer noise */ return 0.5f * ((float)nn / 1073741824.0f); } -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { + float *coord = p->coord; + float x = coord[0]; float y = coord[1]; @@ -71,14 +73,14 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor float bricks2[4]; float mortar[4]; - float mortar_thickness = tex_input_value(in[3], coord, thread); - float bias = tex_input_value(in[4], coord, thread); - float brick_width = tex_input_value(in[5], coord, thread); - float row_height = tex_input_value(in[6], coord, thread); + float mortar_thickness = tex_input_value(in[3], p, thread); + float bias = tex_input_value(in[4], p, thread); + float brick_width = tex_input_value(in[5], p, thread); + float row_height = tex_input_value(in[6], p, thread); - tex_input_rgba(bricks1, in[0], coord, thread); - tex_input_rgba(bricks2, in[1], coord, thread); - tex_input_rgba(mortar, in[2], coord, thread); + tex_input_rgba(bricks1, in[0], p, thread); + tex_input_rgba(bricks2, in[1], p, thread); + tex_input_rgba(mortar, in[2], p, thread); rownum = (int)floor(y / row_height); diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c index 60357782e25..b889f1e2164 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -40,12 +40,12 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - float x = coord[0]; - float y = coord[1]; - float z = coord[2]; - float sz = tex_input_value(in[2], coord, thread); + float x = p->coord[0]; + float y = p->coord[1]; + float z = p->coord[2]; + float sz = tex_input_value(in[2], p, thread); /* 0.00001 because of unit sized stuff */ int xi = (int)fabs(floor(0.00001 + x / sz)); @@ -53,9 +53,9 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor int zi = (int)fabs(floor(0.00001 + z / sz)); if( (xi % 2 == yi % 2) == (zi % 2) ) { - tex_input_rgba(out, in[0], coord, thread); + tex_input_rgba(out, in[0], p, thread); } else { - tex_input_rgba(out, in[1], coord, thread); + tex_input_rgba(out, in[1], p, thread); } } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c index 26576befa3e..9fc4b2ff7c2 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -40,11 +40,11 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { int i; for(i = 0; i < 4; i++) - out[i] = tex_input_value(in[i], coord, thread); + out[i] = tex_input_value(in[i], p, thread); } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c index da487c190af..e5c2b309fb3 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c @@ -33,11 +33,11 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void vectorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void vectorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - out[0] = coord[0]; - out[1] = coord[1]; - out[2] = coord[2]; + out[0] = p->coord[0]; + out[1] = p->coord[1]; + out[2] = p->coord[2]; } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c index 7d1366b5b18..61ebcea7360 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -36,14 +36,13 @@ static bNodeSocketType time_outputs[]= { { -1, 0, "" } }; -static void time_colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { /* stack order output: fac */ float fac= 0.0f; - // XXX SOLVE! these functions should get the TexCallData pointer -// if(node->custom1 < node->custom2) -// fac = (scene->r.cfra - node->custom1)/(float)(node->custom2-node->custom1); + if(node->custom1 < node->custom2) + fac = (p->cfra - node->custom1)/(float)(node->custom2-node->custom1); fac = curvemapping_evaluateF(node->storage, 0, fac); out[0] = CLAMPIS(fac, 0.0f, 1.0f); @@ -90,10 +89,10 @@ static bNodeSocketType rgb_outputs[]= { { -1, 0, "" } }; -static void rgb_colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float cin[4]; - tex_input_rgba(cin, in[0], coord, thread); + tex_input_rgba(cin, in[0], p, thread); curvemapping_evaluateRGBF(node->storage, out, cin); out[3] = cin[3]; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c index c08eb12a18f..f7a409f0230 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -41,27 +41,27 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void valuefn_r(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valuefn_r(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - tex_input_rgba(out, in[0], coord, thread); + tex_input_rgba(out, in[0], p, thread); *out = out[0]; } -static void valuefn_g(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valuefn_g(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - tex_input_rgba(out, in[0], coord, thread); + tex_input_rgba(out, in[0], p, thread); *out = out[1]; } -static void valuefn_b(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valuefn_b(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - tex_input_rgba(out, in[0], coord, thread); + tex_input_rgba(out, in[0], p, thread); *out = out[2]; } -static void valuefn_a(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valuefn_a(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - tex_input_rgba(out, in[0], coord, thread); + tex_input_rgba(out, in[0], p, thread); *out = out[3]; } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c index d23eb6bc589..4e145e26b72 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c @@ -41,12 +41,12 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void valuefn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float coord1[3], coord2[3]; - tex_input_vec(coord1, in[0], coord, thread); - tex_input_vec(coord2, in[1], coord, thread); + tex_input_vec(coord1, in[0], p, thread); + tex_input_vec(coord2, in[1], p, thread); *out = VecLenf(coord2, coord1); } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c index bb1a49fb235..192c7a39ee8 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c @@ -65,15 +65,15 @@ static void do_hue_sat_fac(bNode *node, float *out, float hue, float sat, float } } -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - float hue = tex_input_value(in[0], coord, thread); - float sat = tex_input_value(in[1], coord, thread); - float val = tex_input_value(in[2], coord, thread); - float fac = tex_input_value(in[3], coord, thread); + float hue = tex_input_value(in[0], p, thread); + float sat = tex_input_value(in[1], p, thread); + float val = tex_input_value(in[2], p, thread); + float fac = tex_input_value(in[3], p, thread); float col[4]; - tex_input_rgba(col, in[4], coord, thread); + tex_input_rgba(col, in[4], p, thread); hue += 0.5f; /* [-.5, .5] -> [0, 1] */ diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_image.c b/source/blender/nodes/intern/TEX_nodes/TEX_image.c index b84088da154..0a55af70b52 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_image.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_image.c @@ -22,7 +22,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -34,10 +34,10 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - float x = coord[0]; - float y = coord[1]; + float x = p->coord[0]; + float y = p->coord[1]; Image *ima= (Image *)node->id; ImageUser *iuser= (ImageUser *)node->storage; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c index 09716951009..5663f897ff5 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -39,11 +39,11 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float col[4]; - tex_input_rgba(col, in[0], coord, thread); + tex_input_rgba(col, in[0], p, thread); col[0] = 1.0f - col[0]; col[1] = 1.0f - col[1]; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_math.c b/source/blender/nodes/intern/TEX_nodes/TEX_math.c index bac91fc0901..4ee04140fca 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_math.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_math.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -42,10 +42,10 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void valuefn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - float in0 = tex_input_value(in[0], coord, thread); - float in1 = tex_input_value(in[1], coord, thread); + float in0 = tex_input_value(in[0], p, thread); + float in1 = tex_input_value(in[1], p, thread); switch(node->custom1){ diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c index b1ccb7a3d07..24bdde70127 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -41,13 +41,13 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - float fac = tex_input_value(in[0], coord, thread); + float fac = tex_input_value(in[0], p, thread); float col1[4], col2[4]; - tex_input_rgba(col1, in[1], coord, thread); - tex_input_rgba(col2, in[2], coord, thread); + tex_input_rgba(col1, in[1], p, thread); + tex_input_rgba(col2, in[2], p, thread); CLAMP(fac, 0.0f, 1.0f); diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_output.c b/source/blender/nodes/intern/TEX_nodes/TEX_output.c index 060ea8d7e67..7ce5ec88c48 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_output.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_output.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -35,6 +35,48 @@ static bNodeSocketType inputs[]= { { -1, 0, "" } }; +static void osa( + void (*input_fn)(float *, bNodeStack *, TexParams *, short), + float *out, + bNodeStack *in, + TexParams *p, + short thread +){ + if(!p->dxt) { + input_fn(out, in, p, thread); + } else { + float sample[4] = {0}; + float coord[3]; + TexParams sp = *p; + int i; + + sp.coord = coord; + sp.dxt = sp.dyt = 0; + + QUATCOPY(out, sample); + + for(i=0; i<5; i++) { + VECCOPY(coord, p->coord); + + if(i < 4) + { + if(i % 2) VECADD(coord, coord, p->dxt); + if(i > 1) VECADD(coord, coord, p->dyt); + } + else + { + VECADDFAC(coord, coord, p->dxt, 0.5); + VECADDFAC(coord, coord, p->dyt, 0.5); + } + + input_fn(sample, in, &sp, thread); + + QUATADDFAC(out, out, sample, 0.2); + } + } +} + + /* applies to render pipeline */ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { @@ -49,14 +91,17 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) if(!cdata->do_preview) { if(cdata->which_output == node->custom1) { - tex_input_rgba(&target->tr, in[0], cdata->coord, cdata->thread); + TexParams params; + params_from_cdata(¶ms, cdata); + + osa(tex_input_rgba, &target->tr, in[0], ¶ms, cdata->thread); target->tin = (target->tr + target->tg + target->tb) / 3.0f; target->talpha = 1.0f; if(target->nor) { if(in[1]->hasinput) - tex_input_vec(target->nor, in[1], cdata->coord, cdata->thread); + osa(tex_input_vec, target->nor, in[1], ¶ms, cdata->thread); else target->nor = 0; } @@ -64,13 +109,85 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) } } -static void init(bNode* node) +static void unique_name(bNode *node) { - TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output"); - strcpy(tno->name, "Default"); - node->storage= tno; + TexNodeOutput *tno = (TexNodeOutput *)node->storage; + char *new_name = 0; + int new_len; + int suffix; + bNode *i; + char *name = tno->name; + + i = node; + while(i->prev) i = i->prev; + for(; i; i=i->next) { + if( + i == node || + i->type != TEX_NODE_OUTPUT || + strcmp(name, ((TexNodeOutput*)(i->storage))->name) + ) + continue; + + if(!new_name) { + int len = strlen(name); + if(len >= 4 && sscanf(name + len - 4, ".%03d", &suffix) == 1) { + new_len = len; + } else { + suffix = 0; + new_len = len + 4; + if(new_len > 31) + new_len = 31; + } + + new_name = malloc(new_len + 1); + strcpy(new_name, name); + name = new_name; + } + sprintf(new_name + new_len - 4, ".%03d", ++suffix); + } + + if(new_name) { + strcpy(tno->name, new_name); + free(new_name); + } } +static void assign_index(struct bNode *node) +{ + bNode *tnode; + int index = 1; + + tnode = node; + while(tnode->prev) + tnode = tnode->prev; + + check_index: + for(; tnode; tnode= tnode->next) + if(tnode->type == TEX_NODE_OUTPUT && tnode != node) + if(tnode->custom1 == index) { + index ++; + goto check_index; + } + + node->custom1 = index; +} + +static void init(bNode *node) +{ + TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output"); + node->storage= tno; + + strcpy(tno->name, "Default"); + unique_name(node); + assign_index(node); +} + +static void copy(bNode *orig, bNode *new) +{ + node_copy_standard_storage(orig, new); + unique_name(new); + assign_index(new); +} bNodeType tex_node_output= { /* *next,*prev */ NULL, NULL, @@ -85,6 +202,6 @@ bNodeType tex_node_output= { /* butfunc */ NULL, /* initfunc */ init, /* freestoragefunc */ node_free_standard_storage, - /* copystoragefunc */ node_copy_standard_storage, + /* copystoragefunc */ copy, /* id */ NULL }; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c index ec65cf186a8..ce7324e2085 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -51,7 +51,7 @@ static bNodeSocketType outputs_color_only[]= { { SOCK_RGBA, 1, "Color 2", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f } /* Calls multitex and copies the result to the outputs. Called by xxx_exec, which handles inputs. */ -static void do_proc(float *result, float *coord, float *col1, float *col2, char is_normal, Tex *tex, short thread) +static void do_proc(float *result, TexParams *p, float *col1, float *col2, char is_normal, Tex *tex, short thread) { TexResult texres; int textype; @@ -62,7 +62,7 @@ static void do_proc(float *result, float *coord, float *col1, float *col2, char else texres.nor = NULL; - textype = multitex_thread(tex, coord, 0, 0, 0, &texres, thread, 0); + textype = multitex_thread(tex, p->coord, p->dxt, p->dyt, 0, &texres, thread, 0); if(is_normal) return; @@ -76,11 +76,11 @@ static void do_proc(float *result, float *coord, float *col1, float *col2, char } } -typedef void (*MapFn) (Tex *tex, bNodeStack **in, float *coord, short thread); +typedef void (*MapFn) (Tex *tex, bNodeStack **in, TexParams *p, short thread); static void texfn( float *result, - float *coord, + TexParams *p, bNode *node, bNodeStack **in, char is_normal, @@ -89,12 +89,12 @@ static void texfn( { Tex tex = *((Tex*)(node->storage)); float col1[4], col2[4]; - tex_input_rgba(col1, in[0], coord, thread); - tex_input_rgba(col2, in[1], coord, thread); + tex_input_rgba(col1, in[0], p, thread); + tex_input_rgba(col2, in[1], p, thread); - map_inputs(&tex, in, coord, thread); + map_inputs(&tex, in, p, thread); - do_proc(result, coord, col1, col2, is_normal, &tex, thread); + do_proc(result, p, col1, col2, is_normal, &tex, thread); } static int count_outputs(bNode *node) @@ -110,17 +110,17 @@ static int count_outputs(bNode *node) /* Boilerplate generators */ #define ProcNoInputs(name) \ - static void name##_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) \ + static void name##_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) \ {} #define ProcDef(name) \ - static void name##_colorfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \ + static void name##_colorfn(float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \ { \ - texfn(result, coord, node, in, 0, &name##_map_inputs, thread); \ + texfn(result, p, node, in, 0, &name##_map_inputs, thread); \ } \ - static void name##_normalfn(float *result, float *coord, bNode *node, bNodeStack **in, short thread) \ + static void name##_normalfn(float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \ { \ - texfn(result, coord, node, in, 1, &name##_map_inputs, thread); \ + texfn(result, p, node, in, 1, &name##_map_inputs, thread); \ } \ static void name##_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) \ { \ @@ -144,15 +144,15 @@ static bNodeSocketType voronoi_inputs[]= { { -1, 0, "" } }; -static void voronoi_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void voronoi_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->vn_w1 = tex_input_value(in[I+0], coord, thread); - tex->vn_w2 = tex_input_value(in[I+1], coord, thread); - tex->vn_w3 = tex_input_value(in[I+2], coord, thread); - tex->vn_w4 = tex_input_value(in[I+3], coord, thread); + tex->vn_w1 = tex_input_value(in[I+0], p, thread); + tex->vn_w2 = tex_input_value(in[I+1], p, thread); + tex->vn_w3 = tex_input_value(in[I+2], p, thread); + tex->vn_w4 = tex_input_value(in[I+3], p, thread); - tex->ns_outscale = tex_input_value(in[I+4], coord, thread); - tex->noisesize = tex_input_value(in[I+5], coord, thread); + tex->ns_outscale = tex_input_value(in[I+4], p, thread); + tex->noisesize = tex_input_value(in[I+5], p, thread); } ProcDef(voronoi) @@ -170,9 +170,9 @@ static bNodeSocketType magic_inputs[]= { { SOCK_VALUE, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f }, { -1, 0, "" } }; -static void magic_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void magic_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->turbul = tex_input_value(in[I+0], coord, thread); + tex->turbul = tex_input_value(in[I+0], p, thread); } ProcDef(magic) @@ -183,10 +183,10 @@ static bNodeSocketType marble_inputs[]= { { SOCK_VALUE, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f }, { -1, 0, "" } }; -static void marble_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void marble_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->noisesize = tex_input_value(in[I+0], coord, thread); - tex->turbul = tex_input_value(in[I+1], coord, thread); + tex->noisesize = tex_input_value(in[I+0], p, thread); + tex->turbul = tex_input_value(in[I+1], p, thread); } ProcDef(marble) @@ -196,9 +196,9 @@ static bNodeSocketType clouds_inputs[]= { { SOCK_VALUE, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f }, { -1, 0, "" } }; -static void clouds_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void clouds_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->noisesize = tex_input_value(in[I+0], coord, thread); + tex->noisesize = tex_input_value(in[I+0], p, thread); } ProcDef(clouds) @@ -209,10 +209,10 @@ static bNodeSocketType distnoise_inputs[]= { { SOCK_VALUE, 1, "Distortion", 1.00f, 0.0f, 0.0f, 0.0f, 0.0000f, 10.0f }, { -1, 0, "" } }; -static void distnoise_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void distnoise_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->noisesize = tex_input_value(in[I+0], coord, thread); - tex->dist_amount = tex_input_value(in[I+1], coord, thread); + tex->noisesize = tex_input_value(in[I+0], p, thread); + tex->dist_amount = tex_input_value(in[I+1], p, thread); } ProcDef(distnoise) @@ -223,10 +223,10 @@ static bNodeSocketType wood_inputs[]= { { SOCK_VALUE, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f }, { -1, 0, "" } }; -static void wood_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void wood_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->noisesize = tex_input_value(in[I+0], coord, thread); - tex->turbul = tex_input_value(in[I+1], coord, thread); + tex->noisesize = tex_input_value(in[I+0], p, thread); + tex->turbul = tex_input_value(in[I+1], p, thread); } ProcDef(wood) @@ -241,13 +241,13 @@ static bNodeSocketType musgrave_inputs[]= { { SOCK_VALUE, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f }, { -1, 0, "" } }; -static void musgrave_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void musgrave_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->mg_H = tex_input_value(in[I+0], coord, thread); - tex->mg_lacunarity = tex_input_value(in[I+1], coord, thread); - tex->mg_octaves = tex_input_value(in[I+2], coord, thread); - tex->ns_outscale = tex_input_value(in[I+3], coord, thread); - tex->noisesize = tex_input_value(in[I+4], coord, thread); + tex->mg_H = tex_input_value(in[I+0], p, thread); + tex->mg_lacunarity = tex_input_value(in[I+1], p, thread); + tex->mg_octaves = tex_input_value(in[I+2], p, thread); + tex->ns_outscale = tex_input_value(in[I+3], p, thread); + tex->noisesize = tex_input_value(in[I+4], p, thread); } ProcDef(musgrave) @@ -266,10 +266,10 @@ static bNodeSocketType stucci_inputs[]= { { SOCK_VALUE, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f }, { -1, 0, "" } }; -static void stucci_map_inputs(Tex *tex, bNodeStack **in, float *coord, short thread) +static void stucci_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) { - tex->noisesize = tex_input_value(in[I+0], coord, thread); - tex->turbul = tex_input_value(in[I+1], coord, thread); + tex->noisesize = tex_input_value(in[I+0], p, thread); + tex->turbul = tex_input_value(in[I+1], p, thread); } ProcDef(stucci) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c index 3a2c2b1def1..0fd95642be6 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -42,9 +42,10 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float new_coord[3]; + float *coord = p->coord; float ax[4]; float para[3]; @@ -53,13 +54,13 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor float magsq, ndx; - float a = tex_input_value(in[1], coord, thread); + float a = tex_input_value(in[1], p, thread); float cos_a = cos(a * 2 * M_PI); float sin_a = sin(a * 2 * M_PI); // x' = xcosa + n(n.x)(1-cosa)+(x*n)sina - tex_input_vec(ax, in[2], coord, thread); + tex_input_vec(ax, in[2], p, thread); magsq = ax[0]*ax[0] + ax[1]*ax[1] + ax[2]*ax[2]; if(magsq == 0) magsq = 1; @@ -86,7 +87,11 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor new_coord[1] = para[1] + perp[1] + cp[1]; new_coord[2] = para[2] + perp[2] + cp[2]; - tex_input_rgba(out, in[0], new_coord, thread); + { + TexParams np = *p; + np.coord = new_coord; + tex_input_rgba(out, in[0], &np, thread); + } } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_scale.c b/source/blender/nodes/intern/TEX_nodes/TEX_scale.c index 792c3468e9f..3d4415365aa 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_scale.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_scale.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -40,17 +40,19 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float scale[3], new_coord[3]; + TexParams np = *p; + np.coord = new_coord; - tex_input_vec(scale, in[1], coord, thread); + tex_input_vec(scale, in[1], p, thread); - new_coord[0] = coord[0] * scale[0]; - new_coord[1] = coord[1] * scale[1]; - new_coord[2] = coord[2] * scale[2]; + new_coord[0] = p->coord[0] * scale[0]; + new_coord[1] = p->coord[1] * scale[1]; + new_coord[2] = p->coord[2] * scale[2]; - tex_input_rgba(out, in[0], new_coord, thread); + tex_input_rgba(out, in[0], &np, thread); } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c index 30492b84764..0ca80a82271 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -40,10 +40,11 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { static float red[] = {1,0,0,1}; static float white[] = {1,1,1,1}; + float *coord = p->coord; Tex *nodetex = (Tex *)node->id; @@ -60,8 +61,8 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor float nor[] = {0,0,0}; float col1[4], col2[4]; - tex_input_rgba(col1, in[0], coord, thread); - tex_input_rgba(col2, in[1], coord, thread); + tex_input_rgba(col1, in[0], p, thread); + tex_input_rgba(col2, in[1], p, thread); texres.nor = nor; textype = multitex_ext(nodetex, coord, 0, 0, 0, &texres); diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c index cadd27612f4..ba3dcfa27a2 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -40,17 +40,19 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float offset[3], new_coord[3]; + TexParams np = *p; + np.coord = new_coord; - tex_input_vec(offset, in[1], coord, thread); + tex_input_vec(offset, in[1], p, thread); - new_coord[0] = coord[0] + offset[0]; - new_coord[1] = coord[1] + offset[1]; - new_coord[2] = coord[2] + offset[2]; + new_coord[0] = p->coord[0] + offset[0]; + new_coord[1] = p->coord[1] + offset[1]; + new_coord[2] = p->coord[2] + offset[2]; - tex_input_rgba(out, in[0], new_coord, thread); + tex_input_rgba(out, in[0], &np, thread); } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c index 0d24652a8f6..75b88c3a460 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c @@ -39,28 +39,32 @@ static bNodeSocketType outputs[]= { { -1, 0, "" } }; -static void normalfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void normalfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float new_coord[3]; + float *coord = p->coord; - float nabla = tex_input_value(in[1], coord, thread); + float nabla = tex_input_value(in[1], p, thread); float val; float nor[3]; + + TexParams np = *p; + np.coord = new_coord; - val = tex_input_value(in[0], coord, thread); + val = tex_input_value(in[0], p, thread); new_coord[0] = coord[0] + nabla; new_coord[1] = coord[1]; new_coord[2] = coord[2]; - nor[0] = tex_input_value(in[0], new_coord, thread); + nor[0] = tex_input_value(in[0], &np, thread); new_coord[0] = coord[0]; new_coord[1] = coord[1] + nabla; - nor[1] = tex_input_value(in[0], new_coord, thread); + nor[1] = tex_input_value(in[0], &np, thread); new_coord[1] = coord[1]; new_coord[2] = coord[2] + nabla; - nor[2] = tex_input_value(in[0], new_coord, thread); + nor[2] = tex_input_value(in[0], &np, thread); out[0] = val-nor[0]; out[1] = val-nor[1]; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c index 71d9cb07e18..90a444bcff0 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c @@ -22,7 +22,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ @@ -39,10 +39,10 @@ static bNodeSocketType valtorgb_out[]= { { -1, 0, "" } }; -static void valtorgb_colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { if(node->storage) { - float fac = tex_input_value(in[0], coord, thread); + float fac = tex_input_value(in[0], p, thread); do_colorband(node->storage, fac, out); } @@ -87,10 +87,10 @@ static bNodeSocketType rgbtobw_out[]= { }; -static void rgbtobw_valuefn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +static void rgbtobw_valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { float cin[4]; - tex_input_rgba(cin, in[0], coord, thread); + tex_input_rgba(cin, in[0], p, thread); *out = cin[0] * 0.35f + cin[1] * 0.45f + cin[2] * 0.2f; } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c index acdaacf873c..2d29b03b38c 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Robin Allen * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/nodes/intern/TEX_util.c b/source/blender/nodes/intern/TEX_util.c index 867e754f960..a6a5877722b 100644 --- a/source/blender/nodes/intern/TEX_util.c +++ b/source/blender/nodes/intern/TEX_util.c @@ -47,17 +47,17 @@ #define PREV_RES 128 /* default preview resolution */ -void tex_call_delegate(TexDelegate *dg, float *out, float *coord, short thread) +void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, short thread) { if(dg->node->need_exec) - dg->fn(out, coord, dg->node, dg->in, thread); + dg->fn(out, params, dg->node, dg->in, thread); } -void tex_input(float *out, int sz, bNodeStack *in, float *coord, short thread) +void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, short thread) { TexDelegate *dg = in->data; if(dg) { - tex_call_delegate(dg, in->vec, coord, thread); + tex_call_delegate(dg, in->vec, params, thread); if(in->hasoutput && in->sockettype == SOCK_VALUE) in->vec[1] = in->vec[2] = in->vec[0]; @@ -65,14 +65,14 @@ void tex_input(float *out, int sz, bNodeStack *in, float *coord, short thread) memcpy(out, in->vec, sz * sizeof(float)); } -void tex_input_vec(float *out, bNodeStack *in, float *coord, short thread) +void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread) { - tex_input(out, 3, in, coord, thread); + tex_input(out, 3, in, params, thread); } -void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread) +void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread) { - tex_input(out, 4, in, coord, thread); + tex_input(out, 4, in, params, thread); if(in->hasoutput && in->sockettype == SOCK_VALUE) { @@ -88,10 +88,10 @@ void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread) } } -float tex_input_value(bNodeStack *in, float *coord, short thread) +float tex_input_value(bNodeStack *in, TexParams *params, short thread) { float out[4]; - tex_input_vec(out, in, coord, thread); + tex_input_vec(out, in, params, thread); return out[0]; } @@ -121,11 +121,21 @@ static void init_preview(bNode *node) } } +void params_from_cdata(TexParams *out, TexCallData *in) +{ + out->coord = in->coord; + out->dxt = in->dxt; + out->dyt = in->dyt; + out->cfra = in->cfra; +} + void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata) { int x, y; float *result; bNodePreview *preview; + float coord[3] = {0, 0, 0}; + TexParams params; if(!cdata->do_preview) return; @@ -137,15 +147,20 @@ void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata) preview = node->preview; + params.dxt = 0; + params.dyt = 0; + params.cfra = cdata->cfra; + params.coord = coord; + for(x=0; xxsize; x++) for(y=0; yysize; y++) { - cdata->coord[0] = ((float) x / preview->xsize) * 2 - 1; - cdata->coord[1] = ((float) y / preview->ysize) * 2 - 1; + params.coord[0] = ((float) x / preview->xsize) * 2 - 1; + params.coord[1] = ((float) y / preview->ysize) * 2 - 1; result = preview->rect + 4 * (preview->xsize*y + x); - tex_input_rgba(result, ns, cdata->coord, cdata->thread); + tex_input_rgba(result, ns, ¶ms, cdata->thread); } } @@ -192,13 +207,28 @@ void ntreeTexCheckCyclics(struct bNodeTree *ntree) } } -void ntreeTexExecTree(bNodeTree *nodes, TexResult *texres, float *coord, char do_preview, short thread, Tex *tex, short which_output, int cfra) -{ +void ntreeTexExecTree( + bNodeTree *nodes, + TexResult *texres, + float *coord, + float *dxt, float *dyt, + char do_preview, + short thread, + Tex *tex, + short which_output, + int cfra +){ TexResult dummy_texres; TexCallData data; + /* 0 means don't care, so just use first */ + if(which_output == 0) + which_output = 1; + if(!texres) texres = &dummy_texres; data.coord = coord; + data.dxt = dxt; + data.dyt = dyt; data.target = texres; data.do_preview = do_preview; data.thread = thread; @@ -216,14 +246,12 @@ void ntreeTexUpdatePreviews(bNodeTree* nodetree) for(tex= G.main->tex.first; tex; tex= tex->id.next) if(tex->nodetree == nodetree) break; - if(!tex) return; - - dummy_texres.nor = 0; - - ntreeBeginExecTree(nodetree); - ntreeTexExecTree(nodetree, &dummy_texres, coord, 1, 0, tex, 0, 0); - ntreeEndExecTree(nodetree); + if(tex) { + dummy_texres.nor = 0; + ntreeBeginExecTree(nodetree); + ntreeTexExecTree(nodetree, &dummy_texres, coord, 0, 0, 1, 0, tex, 0, 0); + } } char* ntreeTexOutputMenu(bNodeTree *ntree) @@ -267,19 +295,3 @@ char* ntreeTexOutputMenu(bNodeTree *ntree) return str; } -void ntreeTexAssignIndex(struct bNodeTree *ntree, struct bNode *node) -{ - bNode *tnode; - int index = 0; - - check_index: - for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if(tnode->type == TEX_NODE_OUTPUT && tnode != node) - if(tnode->custom1 == index) { - index ++; - goto check_index; - } - - node->custom1 = index; -} - diff --git a/source/blender/nodes/intern/TEX_util.h b/source/blender/nodes/intern/TEX_util.h index e560aa57921..7fff8d04651 100644 --- a/source/blender/nodes/intern/TEX_util.h +++ b/source/blender/nodes/intern/TEX_util.h @@ -71,13 +71,20 @@ typedef struct TexCallData { TexResult *target; float *coord; + float *dxt, *dyt; char do_preview; short thread; short which_output; int cfra; } TexCallData; -typedef void(*TexFn) (float *out, float *coord, bNode *node, bNodeStack **in, short thread); +typedef struct TexParams { + float *coord; + float *dxt, *dyt; + int cfra; +} TexParams; + +typedef void(*TexFn) (float *out, TexParams *params, bNode *node, bNodeStack **in, short thread); typedef struct TexDelegate { TexFn fn; @@ -86,16 +93,18 @@ typedef struct TexDelegate { int type; } TexDelegate; -void tex_call_delegate(TexDelegate*, float *out, float *coord, short thread); +void tex_call_delegate(TexDelegate*, float *out, TexParams *params, short thread); -void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread); -void tex_input_vec(float *out, bNodeStack *in, float *coord, short thread); -float tex_input_value(bNodeStack *in, float *coord, short thread); +void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread); +void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread); +float tex_input_value(bNodeStack *in, TexParams *params, short thread); void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn); void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata); void ntreeTexUpdatePreviews( bNodeTree* nodetree ); -void ntreeTexExecTree(bNodeTree *nodes, TexResult *texres, float *coord, char do_preview, short thread, struct Tex *tex, short which_output, int cfra); - +void ntreeTexExecTree(bNodeTree *nodes, TexResult *texres, float *coord, float *dxt, float *dyt, char do_preview, short thread, struct Tex *tex, short which_output, int cfra); + +void params_from_cdata(TexParams *out, TexCallData *in); + #endif diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index db0404c33a8..acb45790ed2 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -122,7 +122,7 @@ extern "C" { void BPY_pydriver_update(void); float BPY_pydriver_eval(struct ChannelDriver *driver); - int BPY_button_eval(char *expr, double *value); + int BPY_button_eval(struct bContext *C, char *expr, double *value); /* format importer hook */ int BPY_call_importloader( char *name ); diff --git a/source/blender/python/epy_doc_gen.py b/source/blender/python/epy_doc_gen.py index 8630a0c8f8e..6a515648340 100644 --- a/source/blender/python/epy_doc_gen.py +++ b/source/blender/python/epy_doc_gen.py @@ -76,6 +76,7 @@ def write_func(rna, ident, out, func_type): rna_func_desc = rna.description.strip() items = rna.parameters.items() + for rna_prop_identifier, rna_prop in items: if rna_prop_identifier=='rna_type': continue @@ -88,13 +89,25 @@ def write_func(rna, ident, out, func_type): rna_prop_type = rna_prop.type.lower() # enum, float, int, boolean + # only for rna functions, operators should not get pointers as args + if rna_prop_type=='pointer': + rna_prop_type_refine = "L{%s}" % rna_prop.fixed_type.identifier + else: + rna_prop_type_refine = rna_prop_type + + try: length = rna_prop.array_length except: length = 0 array_str = get_array_str(length) - kw_type_str= "@type %s: %s%s" % (rna_prop_identifier, rna_prop_type, array_str) - kw_param_str= "@param %s: %s" % (rna_prop_identifier, rna_prop.description.strip()) + if rna_prop.use_return: + kw_type_str= "@rtype: %s%s" % (rna_prop_type_refine, array_str) + kw_param_str= "@return: %s" % (rna_prop.description.strip()) + else: + kw_type_str= "@type %s: %s%s" % (rna_prop_identifier, rna_prop_type_refine, array_str) + kw_param_str= "@param %s: %s" % (rna_prop_identifier, rna_prop.description.strip()) + kw_param_set = False if func_type=='OPERATOR': @@ -159,8 +172,11 @@ def write_func(rna, ident, out, func_type): # stora else: # currently functions dont have a default value - kw_args.append('%s' % (rna_prop_identifier)) - + if not rna_prop.use_return: + kw_args.append('%s' % (rna_prop_identifier)) + else: + kw_param_set = True + # Same for operators and functions kw_arg_attrs.append(kw_type_str) @@ -174,7 +190,8 @@ def write_func(rna, ident, out, func_type): out.write(ident+'\t%s\n' % rna_func_desc) for desc in kw_arg_attrs: out.write(ident+'\t%s\n' % desc) - out.write(ident+'\t@rtype: None\n') + + # out.write(ident+'\t@rtype: None\n') # implicit out.write(ident+'\t"""\n') @@ -183,6 +200,7 @@ def rna2epy(target_path): # Use for faster lookups # use rna_struct.identifier as the key for each dict + rna_struct_dict = {} # store identifier:rna lookups rna_full_path_dict = {} # store the result of full_rna_struct_path(rna_struct) rna_children_dict = {} # store all rna_structs nested from here rna_references_dict = {} # store a list of rna path strings that reference this type @@ -199,8 +217,12 @@ def rna2epy(target_path): if rna_base: out.write(ident+ 'class %s(%s):\n' % (identifier, rna_base.identifier)) + rna_base_prop_keys = rna_base.properties.keys() # could be cached + rna_base_func_keys = [f.identifier for f in rna_base.functions] else: out.write(ident+ 'class %s:\n' % identifier) + rna_base_prop_keys = [] + rna_base_func_keys = [] out.write(ident+ '\t"""\n') @@ -232,11 +254,9 @@ def rna2epy(target_path): for rna_prop_identifier, rna_prop in rna_struct.properties.items(): - if rna_prop_identifier=='RNA': - continue - - if rna_prop_identifier=='rna_type': - continue + if rna_prop_identifier=='RNA': continue + if rna_prop_identifier=='rna_type': continue + if rna_prop_identifier in rna_base_prop_keys: continue # does this prop exist in our parent class, if so skip rna_desc = rna_prop.description.strip() @@ -269,7 +289,8 @@ def rna2epy(target_path): out.write(ident+ '\t@ivar %s: %s in (%s)\n' % (rna_prop_identifier, rna_desc, ', '.join(rna_prop.items.keys()))) else: out.write(ident+ '\t@ivar %s: %s in...\n' % (rna_prop_identifier, rna_desc)) - for e in rna_prop.items.keys(): + for e, e_rna_prop in rna_prop.items.items(): + #out.write(ident+ '\t\t- %s: %s\n' % (e, e_rna_prop.description)) # XXX - segfaults, FIXME out.write(ident+ '\t\t- %s\n' % e) out.write(ident+ '\t@type %s: %s%s%s\n' % (rna_prop_identifier, rna_prop_type, array_str, readonly_str)) @@ -290,7 +311,8 @@ def rna2epy(target_path): # Write functions # for rna_func in rna_struct.functions: # Better ignore inherited (line below) for rna_func in rna_functions_dict[identifier]: - write_func(rna_func, ident+'\t', out, 'FUNCTION') + if rna_func not in rna_base_func_keys: + write_func(rna_func, ident+'\t', out, 'FUNCTION') out.write('\n') @@ -313,13 +335,18 @@ def rna2epy(target_path): structs = [] for rna_type_name in dir(bpy.types): rna_type = getattr(bpy.types, rna_type_name) - if hasattr(rna_type, '__rna__'): + + try: rna_struct = rna_type.__rna__ + except: rna_struct = None + + if rna_struct: #if not rna_type_name.startswith('__'): - rna_struct = rna_type.__rna__ + identifier = rna_struct.identifier structs.append( (base_id(rna_struct), identifier, rna_struct) ) - + # Simple lookup + rna_struct_dict[identifier] = rna_struct # Store full rna path 'GameObjectSettings' -> 'Object.GameObjectSettings' rna_full_path_dict[identifier] = full_rna_struct_path(rna_struct) @@ -377,16 +404,21 @@ def rna2epy(target_path): # precalc vars to avoid a lot of looping for (rna_base, identifier, rna_struct) in structs: + if rna_base: + rna_base_prop_keys = rna_struct_dict[rna_base].properties.keys() # could cache + rna_base_func_keys = [f.identifier for f in rna_struct_dict[rna_base].functions] + else: + rna_base_prop_keys = [] + rna_base_func_keys= [] # rna_struct_path = full_rna_struct_path(rna_struct) rna_struct_path = rna_full_path_dict[identifier] for rna_prop_identifier, rna_prop in rna_struct.properties.items(): - if rna_prop_identifier=='RNA': - continue - if rna_prop_identifier=='rna_type': - continue + if rna_prop_identifier=='RNA': continue + if rna_prop_identifier=='rna_type': continue + if rna_prop_identifier in rna_base_prop_keys: continue try: rna_prop_ptr = rna_prop.fixed_type except: rna_prop_ptr = None @@ -395,7 +427,21 @@ def rna2epy(target_path): if rna_prop_ptr: rna_references_dict[rna_prop_ptr.identifier].append( "%s.%s" % (rna_struct_path, rna_prop_identifier) ) - + for rna_func in rna_struct.functions: + for rna_prop_identifier, rna_prop in rna_func.parameters.items(): + + if rna_prop_identifier=='RNA': continue + if rna_prop_identifier=='rna_type': continue + if rna_prop_identifier in rna_base_func_keys: continue + + + try: rna_prop_ptr = rna_prop.fixed_type + except: rna_prop_ptr = None + + # Does this property point to me? + if rna_prop_ptr: + rna_references_dict[rna_prop_ptr.identifier].append( "%s.%s" % (rna_struct_path, rna_func.identifier) ) + # Store nested children nested = rna_struct.nested diff --git a/source/blender/python/generic/BGL.c b/source/blender/python/generic/BGL.c index de82781cf3a..767af8e0836 100644 --- a/source/blender/python/generic/BGL.c +++ b/source/blender/python/generic/BGL.c @@ -67,7 +67,7 @@ static int Buffer_ass_slice( PyObject * self, int begin, int end, PyObject * seq ); static PySequenceMethods Buffer_SeqMethods = { - ( inquiry ) Buffer_len, /*sq_length */ + ( lenfunc ) Buffer_len, /*sq_length */ ( binaryfunc ) 0, /*sq_concat */ ( ssizeargfunc ) 0, /*sq_repeat */ ( ssizeargfunc ) Buffer_item, /*sq_item */ @@ -83,13 +83,7 @@ static PyObject *Buffer_getattr( PyObject * self, char *name ); static PyObject *Buffer_repr( PyObject * self ); PyTypeObject buffer_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "buffer", /*tp_name */ sizeof( Buffer ), /*tp_basicsize */ 0, /*tp_itemsize */ @@ -1090,7 +1084,6 @@ static struct PyMethodDef BGL_methods[] = { {NULL, NULL, 0, NULL} }; -#if (PY_VERSION_HEX >= 0x03000000) static struct PyModuleDef BGL_module_def = { PyModuleDef_HEAD_INIT, "BGL", /* m_name */ @@ -1102,17 +1095,13 @@ static struct PyModuleDef BGL_module_def = { 0, /* m_clear */ 0, /* m_free */ }; -#endif -PyObject *BGL_Init(const char *from) + +PyObject *BGL_Init(void) { PyObject *mod, *dict, *item; -#if (PY_VERSION_HEX >= 0x03000000) mod = PyModule_Create(&BGL_module_def); PyDict_SetItemString(PySys_GetObject("modules"), BGL_module_def.m_name, mod); -#else - mod= Py_InitModule(from, BGL_methods); -#endif dict= PyModule_GetDict(mod); if( PyType_Ready( &buffer_Type) < 0) diff --git a/source/blender/python/generic/BGL.h b/source/blender/python/generic/BGL.h index 938c916bcea..91f88549faf 100644 --- a/source/blender/python/generic/BGL.h +++ b/source/blender/python/generic/BGL.h @@ -42,9 +42,8 @@ #include #include -#include "../intern/bpy_compat.h" -PyObject *BGL_Init( const char *from ); +PyObject *BGL_Init(void); /*@ Buffer Object */ /*@ For Python access to OpenGL functions requiring a pointer. */ @@ -305,31 +304,30 @@ typedef struct _Buffer { #define ret_def_void #define ret_set_void -/* would use Py_RETURN_NONE - except for py 2.3 doesnt have it */ -#define ret_ret_void { Py_INCREF(Py_None); return Py_None; } +#define ret_ret_void return Py_INCREF(Py_None), Py_None #define ret_def_GLint int ret_int #define ret_set_GLint ret_int= -#define ret_ret_GLint return PyLong_FromLong(ret_int); +#define ret_ret_GLint return PyLong_FromLong(ret_int) #define ret_def_GLuint unsigned int ret_uint #define ret_set_GLuint ret_uint= -#define ret_ret_GLuint return PyLong_FromLong((long) ret_uint); +#define ret_ret_GLuint return PyLong_FromLong((long) ret_uint) #define ret_def_GLenum unsigned int ret_uint #define ret_set_GLenum ret_uint= -#define ret_ret_GLenum return PyLong_FromLong((long) ret_uint); +#define ret_ret_GLenum return PyLong_FromLong((long) ret_uint) #define ret_def_GLboolean unsigned char ret_bool #define ret_set_GLboolean ret_bool= -#define ret_ret_GLboolean return PyLong_FromLong((long) ret_bool); +#define ret_ret_GLboolean return PyLong_FromLong((long) ret_bool) #define ret_def_GLstring const unsigned char *ret_str; #define ret_set_GLstring ret_str= #define ret_ret_GLstring \ if (ret_str) {\ - return PyUnicode_FromString(ret_str);\ + return PyUnicode_FromString((const char *)ret_str);\ } else {\ PyErr_SetString(PyExc_AttributeError, "could not get opengl string");\ return NULL;\ diff --git a/source/blender/python/generic/Geometry.c b/source/blender/python/generic/Geometry.c index b4a34d30051..70295d1c2d9 100644 --- a/source/blender/python/generic/Geometry.c +++ b/source/blender/python/generic/Geometry.c @@ -78,7 +78,6 @@ struct PyMethodDef M_Geometry_methods[] = { {NULL, NULL, 0, NULL} }; -#if (PY_VERSION_HEX >= 0x03000000) static struct PyModuleDef M_Geometry_module_def = { PyModuleDef_HEAD_INIT, "Geometry", /* m_name */ @@ -90,19 +89,14 @@ static struct PyModuleDef M_Geometry_module_def = { 0, /* m_clear */ 0, /* m_free */ }; -#endif /*----------------------------MODULE INIT-------------------------*/ -PyObject *Geometry_Init(const char *from) +PyObject *Geometry_Init(void) { PyObject *submodule; -#if (PY_VERSION_HEX >= 0x03000000) submodule = PyModule_Create(&M_Geometry_module_def); PyDict_SetItemString(PySys_GetObject("modules"), M_Geometry_module_def.m_name, submodule); -#else - submodule = Py_InitModule3(from, M_Geometry_methods, M_Geometry_doc); -#endif return (submodule); } diff --git a/source/blender/python/generic/Geometry.h b/source/blender/python/generic/Geometry.h index ebfb054c54a..0e46c0d18db 100644 --- a/source/blender/python/generic/Geometry.h +++ b/source/blender/python/generic/Geometry.h @@ -34,6 +34,6 @@ #include #include "Mathutils.h" -PyObject *Geometry_Init( const char *from ); +PyObject *Geometry_Init(void); #endif /* EXPP_Geometry_H */ diff --git a/source/blender/python/generic/Makefile b/source/blender/python/generic/Makefile index 0dbfbd1d102..dc674478dab 100644 --- a/source/blender/python/generic/Makefile +++ b/source/blender/python/generic/Makefile @@ -43,7 +43,7 @@ CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) # PreProcessor stuff CPPFLAGS += -I$(NAN_GHOST)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include $(NAN_SDLCFLAGS) +CPPFLAGS += $(NAN_SDLCFLAGS) # modules CPPFLAGS += -I../../editors/include diff --git a/source/blender/python/generic/Mathutils.c b/source/blender/python/generic/Mathutils.c index 53077659655..f53fd66ba99 100644 --- a/source/blender/python/generic/Mathutils.c +++ b/source/blender/python/generic/Mathutils.c @@ -94,7 +94,6 @@ struct PyMethodDef M_Mathutils_methods[] = { /*----------------------------MODULE INIT-------------------------*/ /* from can be Blender.Mathutils or GameLogic.Mathutils for the BGE */ -#if (PY_VERSION_HEX >= 0x03000000) static struct PyModuleDef M_Mathutils_module_def = { PyModuleDef_HEAD_INIT, "Mathutils", /* m_name */ @@ -106,21 +105,13 @@ static struct PyModuleDef M_Mathutils_module_def = { 0, /* m_clear */ 0, /* m_free */ }; -#endif -PyObject *Mathutils_Init(const char *from) +PyObject *Mathutils_Init(void) { PyObject *submodule; //seed the generator for the rand function BLI_srand((unsigned int) (PIL_check_seconds_timer() * 0x7FFFFFFF)); - -#if (PY_VERSION_HEX < 0x03000000) - vector_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES; - matrix_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES; - euler_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES; - quaternion_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES; -#endif if( PyType_Ready( &vector_Type ) < 0 ) return NULL; @@ -131,12 +122,8 @@ PyObject *Mathutils_Init(const char *from) if( PyType_Ready( &quaternion_Type ) < 0 ) return NULL; -#if (PY_VERSION_HEX >= 0x03000000) submodule = PyModule_Create(&M_Mathutils_module_def); PyDict_SetItemString(PySys_GetObject("modules"), M_Mathutils_module_def.m_name, submodule); -#else - submodule = Py_InitModule3(from, M_Mathutils_methods, M_Mathutils_doc); -#endif /* each type has its own new() function */ PyModule_AddObject( submodule, "Vector", (PyObject *)&vector_Type ); diff --git a/source/blender/python/generic/Mathutils.h b/source/blender/python/generic/Mathutils.h index 5bdd9d9cfe0..ad67d2e511e 100644 --- a/source/blender/python/generic/Mathutils.h +++ b/source/blender/python/generic/Mathutils.h @@ -32,7 +32,6 @@ #define EXPP_Mathutils_H #include -#include "../intern/bpy_compat.h" #include "vector.h" #include "matrix.h" #include "quat.h" @@ -55,10 +54,7 @@ PyObject *BaseMathObject_getOwner( BaseMathObject * self, void * ); PyObject *BaseMathObject_getWrapped( BaseMathObject *self, void * ); void BaseMathObject_dealloc(BaseMathObject * self); - - - -PyObject *Mathutils_Init( const char * from ); +PyObject *Mathutils_Init(void); PyObject *quat_rotation(PyObject *arg1, PyObject *arg2); diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index 073cb58f1c8..05c846b16f5 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -179,20 +179,12 @@ static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * k PyObject *newmodule; //PyObject_Print(args, stderr, 0); -#if (PY_VERSION_HEX >= 0x02060000) int dummy_val; /* what does this do?*/ static char *kwlist[] = {"name", "globals", "locals", "fromlist", "level", 0}; if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOOi:bpy_import_meth", kwlist, &name, &globals, &locals, &fromlist, &dummy_val) ) return NULL; -#else - static char *kwlist[] = {"name", "globals", "locals", "fromlist", 0}; - - if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOO:bpy_import_meth", kwlist, - &name, &globals, &locals, &fromlist ) ) - return NULL; -#endif /* import existing builtin modules or modules that have been imported alredy */ newmodule = PyImport_ImportModuleEx( name, globals, locals, fromlist ); diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h index aeeafb7c1c4..c93d930dab0 100644 --- a/source/blender/python/generic/bpy_internal_import.h +++ b/source/blender/python/generic/bpy_internal_import.h @@ -32,7 +32,6 @@ #define EXPP_bpy_import_h #include -#include "../intern/bpy_compat.h" #include "compile.h" /* for the PyCodeObject */ #include "eval.h" /* for PyEval_EvalCode */ diff --git a/source/blender/python/generic/euler.c b/source/blender/python/generic/euler.c index 69373b1aa36..73fcaeb457b 100644 --- a/source/blender/python/generic/euler.c +++ b/source/blender/python/generic/euler.c @@ -242,7 +242,7 @@ static PyObject *Euler_Rotate(EulerObject * self, PyObject *args) PyErr_SetString(PyExc_TypeError, "euler.rotate():expected angle (float) and axis (x,y,z)"); return NULL; } - if(!STREQ3(axis,"x","y","z")){ + if(ELEM3(*axis, 'x', 'y', 'z') && axis[1]=='\0'){ PyErr_SetString(PyExc_TypeError, "euler.rotate(): expected axis to be 'x', 'y' or 'z'"); return NULL; } @@ -508,7 +508,7 @@ static int Euler_ass_slice(EulerObject * self, int begin, int end, } //-----------------PROTCOL DECLARATIONS-------------------------- static PySequenceMethods Euler_SeqMethods = { - (inquiry) Euler_len, /* sq_length */ + (lenfunc) Euler_len, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) Euler_item, /* sq_item */ @@ -547,13 +547,7 @@ static PyGetSetDef Euler_getseters[] = { //------------------PY_OBECT DEFINITION-------------------------- PyTypeObject euler_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "euler", //tp_name sizeof(EulerObject), //tp_basicsize 0, //tp_itemsize diff --git a/source/blender/python/generic/euler.h b/source/blender/python/generic/euler.h index a3706d53756..74d184fef81 100644 --- a/source/blender/python/generic/euler.h +++ b/source/blender/python/generic/euler.h @@ -32,7 +32,6 @@ #define EXPP_euler_h #include -#include "../intern/bpy_compat.h" extern PyTypeObject euler_Type; #define EulerObject_Check(_v) PyObject_TypeCheck((_v), &euler_Type) diff --git a/source/blender/python/generic/matrix.c b/source/blender/python/generic/matrix.c index 5bdbf804618..be3e704460a 100644 --- a/source/blender/python/generic/matrix.c +++ b/source/blender/python/generic/matrix.c @@ -37,14 +37,17 @@ static PyObject *column_vector_multiplication(MatrixObject * mat, VectorObject* /* matrix vector callbacks */ int mathutils_matrix_vector_cb_index= -1; -static int mathutils_matrix_vector_check(MatrixObject *self) +static int mathutils_matrix_vector_check(PyObject *self_p) { + MatrixObject *self= (MatrixObject*)self_p; return BaseMath_ReadCallback(self); } -static int mathutils_matrix_vector_get(MatrixObject *self, int subtype, float *vec_from) +static int mathutils_matrix_vector_get(PyObject *self_p, int subtype, float *vec_from) { + MatrixObject *self= (MatrixObject*)self_p; int i; + if(!BaseMath_ReadCallback(self)) return 0; @@ -54,9 +57,11 @@ static int mathutils_matrix_vector_get(MatrixObject *self, int subtype, float *v return 1; } -static int mathutils_matrix_vector_set(MatrixObject *self, int subtype, float *vec_to) +static int mathutils_matrix_vector_set(PyObject *self_p, int subtype, float *vec_to) { + MatrixObject *self= (MatrixObject*)self_p; int i; + if(!BaseMath_ReadCallback(self)) return 0; @@ -67,8 +72,10 @@ static int mathutils_matrix_vector_set(MatrixObject *self, int subtype, float *v return 1; } -static int mathutils_matrix_vector_get_index(MatrixObject *self, int subtype, float *vec_from, int index) +static int mathutils_matrix_vector_get_index(PyObject *self_p, int subtype, float *vec_from, int index) { + MatrixObject *self= (MatrixObject*)self_p; + if(!BaseMath_ReadCallback(self)) return 0; @@ -76,8 +83,10 @@ static int mathutils_matrix_vector_get_index(MatrixObject *self, int subtype, fl return 1; } -static int mathutils_matrix_vector_set_index(MatrixObject *self, int subtype, float *vec_to, int index) +static int mathutils_matrix_vector_set_index(PyObject *self_p, int subtype, float *vec_to, int index) { + MatrixObject *self= (MatrixObject*)self_p; + if(!BaseMath_ReadCallback(self)) return 0; @@ -988,7 +997,7 @@ static PyObject* Matrix_inv(MatrixObject *self) /*-----------------PROTOCOL DECLARATIONS--------------------------*/ static PySequenceMethods Matrix_SeqMethods = { - (inquiry) Matrix_len, /* sq_length */ + (lenfunc) Matrix_len, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) Matrix_item, /* sq_item */ @@ -998,8 +1007,6 @@ static PySequenceMethods Matrix_SeqMethods = { }; - -#if (PY_VERSION_HEX >= 0x03000000) static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item) { if (PyIndex_Check(item)) { @@ -1071,11 +1078,8 @@ static PyMappingMethods Matrix_AsMapping = { (binaryfunc)Matrix_subscript, (objobjargproc)Matrix_ass_subscript }; -#endif /* (PY_VERSION_HEX >= 0x03000000) */ - -#if (PY_VERSION_HEX >= 0x03000000) static PyNumberMethods Matrix_NumMethods = { (binaryfunc) Matrix_add, /*nb_add*/ (binaryfunc) Matrix_sub, /*nb_subtract*/ @@ -1112,33 +1116,6 @@ static PyNumberMethods Matrix_NumMethods = { 0, /* nb_inplace_true_divide */ 0, /* nb_index */ }; -#else -static PyNumberMethods Matrix_NumMethods = { - (binaryfunc) Matrix_add, /* __add__ */ - (binaryfunc) Matrix_sub, /* __sub__ */ - (binaryfunc) Matrix_mul, /* __mul__ */ - (binaryfunc) 0, /* __div__ */ - (binaryfunc) 0, /* __mod__ */ - (binaryfunc) 0, /* __divmod__ */ - (ternaryfunc) 0, /* __pow__ */ - (unaryfunc) 0, /* __neg__ */ - (unaryfunc) 0, /* __pos__ */ - (unaryfunc) 0, /* __abs__ */ - (inquiry) 0, /* __nonzero__ */ - (unaryfunc) Matrix_inv, /* __invert__ */ - (binaryfunc) 0, /* __lshift__ */ - (binaryfunc) 0, /* __rshift__ */ - (binaryfunc) 0, /* __and__ */ - (binaryfunc) 0, /* __xor__ */ - (binaryfunc) 0, /* __or__ */ - /*(coercion)*/ 0, /* __coerce__ */ - (unaryfunc) 0, /* __int__ */ - (unaryfunc) 0, /* __long__ */ - (unaryfunc) 0, /* __float__ */ - (unaryfunc) 0, /* __oct__ */ - (unaryfunc) 0, /* __hex__ */ -}; -#endif static PyObject *Matrix_getRowSize( MatrixObject * self, void *type ) { @@ -1164,13 +1141,7 @@ static PyGetSetDef Matrix_getseters[] = { /*------------------PY_OBECT DEFINITION--------------------------*/ PyTypeObject matrix_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "matrix", /*tp_name*/ sizeof(MatrixObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -1182,11 +1153,7 @@ PyTypeObject matrix_Type = { (reprfunc) Matrix_repr, /*tp_repr*/ &Matrix_NumMethods, /*tp_as_number*/ &Matrix_SeqMethods, /*tp_as_sequence*/ -#if (PY_VERSION_HEX >= 0x03000000) &Matrix_AsMapping, /*tp_as_mapping*/ -#else - 0, -#endif 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ diff --git a/source/blender/python/generic/quat.c b/source/blender/python/generic/quat.c index a353f73c854..7e12fe7925a 100644 --- a/source/blender/python/generic/quat.c +++ b/source/blender/python/generic/quat.c @@ -611,7 +611,7 @@ static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2) //-----------------PROTOCOL DECLARATIONS-------------------------- static PySequenceMethods Quaternion_SeqMethods = { - (inquiry) Quaternion_len, /* sq_length */ + (lenfunc) Quaternion_len, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) Quaternion_item, /* sq_item */ @@ -620,7 +620,6 @@ static PySequenceMethods Quaternion_SeqMethods = { (ssizessizeobjargproc) Quaternion_ass_slice, /* sq_ass_slice */ }; -#if (PY_VERSION_HEX >= 0x03000000) static PyNumberMethods Quaternion_NumMethods = { (binaryfunc) Quaternion_add, /*nb_add*/ (binaryfunc) Quaternion_sub, /*nb_subtract*/ @@ -657,33 +656,6 @@ static PyNumberMethods Quaternion_NumMethods = { 0, /* nb_inplace_true_divide */ 0, /* nb_index */ }; -#else -static PyNumberMethods Quaternion_NumMethods = { - (binaryfunc) Quaternion_add, /* __add__ */ - (binaryfunc) Quaternion_sub, /* __sub__ */ - (binaryfunc) Quaternion_mul, /* __mul__ */ - (binaryfunc) 0, /* __div__ */ - (binaryfunc) 0, /* __mod__ */ - (binaryfunc) 0, /* __divmod__ */ - (ternaryfunc) 0, /* __pow__ */ - (unaryfunc) 0, /* __neg__ */ - (unaryfunc) 0, /* __pos__ */ - (unaryfunc) 0, /* __abs__ */ - (inquiry) 0, /* __nonzero__ */ - (unaryfunc) 0, /* __invert__ */ - (binaryfunc) 0, /* __lshift__ */ - (binaryfunc) 0, /* __rshift__ */ - (binaryfunc) 0, /* __and__ */ - (binaryfunc) 0, /* __xor__ */ - (binaryfunc) 0, /* __or__ */ - /*(coercion)*/ 0, /* __coerce__ */ - (unaryfunc) 0, /* __int__ */ - (unaryfunc) 0, /* __long__ */ - (unaryfunc) 0, /* __float__ */ - (unaryfunc) 0, /* __oct__ */ - (unaryfunc) 0, /* __hex__ */ -}; -#endif static PyObject *Quaternion_getAxis( QuaternionObject * self, void *type ) { @@ -778,13 +750,7 @@ static PyGetSetDef Quaternion_getseters[] = { //------------------PY_OBECT DEFINITION-------------------------- PyTypeObject quaternion_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "quaternion", //tp_name sizeof(QuaternionObject), //tp_basicsize 0, //tp_itemsize diff --git a/source/blender/python/generic/quat.h b/source/blender/python/generic/quat.h index a7cfb7898b1..a1d01b4982d 100644 --- a/source/blender/python/generic/quat.h +++ b/source/blender/python/generic/quat.h @@ -32,7 +32,6 @@ #define EXPP_quat_h #include -#include "../intern/bpy_compat.h" extern PyTypeObject quaternion_Type; #define QuaternionObject_Check(_v) PyObject_TypeCheck((_v), &quaternion_Type) diff --git a/source/blender/python/generic/vector.c b/source/blender/python/generic/vector.c index cf2396b30d4..923c4bbe58a 100644 --- a/source/blender/python/generic/vector.c +++ b/source/blender/python/generic/vector.c @@ -1054,25 +1054,15 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa /*-----------------PROTCOL DECLARATIONS--------------------------*/ static PySequenceMethods Vector_SeqMethods = { - (inquiry) Vector_len, /* sq_length */ + (lenfunc) Vector_len, /* sq_length */ (binaryfunc) 0, /* sq_concat */ (ssizeargfunc) 0, /* sq_repeat */ (ssizeargfunc) Vector_item, /* sq_item */ -#if (PY_VERSION_HEX < 0x03000000) - (ssizessizeargfunc) Vector_slice, /* sq_slice */ /* PY2 ONLY */ -#else - NULL, -#endif + NULL, /* py3 deprecated slice func */ (ssizeobjargproc) Vector_ass_item, /* sq_ass_item */ -#if (PY_VERSION_HEX < 0x03000000) - (ssizessizeobjargproc) Vector_ass_slice, /* sq_ass_slice */ /* PY2 ONLY */ -#else - NULL, -#endif + NULL, /* py3 deprecated slice assign func */ }; - -#if (PY_VERSION_HEX >= 0x03000000) static PyObject *Vector_subscript(VectorObject* self, PyObject* item) { if (PyIndex_Check(item)) { @@ -1144,9 +1134,8 @@ static PyMappingMethods Vector_AsMapping = { (binaryfunc)Vector_subscript, (objobjargproc)Vector_ass_subscript }; -#endif /* (PY_VERSION_HEX >= 0x03000000) */ - -#if (PY_VERSION_HEX >= 0x03000000) + + static PyNumberMethods Vector_NumMethods = { (binaryfunc) Vector_add, /*nb_add*/ (binaryfunc) Vector_sub, /*nb_subtract*/ @@ -1183,53 +1172,6 @@ static PyNumberMethods Vector_NumMethods = { Vector_idiv, /* nb_inplace_true_divide */ 0, /* nb_index */ }; -#else -static PyNumberMethods Vector_NumMethods = { - (binaryfunc) Vector_add, /* __add__ */ - (binaryfunc) Vector_sub, /* __sub__ */ - (binaryfunc) Vector_mul, /* __mul__ */ - (binaryfunc) Vector_div, /* __div__ */ - (binaryfunc) NULL, /* __mod__ */ - (binaryfunc) NULL, /* __divmod__ */ - (ternaryfunc) NULL, /* __pow__ */ - (unaryfunc) Vector_neg, /* __neg__ */ - (unaryfunc) NULL, /* __pos__ */ - (unaryfunc) NULL, /* __abs__ */ - (inquiry) NULL, /* __nonzero__ */ - (unaryfunc) NULL, /* __invert__ */ - (binaryfunc) NULL, /* __lshift__ */ - (binaryfunc) NULL, /* __rshift__ */ - (binaryfunc) NULL, /* __and__ */ - (binaryfunc) NULL, /* __xor__ */ - (binaryfunc) NULL, /* __or__ */ - /*(coercion)*/ NULL, /* __coerce__ */ - (unaryfunc) NULL, /* __int__ */ - (unaryfunc) NULL, /* __long__ */ - (unaryfunc) NULL, /* __float__ */ - (unaryfunc) NULL, /* __oct__ */ - (unaryfunc) NULL, /* __hex__ */ - - /* Added in release 2.0 */ - (binaryfunc) Vector_iadd, /*__iadd__*/ - (binaryfunc) Vector_isub, /*__isub__*/ - (binaryfunc) Vector_imul, /*__imul__*/ - (binaryfunc) Vector_idiv, /*__idiv__*/ - (binaryfunc) NULL, /*__imod__*/ - (ternaryfunc) NULL, /*__ipow__*/ - (binaryfunc) NULL, /*__ilshift__*/ - (binaryfunc) NULL, /*__irshift__*/ - (binaryfunc) NULL, /*__iand__*/ - (binaryfunc) NULL, /*__ixor__*/ - (binaryfunc) NULL, /*__ior__*/ - - /* Added in release 2.2 */ - /* The following require the Py_TPFLAGS_HAVE_CLASS flag */ - (binaryfunc) NULL, /*__floordiv__ __rfloordiv__*/ - (binaryfunc) NULL, /*__truediv__ __rfloordiv__*/ - (binaryfunc) NULL, /*__ifloordiv__*/ - (binaryfunc) NULL, /*__itruediv__*/ -}; -#endif /*------------------PY_OBECT DEFINITION--------------------------*/ @@ -1325,7 +1267,7 @@ static PyObject *Vector_getSwizzle(VectorObject * self, void *closure) /* Unpack the axes from the closure into an array. */ axisA = 0; - swizzleClosure = (unsigned int) closure; + swizzleClosure = GET_INT_FROM_POINTER(closure); while (swizzleClosure & SWIZZLE_VALID_AXIS) { axisB = swizzleClosure & SWIZZLE_AXIS; @@ -1365,7 +1307,7 @@ static int Vector_setSwizzle(VectorObject * self, PyObject * value, void *closur /* Check that the closure can be used with this vector: even 2D vectors have swizzles defined for axes z and w, but they would be invalid. */ - swizzleClosure = (unsigned int) closure; + swizzleClosure = GET_INT_FROM_POINTER(closure); while (swizzleClosure & SWIZZLE_VALID_AXIS) { axisA = swizzleClosure & SWIZZLE_AXIS; @@ -1382,7 +1324,7 @@ static int Vector_setSwizzle(VectorObject * self, PyObject * value, void *closur /* Copy vector contents onto swizzled axes. */ vecVal = (VectorObject*) value; axisB = 0; - swizzleClosure = (unsigned int) closure; + swizzleClosure = GET_INT_FROM_POINTER(closure); while (swizzleClosure & SWIZZLE_VALID_AXIS && axisB < vecVal->size) { axisA = swizzleClosure & SWIZZLE_AXIS; @@ -1398,7 +1340,7 @@ static int Vector_setSwizzle(VectorObject * self, PyObject * value, void *closur { /* Copy list contents onto swizzled axes. */ listLen = PyList_Size(value); - swizzleClosure = (unsigned int) closure; + swizzleClosure = GET_INT_FROM_POINTER(closure); axisB = 0; while (swizzleClosure & SWIZZLE_VALID_AXIS && axisB < listLen) { @@ -1423,7 +1365,7 @@ static int Vector_setSwizzle(VectorObject * self, PyObject * value, void *closur else if (((scalarVal = (float)PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred())==0) { /* Assign the same value to each axis. */ - swizzleClosure = (unsigned int) closure; + swizzleClosure = GET_INT_FROM_POINTER(closure); while (swizzleClosure & SWIZZLE_VALID_AXIS) { axisA = swizzleClosure & SWIZZLE_AXIS; @@ -1482,342 +1424,342 @@ static PyGetSetDef Vector_getseters[] = { NULL}, /* autogenerated swizzle attrs, see python script below */ - {"xx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, NULL, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif /* For printing, in format "." */ "vector", /* char *tp_name; */ sizeof( VectorObject ), /* int tp_basicsize; */ @@ -1897,11 +1833,7 @@ PyTypeObject vector_Type = { &Vector_NumMethods, /* PyNumberMethods *tp_as_number; */ &Vector_SeqMethods, /* PySequenceMethods *tp_as_sequence; */ -#if (PY_VERSION_HEX >= 0x03000000) &Vector_AsMapping, /* PyMappingMethods *tp_as_mapping; */ -#else - NULL, -#endif /* More standard operations (here for binary compatibility) */ diff --git a/source/blender/python/generic/vector.h b/source/blender/python/generic/vector.h index f6babac7ed9..a13ec0f80f3 100644 --- a/source/blender/python/generic/vector.h +++ b/source/blender/python/generic/vector.h @@ -31,7 +31,6 @@ #define EXPP_vector_h #include -#include "../intern/bpy_compat.h" extern PyTypeObject vector_Type; #define VectorObject_Check(_v) PyObject_TypeCheck((_v), &vector_Type) diff --git a/source/blender/python/intern/Makefile b/source/blender/python/intern/Makefile index d210cfaf973..419092cbe21 100644 --- a/source/blender/python/intern/Makefile +++ b/source/blender/python/intern/Makefile @@ -43,7 +43,7 @@ CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) # PreProcessor stuff CPPFLAGS += -I$(NAN_GHOST)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include $(NAN_SDLCFLAGS) +CPPFLAGS += $(NAN_SDLCFLAGS) # modules CPPFLAGS += -I../../editors/include diff --git a/source/blender/python/intern/bpy_compat.h b/source/blender/python/intern/bpy_compat.h deleted file mode 100644 index e999f57c733..00000000000 --- a/source/blender/python/intern/bpy_compat.h +++ /dev/null @@ -1,126 +0,0 @@ -/** - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Contributor(s): Campbell Barton - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/* This file is only to contain definitions to functions that enable - * the python api to compile with different python versions. - * no utility functions please - */ - -#ifndef BPY_COMPAT_H__ -#define BPY_COMPAT_H__ - -/* if you are NOT using python 3.0 - define these */ -#if PY_VERSION_HEX < 0x03000000 -#define _PyUnicode_AsString PyString_AsString - -#undef PyUnicode_Check -#define PyUnicode_Check PyString_Check - -#define PyLong_FromSsize_t PyInt_FromLong -#define PyLong_AsSsize_t PyInt_AsLong - -#undef PyLong_Check -#define PyLong_Check PyInt_Check - - -#ifdef PyUnicode_FromString -#undef PyUnicode_FromString -#endif -#define PyUnicode_FromString PyString_FromString - -#ifdef PyUnicode_FromFormat -#undef PyUnicode_FromFormat -#endif -#define PyUnicode_FromFormat PyString_FromFormat - -#endif - -#ifndef Py_REFCNT -#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) -#endif - -#ifndef Py_TYPE -#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) -#endif - -#ifndef Py_TYPE -#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) -#endif - -/* older then python 2.6 - define these */ -// #if (PY_VERSION_HEX < 0x02060000) -// #endif - -/* older then python 2.5 - define these */ -#if (PY_VERSION_HEX < 0x02050000) -#define Py_ssize_t ssize_t -typedef Py_ssize_t (*lenfunc)(PyObject *); -#ifndef Py_RETURN_NONE -#define Py_RETURN_NONE return Py_BuildValue("O", Py_None) -#endif -#ifndef Py_RETURN_FALSE -#define Py_RETURN_FALSE return PyBool_FromLong(0) -#endif -#ifndef Py_RETURN_TRUE -#define Py_RETURN_TRUE return PyBool_FromLong(1) -#endif - -#define PyInt_FromSsize_t PyInt_FromLong -#define PyNumber_AsSsize_t(ob, exc) PyInt_AsLong(ob) -#define PyIndex_Check(ob) PyInt_Check(ob) - - -#endif - - -#if PY_VERSION_HEX < 0x03000000 -#ifndef ssizeargfunc -#define ssizeargfunc intargfunc -#endif - -#ifndef ssizessizeargfunc -#define ssizessizeargfunc intintargfunc -#endif - -#ifndef ssizeobjargproc -#define ssizeobjargproc intobjargproc -#endif - -#ifndef ssizessizeobjargproc -#define ssizessizeobjargproc intintobjargproc -#endif -#endif - - - -/* defined in bpy_util.c */ -#if PY_VERSION_HEX < 0x03000000 -PyObject *Py_CmpToRich(int op, int cmp); -#endif - -#ifndef Py_CmpToRich -PyObject *Py_CmpToRich(int op, int cmp); /* bpy_util.c */ -#endif - -#endif /* BPY_COMPAT_H__ */ diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 51fda513493..ae2f4244eac 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -14,8 +14,6 @@ #include "compile.h" /* for the PyCodeObject */ #include "eval.h" /* for PyEval_EvalCode */ -#include "bpy_compat.h" - #include "bpy_rna.h" #include "bpy_operator.h" #include "bpy_ui.h" @@ -46,6 +44,80 @@ #include "../generic/BGL.h" +/* for internal use, when starting and ending python scripts */ + +/* incase a python script triggers another python call, stop bpy_context_clear from invalidating */ +static int py_call_level= 0; + + +// only for tests +#define TIME_PY_RUN + +#ifdef TIME_PY_RUN +#include "PIL_time.h" +static int bpy_timer_count = 0; +static double bpy_timer; /* time since python starts */ +static double bpy_timer_run; /* time for each python script run */ +static double bpy_timer_run_tot; /* accumulate python runs */ +#endif + +void bpy_context_set(bContext *C, PyGILState_STATE *gilstate) +{ + py_call_level++; + + if(gilstate) + *gilstate = PyGILState_Ensure(); + + if(py_call_level==1) { + + BPY_update_modules(); /* can give really bad results if this isnt here */ + + if(C) { // XXX - should always be true. + BPy_SetContext(C); + bpy_import_main_set(CTX_data_main(C)); + } + else { + fprintf(stderr, "ERROR: Python context called with a NULL Context. this should not happen!\n"); + } + +#ifdef TIME_PY_RUN + if(bpy_timer_count==0) { + /* record time from the beginning */ + bpy_timer= PIL_check_seconds_timer(); + bpy_timer_run = bpy_timer_run_tot = 0.0; + } + bpy_timer_run= PIL_check_seconds_timer(); + + + bpy_timer_count++; +#endif + } +} + +void bpy_context_clear(bContext *C, PyGILState_STATE *gilstate) +{ + py_call_level--; + + if(gilstate) + PyGILState_Release(*gilstate); + + if(py_call_level < 0) { + fprintf(stderr, "ERROR: Python context internal state bug. this should not happen!\n"); + } + else if(py_call_level==0) { + // XXX - Calling classes currently wont store the context :\, cant set NULL because of this. but this is very flakey still. + //BPy_SetContext(NULL); + //bpy_import_main_set(NULL); + +#ifdef TIME_PY_RUN + bpy_timer_run_tot += PIL_check_seconds_timer() - bpy_timer_run; + bpy_timer_count++; +#endif + + } +} + + void BPY_free_compiled_text( struct Text *text ) { if( text->compiled ) { @@ -69,34 +141,31 @@ static void bpy_init_modules( void ) PyModule_AddObject( mod, "props", BPY_rna_props() ); PyModule_AddObject( mod, "__ops__", BPY_operator_module() ); /* ops is now a python module that does the conversion from SOME_OT_foo -> some.foo */ PyModule_AddObject( mod, "ui", BPY_ui_module() ); // XXX very experimental, consider this a test, especially PyCObject is not meant to be permanent - + + /* Arystan: this module is used by i/o scripts for bpy.sys.expandpath() and others. It should be renamed/move? */ + PyModule_AddObject( mod, "sys", BPY_sys_module() ); + /* add the module so we can import it */ PyDict_SetItemString(PySys_GetObject("modules"), "bpy", mod); Py_DECREF(mod); /* stand alone utility modules not related to blender directly */ - Geometry_Init("Geometry"); - Mathutils_Init("Mathutils"); - BGL_Init("BGL"); + Geometry_Init(); + Mathutils_Init(); + BGL_Init(); } -#if (PY_VERSION_HEX < 0x02050000) -PyObject *PyImport_ImportModuleLevel(char *name, void *a, void *b, void *c, int d) -{ - return PyImport_ImportModule(name); -} -#endif - void BPY_update_modules( void ) { +#if 0 // slow, this runs all the time poll, draw etc 100's of time a sec. PyObject *mod= PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0); PyModule_AddObject( mod, "data", BPY_rna_module() ); - PyModule_AddObject( mod, "types", BPY_rna_types() ); - /* PyModule_AddObject( mod, "util", BPY_util_module() ); */ + PyModule_AddObject( mod, "types", BPY_rna_types() ); // atm this does not need updating +#endif - /* XXX this will move to bpy.util */ - PyModule_AddObject( mod, "sys", BPY_sys_module() ); + /* refreshes the main struct */ + BPY_update_rna_module(); } /***************************************************************************** @@ -111,9 +180,6 @@ static PyObject *CreateGlobalDictionary( bContext *C ) PyDict_SetItemString( dict, "__name__", item ); Py_DECREF(item); - // XXX - evil, need to access context - BPy_SetContext(C); - // XXX - put somewhere more logical { PyMethodDef *ml; @@ -178,9 +244,7 @@ void BPY_start_python( int argc, char **argv ) Py_Initialize( ); -#if (PY_VERSION_HEX < 0x03000000) - PySys_SetArgv( argc, argv); -#else + // PySys_SetArgv( argc, argv); // broken in py3, not a huge deal /* sigh, why do python guys not have a char** version anymore? :( */ { int i; @@ -192,7 +256,6 @@ void BPY_start_python( int argc, char **argv ) PySys_SetObject("argv", py_argv); Py_DECREF(py_argv); } -#endif /* Initialize thread support (also acquires lock) */ PyEval_InitThreads(); @@ -210,38 +273,57 @@ void BPY_start_python( int argc, char **argv ) PyDict_SetItemString(d, "__import__", item=PyCFunction_New(bpy_import_meth, NULL)); Py_DECREF(item); } + pyrna_alloc_types(); + py_tstate = PyGILState_GetThisThreadState(); PyEval_ReleaseThread(py_tstate); } void BPY_end_python( void ) { + // fprintf(stderr, "Ending Python!\n"); + PyGILState_Ensure(); /* finalizing, no need to grab the state */ // free other python data. - //BPY_rna_free_types(); + pyrna_free_types(); + + /* clear all python data from structs */ Py_Finalize( ); - return; +#ifdef TIME_PY_RUN + // measure time since py started + bpy_timer = PIL_check_seconds_timer() - bpy_timer; + + printf("*bpy stats* - "); + printf("tot exec: %d, ", bpy_timer_count); + printf("tot run: %.4fsec, ", bpy_timer_run_tot); + if(bpy_timer_count>0) + printf("average run: %.6fsec, ", (bpy_timer_run_tot/bpy_timer_count)); + + if(bpy_timer>0.0) + printf("tot usage %.4f%%", (bpy_timer_run_tot/bpy_timer)*100.0); + + printf("\n"); + + // fprintf(stderr, "Ending Python Done!\n"); + +#endif + } /* Can run a file or text block */ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struct ReportList *reports) { - PyObject *py_dict, *py_result; + PyObject *py_dict, *py_result= NULL; PyGILState_STATE gilstate; if (fn==NULL && text==NULL) { return 0; } - //BPY_start_python(); - - gilstate = PyGILState_Ensure(); - - BPY_update_modules(); /* can give really bad results if this isnt here */ - bpy_import_main_set(CTX_data_main(C)); + bpy_context_set(C, &gilstate); py_dict = CreateGlobalDictionary(C); @@ -256,13 +338,11 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc MEM_freeN( buf ); if( PyErr_Occurred( ) ) { - BPy_errors_to_report(reports); BPY_free_compiled_text( text ); - PyGILState_Release(gilstate); - return 0; } } - py_result = PyEval_EvalCode( text->compiled, py_dict, py_dict ); + if(text->compiled) + py_result = PyEval_EvalCode( text->compiled, py_dict, py_dict ); } else { #if 0 @@ -292,10 +372,9 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc } Py_DECREF(py_dict); - PyGILState_Release(gilstate); - bpy_import_main_set(NULL); - //BPY_end_python(); + bpy_context_clear(C, &gilstate); + return py_result ? 1:0; } @@ -478,12 +557,7 @@ void BPY_run_ui_scripts(bContext *C, int reload) PyGILState_STATE gilstate; PyObject *sys_path; - gilstate = PyGILState_Ensure(); - - // XXX - evil, need to access context - BPy_SetContext(C); - bpy_import_main_set(CTX_data_main(C)); - + bpy_context_set(C, &gilstate); sys_path= PySys_GetObject("path"); /* borrow */ PyList_Insert(sys_path, 0, Py_None); /* place holder, resizes the list */ @@ -542,12 +616,14 @@ void BPY_run_ui_scripts(bContext *C, int reload) PyList_SetSlice(sys_path, 0, 1, NULL); /* remove the first item */ - bpy_import_main_set(NULL); + bpy_context_clear(C, &gilstate); - PyGILState_Release(gilstate); #ifdef TIME_REGISTRATION printf("script time %f\n", (PIL_check_seconds_timer()-time)); #endif + + /* reset the timer so as not to take loading into the stats */ + bpy_timer_count = 0; } /* ****************************************** */ @@ -745,3 +821,56 @@ float BPY_pydriver_eval (ChannelDriver *driver) return result; } + +int BPY_button_eval(bContext *C, char *expr, double *value) +{ + PyGILState_STATE gilstate; + PyObject *dict, *retval; + int error_ret = 0; + + if (!value || !expr || expr[0]=='\0') return -1; + + bpy_context_set(C, &gilstate); + + dict= CreateGlobalDictionary(C); + retval = PyRun_String(expr, Py_eval_input, dict, dict); + + if (retval == NULL) { + error_ret= -1; + } + else { + double val; + + if(PyTuple_Check(retval)) { + /* Users my have typed in 10km, 2m + * add up all values */ + int i; + val= 0.0; + + for(i=0; iidname, PYOP_ATTR_PROP, i); + PyLineSpit(); PyErr_Print(); PyErr_Clear(); } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 54d7b812fe1..0f031318446 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -23,7 +23,6 @@ */ #include "bpy_rna.h" -#include "bpy_compat.h" #include "bpy_util.h" //#include "blendef.h" #include "BLI_dynstr.h" @@ -33,7 +32,6 @@ #include "RNA_access.h" #include "RNA_define.h" /* for defining our own rna */ -#include "rna_internal_types.h" #include "MEM_guardedalloc.h" #include "BKE_utildefines.h" @@ -134,6 +132,8 @@ Mathutils_Callback mathutils_rna_matrix_cb = { #endif +static StructRNA *pyrna_struct_as_srna(PyObject *self); + static int pyrna_struct_compare( BPy_StructRNA * a, BPy_StructRNA * b ) { return (a->ptr.data==b->ptr.data) ? 0 : -1; @@ -278,7 +278,11 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) /* return a mathutils vector where possible */ if(RNA_property_type(prop)==PROP_FLOAT) { switch(RNA_property_subtype(prop)) { - case PROP_VECTOR: + case PROP_TRANSLATION: + case PROP_DIRECTION: + case PROP_VELOCITY: + case PROP_ACCELERATION: + case PROP_XYZ: if(len>=2 && len <= 4) { PyObject *vec_cb= newVectorObject_cb(ret, len, mathutils_rna_array_cb_index, FALSE); Py_DECREF(ret); /* the vector owns now */ @@ -297,7 +301,8 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) ret= mat_cb; /* return the matrix instead */ } break; - case PROP_ROTATION: + case PROP_EULER: + case PROP_QUATERNION: if(len==3) { /* euler */ PyObject *eul_cb= newEulerObject_cb(ret, mathutils_rna_array_cb_index, FALSE); Py_DECREF(ret); /* the matrix owns now */ @@ -935,10 +940,6 @@ static PyObject *prop_subscript_collection_str(BPy_PropertyRNA * self, char *key } /* static PyObject *prop_subscript_array_str(BPy_PropertyRNA * self, char *keyname) */ - - - -#if PY_VERSION_HEX >= 0x03000000 static PyObject *prop_subscript_collection_slice(BPy_PropertyRNA * self, int start, int stop) { PointerRNA newptr; @@ -973,7 +974,6 @@ static PyObject *prop_subscript_array_slice(BPy_PropertyRNA * self, int start, i return list; } -#endif static PyObject *prop_subscript_collection(BPy_PropertyRNA * self, PyObject *key) { @@ -987,7 +987,6 @@ static PyObject *prop_subscript_collection(BPy_PropertyRNA * self, PyObject *key return prop_subscript_collection_int(self, i); } -#if PY_VERSION_HEX >= 0x03000000 else if (PySlice_Check(key)) { int len= RNA_property_collection_length(&self->ptr, self->prop); Py_ssize_t start, stop, step, slicelength; @@ -1006,7 +1005,6 @@ static PyObject *prop_subscript_collection(BPy_PropertyRNA * self, PyObject *key return NULL; } } -#endif else { PyErr_Format(PyExc_TypeError, "invalid rna key, key must be a string or an int instead of %.200s instance.", Py_TYPE(key)->tp_name); return NULL; @@ -1024,7 +1022,6 @@ static PyObject *prop_subscript_array(BPy_PropertyRNA * self, PyObject *key) return NULL; return prop_subscript_array_int(self, PyLong_AsSsize_t(key)); } -#if PY_VERSION_HEX >= 0x03000000 else if (PySlice_Check(key)) { int len= RNA_property_array_length(self->prop); Py_ssize_t start, stop, step, slicelength; @@ -1043,7 +1040,6 @@ static PyObject *prop_subscript_array(BPy_PropertyRNA * self, PyObject *key) return NULL; } } -#endif else { PyErr_SetString(PyExc_AttributeError, "invalid key, key must be an int"); return NULL; @@ -1063,7 +1059,6 @@ static PyObject *pyrna_prop_subscript( BPy_PropertyRNA * self, PyObject *key ) } -#if PY_VERSION_HEX >= 0x03000000 static int prop_subscript_ass_array_slice(BPy_PropertyRNA * self, int begin, int end, PyObject *value) { int count; @@ -1080,7 +1075,6 @@ static int prop_subscript_ass_array_slice(BPy_PropertyRNA * self, int begin, int return 0; } -#endif static int prop_subscript_ass_array_int(BPy_PropertyRNA * self, int keynum, PyObject *value) { @@ -1118,7 +1112,6 @@ static int pyrna_prop_ass_subscript( BPy_PropertyRNA * self, PyObject *key, PyOb return prop_subscript_ass_array_int(self, i, value); } -#if PY_VERSION_HEX >= 0x03000000 else if (PySlice_Check(key)) { int len= RNA_property_array_length(self->prop); Py_ssize_t start, stop, step, slicelength; @@ -1137,7 +1130,6 @@ static int pyrna_prop_ass_subscript( BPy_PropertyRNA * self, PyObject *key, PyOb return -1; } } -#endif else { PyErr_SetString(PyExc_AttributeError, "invalid key, key must be an int"); return -1; @@ -1489,7 +1481,39 @@ static PyObject *pyrna_prop_get(BPy_PropertyRNA *self, PyObject *args) } -#if (PY_VERSION_HEX >= 0x03000000) /* foreach needs py3 */ +static PyObject *pyrna_prop_add(BPy_PropertyRNA *self, PyObject *args) +{ + PointerRNA newptr; + + RNA_property_collection_add(&self->ptr, self->prop, &newptr); + if(!newptr.data) { + PyErr_SetString( PyExc_TypeError, "add() not supported for this collection"); + return NULL; + } + else { + return pyrna_struct_CreatePyObject(&newptr); + } +} + +static PyObject *pyrna_prop_remove(BPy_PropertyRNA *self, PyObject *args) +{ + PyObject *ret; + int key= 0; + + if (!PyArg_ParseTuple(args, "i:remove", &key)) + return NULL; + + if(!RNA_property_collection_remove(&self->ptr, self->prop, key)) { + PyErr_SetString( PyExc_TypeError, "remove() not supported for this collection"); + return NULL; + } + + ret = Py_None; + Py_INCREF(ret); + + return ret; +} + static void foreach_attr_type( BPy_PropertyRNA *self, char *attr, /* values to assign */ RawPropertyType *raw_type, int *attr_tot, int *attr_signed ) @@ -1724,7 +1748,6 @@ static PyObject *pyrna_prop_foreach_set(BPy_PropertyRNA *self, PyObject *args) { return foreach_getset(self, args, 1); } -#endif /* #if (PY_VERSION_HEX >= 0x03000000) */ /* A bit of a kludge, make a list out of a collection or array, * then return the lists iter function, not especially fast but convenient for now */ @@ -1775,11 +1798,13 @@ static struct PyMethodDef pyrna_prop_methods[] = { {"get", (PyCFunction)pyrna_prop_get, METH_VARARGS, NULL}, -#if (PY_VERSION_HEX >= 0x03000000) + {"add", (PyCFunction)pyrna_prop_add, METH_VARARGS, NULL}, + {"remove", (PyCFunction)pyrna_prop_remove, METH_VARARGS, NULL}, + /* array accessor function */ {"foreach_get", (PyCFunction)pyrna_prop_foreach_get, METH_VARARGS, NULL}, {"foreach_set", (PyCFunction)pyrna_prop_foreach_set, METH_VARARGS, NULL}, -#endif + {NULL, NULL, 0, NULL} }; @@ -1833,7 +1858,7 @@ PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data) ret = PyTuple_New(len); /* for return values, data is a pointer to an array, not first element pointer */ - if (prop->flag & PROP_DYNAMIC_ARRAY) + if (RNA_property_flag(prop) & PROP_DYNAMIC_ARRAY) data = *(char**)(char*)data; switch (type) { @@ -2147,13 +2172,7 @@ static PyObject * pyrna_func_call(PyObject * self, PyObject *args, PyObject *kw) /*-----------------------BPy_StructRNA method def------------------------------*/ PyTypeObject pyrna_struct_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "StructRNA", /* tp_name */ sizeof( BPy_StructRNA ), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2232,14 +2251,7 @@ PyTypeObject pyrna_struct_Type = { /*-----------------------BPy_PropertyRNA method def------------------------------*/ PyTypeObject pyrna_prop_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "PropertyRNA", /* tp_name */ sizeof( BPy_PropertyRNA ), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2322,7 +2334,7 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna) PyObject *item; Py_INCREF(newclass); - + if (RNA_struct_py_type_get(srna)) PyObSpit("RNA WAS SET - ", RNA_struct_py_type_get(srna)); @@ -2332,18 +2344,47 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna) /* Not 100% needed but useful, * having an instance within a type looks wrong however this instance IS an rna type */ + + /* python deals with the curcular ref */ RNA_pointer_create(NULL, &RNA_Struct, srna, &ptr); item = pyrna_struct_CreatePyObject(&ptr); + + //item = PyCObject_FromVoidPtr(srna, NULL); PyDict_SetItemString(((PyTypeObject *)newclass)->tp_dict, "__rna__", item); Py_DECREF(item); /* done with rna instance */ } +/* +static StructRNA *srna_from_self(PyObject *self); +PyObject *BPy_GetStructRNA(PyObject *self) +{ + StructRNA *srna= pyrna_struct_as_srna(self); + PointerRNA ptr; + PyObject *ret; + + RNA_pointer_create(NULL, &RNA_Struct, srna, &ptr); + ret= pyrna_struct_CreatePyObject(&ptr); + + if(ret) { + return ret; + } + else { + Py_RETURN_NONE; + } +} +*/ + static struct PyMethodDef pyrna_struct_subtype_methods[] = { - {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, - {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"EnumProperty", (PyCFunction)BPy_EnumProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"PointerProperty", (PyCFunction)BPy_PointerProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"CollectionProperty", (PyCFunction)BPy_CollectionProperty, METH_VARARGS|METH_KEYWORDS, ""}, + +// {"__get_rna", (PyCFunction)BPy_GetStructRNA, METH_NOARGS, ""}, {NULL, NULL, 0, NULL} }; @@ -2378,18 +2419,26 @@ PyObject* pyrna_srna_Subtype(StructRNA *srna) if(base && base != srna) { /*/printf("debug subtype %s %p\n", RNA_struct_identifier(srna), srna); */ py_base= pyrna_srna_Subtype(base); + Py_DECREF(py_base); /* srna owns, this is only to pass as an arg */ } if(py_base==NULL) { py_base= (PyObject *)&pyrna_struct_Type; - Py_INCREF(py_base); } - newclass = PyObject_CallFunction( (PyObject*)&PyType_Type, "s(N){ssss}", idname, py_base, "__module__","bpy.types", "__doc__",descr); + /* always use O not N when calling, N causes refcount errors */ + newclass = PyObject_CallFunction( (PyObject*)&PyType_Type, "s(O){ssss}", idname, py_base, "__module__","bpy.types", "__doc__",descr); + /* newclass will now have 2 ref's, ???, probably 1 is internal since decrefing here segfaults */ + + /* PyObSpit("new class ref", newclass); */ if (newclass) { + + /* srna owns one, and the other is owned by the caller */ pyrna_subtype_set_rna(newclass, srna); - // PyObSpit("NewStructRNA Type: ", (PyObject *)newclass); + + Py_DECREF(newclass); /* let srna own */ + /* attach functions into the class * so you can do... bpy.types.Scene.SomeFunction() @@ -2412,9 +2461,21 @@ PyObject* pyrna_srna_Subtype(StructRNA *srna) return newclass; } +/* use for subtyping so we know which srna is used for a PointerRNA */ +static StructRNA *srna_from_ptr(PointerRNA *ptr) +{ + if(ptr->type == &RNA_Struct) { + return ptr->data; + } + else { + return ptr->type; + } +} + +/* always returns a new ref, be sure to decref when done */ PyObject* pyrna_struct_Subtype(PointerRNA *ptr) { - return pyrna_srna_Subtype((ptr->type == &RNA_Struct) ? ptr->data : ptr->type); + return pyrna_srna_Subtype(srna_from_ptr(ptr)); } /*-----------------------CreatePyObject---------------------------------*/ @@ -2430,6 +2491,7 @@ PyObject *pyrna_struct_CreatePyObject( PointerRNA *ptr ) if (tp) { pyrna = (BPy_StructRNA *) tp->tp_alloc(tp, 0); + Py_DECREF(tp); /* srna owns, cant hold a ref */ } else { fprintf(stderr, "Could not make type\n"); @@ -2467,8 +2529,11 @@ PyObject *pyrna_prop_CreatePyObject( PointerRNA *ptr, PropertyRNA *prop ) return ( PyObject * ) pyrna; } +/* bpy.data from python */ +static PointerRNA *rna_module_ptr= NULL; PyObject *BPY_rna_module( void ) { + BPy_StructRNA *pyrna; PointerRNA ptr; #ifdef USE_MATHUTILS // register mathutils callbacks, ok to run more then once. @@ -2488,8 +2553,15 @@ PyObject *BPY_rna_module( void ) /* for now, return the base RNA type rather then a real module */ RNA_main_pointer_create(G.main, &ptr); + pyrna= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr); - return pyrna_struct_CreatePyObject(&ptr); + rna_module_ptr= &pyrna->ptr; + return (PyObject *)pyrna; +} + +void BPY_update_rna_module(void) +{ + RNA_main_pointer_create(G.main, rna_module_ptr); } #if 0 @@ -2535,8 +2607,8 @@ static PyObject *pyrna_basetype_getattro( BPy_BaseTypeRNA * self, PyObject *pyna static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self); static struct PyMethodDef pyrna_basetype_methods[] = { {"__dir__", (PyCFunction)pyrna_basetype_dir, METH_NOARGS, ""}, - {"register", (PyCFunction)pyrna_basetype_register, METH_VARARGS, ""}, - {"unregister", (PyCFunction)pyrna_basetype_unregister, METH_VARARGS, ""}, + {"register", (PyCFunction)pyrna_basetype_register, METH_O, ""}, + {"unregister", (PyCFunction)pyrna_basetype_unregister, METH_O, ""}, {NULL, NULL, 0, NULL} }; @@ -2583,14 +2655,16 @@ PyObject *BPY_rna_types(void) } static struct PyMethodDef props_methods[] = { - {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, - {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"EnumProperty", (PyCFunction)BPy_EnumProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"PointerProperty", (PyCFunction)BPy_PointerProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"CollectionProperty", (PyCFunction)BPy_CollectionProperty, METH_VARARGS|METH_KEYWORDS, ""}, {NULL, NULL, 0, NULL} }; -#if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef props_module = { PyModuleDef_HEAD_INIT, "bpy.props", @@ -2599,16 +2673,11 @@ static struct PyModuleDef props_module = { props_methods, NULL, NULL, NULL, NULL }; -#endif PyObject *BPY_rna_props( void ) { PyObject *submodule; -#if PY_VERSION_HEX >= 0x03000000 submodule= PyModule_Create(&props_module); -#else /* Py2.x */ - submodule= Py_InitModule3( "bpy.props", props_methods, "" ); -#endif /* INCREF since its its assumed that all these functions return the * module with a new ref like PyDict_New, since they are passed to @@ -2618,18 +2687,83 @@ PyObject *BPY_rna_props( void ) return submodule; } +static StructRNA *pyrna_struct_as_srna(PyObject *self) +{ + BPy_StructRNA *py_srna= (BPy_StructRNA*)PyObject_GetAttrString(self, "__rna__"); + StructRNA *srna; + + if(py_srna==NULL) { + PyErr_SetString(PyExc_SystemError, "internal error, self had no __rna__ attribute, should never happen."); + return NULL; + } + + if(!BPy_StructRNA_Check(py_srna)) { + PyErr_Format(PyExc_SystemError, "internal error, __rna__ was of type %.200s, instead of %.200s instance.", Py_TYPE(py_srna)->tp_name, pyrna_struct_Type.tp_name); + Py_DECREF(py_srna); + return NULL; + } + + if(py_srna->ptr.type != &RNA_Struct) { + PyErr_SetString(PyExc_SystemError, "internal error, __rna__ was not a RNA_Struct type of rna struct."); + Py_DECREF(py_srna); + return NULL; + } + + srna= py_srna->ptr.data; + Py_DECREF(py_srna); + + return srna; +} + + /* Orphan functions, not sure where they should go */ +/* get the srna for methods attached to types */ +/* */ +static StructRNA *srna_from_self(PyObject *self) +{ + /* a bit sloppy but would cause a very confusing bug if + * an error happened to be set here */ + PyErr_Clear(); + + if(self==NULL) { + return NULL; + } + else if (PyCObject_Check(self)) { + return PyCObject_AsVoidPtr(self); + } + else if (PyType_Check(self)==0) { + return NULL; + } + /* These cases above not errors, they just mean the type was not compatible + * After this any errors will be raised in the script */ + + return pyrna_struct_as_srna(self); +} + +/* operators use this so it can store the args given but defer running + * it until the operator runs where these values are used to setup the + * default args for that operator instance */ +static PyObject *bpy_prop_deferred_return(void *func, PyObject *kw) +{ + PyObject *ret = PyTuple_New(2); + PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr(func, NULL)); + PyTuple_SET_ITEM(ret, 1, kw); + Py_INCREF(kw); + return ret; +} /* Function that sets RNA, NOTE - self is NULL when called from python, but being abused from C so we can pass the srna allong * This isnt incorrect since its a python object - but be careful */ -PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) + +PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) { - static char *kwlist[] = {"attr", "name", "description", "min", "max", "soft_min", "soft_max", "default", NULL}; + static char *kwlist[] = {"attr", "name", "description", "default", NULL}; char *id, *name="", *description=""; - float min=FLT_MIN, max=FLT_MAX, soft_min=FLT_MIN, soft_max=FLT_MAX, def=0.0f; + int def=0; PropertyRNA *prop; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssfffff:FloatProperty", kwlist, &id, &name, &description, &min, &max, &soft_min, &soft_max, &def)) + StructRNA *srna; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssi:BoolProperty", kwlist, &id, &name, &description, &def)) return NULL; if (PyTuple_Size(args) > 0) { @@ -2637,34 +2771,17 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (self && PyCObject_Check(self)) { - StructRNA *srna = PyCObject_AsVoidPtr(self); - prop= RNA_def_float(srna, id, def, min, max, name, description, soft_min, soft_max); + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { + prop= RNA_def_boolean(srna, id, def, name, description); RNA_def_property_duplicate_pointers(prop); Py_RETURN_NONE; - } else if(self && PyType_Check(self)) { - PyObject *pyob= PyObject_GetAttrString(self, "__rna__"); - - if(pyob && BPy_StructRNA_Check(pyob)) { - BPy_StructRNA *py_srna= (BPy_StructRNA*)pyob; - - if(py_srna->ptr.data && py_srna->ptr.type == &RNA_Struct) { - if(RNA_struct_is_ID(py_srna->ptr.data)) { - prop= RNA_def_float(py_srna->ptr.data, id, def, min, max, name, description, soft_min, soft_max); - RNA_def_property_duplicate_pointers(prop); - Py_RETURN_NONE; - } - } - } - - PyErr_SetString(PyExc_ValueError, "only works on ID types"); - return NULL; - } else { - PyObject *ret = PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr((void *)BPy_FloatProperty, NULL)); - PyTuple_SET_ITEM(ret, 1, kw); - Py_INCREF(kw); - return ret; + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_BoolProperty, kw); } } @@ -2674,7 +2791,8 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) char *id, *name="", *description=""; int min=INT_MIN, max=INT_MAX, soft_min=INT_MIN, soft_max=INT_MAX, def=0; PropertyRNA *prop; - + StructRNA *srna; + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiiiii:IntProperty", kwlist, &id, &name, &description, &min, &max, &soft_min, &soft_max, &def)) return NULL; @@ -2683,80 +2801,47 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (self && PyCObject_Check(self)) { - StructRNA *srna = PyCObject_AsVoidPtr(self); + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { prop= RNA_def_int(srna, id, def, min, max, name, description, soft_min, soft_max); RNA_def_property_duplicate_pointers(prop); Py_RETURN_NONE; - } else if(self && PyType_Check(self)) { - PyObject *pyob= PyObject_GetAttrString(self, "__rna__"); - - if(pyob && BPy_StructRNA_Check(pyob)) { - BPy_StructRNA *py_srna= (BPy_StructRNA*)pyob; - - if(py_srna->ptr.data && py_srna->ptr.type == &RNA_Struct) { - if(RNA_struct_is_ID(py_srna->ptr.data)) { - prop= RNA_def_int(py_srna->ptr.data, id, def, min, max, name, description, soft_min, soft_max); - RNA_def_property_duplicate_pointers(prop); - Py_RETURN_NONE; - } - } - } - - PyErr_SetString(PyExc_ValueError, "only works on ID types"); - return NULL; - } else { - PyObject *ret = PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr((void *)BPy_IntProperty, NULL)); - PyTuple_SET_ITEM(ret, 1, kw); - Py_INCREF(kw); - return ret; + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_IntProperty, kw); } } -PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) +PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) { - static char *kwlist[] = {"attr", "name", "description", "default", NULL}; + static char *kwlist[] = {"attr", "name", "description", "min", "max", "soft_min", "soft_max", "default", NULL}; char *id, *name="", *description=""; - int def=0; + float min=FLT_MIN, max=FLT_MAX, soft_min=FLT_MIN, soft_max=FLT_MAX, def=0.0f; PropertyRNA *prop; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssi:BoolProperty", kwlist, &id, &name, &description, &def)) + StructRNA *srna; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssfffff:FloatProperty", kwlist, &id, &name, &description, &min, &max, &soft_min, &soft_max, &def)) return NULL; if (PyTuple_Size(args) > 0) { PyErr_SetString(PyExc_ValueError, "all args must be keywors"); // TODO - py3 can enforce this. return NULL; } - - if (self && PyCObject_Check(self)) { - StructRNA *srna = PyCObject_AsVoidPtr(self); - prop= RNA_def_boolean(srna, id, def, name, description); + + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { + prop= RNA_def_float(srna, id, def, min, max, name, description, soft_min, soft_max); RNA_def_property_duplicate_pointers(prop); Py_RETURN_NONE; - } else if(self && PyType_Check(self)) { - PyObject *pyob= PyObject_GetAttrString(self, "__rna__"); - - if(pyob && BPy_StructRNA_Check(pyob)) { - BPy_StructRNA *py_srna= (BPy_StructRNA*)pyob; - - if(py_srna->ptr.data && py_srna->ptr.type == &RNA_Struct) { - if(RNA_struct_is_ID(py_srna->ptr.data)) { - prop= RNA_def_boolean(py_srna->ptr.data, id, def, name, description); - RNA_def_property_duplicate_pointers(prop); - Py_RETURN_NONE; - } - } - } - - PyErr_SetString(PyExc_ValueError, "only works on ID types"); - return NULL; - } else { - PyObject *ret = PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr((void *)BPy_BoolProperty, NULL)); - PyTuple_SET_ITEM(ret, 1, kw); - Py_INCREF(kw); - return ret; + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_FloatProperty, kw); } } @@ -2766,7 +2851,8 @@ PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw) char *id, *name="", *description="", *def=""; int maxlen=0; PropertyRNA *prop; - + StructRNA *srna; + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssis:StringProperty", kwlist, &id, &name, &description, &maxlen, &def)) return NULL; @@ -2774,36 +2860,191 @@ PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw) PyErr_SetString(PyExc_ValueError, "all args must be keywors"); // TODO - py3 can enforce this. return NULL; } - - if (self && PyCObject_Check(self)) { - StructRNA *srna = PyCObject_AsVoidPtr(self); + + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { prop= RNA_def_string(srna, id, def, maxlen, name, description); RNA_def_property_duplicate_pointers(prop); Py_RETURN_NONE; - } else if(self && PyType_Check(self)) { - PyObject *pyob= PyObject_GetAttrString(self, "__rna__"); + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_StringProperty, kw); + } +} - if(pyob && BPy_StructRNA_Check(pyob)) { - BPy_StructRNA *py_srna= (BPy_StructRNA*)pyob; +static EnumPropertyItem *enum_items_from_py(PyObject *value, const char *def, int *defvalue) +{ + EnumPropertyItem *items= NULL; + PyObject *item; + int seq_len, i, totitem= 0; + + if(!PySequence_Check(value)) { + PyErr_SetString(PyExc_TypeError, "expected a sequence of tuples for the enum items"); + return NULL; + } - if(py_srna->ptr.data && py_srna->ptr.type == &RNA_Struct) { - if(RNA_struct_is_ID(py_srna->ptr.data)) { - prop= RNA_def_string(py_srna->ptr.data, id, def, maxlen, name, description); - RNA_def_property_duplicate_pointers(prop); - Py_RETURN_NONE; - } - } + seq_len = PySequence_Length(value); + for(i=0; i 0) { + PyErr_SetString(PyExc_ValueError, "all args must be keywors"); // TODO - py3 can enforce this. + return NULL; + } + + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { + eitems= enum_items_from_py(items, def, &defvalue); + if(!eitems) + return NULL; + + prop= RNA_def_enum(srna, id, eitems, defvalue, name, description); + RNA_def_property_duplicate_pointers(prop); + MEM_freeN(eitems); + + Py_RETURN_NONE; + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_EnumProperty, kw); + } +} + +static StructRNA *pointer_type_from_py(PyObject *value) +{ + StructRNA *srna; + + srna= srna_from_self(value); + if(!srna) { + PyErr_SetString(PyExc_SystemError, "expected an RNA type derived from IDPropertyGroup (1)"); + return NULL; + } + + if(!RNA_struct_is_a(srna, &RNA_IDPropertyGroup)) { + PyErr_SetString(PyExc_SystemError, "expected an RNA type derived from IDPropertyGroup (3)"); + return NULL; + } + + return srna; +} + +PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw) +{ + static char *kwlist[] = {"attr", "type", "name", "description", NULL}; + char *id, *name="", *description=""; + PropertyRNA *prop; + StructRNA *srna, *ptype; + PyObject *type= Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ss:PointerProperty", kwlist, &id, &type, &name, &description)) + return NULL; + + if (PyTuple_Size(args) > 0) { + PyErr_SetString(PyExc_ValueError, "all args must be keywors"); // TODO - py3 can enforce this. + return NULL; + } + + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { + ptype= pointer_type_from_py(type); + if(!ptype) + return NULL; + + prop= RNA_def_pointer_runtime(srna, id, ptype, name, description); + RNA_def_property_duplicate_pointers(prop); + Py_RETURN_NONE; + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_PointerProperty, kw); + } + return NULL; +} + +PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) +{ + static char *kwlist[] = {"attr", "type", "name", "description", NULL}; + char *id, *name="", *description=""; + PropertyRNA *prop; + StructRNA *srna, *ptype; + PyObject *type= Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ss:CollectionProperty", kwlist, &id, &type, &name, &description)) + return NULL; + + if (PyTuple_Size(args) > 0) { + PyErr_SetString(PyExc_ValueError, "all args must be keywors"); // TODO - py3 can enforce this. + return NULL; + } + + srna= srna_from_self(self); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna) { + ptype= pointer_type_from_py(type); + if(!ptype) + return NULL; + + prop= RNA_def_collection_runtime(srna, id, ptype, name, description); + RNA_def_property_duplicate_pointers(prop); + Py_RETURN_NONE; + } + else { /* operators defer running this function */ + return bpy_prop_deferred_return((void *)BPy_CollectionProperty, kw); + } + return NULL; } /*-------------------- Type Registration ------------------------*/ @@ -2953,9 +3194,10 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par void *retdata= NULL; int err= 0, i, flag; - PyGILState_STATE gilstate = PyGILState_Ensure(); + PyGILState_STATE gilstate; - BPY_update_modules(); // XXX - the RNA pointers can change so update before running, would like a nicer solution for this. + bContext *C= BPy_GetContext(); // XXX - NEEDS FIXING, QUITE BAD. + bpy_context_set(C, &gilstate); py_class= RNA_struct_py_type_get(ptr->type); @@ -3031,57 +3273,103 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par PyErr_Clear(); } - PyGILState_Release(gilstate); + bpy_context_clear(C, &gilstate); return err; } static void bpy_class_free(void *pyob_ptr) { + PyObject *self= (PyObject *)pyob_ptr; + PyGILState_STATE gilstate; + + gilstate = PyGILState_Ensure(); + + PyDict_Clear(((PyTypeObject*)self)->tp_dict); + if(G.f&G_DEBUG) { - if(((PyObject *)pyob_ptr)->ob_refcnt > 1) - PyObSpit("zombie class - ref should be 1", (PyObject *)pyob_ptr); + if(self->ob_refcnt > 1) { + PyObSpit("zombie class - ref should be 1", self); + } } + Py_DECREF((PyObject *)pyob_ptr); + + PyGILState_Release(gilstate); } -PyObject *pyrna_basetype_register(PyObject *self, PyObject *args) +void pyrna_alloc_types(void) +{ + PyGILState_STATE gilstate; + + PointerRNA ptr; + PropertyRNA *prop; + + gilstate = PyGILState_Ensure(); + + /* avoid doing this lookup for every getattr */ + RNA_blender_rna_pointer_create(&ptr); + prop = RNA_struct_find_property(&ptr, "structs"); + + RNA_PROP_BEGIN(&ptr, itemptr, prop) { + Py_DECREF(pyrna_struct_Subtype(&itemptr)); + } + RNA_PROP_END; + + PyGILState_Release(gilstate); +} + + +void pyrna_free_types(void) +{ + PointerRNA ptr; + PropertyRNA *prop; + + /* avoid doing this lookup for every getattr */ + RNA_blender_rna_pointer_create(&ptr); + prop = RNA_struct_find_property(&ptr, "structs"); + + + RNA_PROP_BEGIN(&ptr, itemptr, prop) { + StructRNA *srna= srna_from_ptr(&itemptr); + void *py_ptr= RNA_struct_py_type_get(srna); + + if(py_ptr) { +#if 0 // XXX - should be able to do this but makes python crash on exit + bpy_class_free(py_ptr); +#endif + RNA_struct_py_type_set(srna, NULL); + } + } + RNA_PROP_END; +} + +/* Note! MemLeak XXX + * + * There is currently a bug where moving registering a python class does + * not properly manage refcounts from the python class, since the srna owns + * the python class this should not be so tricky but changing the references as + * youd expect when changing ownership crashes blender on exit so I had to comment out + * the decref. This is not so bad because the leak only happens when re-registering (hold F8) + * - Should still be fixed - Campbell + * */ + +PyObject *pyrna_basetype_register(PyObject *self, PyObject *py_class) { bContext *C= NULL; - PyObject *py_class, *item; ReportList reports; StructRegisterFunc reg; - BPy_StructRNA *py_srna; StructRNA *srna; + StructRNA *srna_new; + PyObject *item; + const char *identifier= ""; - if(!PyArg_ParseTuple(args, "O:register", &py_class)) + srna= pyrna_struct_as_srna(py_class); + if(srna==NULL) return NULL; - if(!PyType_Check(py_class)) { - PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (no a Type object)."); - return NULL; - } - - /* check we got an __rna__ attribute */ - item= PyObject_GetAttrString(py_class, "__rna__"); - - if(!item || !BPy_StructRNA_Check(item)) { - Py_XDECREF(item); - PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (no __rna__ property)."); - return NULL; - } - - /* check the __rna__ attribute has the right type */ - Py_DECREF(item); - py_srna= (BPy_StructRNA*)item; - - if(py_srna->ptr.type != &RNA_Struct) { - PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (not a Struct)."); - return NULL; - } - /* check that we have a register callback for this type */ - reg= RNA_struct_register(py_srna->ptr.data); + reg= RNA_struct_register(srna); if(!reg) { PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (no register supported)."); @@ -3091,11 +3379,19 @@ PyObject *pyrna_basetype_register(PyObject *self, PyObject *args) /* get the context, so register callback can do necessary refreshes */ C= BPy_GetContext(); - /* call the register callback */ + /* call the register callback with reports & identifier */ BKE_reports_init(&reports, RPT_STORE); - srna= reg(C, &reports, py_class, bpy_class_validate, bpy_class_call, bpy_class_free); - if(!srna) { + item= PyObject_GetAttrString(py_class, "__name__"); + + if(item) { + identifier= _PyUnicode_AsString(item); + Py_DECREF(item); /* no need to keep a ref, the class owns it */ + } + + srna_new= reg(C, &reports, py_class, identifier, bpy_class_validate, bpy_class_call, bpy_class_free); + + if(!srna_new) { BPy_reports_to_error(&reports); BKE_reports_clear(&reports); return NULL; @@ -3103,44 +3399,29 @@ PyObject *pyrna_basetype_register(PyObject *self, PyObject *args) BKE_reports_clear(&reports); - pyrna_subtype_set_rna(py_class, srna); /* takes a ref to py_class */ + pyrna_subtype_set_rna(py_class, srna_new); /* takes a ref to py_class */ + + /* old srna still references us, keep the check incase registering somehow can free it */ + if(RNA_struct_py_type_get(srna)) { + RNA_struct_py_type_set(srna, NULL); + // Py_DECREF(py_class); // shuld be able to do this XXX since the old rna adds a new ref. + } Py_RETURN_NONE; } -PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *args) +PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *py_class) { bContext *C= NULL; - PyObject *py_class, *item; - BPy_StructRNA *py_srna; StructUnregisterFunc unreg; + StructRNA *srna; - if(!PyArg_ParseTuple(args, "O:unregister", &py_class)) + srna= pyrna_struct_as_srna(py_class); + if(srna==NULL) return NULL; - - if(!PyType_Check(py_class)) { - PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (no a Type object)."); - return NULL; - } - - /* check we got an __rna__ attribute */ - item= PyDict_GetItemString(((PyTypeObject*)py_class)->tp_dict, "__rna__"); /* borrow ref */ - - if(!item || !BPy_StructRNA_Check(item)) { - PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (no __rna__ property)."); - return NULL; - } - - /* check the __rna__ attribute has the right type */ - py_srna= (BPy_StructRNA*)item; - - if(py_srna->ptr.type != &RNA_Struct) { - PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (not a Struct)."); - return NULL; - } /* check that we have a unregister callback for this type */ - unreg= RNA_struct_unregister(py_srna->ptr.data); + unreg= RNA_struct_unregister(srna); if(!unreg) { PyErr_SetString(PyExc_AttributeError, "expected a Type subclassed from a registerable rna type (no unregister supported)."); @@ -3152,10 +3433,7 @@ PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *args) /* call unregister */ - unreg(C, py_srna->ptr.data); - - /* remove reference to old type */ - Py_DECREF(py_class); + unreg(C, srna); /* calls bpy_class_free, this decref's py_class */ Py_RETURN_NONE; } diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 9138fd511b0..1b8d69bc511 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -61,6 +61,7 @@ typedef struct { #define BPy_BaseTypeRNA BPy_PropertyRNA PyObject *BPY_rna_module( void ); +void BPY_update_rna_module( void ); /*PyObject *BPY_rna_doc( void );*/ PyObject *BPY_rna_types( void ); PyObject *BPY_rna_props( void ); @@ -74,13 +75,20 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop); /* functions for setting up new props - experemental */ -PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw); -PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw); PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw); +PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw); +PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw); PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw); +PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw); +PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw); +PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw); /* function for registering types */ PyObject *pyrna_basetype_register(PyObject *self, PyObject *args); PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *args); +/* called before stopping python */ +void pyrna_alloc_types(void); +void pyrna_free_types(void); + #endif diff --git a/source/blender/python/intern/bpy_ui.c b/source/blender/python/intern/bpy_ui.c index 59e566b3b37..f03a83bee9c 100644 --- a/source/blender/python/intern/bpy_ui.c +++ b/source/blender/python/intern/bpy_ui.c @@ -26,7 +26,6 @@ #include "bpy_util.h" #include "bpy_rna.h" /* for rna buttons */ #include "bpy_operator.h" /* for setting button operator properties */ -#include "bpy_compat.h" #include "WM_types.h" /* for WM_OP_INVOKE_DEFAULT & friends */ @@ -47,7 +46,6 @@ static struct PyMethodDef ui_methods[] = { {NULL, NULL, 0, NULL} }; -#if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef ui_module = { PyModuleDef_HEAD_INIT, "bpy.ui", @@ -56,16 +54,11 @@ static struct PyModuleDef ui_module = { ui_methods, NULL, NULL, NULL, NULL }; -#endif PyObject *BPY_ui_module( void ) { - PyObject *submodule, *mod; -#if PY_VERSION_HEX >= 0x03000000 + PyObject *submodule; submodule= PyModule_Create(&ui_module); -#else /* Py2.x */ - submodule= Py_InitModule3( "bpy.ui", ui_methods, "" ); -#endif /* INCREF since its its assumed that all these functions return the * module with a new ref like PyDict_New, since they are passed to diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index 89a68ba576c..924d1dbf06a 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -129,7 +129,6 @@ int BPY_flag_from_seq(BPY_flag_def *flagdef, PyObject *seq, int *flag) /* Copied from pythons 3's Object.c */ -#ifndef Py_CmpToRich PyObject * Py_CmpToRich(int op, int cmp) { @@ -165,7 +164,6 @@ Py_CmpToRich(int op, int cmp) Py_INCREF(res); return res; } -#endif /* for debugging */ void PyObSpit(char *name, PyObject *var) { @@ -175,7 +173,7 @@ void PyObSpit(char *name, PyObject *var) { } else { PyObject_Print(var, stderr, 0); - fprintf(stderr, " ref:%d ", var->ob_refcnt); + fprintf(stderr, " ref:%d ", (int)var->ob_refcnt); fprintf(stderr, " ptr:%p", (void *)var); fprintf(stderr, " type:"); @@ -378,11 +376,7 @@ PyObject *BPY_exception_buffer(void) * string_io = StringIO.StringIO() */ -#if PY_VERSION_HEX < 0x03000000 - if(! (string_io_mod= PyImport_ImportModule("StringIO")) ) { -#else if(! (string_io_mod= PyImport_ImportModule("io")) ) { -#endif goto error_cleanup; } else if (! (string_io = PyObject_CallMethod(string_io_mod, "StringIO", NULL))) { goto error_cleanup; diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h index 38e2b36c11f..0400d595520 100644 --- a/source/blender/python/intern/bpy_util.h +++ b/source/blender/python/intern/bpy_util.h @@ -27,7 +27,10 @@ #ifndef BPY_UTIL_H #define BPY_UTIL_H -#include "bpy_compat.h" +#if PY_VERSION_HEX < 0x03010000 +#error "Python versions below 3.1 are not supported anymore, you'll need to update your python." +#endif + #include "RNA_types.h" /* for EnumPropertyItem only */ struct EnumPropertyItem; @@ -47,6 +50,8 @@ void PyObSpit(char *name, PyObject *var); void PyLineSpit(void); void BPY_getFileAndNum(char **filename, int *lineno); +PyObject *Py_CmpToRich(int op, int cmp); + PyObject *BPY_exception_buffer(void); /* own python like utility function */ @@ -72,7 +77,7 @@ int BPY_class_validate(const char *class_type, PyObject *class, PyObject *base_c char *BPy_enum_as_string(struct EnumPropertyItem *item); -#define BLANK_PYTHON_TYPE {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} +#define BLANK_PYTHON_TYPE {PyVarObject_HEAD_INIT(NULL, 0) 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} /* error reporting */ int BPy_reports_to_error(struct ReportList *reports); @@ -82,6 +87,8 @@ int BPy_errors_to_report(struct ReportList *reports); struct bContext *BPy_GetContext(void); void BPy_SetContext(struct bContext *C); -PyObject *BPY_util_module(void); +extern void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate); +extern void bpy_context_clear(struct bContext *C, PyGILState_STATE *gilstate); + #endif diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 2df3a0a4f8b..bf02af6ac36 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -266,7 +266,8 @@ typedef struct RenderEngine { ListBase fullresult; } RenderEngine; -void RE_layer_rect_from_file(RenderLayer *layer, struct ReportList *reports, char *filename, int x, int y); +void RE_layer_load_from_file(RenderLayer *layer, struct ReportList *reports, char *filename); +void RE_result_load_from_file(RenderResult *result, struct ReportList *reports, char *filename); struct RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h); void RE_engine_update_result(RenderEngine *engine, struct RenderResult *result); diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index 0ad48fe97a9..5f5b493a9ec 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -55,7 +55,6 @@ typedef struct ShadeResult float refl[3]; float refr[3]; float nor[3]; - float rad[3]; float winspeed[4]; } ShadeResult; @@ -132,7 +131,7 @@ typedef struct ShadeInput float layerfac; /* texture coordinates */ - float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[4], rad[3]; + float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[4]; float refcol[4], displace[3]; float strandco, tang[3], nmaptang[3], stress, winspeed[4]; float duplilo[3], dupliuv[3]; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 2b06f164c12..2c264ce2337 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -895,7 +895,7 @@ static void flag_render_node_material(Render *re, bNodeTree *ntree) if(GS(node->id->name)==ID_MA) { Material *ma= (Material *)node->id; - if(ma->mode & MA_ZTRA) + if((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) re->flag |= R_ZTRA; ma->flag |= MA_IS_USED; @@ -917,7 +917,7 @@ static Material *give_render_material(Render *re, Object *ob, int nr) if(re->r.mode & R_SPEED) ma->texco |= NEED_UV; - if(ma->mode & MA_ZTRA) + if((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) re->flag |= R_ZTRA; /* for light groups */ @@ -3025,11 +3025,6 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) } need_nmap_tangent= 1; } - - /* radio faces need autosmooth, to separate shared vertices in corners */ - if(re->r.mode & R_RADIO) - if(ma->mode & MA_RADIO) - do_autosmooth= 1; } } @@ -3799,7 +3794,7 @@ static void set_phong_threshold(ObjectRen *obr) static void set_fullsample_flag(Render *re, ObjectRen *obr) { VlakRen *vlr; - int a, trace; + int a, trace, mode; if(re->osa==0) return; @@ -3808,12 +3803,13 @@ static void set_fullsample_flag(Render *re, ObjectRen *obr) for(a=obr->totvlak-1; a>=0; a--) { vlr= RE_findOrAddVlak(obr, a); + mode= vlr->mat->mode; - if(vlr->mat->mode & MA_FULL_OSA) + if(mode & MA_FULL_OSA) vlr->flag |= R_FULL_OSA; else if(trace) { - if(vlr->mat->mode & MA_SHLESS); - else if(vlr->mat->mode & (MA_RAYTRANSP|MA_RAYMIRROR)) + if(mode & MA_SHLESS); + else if((mode & MA_RAYMIRROR) || ((mode & MA_TRANSP) && (mode & MA_RAYTRANSP))) /* for blurry reflect/refract, better to take more samples * inside the raytrace than as OSA samples */ if ((vlr->mat->gloss_mir == 1.0) && (vlr->mat->gloss_tra == 1.0)) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 14df6b8ec9f..a6b089c6029 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -868,33 +868,26 @@ static void renderresult_add_names(RenderResult *rr) strcpy(rpass->name, get_pass_name(rpass->passtype, -1)); } - -/* only for temp buffer files, makes exact copy of render result */ -static void read_render_result(Render *re, int sample) +/* called for reading temp files, and for external engines */ +static int read_render_result_from_file(char *filename, RenderResult *rr) { RenderLayer *rl; RenderPass *rpass; void *exrhandle= IMB_exr_get_handle(); int rectx, recty; - char str[FILE_MAX]; - - RE_FreeRenderResult(re->result); - re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM); - render_unique_exr_name(re, str, sample); - if(IMB_exr_begin_read(exrhandle, str, &rectx, &recty)==0) { + if(IMB_exr_begin_read(exrhandle, filename, &rectx, &recty)==0) { IMB_exr_close(exrhandle); - printf("cannot read: %s\n", str); - return; + return 0; } - printf("read exr tmp file: %s\n", str); - - if(re->result == NULL || rectx!=re->result->rectx || recty!=re->result->recty) { + if(rr == NULL || rectx!=rr->rectx || recty!=rr->recty) { printf("error in reading render result\n"); + IMB_exr_close(exrhandle); + return 0; } else { - for(rl= re->result->layers.first; rl; rl= rl->next) { + for(rl= rr->layers.first; rl; rl= rl->next) { /* combined */ if(rl->rectf) { @@ -914,10 +907,27 @@ static void read_render_result(Render *re, int sample) } IMB_exr_read_channels(exrhandle); - renderresult_add_names(re->result); + renderresult_add_names(rr); } IMB_exr_close(exrhandle); + + return 1; +} + +/* only for temp buffer files, makes exact copy of render result */ +static void read_render_result(Render *re, int sample) +{ + char str[FILE_MAX]; + + RE_FreeRenderResult(re->result); + re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM); + + render_unique_exr_name(re, str, sample); + printf("read exr tmp file: %s\n", str); + + if(!read_render_result_from_file(str, re->result)) + printf("cannot read: %s\n", str); } /* *************************************************** */ @@ -2560,8 +2570,15 @@ static int render_initialize_from_scene(Render *re, Scene *scene, int anim, int /* check all scenes involved */ tag_scenes_for_render(re); - /* make sure dynamics are up to date */ - update_physics_cache(re, scene, anim_init); + /* + * Disabled completely for now, + * can be later set as render profile option + * and default for background render. + */ + if(0) { + /* make sure dynamics are up to date */ + update_physics_cache(re, scene, anim_init); + } if(scene->r.scemode & R_SINGLE_LAYER) push_render_result(re); @@ -2692,7 +2709,7 @@ void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra, int tfra) re->result_ok= 0; if(BKE_imtype_is_movie(scene->r.imtype)) - mh->start_movie(&re->r, re->rectx, re->recty); + mh->start_movie(scene, &re->r, re->rectx, re->recty); if (mh->get_next_frame) { while (!(G.afbreek == 1)) { @@ -2937,7 +2954,7 @@ void RE_engine_update_stats(RenderEngine *engine, char *stats, char *info) /* loads in image into a result, size must match * x/y offsets are only used on a partial copy when dimensions dont match */ -void RE_layer_rect_from_file(RenderLayer *layer, ReportList *reports, char *filename, int x, int y) +void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, char *filename) { ImBuf *ibuf = IMB_loadiffname(filename, IB_rect); @@ -2948,7 +2965,7 @@ void RE_layer_rect_from_file(RenderLayer *layer, ReportList *reports, char *file memcpy(layer->rectf, ibuf->rect_float, sizeof(float)*4*layer->rectx*layer->recty); } else { - if ((ibuf->x - x >= layer->rectx) && (ibuf->y - y >= layer->recty)) { + if ((ibuf->x >= layer->rectx) && (ibuf->y >= layer->recty)) { ImBuf *ibuf_clip; if(ibuf->rect_float==NULL) @@ -2956,7 +2973,7 @@ void RE_layer_rect_from_file(RenderLayer *layer, ReportList *reports, char *file ibuf_clip = IMB_allocImBuf(layer->rectx, layer->recty, 32, IB_rectfloat, 0); if(ibuf_clip) { - IMB_rectcpy(ibuf_clip, ibuf, 0,0, x,y, layer->rectx, layer->recty); + IMB_rectcpy(ibuf_clip, ibuf, 0,0, 0,0, layer->rectx, layer->recty); memcpy(layer->rectf, ibuf_clip->rect_float, sizeof(float)*4*layer->rectx*layer->recty); IMB_freeImBuf(ibuf_clip); @@ -2976,6 +2993,15 @@ void RE_layer_rect_from_file(RenderLayer *layer, ReportList *reports, char *file BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'\n", filename); } } + +void RE_result_load_from_file(RenderResult *result, ReportList *reports, char *filename) +{ + if(!read_render_result_from_file(filename, result)) { + BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'\n", filename); + return; + } +} + static void external_render_3d(Render *re, RenderEngineType *type) { RenderEngine engine; diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 010930fcb85..0c8749ce329 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -361,7 +361,7 @@ static float shade_by_transmission(Isect *is, ShadeInput *shi, ShadeResult *shr) { float dx, dy, dz, d, p; - if (0 == (shi->mat->mode & (MA_RAYTRANSP|MA_ZTRA))) + if (0 == (shi->mat->mode & MA_TRANSP)) return -1; if (shi->mat->tx_limit <= 0.0f) { @@ -468,7 +468,7 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo if(depth>0) { - if(shi.mat->mode_l & (MA_RAYTRANSP|MA_ZTRA) && shr.alpha < 1.0f) { + if((shi.mat->mode_l & MA_TRANSP) && shr.alpha < 1.0f) { float nf, f, f1, refract[3], tracol[4]; tracol[0]= shi.r; @@ -476,7 +476,7 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo tracol[2]= shi.b; tracol[3]= col[3]; // we pass on and accumulate alpha - if(shi.mat->mode & MA_RAYTRANSP) { + if((shi.mat->mode & MA_TRANSP) && (shi.mat->mode & MA_RAYTRANSP)) { /* odd depths: use normal facing viewer, otherwise flip */ if(traflag & RAY_TRAFLIP) { float norm[3]; @@ -1183,7 +1183,7 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr) float diff[3]; int do_tra, do_mir; - do_tra= ((shi->mat->mode & (MA_RAYTRANSP)) && shr->alpha!=1.0f); + do_tra= ((shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_RAYTRANSP) && shr->alpha!=1.0f); do_mir= ((shi->mat->mode & MA_RAYMIRROR) && shi->ray_mirror!=0.0f); diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 3a3d6f57830..b774bf6374d 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -477,7 +477,7 @@ static void add_filt_passes(RenderLayer *rl, int curmask, int rectx, int offset, col= shr->refr; break; case SCE_PASS_RADIO: - col= shr->rad; + col= NULL; // removed shr->rad; break; case SCE_PASS_NORMAL: col= shr->nor; @@ -569,7 +569,7 @@ static void add_passes(RenderLayer *rl, int offset, ShadeInput *shi, ShadeResult col= shr->refr; break; case SCE_PASS_RADIO: - col= shr->rad; + col= NULL; // removed shr->rad; break; case SCE_PASS_NORMAL: col= shr->nor; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index c860e9ac5d1..857b401e298 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -156,13 +156,13 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr) /* depth >= 1 when ray-shading */ if(shi->depth==0) { if(R.r.mode & R_RAYTRACE) { - if(shi->ray_mirror!=0.0f || ((shi->mat->mode & MA_RAYTRANSP) && shr->alpha!=1.0f)) { + if(shi->ray_mirror!=0.0f || ((shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_RAYTRANSP) && shr->alpha!=1.0f)) { /* ray trace works on combined, but gives pass info */ ray_trace(shi, shr); } } /* disable adding of sky for raytransp */ - if(shi->mat->mode & MA_RAYTRANSP) + if((shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_RAYTRANSP)) if((shi->layflag & SCE_LAY_SKY) && (R.r.alphamode==R_ADDSKY)) shr->alpha= 1.0f; } @@ -190,7 +190,6 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) if(shi->passflag & (SCE_PASS_VECTOR|SCE_PASS_NORMAL|SCE_PASS_RADIO)) { QUATCOPY(shr->winspeed, shi->winspeed); VECCOPY(shr->nor, shi->vn); - VECCOPY(shr->rad, shi->rad); } /* MIST */ @@ -558,10 +557,6 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert shi->orn[2]= -shi->vn[2]; } - if(mode & MA_RADIO) { - /* not supported */ - } - if(texco & TEXCO_REFL) { /* mirror reflection color textures (and envmap) */ calc_R_ref(shi); /* wrong location for normal maps! XXXXXXXXXXXXXX */ @@ -580,8 +575,6 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } } - shi->rad[0]= shi->rad[1]= shi->rad[2]= 0.0f; - /* this only avalailable for scanline renders */ if(shi->depth==0) { if(texco & TEXCO_WINDOW) { @@ -1154,24 +1147,6 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->orn[2]= -shi->vn[2]; } - if(mode & MA_RADIO) { - float *r1, *r2, *r3; - - r1= RE_vertren_get_rad(obr, v1, 0); - r2= RE_vertren_get_rad(obr, v2, 0); - r3= RE_vertren_get_rad(obr, v3, 0); - - if(r1 && r2 && r3) { - shi->rad[0]= (l*r3[0] - u*r1[0] - v*r2[0]); - shi->rad[1]= (l*r3[1] - u*r1[1] - v*r2[1]); - shi->rad[2]= (l*r3[2] - u*r1[2] - v*r2[2]); - } - else - shi->rad[0]= shi->rad[1]= shi->rad[2]= 0.0f; - } - else - shi->rad[0]= shi->rad[1]= shi->rad[2]= 0.0f; - if(texco & TEXCO_REFL) { /* mirror reflection color textures (and envmap) */ calc_R_ref(shi); /* wrong location for normal maps! XXXXXXXXXXXXXX */ @@ -1199,8 +1174,6 @@ void shade_input_set_shade_texco(ShadeInput *shi) } } } - else - shi->rad[0]= shi->rad[1]= shi->rad[2]= 0.0f; /* this only avalailable for scanline renders */ if(shi->depth==0) { diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 2fbd93df0ce..d5c8cf30b30 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -1713,7 +1713,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) shi->alpha*= fresnel_fac(shi->view, shi->vn, ma->fresnel_tra_i, ma->fresnel_tra); /* note: shi->mode! */ - if(shi->mode & (MA_ZTRA|MA_RAYTRANSP)) { + if(shi->mode & MA_TRANSP) { if(shi->spectra!=0.0f) { float t = MAX3(shr->spec[0], shr->spec[1], shr->spec[2]); t *= shi->spectra; @@ -1730,11 +1730,12 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) shr->combined[1]+= shi->ambg; shr->combined[2]+= shi->ambb; + /* removed if(shi->combinedflag & SCE_PASS_RADIO) { shr->combined[0]+= shi->r*shi->amb*shi->rad[0]; shr->combined[1]+= shi->g*shi->amb*shi->rad[1]; shr->combined[2]+= shi->b*shi->amb*shi->rad[2]; - } + }*/ /* add AO in combined? */ if(R.wrld.mode & WO_AMB_OCC) { diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index a47fef840ca..6e2a0e966dc 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -234,8 +234,8 @@ void interpolate_shade_result(ShadeResult *shr1, ShadeResult *shr2, float t, Sha interpolate_vec3(shr1->refl, shr2->refl, t, negt, shr->refl); if(addpassflag & SCE_PASS_REFRACT) interpolate_vec3(shr1->refr, shr2->refr, t, negt, shr->refr); - if(addpassflag & SCE_PASS_RADIO) - interpolate_vec3(shr1->rad, shr2->rad, t, negt, shr->rad); + /* removed if(addpassflag & SCE_PASS_RADIO) + interpolate_vec3(shr1->rad, shr2->rad, t, negt, shr->rad);*/ if(addpassflag & SCE_PASS_MIST) interpolate_vec1(&shr1->mist, &shr2->mist, t, negt, &shr->mist); } diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index bb491efdaba..3db78bfea93 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -714,12 +714,12 @@ static float voronoiTex(Tex *tex, float *texvec, TexResult *texres) /* ------------------------------------------------------------------------- */ -static int evalnodes(Tex *tex, float *texvec, TexResult *texres, short thread, short which_output) +static int evalnodes(Tex *tex, float *texvec, float *dxt, float *dyt, TexResult *texres, short thread, short which_output) { short rv = TEX_INT; bNodeTree *nodes = tex->nodetree; - ntreeTexExecTree(nodes, texres, texvec, 0, thread, tex, which_output, R.r.cfra); + ntreeTexExecTree(nodes, texres, texvec, dxt, dyt, 0, thread, tex, which_output, R.r.cfra); if(texres->nor) rv |= TEX_NOR; rv |= TEX_RGB; @@ -1180,7 +1180,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, texres->talpha= 0; /* is set when image texture returns alpha (considered premul) */ if(tex->use_nodes && tex->nodetree) { - retval = evalnodes(tex, texvec, texres, thread, which_output); + retval = evalnodes(tex, texvec, dxt, dyt, texres, thread, which_output); } else switch(tex->type) { diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 4436f3aa047..53a05dd0d67 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -2152,7 +2152,7 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, if(obi->lay & lay) { if(vlr->mat!=ma) { ma= vlr->mat; - nofill= ma->mode & (MA_ZTRA|MA_ONLYCAST); + nofill= (ma->mode & MA_ONLYCAST) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)); env= (ma->mode & MA_ENV); wire= (ma->material_type == MA_TYPE_WIRE); @@ -3306,7 +3306,7 @@ static int zbuffer_abuf(RenderPart *pa, APixstr *APixbuf, ListBase *apsmbase, Re if(vlr->mat!=ma) { ma= vlr->mat; - dofill= (ma->mode & MA_ZTRA) && !(ma->mode & MA_ONLYCAST); + dofill= ((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) && !(ma->mode & MA_ONLYCAST); } if(dofill) { @@ -3480,7 +3480,7 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr) col= shr->refl; break; case SCE_PASS_RADIO: - col= shr->rad; + col= NULL; // removed shr->rad; break; case SCE_PASS_REFRACT: col= shr->refr; @@ -3582,7 +3582,7 @@ void add_transp_passes(RenderLayer *rl, int offset, ShadeResult *shr, float alph col= shr->refr; break; case SCE_PASS_RADIO: - col= shr->rad; + col= NULL; // removed shr->rad; break; case SCE_PASS_NORMAL: col= shr->nor; @@ -3817,8 +3817,8 @@ static int addtosamp_shr(ShadeResult *samp_shr, ShadeSample *ssamp, int addpassf if(addpassflag & SCE_PASS_REFRACT) addvecmul(samp_shr->refr, shr->refr, fac); - if(addpassflag & SCE_PASS_RADIO) - addvecmul(samp_shr->rad, shr->rad, fac); + /* removed if(addpassflag & SCE_PASS_RADIO) + addvecmul(samp_shr->rad, shr->rad, fac);*/ if(addpassflag & SCE_PASS_MIST) samp_shr->mist= samp_shr->mist+fac*shr->mist; diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 088bdc99687..a268ffebffb 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -33,13 +33,13 @@ SET(INC . ../include ../imbuf ../render/extern/include ../../../intern/bsp/extern ../radiosity/extern/include ../../../intern/decimation/extern ../blenloader - ../../kernel/gen_system ../../../intern/SoundSystem ../readstreamglue + ../../kernel/gen_system ../readstreamglue ../quicktime ../../../intern/elbeem/extern ../../../intern/ghost ../../../intern/opennl/extern ../../../extern/glew/include ../nodes ../gpu ../blenfont - ${SDL_INC} + ${OPENGL_INCLUDE_DIR} ) IF(WITH_INTERNATIONAL) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index decd855eae0..0f5558382c4 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -172,7 +172,7 @@ void WM_operator_properties_free(struct PointerRNA *ptr); void WM_operator_properties_filesel(struct wmOperatorType *ot, int filter); /* operator as a python command (resultuing string must be free'd) */ -char *WM_operator_pystring(struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args); +char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args); void WM_operator_bl_idname(char *to, const char *from); void WM_operator_py_idname(char *to, const char *from); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index a083d589d31..00e9f6a2fa2 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -133,6 +133,7 @@ typedef struct wmNotifier { #define NC_FILE (14<<24) #define NC_ANIMATION (15<<24) #define NC_CONSOLE (16<<24) +#define NC_NODE (17<<24) /* data type, 256 entries is enough, it can overlap */ #define NOTE_DATA 0x00FF0000 @@ -144,8 +145,9 @@ typedef struct wmNotifier { /* NC_SCREEN screen */ #define ND_SCREENBROWSE (1<<16) -#define ND_SCREENCAST (2<<16) -#define ND_ANIMPLAY (3<<16) +#define ND_SCREENDELETE (2<<16) +#define ND_SCREENCAST (3<<16) +#define ND_ANIMPLAY (4<<16) /* NC_SCENE Scene */ #define ND_SCENEBROWSE (1<<16) @@ -160,6 +162,7 @@ typedef struct wmNotifier { #define ND_RENDER_RESULT (10<<16) #define ND_COMPO_RESULT (11<<16) #define ND_KEYINGSET (12<<16) +#define ND_SCENEDELETE (13<<16) /* NC_OBJECT Object */ #define ND_TRANSFORM (16<<16) diff --git a/source/blender/windowmanager/intern/Makefile b/source/blender/windowmanager/intern/Makefile index 8f0f47c52d0..823423cc28b 100644 --- a/source/blender/windowmanager/intern/Makefile +++ b/source/blender/windowmanager/intern/Makefile @@ -44,7 +44,7 @@ CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) CPPFLAGS += -I$(NAN_GHOST)/include CPPFLAGS += -I$(NAN_ELBEEM)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include $(NAN_SDLCFLAGS) +CPPFLAGS += $(NAN_SDLCFLAGS) # modules CPPFLAGS += -I../../editors/include diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 406541d62ba..85f8a647826 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -103,7 +103,7 @@ void wm_operator_register(bContext *C, wmOperator *op) /* Report the string representation of the operator */ - buf = WM_operator_pystring(op->type, op->ptr, 1); + buf = WM_operator_pystring(C, op->type, op->ptr, 1); BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf); MEM_freeN(buf); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index d40e6c60bfd..f0d9f8c0989 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -156,12 +156,20 @@ void wm_event_do_notifiers(bContext *C) ED_screen_set(C, note->reference); // XXX hrms, think this over! printf("screen set %p\n", note->reference); } + else if(note->data==ND_SCREENDELETE) { + ED_screen_delete(C, note->reference); // XXX hrms, think this over! + printf("screen delete %p\n", note->reference); + } } else if(note->category==NC_SCENE) { if(note->data==ND_SCENEBROWSE) { ED_screen_set_scene(C, note->reference); // XXX hrms, think this over! printf("scene set %p\n", note->reference); } + if(note->data==ND_SCENEDELETE) { + ED_screen_delete_scene(C, note->reference); // XXX hrms, think this over! + printf("scene delete %p\n", note->reference); + } else if(note->data==ND_FRAME) do_anim= 1; } @@ -362,7 +370,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P static void wm_operator_print(wmOperator *op) { - char *buf = WM_operator_pystring(op->type, op->ptr, 1); + char *buf = WM_operator_pystring(NULL, op->type, op->ptr, 1); printf("%s\n", buf); MEM_freeN(buf); } @@ -664,7 +672,19 @@ static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi) int kmitype= wm_userdef_event_map(kmi->type); if(kmi->inactive) return 0; - + + /* exception for middlemouse emulation */ + if((U.flag & USER_TWOBUTTONMOUSE) && (kmi->type == MIDDLEMOUSE)) { + if(winevent->type == LEFTMOUSE && winevent->alt) { + wmKeymapItem tmp= *kmi; + + tmp.type= winevent->type; + tmp.alt= winevent->alt; + if(wm_eventmatch(winevent, &tmp)) + return 1; + } + } + /* the matching rules */ if(kmitype==KM_TEXTINPUT) if(ISKEYBOARD(winevent->type)) return 1; @@ -683,8 +703,15 @@ static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi) if(winevent->alt != kmi->alt && !(winevent->alt & kmi->alt)) return 0; if(kmi->oskey!=KM_ANY) if(winevent->oskey != kmi->oskey && !(winevent->oskey & kmi->oskey)) return 0; + if(kmi->keymodifier) if(winevent->keymodifier!=kmi->keymodifier) return 0; + + /* key modifiers always check when event has it */ + /* otherwise regular keypresses with keymodifier still work */ + if(winevent->keymodifier) + if(ISKEYBOARD(winevent->type)) + if(winevent->keymodifier!=kmi->keymodifier) return 0; return 1; } @@ -1501,11 +1528,6 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata) else event.type= MIDDLEMOUSE; - if(event.val) - event.keymodifier= evt->keymodifier= event.type; - else - event.keymodifier= evt->keymodifier= 0; - update_tablet_data(win, &event); wm_event_add(win, &event); @@ -1544,6 +1566,12 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata) if(event.val==KM_PRESS && (evt->ctrl || evt->alt || evt->shift)) event.oskey= evt->oskey = 3; // define? } + else { + if(event.val==KM_PRESS && event.keymodifier==0) + evt->keymodifier= event.type; /* only set in eventstate, for next event */ + else if(event.val==KM_RELEASE && event.keymodifier==event.type) + event.keymodifier= evt->keymodifier= 0; + } /* if test_break set, it catches this. XXX Keep global for now? */ if(event.type==ESCKEY) diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ffaa315f04e..9c30c99bbdd 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -68,6 +68,7 @@ #include "BKE_main.h" #include "BKE_packedFile.h" #include "BKE_report.h" +#include "BKE_sound.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -224,7 +225,7 @@ static void wm_init_userdef() { UI_init_userdef(); MEM_CacheLimiter_set_maximum(U.memcachelimit * 1024 * 1024); - + sound_init(); } void WM_read_file(bContext *C, char *name, ReportList *reports) @@ -252,7 +253,6 @@ void WM_read_file(bContext *C, char *name, ReportList *reports) wm_check(C); /* opens window(s), checks keymaps */ // XXX mainwindow_set_filename_to_title(G.main->name); -// XXX sound_initialize_sounds(); if(retval==2) wm_init_userdef(); // in case a userdef is read from regular .blend diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 599844f1020..ee826d5f57e 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -38,7 +38,6 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_sound_types.h" #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" @@ -90,17 +89,7 @@ #include "GPU_extensions.h" #include "GPU_draw.h" - - -/* XXX */ -static void sound_init_listener(void) -{ - G.listener = MEM_callocN(sizeof(bSoundListener), "soundlistener"); - G.listener->gain = 1.0; - G.listener->dopplerfactor = 1.0; - G.listener->dopplervelocity = 340.29f; -} - +#include "BKE_sound.h" static void wm_init_reports(bContext *C) { @@ -145,7 +134,6 @@ void WM_init(bContext *C) // glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - sound_init_listener(); // init_node_butfuncs(); ED_preview_init_dbase(); @@ -184,7 +172,9 @@ extern void free_posebuf(); void WM_exit(bContext *C) { wmWindow *win; - + + sound_exit(); + /* first wrap up running stuff, we assume only the active WM is running */ /* modal handlers are on window level freed, others too? */ /* note; same code copied in wm_files.c */ @@ -216,16 +206,6 @@ void WM_exit(bContext *C) BKE_freecubetable(); -// if (G.background == 0) -// sound_end_all_sounds(); - - - /* before free_blender so py's gc happens while library still exists */ - /* needed at least for a rare sigsegv that can happen in pydrivers */ -#ifndef DISABLE_PYTHON - BPY_end_python(); -#endif - fastshade_free_render(); /* shaded view */ ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */ wm_free_reports(C); /* before free_blender! - since the ListBases get freed there */ @@ -245,10 +225,18 @@ void WM_exit(bContext *C) // free_txt_data(); -// sound_exit_audio(); - if(G.listener) MEM_freeN(G.listener); - - + +#ifndef DISABLE_PYTHON + /* XXX - old note */ + /* before free_blender so py's gc happens while library still exists */ + /* needed at least for a rare sigsegv that can happen in pydrivers */ + + /* Update for blender 2.5, move after free_blender because blender now holds references to PyObject's + * so decref'ing them after python ends causes bad problems every time + * the pyDriver bug can be fixed if it happens again we can deal with it then */ + BPY_end_python(); +#endif + libtiff_exit(); #ifdef WITH_QUICKTIME @@ -272,8 +260,10 @@ void WM_exit(bContext *C) UI_exit(); BKE_userdef_free(); - RNA_exit(); + RNA_exit(); /* should be after BPY_end_python so struct python slots are cleared */ + wm_ghost_exit(); + CTX_free(C); if(MEM_get_memory_blocks_in_use()!=0) { diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 41613d0ab78..2e813bac37d 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -322,7 +322,7 @@ void WM_operator_py_idname(char *to, const char *from) /* some.op -> SOME_OT_op */ void WM_operator_bl_idname(char *to, const char *from) { - char *sep= strstr(from, "."); + char *sep= strchr(from, '.'); if(sep) { int i, ofs= (sep-from); @@ -345,7 +345,7 @@ void WM_operator_bl_idname(char *to, const char *from) * When calling from an existing wmOperator do. * WM_operator_pystring(op->type, op->ptr); */ -char *WM_operator_pystring(wmOperatorType *ot, PointerRNA *opptr, int all_args) +char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, int all_args) { const char *arg_name= NULL; char idname_py[OP_MAX_TYPENAME]; @@ -378,7 +378,7 @@ char *WM_operator_pystring(wmOperatorType *ot, PointerRNA *opptr, int all_args) if (strcmp(arg_name, "rna_type")==0) continue; - buf= RNA_property_as_string(opptr, prop); + buf= RNA_property_as_string(C, opptr, prop); ok= 1; @@ -388,7 +388,7 @@ char *WM_operator_pystring(wmOperatorType *ot, PointerRNA *opptr, int all_args) prop_default= RNA_struct_find_property(&opptr_default, arg_name); if(prop_default) { - buf_default= RNA_property_as_string(&opptr_default, prop_default); + buf_default= RNA_property_as_string(C, &opptr_default, prop_default); if(strcmp(buf, buf_default)==0) ok= 0; /* values match, dont bother printing */ @@ -543,7 +543,12 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 300, 20, style); - uiDefAutoButsRNA(C, layout, &ptr, 2); + uiItemL(layout, op->type->name, 0); + + if(op->type->ui) + op->type->ui((bContext*)C, &ptr, layout); + else + uiDefAutoButsRNA(C, layout, &ptr, 2); uiPopupBoundsBlock(block, 4.0f, 0, 0); uiEndBlock(C, block); @@ -585,7 +590,12 @@ static uiBlock *wm_block_create_menu(bContext *C, ARegion *ar, void *arg_op) uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1); layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 300, 20, style); - uiDefAutoButsRNA(C, layout, op->ptr, 2); + uiItemL(layout, op->type->name, 0); + + if(op->type->ui) + op->type->ui(C, op->ptr, layout); + else + uiDefAutoButsRNA(C, layout, op->ptr, 2); uiPopupBoundsBlock(block, 4.0f, 0, 0); uiEndBlock(C, block); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 31e6de2527b..d6bde9a468c 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -207,7 +207,10 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig) win->sizey= winorig->sizey; /* duplicate assigns to window */ - ED_screen_duplicate(win, winorig->screen); + win->screen= ED_screen_duplicate(win, winorig->screen); + BLI_strncpy(win->screenname, win->screen->id.name+2, 21); + win->screen->winid= win->winid; + win->screen->do_refresh= 1; win->screen->do_draw= 1; @@ -443,14 +446,14 @@ void WM_window_open_temp(bContext *C, rcti *position, int type) ED_area_newspace(C, sa, SPACE_IMAGE); } else { - ED_area_newspace(C, sa, SPACE_INFO); + ED_area_newspace(C, sa, SPACE_USERPREF); } ED_screen_set(C, win->screen); if(sa->spacetype==SPACE_IMAGE) GHOST_SetTitle(win->ghostwin, "Blender Render"); - else if(ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_INFO)) + else if(ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF)) GHOST_SetTitle(win->ghostwin, "Blender User Preferences"); else if(sa->spacetype==SPACE_FILE) GHOST_SetTitle(win->ghostwin, "Blender File View"); @@ -585,6 +588,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) kdata.key= GHOST_kKeyCommand; wm_event_add_ghostevent(win, GHOST_kEventKeyUp, &kdata); } + /* keymodifier zero, it hangs on hotkeys that open windows otherwise */ + win->eventstate->keymodifier= 0; /* entering window, update mouse pos. but no event */ GHOST_GetCursorPosition(g_system, &wx, &wy); @@ -756,6 +761,14 @@ void wm_ghost_init(bContext *C) } } +void wm_ghost_exit(void) +{ + if(g_system) + GHOST_DisposeSystem(g_system); + + g_system= NULL; +} + /* **************** timer ********************** */ /* to (de)activate running timers temporary */ diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index c2a2b00b796..f159f7f098d 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -33,6 +33,7 @@ struct bScreen; /* *************** internal api ************** */ void wm_ghost_init (bContext *C); +void wm_ghost_exit(void); wmWindow *wm_window_new (bContext *C); void wm_window_free (bContext *C, wmWindow *win); diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 064681b37ea..a9368e021cd 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -84,123 +84,185 @@ ENDIF(WIN32) SET(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}) +IF(WITH_INSTALL) -IF(UNIX) - ADD_CUSTOM_COMMAND(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/ - #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/ - ) -ENDIF(UNIX) - -IF(UNIX AND NOT APPLE) - ADD_CUSTOM_COMMAND(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - COMMAND rm -Rf ${TARGETDIR}/.blender - COMMAND mkdir ${TARGETDIR}/.blender/ - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/ - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/ - COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/ - COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/.blender/ - COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/.blender/ - COMMAND find ${TARGETDIR} -name CVS -prune -exec rm -rf {} "\;" - ) -ENDIF(UNIX AND NOT APPLE) - -IF(APPLE) - SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app) - SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist) - SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist) - - ADD_CUSTOM_COMMAND(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - COMMAND cp -R ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/ - COMMAND cp -R ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/ - COMMAND cp -R ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/ - COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO} - COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/.blender - COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/Resources/ - COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/Resources/ - COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/io ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/ - COMMAND unzip -q ${LIBDIR}/release/python.zip -d ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/ - COMMAND find ${TARGETDIR}/blender.app -name CVS -prune -exec rm -rf {} "\;" - COMMAND find ${TARGETDIR}/blender.app -name CVS.sandboxinfo -prune -exec rm -rf {} "\;" - COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;" - COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;" - ) -ENDIF(APPLE) - -IF(WIN32) - FILE(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} WIN_SOURCE_DIR) - - ADD_CUSTOM_COMMAND(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - COMMAND if not exist \"${TARGETDIR}\\.blender\" mkdir \"${TARGETDIR}\\.blender\" - COMMAND if not exist \"${TARGETDIR}\\.blender\\locale\" mkdir \"${TARGETDIR}\\.blender\\locale\" - COMMAND if not exist \"${TARGETDIR}\\.blender\\scripts\" mkdir \"${TARGETDIR}\\.blender\\scripts\" - COMMAND if not exist \"${TARGETDIR}\\.blender\\ui\" mkdir \"${TARGETDIR}\\.blender\\ui\" - COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\" - COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\.blender\\\" - COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\.blender\\\" - COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\.blender\\locale\" - COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\.blender\\scripts\" - COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\ui\\*.*\" \"${TARGETDIR}\\.blender\\ui\" - COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\plugins\" - COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\" - COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\windows\\extra\\python26.zip\" \"${TARGETDIR}\\\" - ) - - FILE(TO_NATIVE_PATH "${LIBDIR}" WIN_LIBDIR) - - ADD_CUSTOM_COMMAND(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - COMMAND copy /Y \"${WIN_LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\tiff\\lib\\libtiff.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python26.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python26_d.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\" - ) - - IF(WITH_INTERNATIONAL) + IF(UNIX) ADD_CUSTOM_COMMAND(TARGET blender POST_BUILD MAIN_DEPENDENCY blender - COMMAND copy /Y \"${WIN_LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\" + #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/ + #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/ ) - ENDIF(WITH_INTERNATIONAL) + ENDIF(UNIX) - IF(WITH_FFMPEG) + IF(UNIX AND NOT APPLE) + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMAND rm -Rf ${TARGETDIR}/.blender + COMMAND mkdir ${TARGETDIR}/.blender/ + COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/ + ) + + IF(WITH_INTERNATIONAL) + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/ + COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/ + ) + ENDIF(WITH_INTERNATIONAL) + + IF(WITH_PYTHON) + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMENT "copying blender scripts..." + COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/.blender/ + COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/io ${TARGETDIR}/.blender/ + COMMAND find ${TARGETDIR} -name "*.py?" -prune -exec rm -rf {} "\;" + ) + + # Copy the systems python into the install directory + # Scons copy in tools/Blender.py + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMENT "copying a subset of the systems python..." + + COMMAND mkdir ${TARGETDIR}/.blender/python # PYTHONPATH and PYTHONHOME is set here + COMMAND mkdir ${TARGETDIR}/.blender/python/lib/ + COMMAND cp -R ${PYTHON_LIBPATH}/python${PYTHON_VERSION} ${TARGETDIR}/.blender/python/lib/ + + COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/distutils + COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/lib2to3 + COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/idlelib + COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/tkinter + COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/config + + COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/site-packages + COMMAND mkdir ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/site-packages # python needs it. + + COMMAND rm ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/lib-dynload/_tkinter.so + COMMAND find ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION} -name "test" -prune -exec rm -rf {} "\;" + COMMAND find ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION} -name "*.py?" -exec rm -rf {} "\;" + COMMAND find ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION} -name "*.so"-exec strip -s {} "\;" + ) + + ENDIF(WITH_PYTHON) + + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMAND find ${TARGETDIR} -name .svn -prune -exec rm -rf {} "\;" + ) + + ENDIF(UNIX AND NOT APPLE) + + IF(APPLE) + SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app) + SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist) + SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist) + + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMAND cp -R ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/ + COMMAND cp -R ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/ + COMMAND cp -R ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/ + COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO} + COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/.blender + COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ + COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ + ) + + IF(WITH_INTERNATIONAL) + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ + COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/Resources/ + COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ + COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/Resources/ + ) + ENDIF(WITH_INTERNATIONAL) + + IF(WITH_PYTHON) + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ + COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/io ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ + COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/ + COMMAND unzip -q ${LIBDIR}/release/python.zip -d ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/ + COMMAND find ${TARGETDIR}/blender.app -name "*.py?" -prune -exec rm -rf {} "\;" + ) + ENDIF(WITH_PYTHON) + + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;" + COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;" + ) + ENDIF(APPLE) + + IF(WIN32) + FILE(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} WIN_SOURCE_DIR) + ADD_CUSTOM_COMMAND(TARGET blender POST_BUILD MAIN_DEPENDENCY blender - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac-0.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad-2.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-67.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"${TARGETDIR}\\\" + COMMAND if not exist \"${TARGETDIR}\\.blender\" mkdir \"${TARGETDIR}\\.blender\" + COMMAND if not exist \"${TARGETDIR}\\.blender\\locale\" mkdir \"${TARGETDIR}\\.blender\\locale\" + COMMAND if not exist \"${TARGETDIR}\\.blender\\ui\" mkdir \"${TARGETDIR}\\.blender\\ui\" + COMMAND if not exist \"${TARGETDIR}\\.blender\\io\" mkdir \"${TARGETDIR}\\.blender\\io\" + COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\" + COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\.blender\\\" + COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\.blender\\\" + COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\.blender\\locale\" + COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\.blender\\scripts\" + COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\ui\\*.*\" \"${TARGETDIR}\\.blender\\ui\" + COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\io\\*.*\" \"${TARGETDIR}\\.blender\\io\" + COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\plugins\" + COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\" + COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\windows\\extra\\python26.zip\" \"${TARGETDIR}\\\" ) - ENDIF(WITH_FFMPEG) -ENDIF(WIN32) + + FILE(TO_NATIVE_PATH "${LIBDIR}" WIN_LIBDIR) + + ADD_CUSTOM_COMMAND(TARGET blender + POST_BUILD + MAIN_DEPENDENCY blender + COMMAND copy /Y \"${WIN_LIBDIR}\\release\\python31.zip\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\tiff\\lib\\libtiff.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\samplerate\\lib\\libsamplerate-0.dll\" \"${TARGETDIR}\\\" + ) + + IF(WITH_INTERNATIONAL) + ADD_CUSTOM_COMMAND(TARGET blender + POST_BUILD + MAIN_DEPENDENCY blender + COMMAND copy /Y \"${WIN_LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\" + ) + ENDIF(WITH_INTERNATIONAL) + + IF(WITH_FFMPEG) + ADD_CUSTOM_COMMAND(TARGET blender + POST_BUILD + MAIN_DEPENDENCY blender + COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac-0.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad-2.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-67.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"${TARGETDIR}\\\" + ) + ENDIF(WITH_FFMPEG) + ENDIF(WIN32) +ENDIF(WITH_INSTALL) ADD_DEPENDENCIES(blender makesdna) @@ -220,7 +282,7 @@ IF(UNIX) # Sort libraries SET(BLENDER_SORTED_LIBS bf_windowmanager - bf_editors + bf_editors bf_decimation blender_BSP bf_ghost @@ -231,7 +293,7 @@ IF(UNIX) bf_gen_python bf_blenkernel bf_nodes - bf_gpu + bf_gpu bf_blenloader bf_blenpluginapi bf_imbuf @@ -283,9 +345,13 @@ IF(UNIX) bf_rna bf_dna bf_blenfont - bf_soundsystem + bf_audaspace ) + IF(WITH_CXX_GUARDEDALLOC) + SET(BLENDER_SORTED_LIBS ${BLENDER_SORTED_LIBS} bf_guardedalloc_cpp) + ENDIF(WITH_CXX_GUARDEDALLOC) + FOREACH(SORTLIB ${BLENDER_SORTED_LIBS}) SET(REMLIB ${SORTLIB}) FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS}) diff --git a/source/creator/creator.c b/source/creator/creator.c index d4f0f6cbbbb..e196213c945 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -177,6 +177,8 @@ static void print_help(void) printf (" When the filename has no #, The suffix #### is added to the filename\n"); printf (" The frame number will be added at the end of the filename.\n"); printf (" eg: blender -b foobar.blend -o //render_ -F PNG -x 1 -a\n"); + printf (" -E \tSpecify the render engine.\n"); + printf (" use -E help to list available engines.\n"); printf ("\nFormat options:\n"); printf (" -F \tSet the render format, Valid options are...\n"); printf (" \tTGA IRIS HAMX JPEG MOVIE IRIZ RAWTGA\n"); @@ -201,13 +203,11 @@ static void print_help(void) printf ("\nGame Engine specific options:\n"); printf (" -g fixedtime\t\tRun on 50 hertz without dropping frames\n"); printf (" -g vertexarrays\tUse Vertex Arrays for rendering (usually faster)\n"); - printf (" -g noaudio\t\tNo audio in Game Engine\n"); printf (" -g nomipmap\t\tNo Texture Mipmapping\n"); printf (" -g linearmipmap\tLinear Texture Mipmapping instead of Nearest (default)\n"); printf ("\nMisc options:\n"); printf (" -d\t\tTurn debugging on\n"); - printf (" -noaudio\tDisable audio on systems that support audio\n"); printf (" -nojoystick\tDisable joystick support\n"); printf (" -noglsl\tDisable GLSL shading\n"); printf (" -h\t\tPrint this help text\n"); @@ -267,13 +267,6 @@ int main(int argc, char **argv) bContext *C= CTX_create(); int a, i, stax, stay, sizx, sizy /*XXX, scr_init = 0*/; -#if defined(WIN32) || defined (__linux__) - int audio = 1; -#else - int audio = 0; -#endif - - #ifdef WITH_BINRELOC br_init( NULL ); #endif @@ -468,16 +461,6 @@ int main(int argc, char **argv) break; case 'n': case 'N': - if (BLI_strcasecmp(argv[a], "-noaudio") == 0|| BLI_strcasecmp(argv[a], "-nosound") == 0) { - /** - notify the gameengine that no audio is wanted, even if the user didn't give - the flag -g noaudio. - */ - - SYS_WriteCommandLineInt(syshandle,"noaudio",1); - audio = 0; - if (G.f & G_DEBUG) printf("setting audio to: %d\n", audio); - } if (BLI_strcasecmp(argv[a], "-nojoystick") == 0) { /** don't initialize joysticks if user doesn't want to use joysticks @@ -496,11 +479,6 @@ int main(int argc, char **argv) #ifndef DISABLE_PYTHON BPY_start_python(argc, argv); #endif - /** - * NOTE: sound_init_audio() *must be* after start_python, - * at least on FreeBSD. - * added note (ton): i removed it altogether - */ WM_init(C); @@ -521,12 +499,6 @@ int main(int argc, char **argv) BPY_start_python(argc, argv); #endif BLI_where_is_temp( btempdir, 0 ); /* call after loading the .B.blend so we can read U.tempdir */ - - // (ton) Commented out. I have no idea whats thisfor... will mail around! - // SYS_WriteCommandLineInt(syshandle,"noaudio",1); - // audio = 0; - // sound_init_audio(); - // if (G.f & G_DEBUG) printf("setting audio to: %d\n", audio); } #ifndef DISABLE_PYTHON /** @@ -539,11 +511,13 @@ int main(int argc, char **argv) */ BPY_post_start_python(); - BPY_run_ui_scripts(C, 0); /* dont need to reload the first time */ + if(!G.background) + BPY_run_ui_scripts(C, 0); /* dont need to reload the first time */ #endif CTX_py_init_set(C, 1); - WM_keymap_init(C); /* after BPY_run_ui_scripts() */ + if(!G.background) + WM_keymap_init(C); /* after BPY_run_ui_scripts() */ #ifdef WITH_QUICKTIME @@ -726,6 +700,47 @@ int main(int argc, char **argv) printf("\nError: you must specify a path after '-o '.\n"); } break; + case 'E': + a++; + if (a < argc) + { + if (!strcmp(argv[a],"help")) + { + RenderEngineType *type = NULL; + + for( type = R_engines.first; type; type = type->next ) + { + printf("\t%s\n", type->idname); + } + exit(0); + } + else + { + if (CTX_data_scene(C)==NULL) + { + printf("\nError: no blend loaded. order the arguments so '-E ' is after the blend is loaded.\n"); + } + else + { + Scene *scene= CTX_data_scene(C); + RenderData *rd = &scene->r; + RenderEngineType *type = NULL; + + for( type = R_engines.first; type; type = type->next ) + { + if (!strcmp(argv[a],type->idname)) + { + BLI_strncpy(rd->engine, type->idname, sizeof(rd->engine)); + } + } + } + } + } + else + { + printf("\nEngine not specified.\n"); + } + break; case 'F': a++; if (a < argc){ diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 086c259c4bb..ae46f880711 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -61,7 +61,6 @@ #include "RAS_ListRasterizer.h" #include "NG_LoopBackNetworkDeviceInterface.h" -#include "SND_DeviceManager.h" #include "SYS_System.h" @@ -186,19 +185,8 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw // create a networkdevice NG_NetworkDeviceInterface* networkdevice = new NG_LoopBackNetworkDeviceInterface(); - + // - SYS_SystemHandle hSystem = SYS_GetSystem(); - bool noaudio = SYS_GetCommandLineInt(hSystem,"noaudio",0); - - if (noaudio)/*(noaudio) intrr: disable game engine audio (openal) */ - SND_DeviceManager::SetDeviceType(snd_e_dummydevice); - - // get an audiodevice - SND_DeviceManager::Subscribe(); - SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance(); - audiodevice->UseCD(); - // create a ketsji/blendersystem (only needed for timing and stuff) KX_BlenderSystem* kxsystem = new KX_BlenderSystem(); @@ -213,7 +201,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw ketsjiengine->SetRenderTools(rendertools); ketsjiengine->SetRasterizer(rasterizer); ketsjiengine->SetNetworkDevice(networkdevice); - ketsjiengine->SetAudioDevice(audiodevice); ketsjiengine->SetUseFixedTime(usefixed); ketsjiengine->SetTimingDisplay(frameRate, profile, properties); @@ -363,18 +350,17 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw if(GPU_extensions_minimum_support()) useglslmat = true; - else if(G.fileflags & G_FILE_GAME_MAT_GLSL) + else if(blscene->gm.matmode == GAME_MAT_GLSL) usemat = false; - if(usemat && (G.fileflags & G_FILE_GAME_MAT)) + if(usemat && (blscene->gm.matmode != GAME_MAT_TEXFACE)) sceneconverter->SetMaterials(true); - if(useglslmat && (G.fileflags & G_FILE_GAME_MAT_GLSL)) + if(useglslmat && (blscene->gm.matmode == GAME_MAT_GLSL)) sceneconverter->SetGLSLMaterials(true); KX_Scene* startscene = new KX_Scene(keyboarddevice, mousedevice, networkdevice, - audiodevice, startscenename, blscene); @@ -519,8 +505,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); // clean up some stuff - audiodevice->StopCD(); - if (ketsjiengine) { delete ketsjiengine; @@ -560,8 +544,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw { delete canvas; canvas = NULL; - } - SND_DeviceManager::Unsubscribe(); + } } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); @@ -637,11 +620,6 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, NG_NetworkDeviceInterface* networkdevice = new NG_LoopBackNetworkDeviceInterface(); - // get an audiodevice - SND_DeviceManager::Subscribe(); - SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance(); - audiodevice->UseCD(); - // create a ketsji/blendersystem (only needed for timing and stuff) KX_BlenderSystem* kxsystem = new KX_BlenderSystem(); @@ -692,7 +670,6 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, KX_Scene* startscene = new KX_Scene(keyboarddevice, mousedevice, networkdevice, - audiodevice, startscenename, blscene); @@ -756,7 +733,6 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); // clean up some stuff - audiodevice->StopCD(); if (ketsjiengine) { delete ketsjiengine; @@ -791,8 +767,7 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, { delete rendertools; rendertools = NULL; - } - SND_DeviceManager::Unsubscribe(); + } } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index 2874a0273cc..704e3cef6cd 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -31,7 +31,6 @@ SET(INC ../../../source/gameengine/Physics/Sumo ../../../source/gameengine/Physics/Sumo/Fuzzics/include ../../../source/gameengine/Network/LoopBackNetwork - ../../../intern/SoundSystem ../../../source/blender/misc ../../../source/blender/blenloader ../../../source/blender/gpu diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h index fd41fb90f2f..d49c877f610 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h @@ -40,6 +40,10 @@ #include "KX_BlenderGL.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + struct ARegion; struct wmWindow; @@ -166,6 +170,13 @@ private: struct ARegion* m_ar; struct wmWindow* m_win; RAS_Rect m_area_rect; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderCanvas"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // __KX_BLENDERCANVAS diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h index 32391e63264..d4dd9af3d4f 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h @@ -39,7 +39,9 @@ #include "WM_types.h" #include "SCA_IInputDevice.h" - +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif /** Base Class for Blender specific inputdevices. Blender specific inputdevices are used when the gameengine is running in embedded mode instead of standalone mode. @@ -222,6 +224,12 @@ public: // virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0; virtual bool ConvertBlenderEvent(unsigned short incode,short val)=0; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_BlenderInputDevice"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_BLENDERINPUTDEVICE diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h index 5bf37acf236..c801322e787 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h @@ -31,6 +31,10 @@ #include "KX_BlenderInputDevice.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class KX_BlenderKeyboardDevice : public BL_BlenderInputDevice { bool m_hookesc; @@ -43,6 +47,13 @@ public: virtual bool ConvertBlenderEvent(unsigned short incode,short val); virtual void NextFrame(); virtual void HookEscape(); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderKeyboardDevice"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_BLENDERKEYBOARDDEVICE diff --git a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h index 2f9e956a1d8..92383e4b533 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h @@ -31,6 +31,10 @@ #include "KX_BlenderInputDevice.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class KX_BlenderMouseDevice : public BL_BlenderInputDevice { public: @@ -41,6 +45,13 @@ public: // virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode); virtual bool ConvertBlenderEvent(unsigned short incode,short val); virtual void NextFrame(); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderMouseDevice"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_BLENDERMOUSEDEVICE diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index 60130e6bfc9..70672b8350b 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -37,6 +37,10 @@ #include "RAS_IRenderTools.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + struct KX_ClientObjectInfo; class KX_RayCast; @@ -95,6 +99,13 @@ public: virtual void Render2DFilters(RAS_ICanvas* canvas); virtual void SetClientObject(RAS_IRasterizer *rasty, void* obj); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderRenderTools"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_BLENDERRENDERTOOLS diff --git a/source/gameengine/BlenderRoutines/KX_BlenderSystem.h b/source/gameengine/BlenderRoutines/KX_BlenderSystem.h index d99bb9b14a8..b6b2841e81c 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderSystem.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderSystem.h @@ -34,6 +34,10 @@ */ #include "KX_ISystem.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class KX_BlenderSystem : public KX_ISystem { double m_starttime; @@ -42,6 +46,14 @@ public: KX_BlenderSystem(); virtual ~KX_BlenderSystem() {}; virtual double GetTimeInSeconds(); + + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderSystem"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_BLENDERSYSTEM diff --git a/source/gameengine/BlenderRoutines/Makefile b/source/gameengine/BlenderRoutines/Makefile index ffa99a0c1b2..4b65da667ef 100644 --- a/source/gameengine/BlenderRoutines/Makefile +++ b/source/gameengine/BlenderRoutines/Makefile @@ -38,8 +38,6 @@ CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include -CPPFLAGS += -I$(NAN_FUZZICS)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) # because of kernel dependency on makesdna diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript index 0239af22b8c..eb5f2a76e10 100644 --- a/source/gameengine/BlenderRoutines/SConscript +++ b/source/gameengine/BlenderRoutines/SConscript @@ -17,7 +17,7 @@ incs += ' #source/gameengine/Expressions #source/gameengine/Network' incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common' incs += ' #source/gameengine/Physics/Bullet' incs += ' #source/gameengine/Network/LoopBackNetwork' -incs += ' #intern/SoundSystem #source/blender/misc #source/blender/blenloader' +incs += ' #source/blender/misc #source/blender/blenloader' incs += ' #extern/glew/include #source/blender/gpu' incs += ' #source/blender/windowmanager' diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 30055a717e3..5a3629cfcd3 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -1006,56 +1006,50 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, /* ------------------------------------------------------------------------- */ PyTypeObject BL_ActionActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "BL_ActionActuator", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &SCA_IActuator::Type, - 0,0,0,0,0,0, - py_base_new + "BL_ActionActuator", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &SCA_IActuator::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef BL_ActionActuator::Methods[] = { //Deprecated -----> - {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc}, - {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc}, - {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc}, - {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc}, - {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc}, - {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc}, - {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, - {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc}, - {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc}, + {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (const char *)SetAction_doc}, + {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, (const char *)SetStart_doc}, + {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, (const char *)SetEnd_doc}, + {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, (const char *)SetBlendin_doc}, + {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, (const char *)SetPriority_doc}, + {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, (const char *)SetFrame_doc}, + {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, (const char *)SetFrameProperty_doc}, + {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, (const char *)SetBlendtime_doc}, - {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, (PY_METHODCHAR)GetAction_doc}, - {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, (PY_METHODCHAR)GetStart_doc}, - {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, (PY_METHODCHAR)GetEnd_doc}, - {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, (PY_METHODCHAR)GetBlendin_doc}, - {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, (PY_METHODCHAR)GetPriority_doc}, - {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (PY_METHODCHAR)GetFrame_doc}, - {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc}, - {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (PY_METHODCHAR)GetFrameProperty_doc}, + {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, (const char *)GetAction_doc}, + {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, (const char *)GetStart_doc}, + {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, (const char *)GetEnd_doc}, + {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, (const char *)GetBlendin_doc}, + {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, (const char *)GetPriority_doc}, + {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (const char *)GetFrame_doc}, + {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (const char *)GetProperty_doc}, + {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (const char *)GetFrameProperty_doc}, {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_O}, - {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc}, - {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc}, + {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (const char *)GetType_doc}, + {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (const char *)SetType_doc}, {"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0}, {"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0}, //<------ diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index 684d89d492b..af0b7dc201c 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -93,6 +93,13 @@ protected: short m_activePriority; double m_lastapplyframe; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ArmatureObject"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index a1af195801c..3d38759d951 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -101,9 +101,6 @@ #include "KX_KetsjiEngine.h" #include "KX_BlenderSceneConverter.h" -#include"SND_Scene.h" -#include "SND_SoundListener.h" - /* This little block needed for linking to Blender... */ #ifdef WIN32 #include "BLI_winstuff.h" @@ -626,7 +623,7 @@ bool ConvertMaterial( } // with ztransp enabled, enforce alpha blending mode - if(validmat && (mat->mode & MA_ZTRA) && (material->transp == TF_SOLID)) + if(validmat && (mat->mode & MA_TRANSP) && (mat->mode & MA_ZTRANSP) && (material->transp == TF_SOLID)) material->transp = TF_ALPHA; // always zsort alpha + add @@ -1794,7 +1791,6 @@ static KX_GameObject *gameobject_from_blenderobject( } if (gameobj) { - gameobj->SetPhysicsEnvironment(kxscene->GetPhysicsEnvironment()); gameobj->SetLayer(ob->lay); gameobj->SetBlenderObject(ob); /* set the visibility state based on the objects render option in the outliner */ @@ -1830,7 +1826,8 @@ ListBase *get_active_constraints2(Object *ob) if (!ob) return NULL; - if (ob->flag & OB_POSEMODE) { + // XXX - shouldnt we care about the pose data and not the mode??? + if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; pchan = get_active_posechannel2(ob); @@ -2505,7 +2502,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for (i=0;iGetCount();i++) { KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i); - struct Object* blenderobject = converter->FindBlenderObject(gameobj); + struct Object* blenderobject = gameobj->GetBlenderObject(); int nummeshes = gameobj->GetMeshCount(); RAS_MeshObject* meshobj = 0; if (nummeshes > 0) @@ -2521,7 +2518,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for (i=0;iGetCount();i++) { KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i); - struct Object* blenderobject = converter->FindBlenderObject(gameobj); + struct Object* blenderobject = gameobj->GetBlenderObject(); int nummeshes = gameobj->GetMeshCount(); RAS_MeshObject* meshobj = 0; if (nummeshes > 0) @@ -2549,7 +2546,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for (i=0;iGetCount();i++) { KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i); - struct Object* blenderobject = converter->FindBlenderObject(gameobj); + struct Object* blenderobject = gameobj->GetBlenderObject(); ListBase *conlist; bConstraint *curcon; conlist = get_active_constraints2(blenderobject); @@ -2617,23 +2614,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, } } - sumolist->Release(); - - // convert global sound stuff - - /* XXX, glob is the very very wrong place for this - * to be, re-enable once the listener has been moved into - * the scene. */ -#if 1 - SND_Scene* soundscene = kxscene->GetSoundScene(); - SND_SoundListener* listener = soundscene->GetListener(); - if (listener && G.listener) - { - listener->SetDopplerFactor(G.listener->dopplerfactor); - listener->SetDopplerVelocity(G.listener->dopplervelocity); - listener->SetGain(G.listener->gain); - } -#endif + sumolist->Release(); // convert world KX_WorldInfo* worldinfo = new BlenderWorldInfo(blenderscene->world); @@ -2646,7 +2627,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for (i=0;iGetCount();i++) { KX_GameObject* gameobj = static_cast(logicbrick_conversionlist->GetValue(i)); - struct Object* blenderobj = converter->FindBlenderObject(gameobj); + struct Object* blenderobj = gameobj->GetBlenderObject(); int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0; bool isInActiveLayer = (blenderobj->lay & layerMask)!=0; BL_ConvertActuators(maggie->name, blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,layerMask,isInActiveLayer,rendertools,converter); @@ -2654,7 +2635,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for ( i=0;iGetCount();i++) { KX_GameObject* gameobj = static_cast(logicbrick_conversionlist->GetValue(i)); - struct Object* blenderobj = converter->FindBlenderObject(gameobj); + struct Object* blenderobj = gameobj->GetBlenderObject(); int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0; bool isInActiveLayer = (blenderobj->lay & layerMask)!=0; BL_ConvertControllers(blenderobj,gameobj,logicmgr,pythondictionary,layerMask,isInActiveLayer,converter); @@ -2662,7 +2643,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for ( i=0;iGetCount();i++) { KX_GameObject* gameobj = static_cast(logicbrick_conversionlist->GetValue(i)); - struct Object* blenderobj = converter->FindBlenderObject(gameobj); + struct Object* blenderobj = gameobj->GetBlenderObject(); int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0; bool isInActiveLayer = (blenderobj->lay & layerMask)!=0; BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,layerMask,isInActiveLayer,canvas,converter); diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h index b20b8e81b37..ed329e7953d 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.h +++ b/source/gameengine/Converter/BL_DeformableGameObject.h @@ -45,7 +45,6 @@ struct Key; class BL_DeformableGameObject : public KX_GameObject { public: - CValue* GetReplica(); double GetLastFrame () @@ -100,6 +99,12 @@ protected: Object* m_blendobj; short m_activePriority; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_DeformableGameObject"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index 289826e45e7..1749d438d21 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -85,6 +85,13 @@ protected: int m_tvtot; BL_DeformableGameObject* m_gameobj; double m_lastDeformUpdate; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_MeshDeformer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BL_ModifierDeformer.h b/source/gameengine/Converter/BL_ModifierDeformer.h index b09cc2087ca..5cc84c7d1e4 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.h +++ b/source/gameengine/Converter/BL_ModifierDeformer.h @@ -101,6 +101,12 @@ protected: Scene *m_scene; DerivedMesh *m_dm; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ModifierDeformer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 970539777f4..4af9a6c83a9 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -411,55 +411,49 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame) /* Integration hooks ------------------------------------------------------- */ PyTypeObject BL_ShapeActionActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "BL_ShapeActionActuator", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &SCA_IActuator::Type, - 0,0,0,0,0,0, - py_base_new + "BL_ShapeActionActuator", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &SCA_IActuator::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef BL_ShapeActionActuator::Methods[] = { - {"setAction", (PyCFunction) BL_ShapeActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc}, - {"setStart", (PyCFunction) BL_ShapeActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc}, - {"setEnd", (PyCFunction) BL_ShapeActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc}, - {"setBlendin", (PyCFunction) BL_ShapeActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc}, - {"setPriority", (PyCFunction) BL_ShapeActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc}, - {"setFrame", (PyCFunction) BL_ShapeActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc}, - {"setProperty", (PyCFunction) BL_ShapeActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, - {"setFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc}, - {"setBlendtime", (PyCFunction) BL_ShapeActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc}, + {"setAction", (PyCFunction) BL_ShapeActionActuator::sPySetAction, METH_VARARGS, (const char *)SetAction_doc}, + {"setStart", (PyCFunction) BL_ShapeActionActuator::sPySetStart, METH_VARARGS, (const char *)SetStart_doc}, + {"setEnd", (PyCFunction) BL_ShapeActionActuator::sPySetEnd, METH_VARARGS, (const char *)SetEnd_doc}, + {"setBlendin", (PyCFunction) BL_ShapeActionActuator::sPySetBlendin, METH_VARARGS, (const char *)SetBlendin_doc}, + {"setPriority", (PyCFunction) BL_ShapeActionActuator::sPySetPriority, METH_VARARGS, (const char *)SetPriority_doc}, + {"setFrame", (PyCFunction) BL_ShapeActionActuator::sPySetFrame, METH_VARARGS, (const char *)SetFrame_doc}, + {"setProperty", (PyCFunction) BL_ShapeActionActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"setFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPySetFrameProperty, METH_VARARGS, (const char *)SetFrameProperty_doc}, + {"setBlendtime", (PyCFunction) BL_ShapeActionActuator::sPySetBlendtime, METH_VARARGS, (const char *)SetBlendtime_doc}, - {"getAction", (PyCFunction) BL_ShapeActionActuator::sPyGetAction, METH_NOARGS, (PY_METHODCHAR)GetAction_doc}, - {"getStart", (PyCFunction) BL_ShapeActionActuator::sPyGetStart, METH_NOARGS, (PY_METHODCHAR)GetStart_doc}, - {"getEnd", (PyCFunction) BL_ShapeActionActuator::sPyGetEnd, METH_NOARGS, (PY_METHODCHAR)GetEnd_doc}, - {"getBlendin", (PyCFunction) BL_ShapeActionActuator::sPyGetBlendin, METH_NOARGS, (PY_METHODCHAR)GetBlendin_doc}, - {"getPriority", (PyCFunction) BL_ShapeActionActuator::sPyGetPriority, METH_NOARGS, (PY_METHODCHAR)GetPriority_doc}, - {"getFrame", (PyCFunction) BL_ShapeActionActuator::sPyGetFrame, METH_NOARGS, (PY_METHODCHAR)GetFrame_doc}, - {"getProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetProperty, METH_NOARGS, (PY_METHODCHAR)GetProperty_doc}, - {"getFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetFrameProperty, METH_NOARGS, (PY_METHODCHAR)GetFrameProperty_doc}, - {"getType", (PyCFunction) BL_ShapeActionActuator::sPyGetType, METH_NOARGS, (PY_METHODCHAR)GetType_doc}, - {"setType", (PyCFunction) BL_ShapeActionActuator::sPySetType, METH_NOARGS, (PY_METHODCHAR)SetType_doc}, + {"getAction", (PyCFunction) BL_ShapeActionActuator::sPyGetAction, METH_NOARGS, (const char *)GetAction_doc}, + {"getStart", (PyCFunction) BL_ShapeActionActuator::sPyGetStart, METH_NOARGS, (const char *)GetStart_doc}, + {"getEnd", (PyCFunction) BL_ShapeActionActuator::sPyGetEnd, METH_NOARGS, (const char *)GetEnd_doc}, + {"getBlendin", (PyCFunction) BL_ShapeActionActuator::sPyGetBlendin, METH_NOARGS, (const char *)GetBlendin_doc}, + {"getPriority", (PyCFunction) BL_ShapeActionActuator::sPyGetPriority, METH_NOARGS, (const char *)GetPriority_doc}, + {"getFrame", (PyCFunction) BL_ShapeActionActuator::sPyGetFrame, METH_NOARGS, (const char *)GetFrame_doc}, + {"getProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetProperty, METH_NOARGS, (const char *)GetProperty_doc}, + {"getFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetFrameProperty, METH_NOARGS, (const char *)GetFrameProperty_doc}, + {"getType", (PyCFunction) BL_ShapeActionActuator::sPyGetType, METH_NOARGS, (const char *)GetType_doc}, + {"setType", (PyCFunction) BL_ShapeActionActuator::sPySetType, METH_NOARGS, (const char *)SetType_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index 949e5e1e3ad..ca3770d4006 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -83,6 +83,12 @@ protected: vector m_shapeDrivers; double m_lastShapeUpdate; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ShapeDeformer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index 7c43246a9d7..b83895d5609 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -105,6 +105,12 @@ protected: bool m_poseApplied; bool m_recalcNormal; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_SkinDeformer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BL_SkinMeshObject.h b/source/gameengine/Converter/BL_SkinMeshObject.h index e2d0e37664d..838c6c3cb95 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.h +++ b/source/gameengine/Converter/BL_SkinMeshObject.h @@ -54,6 +54,13 @@ public: // for shape keys, void CheckWeightCache(struct Object* obj); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_SkinMeshObject"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h index fd6bb0212b7..7ccb96e4683 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.h +++ b/source/gameengine/Converter/BlenderWorldInfo.h @@ -94,6 +94,13 @@ public: setMistColorBlue( float d ); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BlenderWorldInfo"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__BLENDERWORLDINFO_H diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index 031c2234ea8..6732a62a5cb 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -32,11 +32,7 @@ SET(INC ../../../intern/string ../../../intern/guardedalloc ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../intern/SoundSystem - ../../../intern/SoundSystem/include - ../../../intern/SoundSystem/openal - ../../../intern/SoundSystem/dummy - ../../../intern/SoundSystem/intern + ../../../intern/audaspace/intern ../../../source/gameengine/Converter ../../../source/gameengine/BlenderRoutines ../../../source/blender/imbuf diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h index 396a7d197df..eb15cee8ff9 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h @@ -49,6 +49,13 @@ public: private: struct FCurve *m_fcu; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ScalarInterpolator"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; @@ -58,6 +65,13 @@ public: ~BL_InterpolatorList(); KX_IScalarInterpolator *GetScalarInterpolator(char *rna_path, int array_index); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_InterpolatorList"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_SCALARINTERPOLATOR_H diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 4df9df75d3d..ebabaa55e21 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -260,38 +260,34 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene, if (blenderscene) { - if (blenderscene->world) + switch (blenderscene->gm.physicsEngine) { - switch (blenderscene->world->physicsEngine) + case WOPHY_BULLET: { - case WOPHY_BULLET: - { - physics_engine = UseBullet; - useDbvtCulling = (blenderscene->world->mode & WO_DBVT_CULLING) != 0; - break; - } - - case WOPHY_ODE: - { - physics_engine = UseODE; - break; - } - case WOPHY_DYNAMO: - { - physics_engine = UseDynamo; - break; - } - case WOPHY_SUMO: - { - physics_engine = UseSumo; - break; - } - case WOPHY_NONE: - { - physics_engine = UseNone; - } + physics_engine = UseBullet; + useDbvtCulling = (blenderscene->gm.mode & WO_DBVT_CULLING) != 0; + break; + } + + case WOPHY_ODE: + { + physics_engine = UseODE; + break; + } + case WOPHY_DYNAMO: + { + physics_engine = UseDynamo; + break; + } + case WOPHY_SUMO: + { + physics_engine = UseSumo; + break; + } + case WOPHY_NONE: + { + physics_engine = UseNone; } - } } @@ -349,10 +345,6 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene, //This cache mecanism is buggy so I leave it disable and the memory leak //that would result from this is fixed in RemoveScene() m_map_mesh_to_gamemesh.clear(); - //Don't clear this lookup, it is needed for the baking physics into ipo animation - //To avoid it's infinite grows, object will be unregister when they are deleted - //see KX_Scene::NewRemoveObject - //m_map_gameobject_to_blender.clear(); } // This function removes all entities stored in the converter for that scene @@ -466,27 +458,28 @@ void KX_BlenderSceneConverter::RegisterGameObject( KX_GameObject *gameobject, struct Object *for_blenderobject) { - m_map_gameobject_to_blender.insert(CHashedPtr(gameobject),for_blenderobject); + /* only maintained while converting, freed during game runtime */ m_map_blender_to_gameobject.insert(CHashedPtr(for_blenderobject),gameobject); } void KX_BlenderSceneConverter::UnregisterGameObject( KX_GameObject *gameobject) { - CHashedPtr gptr(gameobject); - struct Object **bobp= m_map_gameobject_to_blender[gptr]; +#if 0 + struct Object *bobp= gameobject->GetBlenderObject(); if (bobp) { - CHashedPtr bptr(*bobp); + CHashedPtr bptr(bobp); KX_GameObject **gobp= m_map_blender_to_gameobject[bptr]; if (gobp && *gobp == gameobject) + { // also maintain m_map_blender_to_gameobject if the gameobject // being removed is matching the blender object m_map_blender_to_gameobject.remove(bptr); - m_map_gameobject_to_blender.remove(gptr); + } } +#endif } - KX_GameObject *KX_BlenderSceneConverter::FindGameObject( struct Object *for_blenderobject) { @@ -495,18 +488,6 @@ KX_GameObject *KX_BlenderSceneConverter::FindGameObject( return obp?*obp:NULL; } - - -struct Object *KX_BlenderSceneConverter::FindBlenderObject( - KX_GameObject *for_gameobject) -{ - struct Object **obp= m_map_gameobject_to_blender[CHashedPtr(for_gameobject)]; - - return obp?*obp:NULL; -} - - - void KX_BlenderSceneConverter::RegisterGameMesh( RAS_MeshObject *gamemesh, struct Mesh *for_blendermesh) @@ -693,7 +674,7 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo) { //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); - Object* blenderObject = FindBlenderObject(gameObj); + Object* blenderObject = gameObj->GetBlenderObject(); if (blenderObject) { //erase existing ipo's @@ -757,7 +738,7 @@ void KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo(){ for (int ix=0;ixGetCount();ix++){ KX_GameObject* gameobj = (KX_GameObject*)parentList->GetValue(ix); if (!gameobj->IsDynamic()){ - Object* blenderobject = FindBlenderObject(gameobj); + Object* blenderobject = gameobj->GetBlenderObject(); if (!blenderobject) continue; if (blenderobject->type==OB_ARMATURE) @@ -811,7 +792,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) { //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); - Object* blenderObject = FindBlenderObject(gameObj); + Object* blenderObject = gameObj->GetBlenderObject(); if (blenderObject && blenderObject->ipo) { const MT_Point3& position = gameObj->NodeGetWorldPosition(); @@ -912,7 +893,7 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo() { //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); - Object* blenderObject = FindBlenderObject(gameObj); + Object* blenderObject = gameObj->GetBlenderObject(); if (blenderObject && blenderObject->ipo) { // XXX animato diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index 50ce8d61336..bb87a21a683 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -56,14 +56,10 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter // Should also have a list of collision shapes. // For the time being this is held in KX_Scene::m_shapes - GEN_Map m_map_gameobject_to_blender; - GEN_Map m_map_blender_to_gameobject; - - GEN_Map m_map_mesh_to_gamemesh; -// GEN_Map m_map_gamemesh_to_sumoshape; - - GEN_Map m_map_blender_to_gameactuator; - GEN_Map m_map_blender_to_gamecontroller; + GEN_Map m_map_blender_to_gameobject; /* cleared after conversion */ + GEN_Map m_map_mesh_to_gamemesh; /* cleared after conversion */ + GEN_Map m_map_blender_to_gameactuator; /* cleared after conversion */ + GEN_Mapm_map_blender_to_gamecontroller; /* cleared after conversion */ GEN_Map m_map_blender_to_gameAdtList; @@ -107,14 +103,10 @@ public: void RegisterGameObject(KX_GameObject *gameobject, struct Object *for_blenderobject); void UnregisterGameObject(KX_GameObject *gameobject); KX_GameObject *FindGameObject(struct Object *for_blenderobject); - struct Object *FindBlenderObject(KX_GameObject *for_gameobject); void RegisterGameMesh(RAS_MeshObject *gamemesh, struct Mesh *for_blendermesh); RAS_MeshObject *FindGameMesh(struct Mesh *for_blendermesh/*, unsigned int onlayer*/); -// void RegisterSumoShape(DT_ShapeHandle shape, RAS_MeshObject *for_gamemesh); -// DT_ShapeHandle FindSumoShape(RAS_MeshObject *for_gamemesh); - void RegisterPolyMaterial(RAS_IPolyMaterial *polymat); void RegisterBlenderMaterial(BL_Material *mat); @@ -151,6 +143,12 @@ public: struct Main* GetMain() { return m_maggie; }; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderSceneConverter"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_BLENDERSCENECONVERTER_H diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index c18e4fce8a5..07f6f628e06 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -38,7 +38,7 @@ #include "KX_BlenderSceneConverter.h" #include "KX_ConvertActuators.h" -#include "SND_Scene.h" +#include "AUD_C-API.h" // Actuators //SCA logiclibrary native logicbricks #include "SCA_PropertyActuator.h" @@ -50,7 +50,6 @@ #include "KX_SceneActuator.h" #include "KX_IpoActuator.h" #include "KX_SoundActuator.h" -#include "KX_CDActuator.h" #include "KX_ObjectActuator.h" #include "KX_TrackToActuator.h" #include "KX_ConstraintActuator.h" @@ -347,8 +346,7 @@ void BL_ConvertActuators(char* maggiename, { bSoundActuator* soundact = (bSoundActuator*) bact->data; /* get type, and possibly a start and end frame */ - short startFrame = soundact->sta, stopFrame = soundact->end; - KX_SoundActuator::KX_SOUNDACT_TYPE + KX_SoundActuator::KX_SOUNDACT_TYPE soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF; switch(soundact->type) { @@ -378,173 +376,38 @@ void BL_ConvertActuators(char* maggiename, if (soundActuatorType != KX_SoundActuator::KX_SOUNDACT_NODEF) { - SND_Scene* soundscene = scene->GetSoundScene(); - STR_String samplename = ""; - bool sampleisloaded = false; - - if (soundact->sound) { - /* Need to convert the samplename into absolute path - * before checking if its loaded */ - char fullpath[FILE_MAX]; - - /* dont modify soundact->sound->name, only change a copy */ - BLI_strncpy(fullpath, soundact->sound->name, sizeof(fullpath)); - BLI_convertstringcode(fullpath, maggiename); - samplename = fullpath; - - /* let's see if the sample was already loaded */ - if (soundscene->IsSampleLoaded(samplename)) - { - sampleisloaded = true; - } - else { - /* if not, make it so */ - PackedFile* pf = soundact->sound->newpackedfile; - - /* but we need a packed file then */ - if (pf) - { - if (soundscene->LoadSample(samplename, pf->data, pf->size) > -1) - sampleisloaded = true; - } - /* or else load it from disk */ - else - { - if (soundscene->LoadSample(samplename, NULL, 0) > -1) { - sampleisloaded = true; - } - else { - std::cout << "WARNING: Sound actuator \"" << bact->name << - "\" from object \"" << blenderobject->id.name+2 << - "\" failed to load sample." << std::endl; - } - } - } - } else { + bSound* sound = soundact->sound; + bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false; + AUD_Sound* snd_sound = NULL; + KX_3DSoundSettings settings; + settings.cone_inner_angle = soundact->sound3D.cone_inner_angle; + settings.cone_outer_angle = soundact->sound3D.cone_outer_angle; + settings.cone_outer_gain = soundact->sound3D.cone_outer_gain; + settings.max_distance = soundact->sound3D.max_distance; + settings.max_gain = soundact->sound3D.max_gain; + settings.min_gain = soundact->sound3D.min_gain; + settings.reference_distance = soundact->sound3D.reference_distance; + settings.rolloff_factor = soundact->sound3D.rolloff_factor; + + if(!sound) + { std::cout << "WARNING: Sound actuator \"" << bact->name << "\" from object \"" << blenderobject->id.name+2 << "\" has no sound datablock." << std::endl; } - - /* Note, allowing actuators for sounds that are not there was added since 2.47 - * This is because python may expect the actuator and raise an exception if it dosnt find it - * better just to add a dummy sound actuator. */ - SND_SoundObject* sndobj = NULL; - if (sampleisloaded) - { - /* setup the SND_SoundObject */ - sndobj = new SND_SoundObject(); - sndobj->SetSampleName(samplename.Ptr()); - sndobj->SetObjectName(bact->name); - if (soundact->sound) { - sndobj->SetRollOffFactor(soundact->sound->attenuation); - sndobj->SetGain(soundact->sound->volume); - sndobj->SetPitch(exp((soundact->sound->pitch / 12.0) * log(2.0))); - // sndobj->SetLoopStart(soundact->sound->loopstart); - // sndobj->SetLoopStart(soundact->sound->loopend); - if (soundact->sound->flags & SOUND_FLAGS_LOOP) - { - if (soundact->sound->flags & SOUND_FLAGS_BIDIRECTIONAL_LOOP) - sndobj->SetLoopMode(SND_LOOP_BIDIRECTIONAL); - else - sndobj->SetLoopMode(SND_LOOP_NORMAL); - } - else { - sndobj->SetLoopMode(SND_LOOP_OFF); - } - - if (soundact->sound->flags & SOUND_FLAGS_PRIORITY) - sndobj->SetHighPriority(true); - else - sndobj->SetHighPriority(false); - - if (soundact->sound->flags & SOUND_FLAGS_3D) - sndobj->Set3D(true); - else - sndobj->Set3D(false); - } - else { - /* dummy values for a NULL sound - * see editsound.c - defaults are unlikely to change soon */ - sndobj->SetRollOffFactor(1.0); - sndobj->SetGain(1.0); - sndobj->SetPitch(1.0); - sndobj->SetLoopMode(SND_LOOP_OFF); - sndobj->SetHighPriority(false); - sndobj->Set3D(false); - } - } - KX_SoundActuator* tmpsoundact = - new KX_SoundActuator(gameobj, - sndobj, - scene->GetSoundScene(), // needed for replication! - soundActuatorType, - startFrame, - stopFrame); - + else + snd_sound = sound->cache ? sound->cache : sound->snd_sound; + KX_SoundActuator* tmpsoundact = + new KX_SoundActuator(gameobj, + snd_sound, + soundact->volume, + exp((soundact->pitch / 12.0) * log(2.0)), + is3d, + settings, + soundActuatorType); + tmpsoundact->SetName(bact->name); baseact = tmpsoundact; - if (sndobj) - soundscene->AddObject(sndobj); - } - break; - } - case ACT_CD: - { - bCDActuator* cdact = (bCDActuator*) bact->data; - /* get type, and possibly a start and end frame */ - short startFrame = cdact->sta, stopFrame = cdact->end; - KX_CDActuator::KX_CDACT_TYPE - cdActuatorType = KX_CDActuator::KX_CDACT_NODEF; - - switch(cdact->type) - { - case ACT_CD_PLAY_ALL: - cdActuatorType = KX_CDActuator::KX_CDACT_PLAY_ALL; - break; - case ACT_CD_PLAY_TRACK: - cdActuatorType = KX_CDActuator::KX_CDACT_PLAY_TRACK; - break; - case ACT_CD_LOOP_TRACK: - cdActuatorType = KX_CDActuator::KX_CDACT_LOOP_TRACK; - break; - case ACT_CD_VOLUME: - cdActuatorType = KX_CDActuator::KX_CDACT_VOLUME; - break; - case ACT_CD_STOP: - cdActuatorType = KX_CDActuator::KX_CDACT_STOP; - break; - case ACT_CD_PAUSE: - cdActuatorType = KX_CDActuator::KX_CDACT_PAUSE; - break; - case ACT_CD_RESUME: - cdActuatorType = KX_CDActuator::KX_CDACT_RESUME; - break; - - default: - /* This is an error!!! */ - cdActuatorType = KX_CDActuator::KX_CDACT_NODEF; - } - - if (cdActuatorType != KX_CDActuator::KX_CDACT_NODEF) - { - SND_CDObject* pCD = SND_CDObject::Instance(); - - if (pCD) - { - pCD->SetGain(cdact->volume); - - KX_CDActuator* tmpcdact = - new KX_CDActuator(gameobj, - scene->GetSoundScene(), // needed for replication! - cdActuatorType, - cdact->track, - startFrame, - stopFrame); - - tmpcdact->SetName(bact->name); - baseact = tmpcdact; - } } break; } diff --git a/source/gameengine/Converter/Makefile b/source/gameengine/Converter/Makefile index ed95aa968c7..e261f9350e9 100644 --- a/source/gameengine/Converter/Makefile +++ b/source/gameengine/Converter/Makefile @@ -37,10 +37,10 @@ CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_MOTO)/include +CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_BULLET2)/include +CPPFLAGS += -I$(NAN_AUDASPACE)/include CPPFLAGS += -I../../blender # these two needed because of blenkernel diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript index 05ea01c902a..7d3185605d5 100644 --- a/source/gameengine/Converter/SConscript +++ b/source/gameengine/Converter/SConscript @@ -6,8 +6,7 @@ defs = [] incs = '. #source/kernel/gen_system #intern/string #intern/guardedalloc' incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer' -incs += ' #intern/SoundSystem #intern/SoundSystem/include #intern/SoundSystem/openal' -incs += ' #intern/SoundSystem/dummy #intern/SoundSystem/intern #source/gameengine/Converter' +incs += ' #intern/audaspace/intern #source/gameengine/Converter' incs += ' #source/gameengine/BlenderRoutines #source/blender/imbuf' incs += ' #intern/moto/include #source/gameengine/Ketsji #source/gameengine/Ketsji/KXNetwork' incs += ' #source/blender/blenlib #source/blender/blenkernel #source/blender' diff --git a/source/gameengine/Expressions/BoolValue.h b/source/gameengine/Expressions/BoolValue.h index 726619e7193..4d0103ec1dd 100644 --- a/source/gameengine/Expressions/BoolValue.h +++ b/source/gameengine/Expressions/BoolValue.h @@ -49,6 +49,13 @@ public: private: bool m_bool; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CBoolValue"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined _BOOLVALUE_H diff --git a/source/gameengine/Expressions/ConstExpr.h b/source/gameengine/Expressions/ConstExpr.h index b117140fe70..f48b8d34355 100644 --- a/source/gameengine/Expressions/ConstExpr.h +++ b/source/gameengine/Expressions/ConstExpr.h @@ -41,6 +41,13 @@ public: private: CValue* m_value; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CConstExpr"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined(AFX_CONSTEXPR_H__061ECFC3_BE87_11D1_A51C_00A02472FC58__INCLUDED_) diff --git a/source/gameengine/Expressions/EmptyValue.h b/source/gameengine/Expressions/EmptyValue.h index fb6b4a477a6..01029d1655d 100644 --- a/source/gameengine/Expressions/EmptyValue.h +++ b/source/gameengine/Expressions/EmptyValue.h @@ -34,6 +34,13 @@ public: CValue * Calc(VALUE_OPERATOR op, CValue *val); CValue * CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val); virtual CValue* GetReplica(); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CEmptyValue"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined _EMPTYVALUE_H diff --git a/source/gameengine/Expressions/ErrorValue.h b/source/gameengine/Expressions/ErrorValue.h index b4b758feea7..2f65850c4f1 100644 --- a/source/gameengine/Expressions/ErrorValue.h +++ b/source/gameengine/Expressions/ErrorValue.h @@ -33,6 +33,13 @@ public: private: STR_String m_strErrorText; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CErrorValue"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined _ERRORVALUE_H diff --git a/source/gameengine/Expressions/Expression.h b/source/gameengine/Expressions/Expression.h index 400a2b7c789..bd346fd0552 100644 --- a/source/gameengine/Expressions/Expression.h +++ b/source/gameengine/Expressions/Expression.h @@ -63,6 +63,12 @@ class CBrokenLinkInfo CExpression* m_pExpr; bool m_bRestored; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CBrokenLinkInfo"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; @@ -126,6 +132,13 @@ public: protected: int m_refcount; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CExpression"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined _EXPRESSION_H diff --git a/source/gameengine/Expressions/FloatValue.h b/source/gameengine/Expressions/FloatValue.h index fb75b7c702b..442f0eb6cf8 100644 --- a/source/gameengine/Expressions/FloatValue.h +++ b/source/gameengine/Expressions/FloatValue.h @@ -42,6 +42,12 @@ protected: float m_float; STR_String* m_pstrRep; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CFloatValue"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined _FLOATVALUE_H diff --git a/source/gameengine/Expressions/IdentifierExpr.h b/source/gameengine/Expressions/IdentifierExpr.h index b307228c8b9..7c14329f755 100644 --- a/source/gameengine/Expressions/IdentifierExpr.h +++ b/source/gameengine/Expressions/IdentifierExpr.h @@ -46,6 +46,13 @@ public: virtual CExpression* CheckLink(std::vector& brokenlinks); virtual void ClearModified(); virtual void BroadcastOperators(VALUE_OPERATOR op); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CIdentifierExpr"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__IDENTIFIER_EXPR diff --git a/source/gameengine/Expressions/IfExpr.h b/source/gameengine/Expressions/IfExpr.h index 9ab13dca413..f06718c851f 100644 --- a/source/gameengine/Expressions/IfExpr.h +++ b/source/gameengine/Expressions/IfExpr.h @@ -44,6 +44,13 @@ public: virtual CExpression* CheckLink(std::vector& brokenlinks); virtual void ClearModified(); virtual void BroadcastOperators(VALUE_OPERATOR op); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CIfExpr"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined(AFX_IFEXPR_H__1F691841_C5C7_11D1_A863_0000B4542BD8__INCLUDED_) diff --git a/source/gameengine/Expressions/InputParser.h b/source/gameengine/Expressions/InputParser.h index 810bdc244a8..0d7eab27aeb 100644 --- a/source/gameengine/Expressions/InputParser.h +++ b/source/gameengine/Expressions/InputParser.h @@ -102,7 +102,13 @@ private: int Priority(int optor); CExpression *Ex(int i); CExpression *Expr(); - + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CParser"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Expressions/IntValue.h b/source/gameengine/Expressions/IntValue.h index 06bf1755749..0513026c4cf 100644 --- a/source/gameengine/Expressions/IntValue.h +++ b/source/gameengine/Expressions/IntValue.h @@ -56,6 +56,12 @@ private: cInt m_int; STR_String* m_pstrRep; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CIntValue"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined _INTVALUE_H diff --git a/source/gameengine/Expressions/KX_HashedPtr.h b/source/gameengine/Expressions/KX_HashedPtr.h index b11efb99d68..0b54436147b 100644 --- a/source/gameengine/Expressions/KX_HashedPtr.h +++ b/source/gameengine/Expressions/KX_HashedPtr.h @@ -29,6 +29,10 @@ #ifndef __KX_HASHEDPTR #define __KX_HASHEDPTR +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + unsigned int KX_Hash(void * inDWord); class CHashedPtr @@ -44,6 +48,13 @@ public: { return rhs.m_valptr == lhs.m_valptr; } + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CHashedPtr"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_HASHEDPTR diff --git a/source/gameengine/Expressions/KX_Python.h b/source/gameengine/Expressions/KX_Python.h index 61f7ef05042..f41accec730 100644 --- a/source/gameengine/Expressions/KX_Python.h +++ b/source/gameengine/Expressions/KX_Python.h @@ -30,6 +30,17 @@ #define KX_PYTHON_H //#define USE_DL_EXPORT + +/* python redefines, quiet the compiler */ +#ifdef _XOPEN_SOURCE +#undef _XOPEN_SOURCE +#endif + +#ifdef _POSIX_C_SOURCE +#undef _POSIX_C_SOURCE +#endif + + #include "Python.h" #define USE_MATHUTILS // Blender 2.5x api will use mathutils, for a while we might want to test without it diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index 38b00dcc8fb..5f45cdc48a2 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -242,15 +242,10 @@ static PySequenceMethods listvalue_as_sequence = { listvalue_buffer_concat, /*sq_concat*/ NULL, /*sq_repeat*/ listvalue_buffer_item, /*sq_item*/ -#if (PY_VERSION_HEX >= 0x03000000) // TODO, slicing in py3? - NULL, - NULL, - NULL, -#else - listvalue_buffer_slice, /*sq_slice*/ +// TODO, slicing in py3 + NULL, // listvalue_buffer_slice, /*sq_slice*/ NULL, /*sq_ass_item*/ NULL, /*sq_ass_slice*/ -#endif (objobjproc)listvalue_buffer_contains, /* sq_contains */ }; @@ -266,13 +261,7 @@ static PyMappingMethods instance_as_mapping = { PyTypeObject CListValue::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "CListValue", /*tp_name*/ sizeof(PyObjectPlus_Proxy), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/source/gameengine/Expressions/Operator1Expr.h b/source/gameengine/Expressions/Operator1Expr.h index 4a1deb0eca3..c2bc68076a0 100644 --- a/source/gameengine/Expressions/Operator1Expr.h +++ b/source/gameengine/Expressions/Operator1Expr.h @@ -46,6 +46,13 @@ public: private: VALUE_OPERATOR m_op; CExpression * m_lhs; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:COperator1Expr"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined(AFX_OPERATOR1EXPR_H__A1653901_BF41_11D1_A51C_00A02472FC58__INCLUDED_) diff --git a/source/gameengine/Expressions/Operator2Expr.h b/source/gameengine/Expressions/Operator2Expr.h index 4064890bbae..bb26b7c03be 100644 --- a/source/gameengine/Expressions/Operator2Expr.h +++ b/source/gameengine/Expressions/Operator2Expr.h @@ -52,7 +52,13 @@ protected: private: VALUE_OPERATOR m_op; - + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:COperator2Expr"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined _OPERATOR2EXPR_H diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 729fff31052..5be703f0fa4 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -57,13 +57,7 @@ PyTypeObject PyObjectPlus::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "PyObjectPlus", /*tp_name*/ sizeof(PyObjectPlus_Proxy), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -87,8 +81,8 @@ PyTypeObject PyObjectPlus::Type = { PyObjectPlus::~PyObjectPlus() { if(m_proxy) { - Py_DECREF(m_proxy); /* Remove own reference, python may still have 1 */ BGE_PROXY_REF(m_proxy)= NULL; + Py_DECREF(m_proxy); /* Remove own reference, python may still have 1 */ } // assert(ob_refcnt==0); } diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index a18df9d36a9..e9e81dddaaa 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -51,44 +51,6 @@ extern "C" { } #endif -extern "C" { -#include "../../blender/python/intern/bpy_compat.h" -} - - -/* - Py_RETURN_NONE - Python 2.4 macro. - defined here until we switch to 2.4 - also in api2_2x/gen_utils.h -*/ -#ifndef Py_RETURN_NONE -#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None -#endif -#ifndef Py_RETURN_FALSE -#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False -#endif -#ifndef Py_RETURN_TRUE -#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True -#endif - -/* for pre Py 2.5 */ -#if PY_VERSION_HEX < 0x02050000 -typedef int Py_ssize_t; -typedef Py_ssize_t (*lenfunc)(PyObject *); -#define PY_SSIZE_T_MAX INT_MAX -#define PY_SSIZE_T_MIN INT_MIN -#define PY_METHODCHAR char * -#else -/* Py 2.5 and later */ -#define intargfunc ssizeargfunc -#define intintargfunc ssizessizeargfunc -#define PY_METHODCHAR const char * -#endif - -#include "descrobject.h" - - static inline void Py_Fatal(const char *M) { fprintf(stderr, "%s\n", M); exit(-1); @@ -140,7 +102,7 @@ typedef struct { // This must be the first line of each // PyC++ class -#define Py_Header \ +#define __Py_Header \ public: \ static PyTypeObject Type; \ static PyMethodDef Methods[]; \ @@ -149,6 +111,16 @@ typedef struct { virtual PyObject *GetProxy() {return GetProxy_Ext(this, &Type);}; \ virtual PyObject *NewProxy(bool py_owns) {return NewProxy_Ext(this, &Type, py_owns);}; \ + +#ifdef WITH_CXX_GUARDEDALLOC +#define Py_Header __Py_Header \ + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, Type.tp_name); } \ + void operator delete( void *mem ) { MEM_freeN(mem); } \ + +#else +#define Py_Header __Py_Header +#endif + /* * nonzero values are an error for setattr * however because of the nested lookups we need to know if the errors @@ -230,13 +202,13 @@ typedef struct { * Method table macro (with doc) */ #define KX_PYMETHODTABLE(class_name, method_name) \ - {#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS, (PY_METHODCHAR)class_name::method_name##_doc} + {#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS, (const char *)class_name::method_name##_doc} #define KX_PYMETHODTABLE_O(class_name, method_name) \ - {#method_name , (PyCFunction) class_name::sPy##method_name, METH_O, (PY_METHODCHAR)class_name::method_name##_doc} + {#method_name , (PyCFunction) class_name::sPy##method_name, METH_O, (const char *)class_name::method_name##_doc} #define KX_PYMETHODTABLE_NOARGS(class_name, method_name) \ - {#method_name , (PyCFunction) class_name::sPy##method_name, METH_NOARGS, (PY_METHODCHAR)class_name::method_name##_doc} + {#method_name , (PyCFunction) class_name::sPy##method_name, METH_NOARGS, (const char *)class_name::method_name##_doc} /** * Function implementation macro diff --git a/source/gameengine/Expressions/StringValue.h b/source/gameengine/Expressions/StringValue.h index c580e8fd23a..069eb8d9c24 100644 --- a/source/gameengine/Expressions/StringValue.h +++ b/source/gameengine/Expressions/StringValue.h @@ -46,6 +46,13 @@ public: private: // data member STR_String m_strString; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CStringValue"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 2759b68b62e..04bcc3a5561 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -36,13 +36,7 @@ double CValue::m_sZeroVec[3] = {0.0,0.0,0.0}; #ifndef NO_EXP_PYTHON_EMBEDDING PyTypeObject CValue::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "CValue", sizeof(PyObjectPlus_Proxy), 0, @@ -594,12 +588,6 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix) { vallie = new CFloatValue( (float)PyFloat_AsDouble(pyobj) ); } else -#if PY_VERSION_HEX < 0x03000000 - if (PyInt_Check(pyobj)) - { - vallie = new CIntValue( (cInt)PyInt_AS_LONG(pyobj) ); - } else -#endif if (PyLong_Check(pyobj)) { vallie = new CIntValue( (cInt)PyLong_AsLongLong(pyobj) ); diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index 8c9f99b335e..5f08736afde 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -42,6 +42,10 @@ #include // array functionality for the propertylist #include "STR_String.h" // STR_String class +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + #ifndef GEN_NO_ASSERT #undef assert #define assert(exp) ((void)NULL) @@ -173,6 +177,13 @@ public: virtual ~CAction(){ }; virtual void Execute() const =0; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CAction"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; // @@ -407,7 +418,6 @@ public: \ class CPropValue : public CValue { public: - #ifndef NO_EXP_PYTHON_EMBEDDING CPropValue() : CValue(), @@ -436,6 +446,13 @@ public: protected: STR_String m_strNewName; // Identification + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CPropValue"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined _VALUEBASECLASS_H diff --git a/source/gameengine/Expressions/VectorValue.h b/source/gameengine/Expressions/VectorValue.h index 19c7dd30076..49fb1e7ea08 100644 --- a/source/gameengine/Expressions/VectorValue.h +++ b/source/gameengine/Expressions/VectorValue.h @@ -79,6 +79,13 @@ public: protected: double m_vec[3]; double m_transformedvec[3]; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CVectorValue"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined _VECTORVALUE_H diff --git a/source/gameengine/Expressions/VoidValue.h b/source/gameengine/Expressions/VoidValue.h index 10a6ff9ad3d..50ec4ff1ee7 100644 --- a/source/gameengine/Expressions/VoidValue.h +++ b/source/gameengine/Expressions/VoidValue.h @@ -59,6 +59,13 @@ public: /// Data members bool m_bDeleteOnDestruct; void* m_pAnything; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CVoidValue"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // !defined _VOIDVALUE_H diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index 530664dce55..a1dce49e14b 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -38,7 +38,7 @@ SET(INC ) IF(WITH_SDL) - SET(INC ${INC} ${SDL_INC}) + SET(INC ${INC} ${SDL_INCLUDE_DIR}) ELSE(WITH_SDL) ADD_DEFINITIONS(-DDISABLE_SDL) ENDIF(WITH_SDL) diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index 04d46e259d3..9dfb5ddc38f 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -107,31 +107,25 @@ void SCA_2DFilterActuator::SetShaderText(const char *text) /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_2DFilterActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "SCA_2DFilterActuator", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &SCA_IActuator::Type, - 0,0,0,0,0,0, - py_base_new + "SCA_2DFilterActuator", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &SCA_IActuator::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef SCA_2DFilterActuator::Methods[] = { diff --git a/source/gameengine/GameLogic/SCA_ANDController.cpp b/source/gameengine/GameLogic/SCA_ANDController.cpp index 78e1350428e..ac9e238bd64 100644 --- a/source/gameengine/GameLogic/SCA_ANDController.cpp +++ b/source/gameengine/GameLogic/SCA_ANDController.cpp @@ -99,13 +99,7 @@ CValue* SCA_ANDController::GetReplica() /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_ANDController::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_ANDController", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h index a7d61627c23..f3884c87a75 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h +++ b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h @@ -45,6 +45,13 @@ public: virtual void NextFrame(); virtual void UpdateFrame(); //SCA_LogicManager* GetLogicManager() { return m_logicmgr;} + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_ActuatorEventManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_ACTUATOREVENTMANAGER diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp index bdcc923e1d9..11ea089270a 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp @@ -121,13 +121,7 @@ void SCA_ActuatorSensor::Update() /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_ActuatorSensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_ActuatorSensor", sizeof(PyObjectPlus_Proxy), 0, @@ -150,8 +144,8 @@ PyTypeObject SCA_ActuatorSensor::Type = { PyMethodDef SCA_ActuatorSensor::Methods[] = { //Deprecated functions ------> - {"getActuator", (PyCFunction) SCA_ActuatorSensor::sPyGetActuator, METH_NOARGS, (PY_METHODCHAR)GetActuator_doc}, - {"setActuator", (PyCFunction) SCA_ActuatorSensor::sPySetActuator, METH_VARARGS, (PY_METHODCHAR)SetActuator_doc}, + {"getActuator", (PyCFunction) SCA_ActuatorSensor::sPyGetActuator, METH_NOARGS, (const char *)GetActuator_doc}, + {"setActuator", (PyCFunction) SCA_ActuatorSensor::sPySetActuator, METH_VARARGS, (const char *)SetActuator_doc}, //<----- Deprecated {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h index a619eecddd4..9540e3b71f6 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h +++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h @@ -41,6 +41,11 @@ public: virtual void NextFrame(); +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_AlwaysEventManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_ALWAYSEVENTMGR diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp index ddb54c580b8..35b035f6466 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp +++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp @@ -104,13 +104,7 @@ bool SCA_AlwaysSensor::Evaluate() /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_AlwaysSensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_AlwaysSensor", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp index 11c6996a0a1..0d563db910e 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp +++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp @@ -130,13 +130,7 @@ bool SCA_DelaySensor::Evaluate() /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_DelaySensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_DelaySensor", sizeof(PyObjectPlus_Proxy), 0, @@ -160,13 +154,13 @@ PyTypeObject SCA_DelaySensor::Type = { PyMethodDef SCA_DelaySensor::Methods[] = { //Deprecated functions ------> /* setProperty */ - {"setDelay", (PyCFunction) SCA_DelaySensor::sPySetDelay, METH_VARARGS, (PY_METHODCHAR)SetDelay_doc}, - {"setDuration", (PyCFunction) SCA_DelaySensor::sPySetDuration, METH_VARARGS, (PY_METHODCHAR)SetDuration_doc}, - {"setRepeat", (PyCFunction) SCA_DelaySensor::sPySetRepeat, METH_VARARGS, (PY_METHODCHAR)SetRepeat_doc}, + {"setDelay", (PyCFunction) SCA_DelaySensor::sPySetDelay, METH_VARARGS, (const char *)SetDelay_doc}, + {"setDuration", (PyCFunction) SCA_DelaySensor::sPySetDuration, METH_VARARGS, (const char *)SetDuration_doc}, + {"setRepeat", (PyCFunction) SCA_DelaySensor::sPySetRepeat, METH_VARARGS, (const char *)SetRepeat_doc}, /* getProperty */ - {"getDelay", (PyCFunction) SCA_DelaySensor::sPyGetDelay, METH_NOARGS, (PY_METHODCHAR)GetDelay_doc}, - {"getDuration", (PyCFunction) SCA_DelaySensor::sPyGetDuration, METH_NOARGS, (PY_METHODCHAR)GetDuration_doc}, - {"getRepeat", (PyCFunction) SCA_DelaySensor::sPyGetRepeat, METH_NOARGS, (PY_METHODCHAR)GetRepeat_doc}, + {"getDelay", (PyCFunction) SCA_DelaySensor::sPyGetDelay, METH_NOARGS, (const char *)GetDelay_doc}, + {"getDuration", (PyCFunction) SCA_DelaySensor::sPyGetDuration, METH_NOARGS, (const char *)GetDuration_doc}, + {"getRepeat", (PyCFunction) SCA_DelaySensor::sPyGetRepeat, METH_NOARGS, (const char *)GetRepeat_doc}, //<----- Deprecated {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h index 5ff55849bfe..424150ffa63 100644 --- a/source/gameengine/GameLogic/SCA_EventManager.h +++ b/source/gameengine/GameLogic/SCA_EventManager.h @@ -71,6 +71,13 @@ public: protected: EVENT_MANAGER_TYPE m_mgrtype; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_EventManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.h b/source/gameengine/GameLogic/SCA_ExpressionController.h index 705f6dfc415..4c1dfcb95a2 100644 --- a/source/gameengine/GameLogic/SCA_ExpressionController.h +++ b/source/gameengine/GameLogic/SCA_ExpressionController.h @@ -53,6 +53,13 @@ public: * so that self references are removed before the controller itself is released */ virtual void Delete(); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_ExpressionController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_EXPRESSIONCONTROLLER diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h index 13c718ee837..00ba8c9ce4e 100644 --- a/source/gameengine/GameLogic/SCA_IActuator.h +++ b/source/gameengine/GameLogic/SCA_IActuator.h @@ -127,6 +127,13 @@ public: void IncLink() { m_links++; } void DecLink(); bool IsNoLink() const { return !m_links; } + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_IActuator"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_IACTUATOR diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp index 7cbb728753a..24c39563c28 100644 --- a/source/gameengine/GameLogic/SCA_IController.cpp +++ b/source/gameengine/GameLogic/SCA_IController.cpp @@ -199,31 +199,25 @@ void SCA_IController::ApplyState(unsigned int state) /* Python api */ PyTypeObject SCA_IController::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "SCA_IController", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &SCA_ILogicBrick::Type, - 0,0,0,0,0,0, - py_base_new + "SCA_IController", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &SCA_ILogicBrick::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef SCA_IController::Methods[] = { diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h index a0d77ed3c03..228d7684b0f 100644 --- a/source/gameengine/GameLogic/SCA_IInputDevice.h +++ b/source/gameengine/GameLogic/SCA_IInputDevice.h @@ -33,6 +33,10 @@ #ifndef KX_INPUTDEVICE_H #define KX_INPUTDEVICE_H +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class SCA_InputEvent { @@ -302,6 +306,12 @@ public: */ virtual void NextFrame(); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_InputEvent"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //KX_INPUTDEVICE_H diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index ccb79a2d49f..2c64e02913d 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -177,13 +177,7 @@ CValue* SCA_ILogicBrick::GetEvent() /* python stuff */ PyTypeObject SCA_ILogicBrick::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_ILogicBrick", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index 6cd11f9e553..2bffd029bd4 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -288,13 +288,7 @@ void SCA_IObject::SetState(unsigned int state) /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_IObject::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_IObject", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/GameLogic/SCA_IScene.h b/source/gameengine/GameLogic/SCA_IScene.h index 79d922a998e..ced9ca94cec 100644 --- a/source/gameengine/GameLogic/SCA_IScene.h +++ b/source/gameengine/GameLogic/SCA_IScene.h @@ -33,6 +33,10 @@ #include "STR_String.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + struct SCA_DebugProp { class CValue* m_obj; @@ -60,6 +64,13 @@ public: void AddDebugProperty(class CValue* debugprop, const STR_String &name); void RemoveAllDebugProperties(); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_IScene"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_ISCENE_H diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 4c1e0bd01c4..b018124dcca 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -472,13 +472,7 @@ KX_PYMETHODDEF_DOC_NOARGS(SCA_ISensor, reset, /* ----------------------------------------------- */ PyTypeObject SCA_ISensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_ISensor", sizeof(PyObjectPlus_Proxy), 0, @@ -502,29 +496,29 @@ PyTypeObject SCA_ISensor::Type = { PyMethodDef SCA_ISensor::Methods[] = { //Deprecated functions -----> {"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive, - METH_NOARGS, (PY_METHODCHAR)IsPositive_doc}, + METH_NOARGS, (const char *)IsPositive_doc}, {"isTriggered", (PyCFunction) SCA_ISensor::sPyIsTriggered, - METH_VARARGS, (PY_METHODCHAR)IsTriggered_doc}, + METH_VARARGS, (const char *)IsTriggered_doc}, {"getUsePosPulseMode", (PyCFunction) SCA_ISensor::sPyGetUsePosPulseMode, - METH_NOARGS, (PY_METHODCHAR)GetUsePosPulseMode_doc}, + METH_NOARGS, (const char *)GetUsePosPulseMode_doc}, {"setUsePosPulseMode", (PyCFunction) SCA_ISensor::sPySetUsePosPulseMode, - METH_VARARGS, (PY_METHODCHAR)SetUsePosPulseMode_doc}, + METH_VARARGS, (const char *)SetUsePosPulseMode_doc}, {"getFrequency", (PyCFunction) SCA_ISensor::sPyGetFrequency, - METH_NOARGS, (PY_METHODCHAR)GetFrequency_doc}, + METH_NOARGS, (const char *)GetFrequency_doc}, {"setFrequency", (PyCFunction) SCA_ISensor::sPySetFrequency, - METH_VARARGS, (PY_METHODCHAR)SetFrequency_doc}, + METH_VARARGS, (const char *)SetFrequency_doc}, {"getUseNegPulseMode", (PyCFunction) SCA_ISensor::sPyGetUseNegPulseMode, - METH_NOARGS, (PY_METHODCHAR)GetUseNegPulseMode_doc}, + METH_NOARGS, (const char *)GetUseNegPulseMode_doc}, {"setUseNegPulseMode", (PyCFunction) SCA_ISensor::sPySetUseNegPulseMode, - METH_VARARGS, (PY_METHODCHAR)SetUseNegPulseMode_doc}, + METH_VARARGS, (const char *)SetUseNegPulseMode_doc}, {"getInvert", (PyCFunction) SCA_ISensor::sPyGetInvert, - METH_NOARGS, (PY_METHODCHAR)GetInvert_doc}, + METH_NOARGS, (const char *)GetInvert_doc}, {"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert, - METH_VARARGS, (PY_METHODCHAR)SetInvert_doc}, + METH_VARARGS, (const char *)SetInvert_doc}, {"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel, - METH_NOARGS, (PY_METHODCHAR)GetLevel_doc}, + METH_NOARGS, (const char *)GetLevel_doc}, {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel, - METH_VARARGS, (PY_METHODCHAR)SetLevel_doc}, + METH_VARARGS, (const char *)SetLevel_doc}, //<----- Deprecated KX_PYMETHODTABLE_NOARGS(SCA_ISensor, reset), {NULL,NULL} //Sentinel diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.h b/source/gameengine/GameLogic/SCA_JoystickManager.h index d3a7ac95bea..be55e95b033 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.h +++ b/source/gameengine/GameLogic/SCA_JoystickManager.h @@ -47,6 +47,12 @@ public: virtual void NextFrame(double curtime,double deltatime); SCA_Joystick* GetJoystickDevice(short int joyindex); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_JoystickManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index f55921e648b..02be7cd6a08 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -252,54 +252,48 @@ bool SCA_JoystickSensor::isValid(SCA_JoystickSensor::KX_JOYSENSORMODE m) /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_JoystickSensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "SCA_JoystickSensor", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &SCA_ISensor::Type, - 0,0,0,0,0,0, - py_base_new + "SCA_JoystickSensor", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &SCA_ISensor::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef SCA_JoystickSensor::Methods[] = { //Deprecated functions ------> - {"getIndex", (PyCFunction) SCA_JoystickSensor::sPyGetIndex, METH_NOARGS, (PY_METHODCHAR)GetIndex_doc}, - {"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, (PY_METHODCHAR)SetIndex_doc}, - {"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, (PY_METHODCHAR)GetAxis_doc}, - {"setAxis", (PyCFunction) SCA_JoystickSensor::sPySetAxis, METH_VARARGS, (PY_METHODCHAR)SetAxis_doc}, - {"getAxisValue", (PyCFunction) SCA_JoystickSensor::sPyGetAxisValue, METH_NOARGS, (PY_METHODCHAR)GetAxisValue_doc}, - {"getThreshold", (PyCFunction) SCA_JoystickSensor::sPyGetThreshold, METH_NOARGS, (PY_METHODCHAR)GetThreshold_doc}, - {"setThreshold", (PyCFunction) SCA_JoystickSensor::sPySetThreshold, METH_VARARGS, (PY_METHODCHAR)SetThreshold_doc}, - {"getButton", (PyCFunction) SCA_JoystickSensor::sPyGetButton, METH_NOARGS, (PY_METHODCHAR)GetButton_doc}, - {"setButton", (PyCFunction) SCA_JoystickSensor::sPySetButton, METH_O, (PY_METHODCHAR)SetButton_doc}, - {"getHat", (PyCFunction) SCA_JoystickSensor::sPyGetHat, METH_NOARGS, (PY_METHODCHAR)GetHat_doc}, - {"setHat", (PyCFunction) SCA_JoystickSensor::sPySetHat, METH_VARARGS, (PY_METHODCHAR)SetHat_doc}, - {"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, (PY_METHODCHAR)NumberOfAxes_doc}, - {"getNumButtons",(PyCFunction) SCA_JoystickSensor::sPyNumberOfButtons,METH_NOARGS, (PY_METHODCHAR)NumberOfButtons_doc}, - {"getNumHats", (PyCFunction) SCA_JoystickSensor::sPyNumberOfHats, METH_NOARGS, (PY_METHODCHAR)NumberOfHats_doc}, - {"isConnected", (PyCFunction) SCA_JoystickSensor::sPyConnected, METH_NOARGS, (PY_METHODCHAR)Connected_doc}, - {"getButtonValue",(PyCFunction) SCA_JoystickSensor::sPyGetButtonValue, METH_NOARGS,(PY_METHODCHAR)GetButtonValue_doc}, + {"getIndex", (PyCFunction) SCA_JoystickSensor::sPyGetIndex, METH_NOARGS, (const char *)GetIndex_doc}, + {"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, (const char *)SetIndex_doc}, + {"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, (const char *)GetAxis_doc}, + {"setAxis", (PyCFunction) SCA_JoystickSensor::sPySetAxis, METH_VARARGS, (const char *)SetAxis_doc}, + {"getAxisValue", (PyCFunction) SCA_JoystickSensor::sPyGetAxisValue, METH_NOARGS, (const char *)GetAxisValue_doc}, + {"getThreshold", (PyCFunction) SCA_JoystickSensor::sPyGetThreshold, METH_NOARGS, (const char *)GetThreshold_doc}, + {"setThreshold", (PyCFunction) SCA_JoystickSensor::sPySetThreshold, METH_VARARGS, (const char *)SetThreshold_doc}, + {"getButton", (PyCFunction) SCA_JoystickSensor::sPyGetButton, METH_NOARGS, (const char *)GetButton_doc}, + {"setButton", (PyCFunction) SCA_JoystickSensor::sPySetButton, METH_O, (const char *)SetButton_doc}, + {"getHat", (PyCFunction) SCA_JoystickSensor::sPyGetHat, METH_NOARGS, (const char *)GetHat_doc}, + {"setHat", (PyCFunction) SCA_JoystickSensor::sPySetHat, METH_VARARGS, (const char *)SetHat_doc}, + {"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, (const char *)NumberOfAxes_doc}, + {"getNumButtons",(PyCFunction) SCA_JoystickSensor::sPyNumberOfButtons,METH_NOARGS, (const char *)NumberOfButtons_doc}, + {"getNumHats", (PyCFunction) SCA_JoystickSensor::sPyNumberOfHats, METH_NOARGS, (const char *)NumberOfHats_doc}, + {"isConnected", (PyCFunction) SCA_JoystickSensor::sPyConnected, METH_NOARGS, (const char *)Connected_doc}, + {"getButtonValue",(PyCFunction) SCA_JoystickSensor::sPyGetButtonValue, METH_NOARGS,(const char *)GetButtonValue_doc}, //<----- Deprecated - {"getButtonActiveList",(PyCFunction) SCA_JoystickSensor::sPyGetButtonActiveList, METH_NOARGS,(PY_METHODCHAR)GetButtonActiveList_doc}, - {"getButtonStatus",(PyCFunction) SCA_JoystickSensor::sPyGetButtonStatus, METH_VARARGS,(PY_METHODCHAR)GetButtonStatus_doc}, + {"getButtonActiveList",(PyCFunction) SCA_JoystickSensor::sPyGetButtonActiveList, METH_NOARGS,(const char *)GetButtonActiveList_doc}, + {"getButtonStatus",(PyCFunction) SCA_JoystickSensor::sPyGetButtonStatus, METH_VARARGS,(const char *)GetButtonStatus_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.h b/source/gameengine/GameLogic/SCA_KeyboardManager.h index 8f3cc0ab715..c5553a74aef 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardManager.h +++ b/source/gameengine/GameLogic/SCA_KeyboardManager.h @@ -56,6 +56,13 @@ public: virtual void NextFrame(); SCA_IInputDevice* GetInputDevice(); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_KeyboardManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_KEYBOARDMANAGER diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index 999e34dfa36..f065452f8c6 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -614,13 +614,7 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus, /* ------------------------------------------------------------------------- */ PyTypeObject SCA_KeyboardSensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_KeyboardSensor", sizeof(PyObjectPlus_Proxy), 0, @@ -643,14 +637,14 @@ PyTypeObject SCA_KeyboardSensor::Type = { PyMethodDef SCA_KeyboardSensor::Methods[] = { //Deprecated functions ------> - {"getKey", (PyCFunction) SCA_KeyboardSensor::sPyGetKey, METH_NOARGS, (PY_METHODCHAR)GetKey_doc}, - {"setKey", (PyCFunction) SCA_KeyboardSensor::sPySetKey, METH_VARARGS, (PY_METHODCHAR)SetKey_doc}, - {"getHold1", (PyCFunction) SCA_KeyboardSensor::sPyGetHold1, METH_NOARGS, (PY_METHODCHAR)GetHold1_doc}, - {"setHold1", (PyCFunction) SCA_KeyboardSensor::sPySetHold1, METH_VARARGS, (PY_METHODCHAR)SetHold1_doc}, - {"getHold2", (PyCFunction) SCA_KeyboardSensor::sPyGetHold2, METH_NOARGS, (PY_METHODCHAR)GetHold2_doc}, - {"setHold2", (PyCFunction) SCA_KeyboardSensor::sPySetHold2, METH_VARARGS, (PY_METHODCHAR)SetHold2_doc}, - {"getPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetPressedKeys, METH_NOARGS, (PY_METHODCHAR)GetPressedKeys_doc}, - {"getCurrentlyPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetCurrentlyPressedKeys, METH_NOARGS, (PY_METHODCHAR)GetCurrentlyPressedKeys_doc}, + {"getKey", (PyCFunction) SCA_KeyboardSensor::sPyGetKey, METH_NOARGS, (const char *)GetKey_doc}, + {"setKey", (PyCFunction) SCA_KeyboardSensor::sPySetKey, METH_VARARGS, (const char *)SetKey_doc}, + {"getHold1", (PyCFunction) SCA_KeyboardSensor::sPyGetHold1, METH_NOARGS, (const char *)GetHold1_doc}, + {"setHold1", (PyCFunction) SCA_KeyboardSensor::sPySetHold1, METH_VARARGS, (const char *)SetHold1_doc}, + {"getHold2", (PyCFunction) SCA_KeyboardSensor::sPyGetHold2, METH_NOARGS, (const char *)GetHold2_doc}, + {"setHold2", (PyCFunction) SCA_KeyboardSensor::sPySetHold2, METH_VARARGS, (const char *)SetHold2_doc}, + {"getPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetPressedKeys, METH_NOARGS, (const char *)GetPressedKeys_doc}, + {"getCurrentlyPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetCurrentlyPressedKeys, METH_NOARGS, (const char *)GetCurrentlyPressedKeys_doc}, //<----- Deprecated KX_PYMETHODTABLE_O(SCA_KeyboardSensor, getKeyStatus), {NULL,NULL} //Sentinel diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h index 53e75e1eaee..402090357cb 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.h +++ b/source/gameengine/GameLogic/SCA_LogicManager.h @@ -137,6 +137,13 @@ public: void RegisterGameObj(void* blendobj, CValue* gameobj); void UnregisterGameObj(void* blendobj, CValue* gameobj); CValue* FindGameObjByBlendObj(void* blendobj); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_LogicManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_LOGICMANAGER diff --git a/source/gameengine/GameLogic/SCA_MouseManager.h b/source/gameengine/GameLogic/SCA_MouseManager.h index efa4c639ce7..ef1533c636b 100644 --- a/source/gameengine/GameLogic/SCA_MouseManager.h +++ b/source/gameengine/GameLogic/SCA_MouseManager.h @@ -63,6 +63,13 @@ public: bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode); virtual void NextFrame(); SCA_IInputDevice* GetInputDevice(); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_MouseManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_MOUSEMANAGER diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 49fa19dce38..c6703452337 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -295,13 +295,7 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus, /* ------------------------------------------------------------------------- */ PyTypeObject SCA_MouseSensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_MouseSensor", sizeof(PyObjectPlus_Proxy), 0, @@ -324,8 +318,8 @@ PyTypeObject SCA_MouseSensor::Type = { PyMethodDef SCA_MouseSensor::Methods[] = { //Deprecated functions ------> - {"getXPosition", (PyCFunction) SCA_MouseSensor::sPyGetXPosition, METH_VARARGS, (PY_METHODCHAR)GetXPosition_doc}, - {"getYPosition", (PyCFunction) SCA_MouseSensor::sPyGetYPosition, METH_VARARGS, (PY_METHODCHAR)GetYPosition_doc}, + {"getXPosition", (PyCFunction) SCA_MouseSensor::sPyGetXPosition, METH_VARARGS, (const char *)GetXPosition_doc}, + {"getYPosition", (PyCFunction) SCA_MouseSensor::sPyGetYPosition, METH_VARARGS, (const char *)GetYPosition_doc}, //<----- Deprecated KX_PYMETHODTABLE_O(SCA_MouseSensor, getButtonStatus), {NULL,NULL} //Sentinel diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp index c00e5d6e617..c971c06fadd 100644 --- a/source/gameengine/GameLogic/SCA_NANDController.cpp +++ b/source/gameengine/GameLogic/SCA_NANDController.cpp @@ -99,13 +99,7 @@ CValue* SCA_NANDController::GetReplica() /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_NANDController::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_NANDController", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp index 9762d44fd5d..7a8b09e4bec 100644 --- a/source/gameengine/GameLogic/SCA_NORController.cpp +++ b/source/gameengine/GameLogic/SCA_NORController.cpp @@ -99,13 +99,7 @@ CValue* SCA_NORController::GetReplica() /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_NORController::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_NORController", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/GameLogic/SCA_ORController.cpp b/source/gameengine/GameLogic/SCA_ORController.cpp index a526dd8353c..12e2f610986 100644 --- a/source/gameengine/GameLogic/SCA_ORController.cpp +++ b/source/gameengine/GameLogic/SCA_ORController.cpp @@ -93,13 +93,7 @@ void SCA_ORController::Trigger(SCA_LogicManager* logicmgr) /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_ORController::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_ORController", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index 215e30eceaf..5afb537c28a 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -228,13 +228,7 @@ void SCA_PropertyActuator::Relink(GEN_Map *obj_map) /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_PropertyActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_PropertyActuator", sizeof(PyObjectPlus_Proxy), 0, @@ -257,10 +251,10 @@ PyTypeObject SCA_PropertyActuator::Type = { PyMethodDef SCA_PropertyActuator::Methods[] = { //Deprecated functions ------> - {"setProperty", (PyCFunction) SCA_PropertyActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, - {"getProperty", (PyCFunction) SCA_PropertyActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc}, - {"setValue", (PyCFunction) SCA_PropertyActuator::sPySetValue, METH_VARARGS, (PY_METHODCHAR)SetValue_doc}, - {"getValue", (PyCFunction) SCA_PropertyActuator::sPyGetValue, METH_VARARGS, (PY_METHODCHAR)GetValue_doc}, + {"setProperty", (PyCFunction) SCA_PropertyActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"getProperty", (PyCFunction) SCA_PropertyActuator::sPyGetProperty, METH_VARARGS, (const char *)GetProperty_doc}, + {"setValue", (PyCFunction) SCA_PropertyActuator::sPySetValue, METH_VARARGS, (const char *)SetValue_doc}, + {"getValue", (PyCFunction) SCA_PropertyActuator::sPyGetValue, METH_VARARGS, (const char *)GetValue_doc}, //<----- Deprecated {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.h b/source/gameengine/GameLogic/SCA_PropertyEventManager.h index f166065b198..011f3285f63 100644 --- a/source/gameengine/GameLogic/SCA_PropertyEventManager.h +++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.h @@ -40,6 +40,12 @@ class SCA_PropertyEventManager : public SCA_EventManager class SCA_LogicManager* m_logicmgr; public: + +#ifdef WITH_CXX_GUARDEDALLOC + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_PropertyEventManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif + SCA_PropertyEventManager(class SCA_LogicManager* logicmgr); virtual ~SCA_PropertyEventManager(); virtual void NextFrame(); diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index 6d2e1a0aca5..96c769bd3d3 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -302,13 +302,7 @@ int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*) /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_PropertySensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_PropertySensor", sizeof(PyObjectPlus_Proxy), 0, @@ -331,12 +325,12 @@ PyTypeObject SCA_PropertySensor::Type = { PyMethodDef SCA_PropertySensor::Methods[] = { //Deprecated functions ------> - {"getType", (PyCFunction) SCA_PropertySensor::sPyGetType, METH_NOARGS, (PY_METHODCHAR)GetType_doc}, - {"setType", (PyCFunction) SCA_PropertySensor::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc}, - {"getProperty", (PyCFunction) SCA_PropertySensor::sPyGetProperty, METH_NOARGS, (PY_METHODCHAR)GetProperty_doc}, - {"setProperty", (PyCFunction) SCA_PropertySensor::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, - {"getValue", (PyCFunction) SCA_PropertySensor::sPyGetValue, METH_NOARGS, (PY_METHODCHAR)GetValue_doc}, - {"setValue", (PyCFunction) SCA_PropertySensor::sPySetValue, METH_VARARGS, (PY_METHODCHAR)SetValue_doc}, + {"getType", (PyCFunction) SCA_PropertySensor::sPyGetType, METH_NOARGS, (const char *)GetType_doc}, + {"setType", (PyCFunction) SCA_PropertySensor::sPySetType, METH_VARARGS, (const char *)SetType_doc}, + {"getProperty", (PyCFunction) SCA_PropertySensor::sPyGetProperty, METH_NOARGS, (const char *)GetProperty_doc}, + {"setProperty", (PyCFunction) SCA_PropertySensor::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"getValue", (PyCFunction) SCA_PropertySensor::sPyGetValue, METH_NOARGS, (const char *)GetValue_doc}, + {"setValue", (PyCFunction) SCA_PropertySensor::sPySetValue, METH_VARARGS, (const char *)SetValue_doc}, //<----- Deprecated {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index ffd95f00699..8ece7fb4ae1 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -227,31 +227,25 @@ const char* SCA_PythonController::sPyGetCurrentController__doc__ = "getCurrentCo const char* SCA_PythonController::sPyAddActiveActuator__doc__= "addActiveActuator(actuator,bool)"; PyTypeObject SCA_PythonController::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "SCA_PythonController", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &SCA_IController::Type, - 0,0,0,0,0,0, - py_base_new + "SCA_PythonController", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &SCA_IController::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef SCA_PythonController::Methods[] = { diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index e903d10f9a5..2b10f491378 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -315,13 +315,7 @@ void SCA_RandomActuator::enforceConstraints() { /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_RandomActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_RandomActuator", sizeof(PyObjectPlus_Proxy), 0, @@ -344,13 +338,13 @@ PyTypeObject SCA_RandomActuator::Type = { PyMethodDef SCA_RandomActuator::Methods[] = { //Deprecated functions ------> - {"setSeed", (PyCFunction) SCA_RandomActuator::sPySetSeed, METH_VARARGS, (PY_METHODCHAR)SetSeed_doc}, - {"getSeed", (PyCFunction) SCA_RandomActuator::sPyGetSeed, METH_NOARGS, (PY_METHODCHAR)GetSeed_doc}, - {"getPara1", (PyCFunction) SCA_RandomActuator::sPyGetPara1, METH_NOARGS, (PY_METHODCHAR)GetPara1_doc}, - {"getPara2", (PyCFunction) SCA_RandomActuator::sPyGetPara2, METH_NOARGS, (PY_METHODCHAR)GetPara2_doc}, - {"getDistribution", (PyCFunction) SCA_RandomActuator::sPyGetDistribution, METH_NOARGS, (PY_METHODCHAR)GetDistribution_doc}, - {"setProperty", (PyCFunction) SCA_RandomActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, - {"getProperty", (PyCFunction) SCA_RandomActuator::sPyGetProperty, METH_NOARGS, (PY_METHODCHAR)GetProperty_doc}, + {"setSeed", (PyCFunction) SCA_RandomActuator::sPySetSeed, METH_VARARGS, (const char *)SetSeed_doc}, + {"getSeed", (PyCFunction) SCA_RandomActuator::sPyGetSeed, METH_NOARGS, (const char *)GetSeed_doc}, + {"getPara1", (PyCFunction) SCA_RandomActuator::sPyGetPara1, METH_NOARGS, (const char *)GetPara1_doc}, + {"getPara2", (PyCFunction) SCA_RandomActuator::sPyGetPara2, METH_NOARGS, (const char *)GetPara2_doc}, + {"getDistribution", (PyCFunction) SCA_RandomActuator::sPyGetDistribution, METH_NOARGS, (const char *)GetDistribution_doc}, + {"setProperty", (PyCFunction) SCA_RandomActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"getProperty", (PyCFunction) SCA_RandomActuator::sPyGetProperty, METH_NOARGS, (const char *)GetProperty_doc}, //<----- Deprecated KX_PYMETHODTABLE(SCA_RandomActuator, setBoolConst), KX_PYMETHODTABLE_NOARGS(SCA_RandomActuator, setBoolUniform), diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.h b/source/gameengine/GameLogic/SCA_RandomEventManager.h index 79138c23c62..c8b511b87b7 100644 --- a/source/gameengine/GameLogic/SCA_RandomEventManager.h +++ b/source/gameengine/GameLogic/SCA_RandomEventManager.h @@ -45,6 +45,13 @@ public: SCA_RandomEventManager(class SCA_LogicManager* logicmgr); virtual void NextFrame(); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_RandomEventManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_RANDOMEVENTMGR diff --git a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h index 842a0331752..f986fadeaf0 100644 --- a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h +++ b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h @@ -34,6 +34,10 @@ #ifndef __KX_RANDOMNUMBERGENERATOR #define __KX_RANDOMNUMBERGENERATOR +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class SCA_RandomNumberGenerator { /* reference counted for memleak */ @@ -69,6 +73,13 @@ class SCA_RandomNumberGenerator { if (--m_refcount == 0) delete this; } + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_RandomNumberGenerator"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif /* __KX_RANDOMNUMBERGENERATOR */ diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index e036a77707e..a09d8328906 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -130,13 +130,7 @@ bool SCA_RandomSensor::Evaluate() /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_RandomSensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_RandomSensor", sizeof(PyObjectPlus_Proxy), 0, @@ -159,9 +153,9 @@ PyTypeObject SCA_RandomSensor::Type = { PyMethodDef SCA_RandomSensor::Methods[] = { //Deprecated functions -----> - {"setSeed", (PyCFunction) SCA_RandomSensor::sPySetSeed, METH_VARARGS, (PY_METHODCHAR)SetSeed_doc}, - {"getSeed", (PyCFunction) SCA_RandomSensor::sPyGetSeed, METH_NOARGS, (PY_METHODCHAR)GetSeed_doc}, - {"getLastDraw", (PyCFunction) SCA_RandomSensor::sPyGetLastDraw, METH_NOARGS, (PY_METHODCHAR)GetLastDraw_doc}, + {"setSeed", (PyCFunction) SCA_RandomSensor::sPySetSeed, METH_VARARGS, (const char *)SetSeed_doc}, + {"getSeed", (PyCFunction) SCA_RandomSensor::sPyGetSeed, METH_NOARGS, (const char *)GetSeed_doc}, + {"getLastDraw", (PyCFunction) SCA_RandomSensor::sPyGetLastDraw, METH_NOARGS, (const char *)GetLastDraw_doc}, //<----- Deprecated {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.h b/source/gameengine/GameLogic/SCA_TimeEventManager.h index bd57e12eb44..089f21e603b 100644 --- a/source/gameengine/GameLogic/SCA_TimeEventManager.h +++ b/source/gameengine/GameLogic/SCA_TimeEventManager.h @@ -48,6 +48,13 @@ public: virtual void RemoveSensor(class SCA_ISensor* sensor); void AddTimeProperty(CValue* timeval); void RemoveTimeProperty(CValue* timeval); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_TimeEventManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_TIMEEVENTMANAGER diff --git a/source/gameengine/GameLogic/SCA_XNORController.cpp b/source/gameengine/GameLogic/SCA_XNORController.cpp index 527adc70cc6..17350feb98b 100644 --- a/source/gameengine/GameLogic/SCA_XNORController.cpp +++ b/source/gameengine/GameLogic/SCA_XNORController.cpp @@ -103,13 +103,7 @@ CValue* SCA_XNORController::GetReplica() /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_XNORController::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_XNORController", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp index c0916224fe6..a6a7cc25897 100644 --- a/source/gameengine/GameLogic/SCA_XORController.cpp +++ b/source/gameengine/GameLogic/SCA_XORController.cpp @@ -103,13 +103,7 @@ CValue* SCA_XORController::GetReplica() /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_XORController::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "SCA_XORController", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt index ce1cd217f60..af25f4b884e 100644 --- a/source/gameengine/GamePlayer/common/CMakeLists.txt +++ b/source/gameengine/GamePlayer/common/CMakeLists.txt @@ -43,7 +43,6 @@ SET(INC ../../../../intern/ghost ../../../../intern/guardedalloc ../../../../intern/moto/include - ../../../../intern/SoundSystem ../../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer ../../../../source/kernel/gen_system ../../../../source/kernel/gen_messaging @@ -70,7 +69,6 @@ SET(INC ../../../../source/blender/gpu ../../../../extern/glew/include ${PYTHON_INC} - ${SOLID_INC} ${PNG_INC} ${ZLIB_INC} ) diff --git a/source/gameengine/GamePlayer/common/Makefile b/source/gameengine/GamePlayer/common/Makefile index 4a952856739..e1b07a226f6 100644 --- a/source/gameengine/GamePlayer/common/Makefile +++ b/source/gameengine/GamePlayer/common/Makefile @@ -47,14 +47,13 @@ CPPFLAGS += -I../../../blender/gpu CPPFLAGS += -I../../../kernel/gen_system CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include -CPPFLAGS += -I$(NAN_FUZZICS)/include CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_PNG)/include CPPFLAGS += -I$(NAN_ZLIB)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) +CPPFLAGS += -I$(NAN_AUDASPACE)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I../../../gameengine/Converter CPPFLAGS += -I../../../gameengine/Expressions CPPFLAGS += -I../../../gameengine/GameLogic diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript index b7b3b9b12c4..1942cde2531 100644 --- a/source/gameengine/GamePlayer/common/SConscript +++ b/source/gameengine/GamePlayer/common/SConscript @@ -19,7 +19,6 @@ incs = ['.', '#intern/ghost', '#intern/guardedalloc', '#intern/moto/include', - '#intern/SoundSystem', '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', '#source/kernel/gen_system', '#source/kernel/gen_messaging', diff --git a/source/gameengine/GamePlayer/common/unix/Makefile b/source/gameengine/GamePlayer/common/unix/Makefile index 08c52ddc904..c86f61b45d8 100644 --- a/source/gameengine/GamePlayer/common/unix/Makefile +++ b/source/gameengine/GamePlayer/common/unix/Makefile @@ -56,8 +56,6 @@ CPPFLAGS += -I../../../../gameengine/Rasterizer CPPFLAGS += -I../../../../gameengine/Rasterizer/RAS_OpenGLRasterizer CPPFLAGS += -I../../../../gameengine/SceneGraph -CPPFLAGS += -I$(NAN_FUZZICS)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_MOTO)/include # Blender stuff diff --git a/source/gameengine/GamePlayer/common/windows/Makefile b/source/gameengine/GamePlayer/common/windows/Makefile index b622ee974c8..3f1deb05f3a 100644 --- a/source/gameengine/GamePlayer/common/windows/Makefile +++ b/source/gameengine/GamePlayer/common/windows/Makefile @@ -48,7 +48,6 @@ CPPFLAGS += -I$(SRCHOME)/gameengine/Physics/Sumo/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_STRING)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_GLEW)/include # Blender stuff diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index 0d4abf1e1fe..e07a7fb26ad 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -38,7 +38,6 @@ SET(INC ../../../../intern/ghost ../../../../intern/guardedalloc ../../../../intern/moto/include - ../../../../intern/SoundSystem ../../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer ../../../../source/kernel/gen_system ../../../../source/kernel/gen_messaging diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 4c824a8df40..c9a2e81bdae 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -524,16 +524,17 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) // SYS_WriteCommandLineInt(syshandle, "fixedtime", 0); // SYS_WriteCommandLineInt(syshandle, "vertexarrays",1); + GameData *gm= &m_startScene->gm; bool properties = (SYS_GetCommandLineInt(syshandle, "show_properties", 0) != 0); bool profile = (SYS_GetCommandLineInt(syshandle, "show_profile", 0) != 0); - bool fixedFr = (G.fileflags & G_FILE_ENABLE_ALL_FRAMES); + bool fixedFr = (gm->flag & GAME_ENABLE_ALL_FRAMES); - bool showPhysics = (G.fileflags & G_FILE_SHOW_PHYSICS); + bool showPhysics = (gm->flag & GAME_SHOW_PHYSICS); SYS_WriteCommandLineInt(syshandle, "show_physics", showPhysics); bool fixed_framerate= (SYS_GetCommandLineInt(syshandle, "fixed_framerate", fixedFr) != 0); bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0); - bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DISPLAY_LISTS) != 0); + bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", gm->flag & GAME_DISPLAY_LISTS) != 0); bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 1) != 0); if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) @@ -541,7 +542,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) if(GPU_extensions_minimum_support()) m_blenderglslmat = (SYS_GetCommandLineInt(syshandle, "blender_glsl_material", 1) != 0); - else if(G.fileflags & G_FILE_GAME_MAT_GLSL) + else if(gm->matmode == GAME_MAT_GLSL) m_blendermat = false; // create the canvas, rasterizer and rendertools @@ -671,9 +672,9 @@ bool GPG_Application::startEngine(void) // if (always_use_expand_framing) // sceneconverter->SetAlwaysUseExpandFraming(true); - if(m_blendermat && (G.fileflags & G_FILE_GAME_MAT)) + if(m_blendermat && (m_startScene->gm.matmode != GAME_MAT_TEXFACE)) m_sceneconverter->SetMaterials(true); - if(m_blenderglslmat && (G.fileflags & G_FILE_GAME_MAT_GLSL)) + if(m_blenderglslmat && (m_startScene->gm.matmode == GAME_MAT_GLSL)) m_sceneconverter->SetGLSLMaterials(true); KX_Scene* startscene = new KX_Scene(m_keyboard, diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile index 49ad9457ee3..a7fcf46b695 100644 --- a/source/gameengine/GamePlayer/ghost/Makefile +++ b/source/gameengine/GamePlayer/ghost/Makefile @@ -39,7 +39,6 @@ CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include CPPFLAGS += -I../../GamePlayer/common diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index ca06b9ca0dd..83bc61381c0 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -13,7 +13,6 @@ incs = ['.', '#intern/ghost', '#intern/guardedalloc', '#intern/moto/include', - '#intern/SoundSystem', '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', '#source/kernel/gen_system', '#source/kernel/gen_messaging', diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index a0a61d01bb2..109a693ec6d 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -44,7 +44,7 @@ void BL_BlenderShader::SetProg(bool enable, double time) { if(VerifyShader()) { if(enable) - GPU_material_bind(mGPUMat, mLightLayer, mBlenderScene->lay, time); + GPU_material_bind(mGPUMat, mLightLayer, mBlenderScene->lay, time, 1); else GPU_material_unbind(mGPUMat); } diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h index 9af53bfc863..073ce8f1ca5 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.h +++ b/source/gameengine/Ketsji/BL_BlenderShader.h @@ -57,6 +57,13 @@ public: int GetBlendMode(); bool Equals(BL_BlenderShader *blshader); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_BlenderShader"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif//__BL_GPUSHADER_H__ diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h index 4f572f95891..6b53e7fa8b1 100644 --- a/source/gameengine/Ketsji/BL_Material.h +++ b/source/gameengine/Ketsji/BL_Material.h @@ -4,6 +4,10 @@ #include "STR_String.h" #include "MT_Point2.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + // -- struct MTex; struct Material; @@ -98,6 +102,13 @@ public: void SetSharedMaterial(bool v); bool IsShared(); void SetUsers(int num); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Material"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; // BL_Material::IdMode diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 8bde5dd3a51..f548bcdaae1 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -765,31 +765,25 @@ PyAttributeDef BL_Shader::Attributes[] = { }; PyTypeObject BL_Shader::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "BL_Shader", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &PyObjectPlus::Type, - 0,0,0,0,0,0, - py_base_new + "BL_Shader", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &PyObjectPlus::Type, + 0,0,0,0,0,0, + py_base_new }; KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProgram)" ) diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h index 42969996b3e..b2610d7762a 100644 --- a/source/gameengine/Ketsji/BL_Shader.h +++ b/source/gameengine/Ketsji/BL_Shader.h @@ -25,6 +25,12 @@ public: { } int mLoc; // Sampler location + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Sampler"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; /** @@ -65,6 +71,13 @@ public: int GetLocation() { return mLoc; } void* getData() { return mData; } + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Uniform"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; /** @@ -83,6 +96,13 @@ public: int mType; int mLoc; unsigned int mFlag; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_DefUniform"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; /** diff --git a/source/gameengine/Ketsji/BL_Texture.h b/source/gameengine/Ketsji/BL_Texture.h index 830ffceb0f7..2dfd9c542d3 100644 --- a/source/gameengine/Ketsji/BL_Texture.h +++ b/source/gameengine/Ketsji/BL_Texture.h @@ -67,6 +67,12 @@ public: return tmp; } + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Texture"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif//__BL_TEXTURE_H__ diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index f703841c40b..77bdd80721f 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -55,7 +55,7 @@ SET(INC ../../../source/gameengine/Physics/Sumo ../../../source/gameengine/Physics/Sumo/Fuzzics/include ../../../source/gameengine/Network/LoopBackNetwork - ../../../intern/SoundSystem + ../../../intern/audaspace/intern ../../../source/blender/misc ../../../source/blender/blenloader ../../../source/blender/gpu @@ -66,7 +66,7 @@ SET(INC ) IF(WITH_SDL) - SET(INC ${INC} ${SDL_INC}) + SET(INC ${INC} ${SDL_INCLUDE_DIR}) ELSE(WITH_SDL) ADD_DEFINITIONS(-DDISABLE_SDL) ENDIF(WITH_SDL) diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp index de820ddaaae..410cf308217 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp @@ -101,13 +101,7 @@ CValue* KX_NetworkMessageActuator::GetReplica() /* Integration hooks -------------------------------------------------- */ PyTypeObject KX_NetworkMessageActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_NetworkMessageActuator", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 78dda1f6db7..7123277d4ef 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -165,13 +165,7 @@ bool KX_NetworkMessageSensor::IsPositiveTrigger() /* Integration hooks --------------------------------------------------- */ PyTypeObject KX_NetworkMessageSensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_NetworkMessageSensor", sizeof(PyObjectPlus_Proxy), 0, @@ -196,19 +190,19 @@ PyMethodDef KX_NetworkMessageSensor::Methods[] = { // Deprecated -----> {"setSubjectFilterText", (PyCFunction) KX_NetworkMessageSensor::sPySetSubjectFilterText, METH_O, - (PY_METHODCHAR)SetSubjectFilterText_doc}, + (const char *)SetSubjectFilterText_doc}, {"getFrameMessageCount", (PyCFunction) KX_NetworkMessageSensor::sPyGetFrameMessageCount, METH_NOARGS, - (PY_METHODCHAR)GetFrameMessageCount_doc}, + (const char *)GetFrameMessageCount_doc}, {"getBodies", (PyCFunction) KX_NetworkMessageSensor::sPyGetBodies, METH_NOARGS, - (PY_METHODCHAR)GetBodies_doc}, + (const char *)GetBodies_doc}, {"getSubject", (PyCFunction) KX_NetworkMessageSensor::sPyGetSubject, METH_NOARGS, - (PY_METHODCHAR)GetSubject_doc}, + (const char *)GetSubject_doc}, {"getSubjects", (PyCFunction) KX_NetworkMessageSensor::sPyGetSubjects, METH_NOARGS, - (PY_METHODCHAR)GetSubjects_doc}, + (const char *)GetSubjects_doc}, // <----- {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index d93175ff35a..be3d4906761 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -235,7 +235,7 @@ void KX_BlenderMaterial::OnExit() } if( mMaterial->tface ) - GPU_set_tpage(mMaterial->tface); + GPU_set_tpage(mMaterial->tface, 1); } @@ -794,31 +794,25 @@ PyAttributeDef KX_BlenderMaterial::Attributes[] = { }; PyTypeObject KX_BlenderMaterial::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_BlenderMaterial", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &PyObjectPlus::Type, - 0,0,0,0,0,0, - py_base_new + "KX_BlenderMaterial", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &PyObjectPlus::Type, + 0,0,0,0,0,0, + py_base_new }; KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()") diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 605ca207949..cdbdc4bd429 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -15,6 +15,10 @@ #include "MT_Vector3.h" #include "MT_Vector4.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + struct MTFace; class KX_Scene; diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 755b1cbd780..7fc799abb7e 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -18,7 +18,6 @@ private: btCollisionShape* m_bulletChildShape; public: - KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool sensor, bool compound); virtual ~KX_BulletPhysicsController (); @@ -81,6 +80,12 @@ public: // intentionally empty }; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BulletPhysicsController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //KX_BULLET2PHYSICS_CONTROLLER diff --git a/source/gameengine/Ketsji/KX_CDActuator.cpp b/source/gameengine/Ketsji/KX_CDActuator.cpp deleted file mode 100644 index bfca81f45d9..00000000000 --- a/source/gameengine/Ketsji/KX_CDActuator.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/** - * KX_CDActuator.cpp - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - */ - -#include "KX_CDActuator.h" -#include "SND_CDObject.h" -#include "KX_GameObject.h" -#include "SND_Scene.h" // needed for replication -#include - -#ifdef HAVE_CONFIG_H -#include -#endif - -/* ------------------------------------------------------------------------- */ -/* Native functions */ -/* ------------------------------------------------------------------------- */ -KX_CDActuator::KX_CDActuator(SCA_IObject* gameobject, - SND_Scene* soundscene, - KX_CDACT_TYPE type, - int track, - short start, - short end) - : SCA_IActuator(gameobject) -{ - m_soundscene = soundscene; - m_type = type; - m_track = track; - m_lastEvent = true; - m_isplaying = false; - m_startFrame = start; - m_endFrame = end; - m_gain = SND_CDObject::Instance()->GetGain(); -} - - - -KX_CDActuator::~KX_CDActuator() -{ -} - - -/* hmmm, do we want this? */ -CValue* KX_CDActuator::GetReplica() -{ - KX_CDActuator* replica = new KX_CDActuator(*this); - replica->ProcessReplica(); - return replica; -}; - - - -bool KX_CDActuator::Update() -{ - bool result = false; - bool bNegativeEvent = IsNegativeEvent(); - - RemoveAllEvents(); - - if (!bNegativeEvent) - { - switch (m_type) - { - case KX_CDACT_PLAY_ALL: - { - SND_CDObject::Instance()->SetPlaymode(SND_CD_ALL); - SND_CDObject::Instance()->SetTrack(1); - SND_CDObject::Instance()->SetPlaystate(SND_MUST_PLAY); - //result = true; - break; - } - case KX_CDACT_PLAY_TRACK: - { - SND_CDObject::Instance()->SetPlaymode(SND_CD_TRACK); - SND_CDObject::Instance()->SetTrack(m_track); - SND_CDObject::Instance()->SetPlaystate(SND_MUST_PLAY); - //result = true; - break; - } - case KX_CDACT_LOOP_TRACK: - { - SND_CDObject::Instance()->SetPlaymode(SND_CD_ALL); - SND_CDObject::Instance()->SetTrack(m_track); - SND_CDObject::Instance()->SetPlaystate(SND_MUST_PLAY); - //result = true; - break; - } - case KX_CDACT_STOP: - { - SND_CDObject::Instance()->SetPlaystate(SND_MUST_STOP); - break; - } - case KX_CDACT_PAUSE: - { - SND_CDObject::Instance()->SetPlaystate(SND_MUST_PAUSE); - //result = true; - break; - } - case KX_CDACT_RESUME: - { - SND_CDObject::Instance()->SetPlaystate(SND_MUST_RESUME); - //result = true; - break; - } - case KX_CDACT_VOLUME: - { - SND_CDObject::Instance()->SetGain(m_gain); - //result = true; - break; - } - default: - // implement me !! - break; - } - } - return result; -} - - - -/* ------------------------------------------------------------------------- */ -/* Python functions */ -/* ------------------------------------------------------------------------- */ - - - -/* Integration hooks ------------------------------------------------------- */ -PyTypeObject KX_CDActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) - PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_SoundActuator", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &SCA_IActuator::Type, - 0,0,0,0,0,0, - py_base_new -}; - -PyMethodDef KX_CDActuator::Methods[] = { - // Deprecated -----> - {"setGain",(PyCFunction) KX_CDActuator::sPySetGain,METH_VARARGS,NULL}, - {"getGain",(PyCFunction) KX_CDActuator::sPyGetGain,METH_VARARGS,NULL}, - // <----- - KX_PYMETHODTABLE_NOARGS(KX_CDActuator, startCD), - KX_PYMETHODTABLE_NOARGS(KX_CDActuator, pauseCD), - KX_PYMETHODTABLE_NOARGS(KX_CDActuator, resumeCD), - KX_PYMETHODTABLE_NOARGS(KX_CDActuator, stopCD), - KX_PYMETHODTABLE_NOARGS(KX_CDActuator, playAll), - KX_PYMETHODTABLE_O(KX_CDActuator, playTrack), - {NULL,NULL,NULL,NULL} //Sentinel -}; - -PyAttributeDef KX_CDActuator::Attributes[] = { - KX_PYATTRIBUTE_FLOAT_RW_CHECK("volume", 0.0, 1.0, KX_CDActuator, m_gain,pyattr_setGain), - KX_PYATTRIBUTE_INT_RW("track", 1, 99, false, KX_CDActuator, m_track), - { NULL } //Sentinel -}; - -int KX_CDActuator::pyattr_setGain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) -{ - KX_CDActuator* act = static_cast(self); - SND_CDObject::Instance()->SetGain(act->m_gain); - return PY_SET_ATTR_SUCCESS; -} - -KX_PYMETHODDEF_DOC_NOARGS(KX_CDActuator, startCD, -"startCD()\n" -"\tStarts the CD playing.\n") -{ - SND_CDObject::Instance()->SetPlaystate(SND_MUST_PLAY); - Py_RETURN_NONE; -} - - -KX_PYMETHODDEF_DOC_NOARGS(KX_CDActuator, pauseCD, -"pauseCD()\n" -"\tPauses the CD playing.\n") -{ - SND_CDObject::Instance()->SetPlaystate(SND_MUST_PAUSE); - Py_RETURN_NONE; -} - - -KX_PYMETHODDEF_DOC_NOARGS(KX_CDActuator, resumeCD, -"resumeCD()\n" -"\tResumes the CD playing.\n") -{ - SND_CDObject::Instance()->SetPlaystate(SND_MUST_RESUME); - Py_RETURN_NONE; -} - - -KX_PYMETHODDEF_DOC_NOARGS(KX_CDActuator, stopCD, -"stopCD()\n" -"\tStops the CD playing.\n") -{ - SND_CDObject::Instance()->SetPlaystate(SND_MUST_STOP); - Py_RETURN_NONE; -} - - -KX_PYMETHODDEF_DOC_O(KX_CDActuator, playTrack, -"playTrack(trackNumber)\n" -"\tPlays the track selected.\n") -{ - if (PyLong_Check(value)) { - int track = PyLong_AsSsize_t(value); - SND_CDObject::Instance()->SetPlaymode(SND_CD_TRACK); - SND_CDObject::Instance()->SetTrack(track); - SND_CDObject::Instance()->SetPlaystate(SND_MUST_PLAY); - } - Py_RETURN_NONE; -} - - - -KX_PYMETHODDEF_DOC_NOARGS(KX_CDActuator, playAll, -"playAll()\n" -"\tPlays the CD from the beginning.\n") -{ - SND_CDObject::Instance()->SetPlaymode(SND_CD_ALL); - SND_CDObject::Instance()->SetTrack(1); - SND_CDObject::Instance()->SetPlaystate(SND_MUST_PLAY); - Py_RETURN_NONE; -} - -// Deprecated -----> -PyObject* KX_CDActuator::PySetGain(PyObject* args) -{ - float gain = 1.0; - ShowDeprecationWarning("setGain()", "the volume property"); - if (!PyArg_ParseTuple(args, "f:setGain", &gain)) - return NULL; - - SND_CDObject::Instance()->SetGain(gain); - - Py_RETURN_NONE; -} - - - -PyObject* KX_CDActuator::PyGetGain(PyObject* args) -{ - float gain = SND_CDObject::Instance()->GetGain(); - ShowDeprecationWarning("getGain()", "the volume property"); - PyObject* result = PyFloat_FromDouble(gain); - - return result; -} -// <----- diff --git a/source/gameengine/Ketsji/KX_CDActuator.h b/source/gameengine/Ketsji/KX_CDActuator.h deleted file mode 100644 index b01ad73777e..00000000000 --- a/source/gameengine/Ketsji/KX_CDActuator.h +++ /dev/null @@ -1,101 +0,0 @@ -/** - * KX_CDActuator.h - * - * $Id$ - * - * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __KX_CDACTUATOR -#define __KX_CDACTUATOR - -#include "SCA_IActuator.h" -#include "SND_CDObject.h" - -class KX_CDActuator : public SCA_IActuator -{ - Py_Header; - bool m_lastEvent; - bool m_isplaying; - /* just some handles to the audio-data... */ - class SND_Scene* m_soundscene; - int m_track; - float m_gain; - short m_startFrame; - short m_endFrame; - -public: - enum KX_CDACT_TYPE - { - KX_CDACT_NODEF = 0, - KX_CDACT_PLAY_ALL, - KX_CDACT_PLAY_TRACK, - KX_CDACT_LOOP_TRACK, - KX_CDACT_VOLUME, - KX_CDACT_STOP, - KX_CDACT_PAUSE, - KX_CDACT_RESUME, - KX_SOUNDACT_MAX - }; - - KX_CDACT_TYPE m_type; - - KX_CDActuator(SCA_IObject* gameobject, - SND_Scene* soundscene, - KX_CDACT_TYPE type, - int track, - short start, - short end); - - ~KX_CDActuator(); - - virtual bool Update(); - - CValue* GetReplica(); - - /* -------------------------------------------------------------------- */ - /* Python interface --------------------------------------------------- */ - /* -------------------------------------------------------------------- */ - - // Deprecated -----> - KX_PYMETHOD_VARARGS(KX_CDActuator,SetGain); - KX_PYMETHOD_VARARGS(KX_CDActuator,GetGain); - // <----- - - KX_PYMETHOD_DOC_NOARGS(KX_CDActuator, startCD); - KX_PYMETHOD_DOC_NOARGS(KX_CDActuator, pauseCD); - KX_PYMETHOD_DOC_NOARGS(KX_CDActuator, resumeCD); - KX_PYMETHOD_DOC_NOARGS(KX_CDActuator, stopCD); - KX_PYMETHOD_DOC_NOARGS(KX_CDActuator, playAll); - KX_PYMETHOD_DOC_O(KX_CDActuator, playTrack); - - static int pyattr_setGain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - - -}; - -#endif //__KX_CDACTUATOR - diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index f762699f780..fd289a0b55e 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -530,37 +530,31 @@ PyAttributeDef KX_Camera::Attributes[] = { }; PyTypeObject KX_Camera::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_Camera", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0, - &KX_GameObject::Sequence, - &KX_GameObject::Mapping, - 0,0,0, - NULL, - NULL, - 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &KX_GameObject::Type, - 0,0,0,0,0,0, - py_base_new + "KX_Camera", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0, + &KX_GameObject::Sequence, + &KX_GameObject::Mapping, + 0,0,0, + NULL, + NULL, + 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &KX_GameObject::Type, + 0,0,0,0,0,0, + py_base_new }; KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, sphereInsideFrustum, diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 3d3b68ed85d..faf0ca50407 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -368,13 +368,7 @@ bool KX_CameraActuator::string2axischoice(const char *axisString) /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_CameraActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_CameraActuator", sizeof(PyObjectPlus_Proxy), 0, @@ -397,16 +391,16 @@ PyTypeObject KX_CameraActuator::Type = { PyMethodDef KX_CameraActuator::Methods[] = { // ---> deprecated (all) - {"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc}, - {"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc}, - {"setMin" ,(PyCFunction) KX_CameraActuator::sPySetMin, METH_VARARGS, (PY_METHODCHAR)SetMin_doc}, - {"getMin" ,(PyCFunction) KX_CameraActuator::sPyGetMin, METH_NOARGS, (PY_METHODCHAR)GetMin_doc}, - {"setMax" ,(PyCFunction) KX_CameraActuator::sPySetMax, METH_VARARGS, (PY_METHODCHAR)SetMax_doc}, - {"getMax" ,(PyCFunction) KX_CameraActuator::sPyGetMax, METH_NOARGS, (PY_METHODCHAR)GetMax_doc}, - {"setHeight",(PyCFunction) KX_CameraActuator::sPySetHeight, METH_VARARGS, (PY_METHODCHAR)SetHeight_doc}, - {"getHeight",(PyCFunction) KX_CameraActuator::sPyGetHeight, METH_NOARGS, (PY_METHODCHAR)GetHeight_doc}, - {"setXY" ,(PyCFunction) KX_CameraActuator::sPySetXY, METH_VARARGS, (PY_METHODCHAR)SetXY_doc}, - {"getXY" ,(PyCFunction) KX_CameraActuator::sPyGetXY, METH_NOARGS, (PY_METHODCHAR)GetXY_doc}, + {"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_O, (const char *)SetObject_doc}, + {"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_VARARGS, (const char *)GetObject_doc}, + {"setMin" ,(PyCFunction) KX_CameraActuator::sPySetMin, METH_VARARGS, (const char *)SetMin_doc}, + {"getMin" ,(PyCFunction) KX_CameraActuator::sPyGetMin, METH_NOARGS, (const char *)GetMin_doc}, + {"setMax" ,(PyCFunction) KX_CameraActuator::sPySetMax, METH_VARARGS, (const char *)SetMax_doc}, + {"getMax" ,(PyCFunction) KX_CameraActuator::sPyGetMax, METH_NOARGS, (const char *)GetMax_doc}, + {"setHeight",(PyCFunction) KX_CameraActuator::sPySetHeight, METH_VARARGS, (const char *)SetHeight_doc}, + {"getHeight",(PyCFunction) KX_CameraActuator::sPyGetHeight, METH_NOARGS, (const char *)GetHeight_doc}, + {"setXY" ,(PyCFunction) KX_CameraActuator::sPySetXY, METH_VARARGS, (const char *)SetXY_doc}, + {"getXY" ,(PyCFunction) KX_CameraActuator::sPyGetXY, METH_NOARGS, (const char *)GetXY_doc}, {NULL,NULL,NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_CameraIpoSGController.h b/source/gameengine/Ketsji/KX_CameraIpoSGController.h index 33245e79c23..85d93962a14 100644 --- a/source/gameengine/Ketsji/KX_CameraIpoSGController.h +++ b/source/gameengine/Ketsji/KX_CameraIpoSGController.h @@ -84,6 +84,13 @@ public: m_modify_clipstart = modify; } void AddInterpolator(KX_IInterpolator* interp); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_CameraIpoSGController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // KX_CAMERAIPOSGCONTROLLER_H diff --git a/source/gameengine/Ketsji/KX_ClientObjectInfo.h b/source/gameengine/Ketsji/KX_ClientObjectInfo.h index 1898dc71ef8..74647dd47fd 100644 --- a/source/gameengine/Ketsji/KX_ClientObjectInfo.h +++ b/source/gameengine/Ketsji/KX_ClientObjectInfo.h @@ -74,6 +74,13 @@ public: bool isActor() { return m_type <= ACTOR; } bool isSensor() { return m_type >= SENSOR && m_type <= OBACTORSENSOR; } + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_ClientObjectInfo"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_CLIENTOBJECT_INFO_H diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index d09eae647c8..5f6244c3ab6 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -36,6 +36,7 @@ #include "MT_Matrix3x3.h" #include "KX_GameObject.h" #include "KX_RayCast.h" +#include "KX_PythonInit.h" // KX_GetActiveScene #ifdef HAVE_CONFIG_H #include @@ -327,7 +328,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) } { MT_Point3 topoint = position + (m_maximumBound) * direction; - PHY_IPhysicsEnvironment* pe = obj->GetPhysicsEnvironment(); + PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment(); KX_IPhysicsController *spc = obj->GetPhysicsController(); if (!pe) { @@ -440,7 +441,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) } normal.normalize(); { - PHY_IPhysicsEnvironment* pe = obj->GetPhysicsEnvironment(); + PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment(); KX_IPhysicsController *spc = obj->GetPhysicsController(); if (!pe) { @@ -564,13 +565,7 @@ bool KX_ConstraintActuator::IsValidMode(KX_ConstraintActuator::KX_CONSTRAINTTYPE /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_ConstraintActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_ConstraintActuator", sizeof(PyObjectPlus_Proxy), 0, @@ -593,28 +588,28 @@ PyTypeObject KX_ConstraintActuator::Type = { PyMethodDef KX_ConstraintActuator::Methods[] = { // Deprecated --> - {"setDamp", (PyCFunction) KX_ConstraintActuator::sPySetDamp, METH_VARARGS, (PY_METHODCHAR)SetDamp_doc}, - {"getDamp", (PyCFunction) KX_ConstraintActuator::sPyGetDamp, METH_NOARGS, (PY_METHODCHAR)GetDamp_doc}, - {"setRotDamp", (PyCFunction) KX_ConstraintActuator::sPySetRotDamp, METH_VARARGS, (PY_METHODCHAR)SetRotDamp_doc}, - {"getRotDamp", (PyCFunction) KX_ConstraintActuator::sPyGetRotDamp, METH_NOARGS, (PY_METHODCHAR)GetRotDamp_doc}, - {"setDirection", (PyCFunction) KX_ConstraintActuator::sPySetDirection, METH_VARARGS, (PY_METHODCHAR)SetDirection_doc}, - {"getDirection", (PyCFunction) KX_ConstraintActuator::sPyGetDirection, METH_NOARGS, (PY_METHODCHAR)GetDirection_doc}, - {"setOption", (PyCFunction) KX_ConstraintActuator::sPySetOption, METH_VARARGS, (PY_METHODCHAR)SetOption_doc}, - {"getOption", (PyCFunction) KX_ConstraintActuator::sPyGetOption, METH_NOARGS, (PY_METHODCHAR)GetOption_doc}, - {"setTime", (PyCFunction) KX_ConstraintActuator::sPySetTime, METH_VARARGS, (PY_METHODCHAR)SetTime_doc}, - {"getTime", (PyCFunction) KX_ConstraintActuator::sPyGetTime, METH_NOARGS, (PY_METHODCHAR)GetTime_doc}, - {"setProperty", (PyCFunction) KX_ConstraintActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, - {"getProperty", (PyCFunction) KX_ConstraintActuator::sPyGetProperty, METH_NOARGS, (PY_METHODCHAR)GetProperty_doc}, - {"setMin", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, (PY_METHODCHAR)SetMin_doc}, - {"getMin", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, (PY_METHODCHAR)GetMin_doc}, - {"setDistance", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, (PY_METHODCHAR)SetDistance_doc}, - {"getDistance", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, (PY_METHODCHAR)GetDistance_doc}, - {"setMax", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, (PY_METHODCHAR)SetMax_doc}, - {"getMax", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, (PY_METHODCHAR)GetMax_doc}, - {"setRayLength", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, (PY_METHODCHAR)SetRayLength_doc}, - {"getRayLength", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, (PY_METHODCHAR)GetRayLength_doc}, - {"setLimit", (PyCFunction) KX_ConstraintActuator::sPySetLimit, METH_VARARGS, (PY_METHODCHAR)SetLimit_doc}, - {"getLimit", (PyCFunction) KX_ConstraintActuator::sPyGetLimit, METH_NOARGS, (PY_METHODCHAR)GetLimit_doc}, + {"setDamp", (PyCFunction) KX_ConstraintActuator::sPySetDamp, METH_VARARGS, (const char *)SetDamp_doc}, + {"getDamp", (PyCFunction) KX_ConstraintActuator::sPyGetDamp, METH_NOARGS, (const char *)GetDamp_doc}, + {"setRotDamp", (PyCFunction) KX_ConstraintActuator::sPySetRotDamp, METH_VARARGS, (const char *)SetRotDamp_doc}, + {"getRotDamp", (PyCFunction) KX_ConstraintActuator::sPyGetRotDamp, METH_NOARGS, (const char *)GetRotDamp_doc}, + {"setDirection", (PyCFunction) KX_ConstraintActuator::sPySetDirection, METH_VARARGS, (const char *)SetDirection_doc}, + {"getDirection", (PyCFunction) KX_ConstraintActuator::sPyGetDirection, METH_NOARGS, (const char *)GetDirection_doc}, + {"setOption", (PyCFunction) KX_ConstraintActuator::sPySetOption, METH_VARARGS, (const char *)SetOption_doc}, + {"getOption", (PyCFunction) KX_ConstraintActuator::sPyGetOption, METH_NOARGS, (const char *)GetOption_doc}, + {"setTime", (PyCFunction) KX_ConstraintActuator::sPySetTime, METH_VARARGS, (const char *)SetTime_doc}, + {"getTime", (PyCFunction) KX_ConstraintActuator::sPyGetTime, METH_NOARGS, (const char *)GetTime_doc}, + {"setProperty", (PyCFunction) KX_ConstraintActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"getProperty", (PyCFunction) KX_ConstraintActuator::sPyGetProperty, METH_NOARGS, (const char *)GetProperty_doc}, + {"setMin", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, (const char *)SetMin_doc}, + {"getMin", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, (const char *)GetMin_doc}, + {"setDistance", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, (const char *)SetDistance_doc}, + {"getDistance", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, (const char *)GetDistance_doc}, + {"setMax", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, (const char *)SetMax_doc}, + {"getMax", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, (const char *)GetMax_doc}, + {"setRayLength", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, (const char *)SetRayLength_doc}, + {"getRayLength", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, (const char *)GetRayLength_doc}, + {"setLimit", (PyCFunction) KX_ConstraintActuator::sPySetLimit, METH_VARARGS, (const char *)SetLimit_doc}, + {"getLimit", (PyCFunction) KX_ConstraintActuator::sPyGetLimit, METH_NOARGS, (const char *)GetLimit_doc}, // <-- {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp index ec7bb470235..54e083b48f0 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp @@ -83,31 +83,25 @@ PyObject* KX_ConstraintWrapper::PySetParam(PyObject* args, PyObject* kwds) //python specific stuff PyTypeObject KX_ConstraintWrapper::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_ConstraintWrapper", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &PyObjectPlus::Type, - 0,0,0,0,0,0, - py_base_new + "KX_ConstraintWrapper", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &PyObjectPlus::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef KX_ConstraintWrapper::Methods[] = { diff --git a/source/gameengine/Ketsji/KX_Dome.h b/source/gameengine/Ketsji/KX_Dome.h index 20b60ef0173..9ff33fe2852 100644 --- a/source/gameengine/Ketsji/KX_Dome.h +++ b/source/gameengine/Ketsji/KX_Dome.h @@ -18,7 +18,7 @@ http://www.gnu.org/copyleft/lesser.txt. Contributor(s): Dalai Felinto This source uses some of the ideas and code from Paul Bourke. -Developed as part of a Research and Development project for SAT - La Société des arts technologiques. +Developed as part of a Research and Development project for SAT - La Soci�t� des arts technologiques. ----------------------------------------------------------------------------- */ @@ -78,7 +78,7 @@ public: bool fboSupported; //openGL names: - GLuint domefacesId[7]; // ID of the images -- room for 7 images, using only 4 for 180º x 360º dome, 6 for panoramic and +1 for warp mesh + GLuint domefacesId[7]; // ID of the images -- room for 7 images, using only 4 for 180� x 360� dome, 6 for panoramic and +1 for warp mesh GLuint dlistId; // ID of the Display Lists of the images (used as an offset) typedef struct { @@ -184,6 +184,13 @@ protected: RAS_IRenderTools* m_rendertools; /// engine KX_KetsjiEngine* m_engine; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_Dome"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Ketsji/KX_EmptyObject.h b/source/gameengine/Ketsji/KX_EmptyObject.h index 62aa7fcd017..fa405e20076 100644 --- a/source/gameengine/Ketsji/KX_EmptyObject.h +++ b/source/gameengine/Ketsji/KX_EmptyObject.h @@ -37,7 +37,13 @@ public: KX_GameObject(sgReplicationInfo,callbacks) {}; virtual ~KX_EmptyObject(); - + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_EmptyObject"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_EMPTYOBJECT diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp index 560c7fa4bb4..3f67de1e9a9 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.cpp +++ b/source/gameengine/Ketsji/KX_GameActuator.cpp @@ -207,38 +207,32 @@ bool KX_GameActuator::Update() /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_GameActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_GameActuator", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &SCA_IActuator::Type, - 0,0,0,0,0,0, - py_base_new + "KX_GameActuator", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &SCA_IActuator::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef KX_GameActuator::Methods[] = { // Deprecated -----> - {"getFile", (PyCFunction) KX_GameActuator::sPyGetFile, METH_VARARGS, (PY_METHODCHAR)GetFile_doc}, - {"setFile", (PyCFunction) KX_GameActuator::sPySetFile, METH_VARARGS, (PY_METHODCHAR)SetFile_doc}, + {"getFile", (PyCFunction) KX_GameActuator::sPyGetFile, METH_VARARGS, (const char *)GetFile_doc}, + {"setFile", (PyCFunction) KX_GameActuator::sPySetFile, METH_VARARGS, (const char *)SetFile_doc}, // <----- {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 170b7405145..146b83abd17 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -101,7 +101,6 @@ KX_GameObject::KX_GameObject( m_bOccluder(false), m_pPhysicsController1(NULL), m_pGraphicController(NULL), - m_pPhysicsEnvironment(NULL), m_xray(false), m_pHitObject(NULL), m_isDeformable(false), @@ -1682,37 +1681,31 @@ PySequenceMethods KX_GameObject::Sequence = { }; PyTypeObject KX_GameObject::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_GameObject", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0, - &Sequence, - &Mapping, - 0,0,0, - NULL, - NULL, - 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &SCA_IObject::Type, - 0,0,0,0,0,0, - py_base_new + "KX_GameObject", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0, + &Sequence, + &Mapping, + 0,0,0, + NULL, + NULL, + 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &SCA_IObject::Type, + 0,0,0,0,0,0, + py_base_new }; PyObject* KX_GameObject::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -2693,8 +2686,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, toDir.normalize(); toPoint = fromPoint + (dist) * toDir; } - - PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment(); + PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment(); KX_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); if (!spc && parent) @@ -2821,7 +2813,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, return none_tuple_3(); } - PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment(); + PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment(); KX_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); if (!spc && parent) diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index b235464259f..ba7451fdeef 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -98,8 +98,6 @@ protected: KX_IPhysicsController* m_pPhysicsController1; PHY_IGraphicController* m_pGraphicController; - // used for ray casting - PHY_IPhysicsEnvironment* m_pPhysicsEnvironment; STR_String m_testPropName; bool m_xray; KX_GameObject* m_pHitObject; @@ -337,20 +335,6 @@ public: bool ang_vel_local ); - - /** - * @return a pointer to the physics environment in use during the game, for rayCasting - */ - PHY_IPhysicsEnvironment* GetPhysicsEnvironment() - { - return m_pPhysicsEnvironment; - } - - void SetPhysicsEnvironment(PHY_IPhysicsEnvironment* physicsEnvironment) - { - m_pPhysicsEnvironment = physicsEnvironment; - } - /** * @return a pointer to the physics controller owned by this class. */ diff --git a/source/gameengine/Ketsji/KX_IInterpolator.h b/source/gameengine/Ketsji/KX_IInterpolator.h index 8c899a4db0b..52b9b3be5af 100644 --- a/source/gameengine/Ketsji/KX_IInterpolator.h +++ b/source/gameengine/Ketsji/KX_IInterpolator.h @@ -31,11 +31,22 @@ #include +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class KX_IInterpolator { public: virtual ~KX_IInterpolator() {} virtual void Execute(float currentTime) const = 0; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_IInterpolator"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; typedef std::vector T_InterpolatorList; diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.h b/source/gameengine/Ketsji/KX_IPO_SGController.h index 031b74294ce..68a74c3a364 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.h +++ b/source/gameengine/Ketsji/KX_IPO_SGController.h @@ -116,6 +116,12 @@ public: m_ipotime = time; m_modified = true; } + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_IpoSGController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__IPO_SGCONTROLLER_H diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h index 81c01045071..f9dcf81bca5 100644 --- a/source/gameengine/Ketsji/KX_IPhysicsController.h +++ b/source/gameengine/Ketsji/KX_IPhysicsController.h @@ -126,6 +126,13 @@ public: // call from scene graph to update virtual bool Update(double time)=0; void* GetUserData() { return m_userdata;} + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_IPhysicsController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_IPHYSICSCONTROLLER_H diff --git a/source/gameengine/Ketsji/KX_IScalarInterpolator.h b/source/gameengine/Ketsji/KX_IScalarInterpolator.h index 6ba685885e9..ec6183b88a1 100644 --- a/source/gameengine/Ketsji/KX_IScalarInterpolator.h +++ b/source/gameengine/Ketsji/KX_IScalarInterpolator.h @@ -29,11 +29,22 @@ #ifndef KX_ISCALARINTERPOLATOR_H #define KX_ISCALARINTERPOLATOR_H +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class KX_IScalarInterpolator { public: virtual ~KX_IScalarInterpolator() {} virtual float GetValue(float currentTime) const = 0; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_IScalarInterpolator"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h index 45b3276e98c..f098b0bebf5 100644 --- a/source/gameengine/Ketsji/KX_ISceneConverter.h +++ b/source/gameengine/Ketsji/KX_ISceneConverter.h @@ -32,6 +32,10 @@ #include "STR_String.h" #include "KX_Python.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + struct Scene; class KX_ISceneConverter @@ -80,6 +84,13 @@ public: virtual bool GetGLSLMaterials()=0; virtual struct Scene* GetBlenderSceneForName(const STR_String& name)=0; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_ISceneConverter"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_ISCENECONVERTER_H diff --git a/source/gameengine/Ketsji/KX_ISystem.h b/source/gameengine/Ketsji/KX_ISystem.h index 204e116e822..deee91f62e8 100644 --- a/source/gameengine/Ketsji/KX_ISystem.h +++ b/source/gameengine/Ketsji/KX_ISystem.h @@ -37,6 +37,10 @@ using namespace std; #include "STR_String.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + /** * System Abstraction, needed only for getting some timing stuff from the host. */ @@ -47,6 +51,13 @@ public: virtual ~KX_ISystem() {}; virtual double GetTimeInSeconds()=0; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_ISystem"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index 73a370a1681..e4eaff4f401 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -412,13 +412,7 @@ int KX_IpoActuator::string2mode(char* modename) { /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_IpoActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_IpoActuator", sizeof(PyObjectPlus_Proxy), 0, @@ -441,20 +435,20 @@ PyTypeObject KX_IpoActuator::Type = { PyMethodDef KX_IpoActuator::Methods[] = { // deprecated - {"set", (PyCFunction) KX_IpoActuator::sPySet, METH_VARARGS, (PY_METHODCHAR)Set_doc}, - {"setProperty", (PyCFunction) KX_IpoActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, - {"setStart", (PyCFunction) KX_IpoActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc}, - {"getStart", (PyCFunction) KX_IpoActuator::sPyGetStart, METH_NOARGS, (PY_METHODCHAR)GetStart_doc}, - {"setEnd", (PyCFunction) KX_IpoActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc}, - {"getEnd", (PyCFunction) KX_IpoActuator::sPyGetEnd, METH_NOARGS, (PY_METHODCHAR)GetEnd_doc}, - {"setIpoAsForce", (PyCFunction) KX_IpoActuator::sPySetIpoAsForce, METH_VARARGS, (PY_METHODCHAR)SetIpoAsForce_doc}, - {"getIpoAsForce", (PyCFunction) KX_IpoActuator::sPyGetIpoAsForce, METH_NOARGS, (PY_METHODCHAR)GetIpoAsForce_doc}, - {"setIpoAdd", (PyCFunction) KX_IpoActuator::sPySetIpoAdd, METH_VARARGS, (PY_METHODCHAR)SetIpoAdd_doc}, - {"getIpoAdd", (PyCFunction) KX_IpoActuator::sPyGetIpoAdd, METH_NOARGS, (PY_METHODCHAR)GetIpoAdd_doc}, - {"setForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPySetForceIpoActsLocal, METH_VARARGS, (PY_METHODCHAR)SetForceIpoActsLocal_doc}, - {"getForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPyGetForceIpoActsLocal, METH_NOARGS, (PY_METHODCHAR)GetForceIpoActsLocal_doc}, - {"setType", (PyCFunction) KX_IpoActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc}, - {"getType", (PyCFunction) KX_IpoActuator::sPyGetType, METH_NOARGS, (PY_METHODCHAR)GetType_doc}, + {"set", (PyCFunction) KX_IpoActuator::sPySet, METH_VARARGS, (const char *)Set_doc}, + {"setProperty", (PyCFunction) KX_IpoActuator::sPySetProperty, METH_VARARGS, (const char *)SetProperty_doc}, + {"setStart", (PyCFunction) KX_IpoActuator::sPySetStart, METH_VARARGS, (const char *)SetStart_doc}, + {"getStart", (PyCFunction) KX_IpoActuator::sPyGetStart, METH_NOARGS, (const char *)GetStart_doc}, + {"setEnd", (PyCFunction) KX_IpoActuator::sPySetEnd, METH_VARARGS, (const char *)SetEnd_doc}, + {"getEnd", (PyCFunction) KX_IpoActuator::sPyGetEnd, METH_NOARGS, (const char *)GetEnd_doc}, + {"setIpoAsForce", (PyCFunction) KX_IpoActuator::sPySetIpoAsForce, METH_VARARGS, (const char *)SetIpoAsForce_doc}, + {"getIpoAsForce", (PyCFunction) KX_IpoActuator::sPyGetIpoAsForce, METH_NOARGS, (const char *)GetIpoAsForce_doc}, + {"setIpoAdd", (PyCFunction) KX_IpoActuator::sPySetIpoAdd, METH_VARARGS, (const char *)SetIpoAdd_doc}, + {"getIpoAdd", (PyCFunction) KX_IpoActuator::sPyGetIpoAdd, METH_NOARGS, (const char *)GetIpoAdd_doc}, + {"setForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPySetForceIpoActsLocal, METH_VARARGS, (const char *)SetForceIpoActsLocal_doc}, + {"getForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPyGetForceIpoActsLocal, METH_NOARGS, (const char *)GetForceIpoActsLocal_doc}, + {"setType", (PyCFunction) KX_IpoActuator::sPySetType, METH_VARARGS, (const char *)SetType_doc}, + {"getType", (PyCFunction) KX_IpoActuator::sPyGetType, METH_NOARGS, (const char *)GetType_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index da72fe2fa50..13643e3a1ac 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -61,8 +61,7 @@ #include "KX_PyConstraintBinding.h" #include "PHY_IPhysicsEnvironment.h" -#include "SND_Scene.h" -#include "SND_IAudioDevice.h" +#include "AUD_C-API.h" #include "NG_NetworkScene.h" #include "NG_NetworkDeviceInterface.h" @@ -113,7 +112,6 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_rendertools(NULL), m_sceneconverter(NULL), m_networkdevice(NULL), - m_audiodevice(NULL), m_pythondictionary(NULL), m_keyboarddevice(NULL), m_mousedevice(NULL), @@ -211,15 +209,6 @@ void KX_KetsjiEngine::SetNetworkDevice(NG_NetworkDeviceInterface* networkdevice) } - -void KX_KetsjiEngine::SetAudioDevice(SND_IAudioDevice* audiodevice) -{ - MT_assert(audiodevice); - m_audiodevice = audiodevice; -} - - - void KX_KetsjiEngine::SetCanvas(RAS_ICanvas* canvas) { MT_assert(canvas); @@ -690,10 +679,7 @@ else if (m_networkdevice) m_networkdevice->NextFrame(); - - if (m_audiodevice) - m_audiodevice->NextFrame(); - + // scene management ProcessScheduledScenes(); @@ -970,13 +956,40 @@ void KX_KetsjiEngine::DoSound(KX_Scene* scene) MT_Vector3 listenervelocity = cam->GetLinearVelocity(); MT_Matrix3x3 listenerorientation = cam->NodeGetWorldOrientation(); - SND_Scene* soundscene = scene->GetSoundScene(); - soundscene->SetListenerTransform( - listenerposition, - listenervelocity, - listenerorientation); + { + AUD_3DData data; + float f; - soundscene->Proceed(); + listenerorientation.getValue3x3(data.orientation); + listenerposition.getValue(data.position); + listenervelocity.getValue(data.velocity); + + f = data.position[1]; + data.position[1] = data.position[2]; + data.position[2] = -f; + + f = data.velocity[1]; + data.velocity[1] = data.velocity[2]; + data.velocity[2] = -f; + + f = data.orientation[1]; + data.orientation[1] = data.orientation[2]; + data.orientation[2] = -f; + + f = data.orientation[3]; + data.orientation[3] = -data.orientation[6]; + data.orientation[6] = f; + + f = data.orientation[4]; + data.orientation[4] = -data.orientation[8]; + data.orientation[8] = -f; + + f = data.orientation[5]; + data.orientation[5] = data.orientation[7]; + data.orientation[7] = f; + + AUD_updateListener(&data); + } } @@ -1595,7 +1608,6 @@ KX_Scene* KX_KetsjiEngine::CreateScene(const STR_String& scenename) KX_Scene* tmpscene = new KX_Scene(m_keyboarddevice, m_mousedevice, m_networkdevice, - m_audiodevice, scenename, scene); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index abba23ca376..acb9e53df8a 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -70,7 +70,6 @@ private: class RAS_IRenderTools* m_rendertools; class KX_ISceneConverter* m_sceneconverter; class NG_NetworkDeviceInterface* m_networkdevice; - class SND_IAudioDevice* m_audiodevice; PyObject* m_pythondictionary; class SCA_IInputDevice* m_keyboarddevice; class SCA_IInputDevice* m_mousedevice; @@ -191,7 +190,6 @@ private: void DoSound(KX_Scene* scene); public: - KX_KetsjiEngine(class KX_ISystem* system); virtual ~KX_KetsjiEngine(); @@ -200,7 +198,6 @@ public: void SetKeyboardDevice(SCA_IInputDevice* keyboarddevice); void SetMouseDevice(SCA_IInputDevice* mousedevice); void SetNetworkDevice(NG_NetworkDeviceInterface* networkdevice); - void SetAudioDevice(SND_IAudioDevice* audiodevice); void SetCanvas(RAS_ICanvas* canvas); void SetRenderTools(RAS_IRenderTools* rendertools); void SetRasterizer(RAS_IRasterizer* rasterizer); @@ -398,6 +395,13 @@ protected: bool BeginFrame(); void ClearFrame(); void EndFrame(); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_KetsjiEngine"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_KETSJI_ENGINE diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index fb385f8a9a2..85c495bc2bd 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -269,37 +269,31 @@ void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras) /* ------------------------------------------------------------------------- */ PyTypeObject KX_LightObject::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_LightObject", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0, - &KX_GameObject::Sequence, - &KX_GameObject::Mapping, - 0,0,0, - NULL, - NULL, - 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &KX_GameObject::Type, - 0,0,0,0,0,0, - py_base_new + "KX_LightObject", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0, + &KX_GameObject::Sequence, + &KX_GameObject::Mapping, + 0,0,0, + NULL, + NULL, + 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &KX_GameObject::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef KX_LightObject::Methods[] = { diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.h b/source/gameengine/Ketsji/KX_LightIpoSGController.h index 98870cf5b3f..811dba5dba8 100644 --- a/source/gameengine/Ketsji/KX_LightIpoSGController.h +++ b/source/gameengine/Ketsji/KX_LightIpoSGController.h @@ -92,6 +92,13 @@ public: }; void AddInterpolator(KX_IInterpolator* interp); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_LightIpoSGController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // KX_LIGHTIPOSGCONTROLLER_H diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.h b/source/gameengine/Ketsji/KX_MaterialIpoController.h index 4d2e258bf94..906c12426eb 100644 --- a/source/gameengine/Ketsji/KX_MaterialIpoController.h +++ b/source/gameengine/Ketsji/KX_MaterialIpoController.h @@ -50,6 +50,13 @@ public: void AddInterpolator(KX_IInterpolator* interp); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_MaterialIpoController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index ea9bc3e0fbc..e15847fe6c6 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -46,13 +46,7 @@ #include "PyObjectPlus.h" PyTypeObject KX_MeshProxy::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_MeshProxy", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/Ketsji/KX_MotionState.h b/source/gameengine/Ketsji/KX_MotionState.h index 0e43e88fbeb..63c265aa8a7 100644 --- a/source/gameengine/Ketsji/KX_MotionState.h +++ b/source/gameengine/Ketsji/KX_MotionState.h @@ -31,6 +31,10 @@ #include "PHY_IMotionState.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class KX_MotionState : public PHY_IMotionState { class SG_Spatial* m_node; @@ -48,6 +52,12 @@ public: virtual void setWorldOrientation(const float* ori); virtual void calculateWorldTransformations(); + + +#ifdef WITH_CXX_GUARDEDALLOC + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_MotionState"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_MOTIONSTATE diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index ba4b47cb03f..58053e1038d 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -339,13 +339,7 @@ const MT_Vector3& KX_MouseFocusSensor::HitNormal() const /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_MouseFocusSensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_MouseFocusSensor", sizeof(PyObjectPlus_Proxy), 0, @@ -367,12 +361,12 @@ PyTypeObject KX_MouseFocusSensor::Type = { }; PyMethodDef KX_MouseFocusSensor::Methods[] = { - {"getRayTarget", (PyCFunction) KX_MouseFocusSensor::sPyGetRayTarget, METH_NOARGS, (PY_METHODCHAR)GetRayTarget_doc}, - {"getRaySource", (PyCFunction) KX_MouseFocusSensor::sPyGetRaySource, METH_NOARGS, (PY_METHODCHAR)GetRaySource_doc}, - {"getHitObject",(PyCFunction) KX_MouseFocusSensor::sPyGetHitObject,METH_NOARGS, (PY_METHODCHAR)GetHitObject_doc}, - {"getHitPosition",(PyCFunction) KX_MouseFocusSensor::sPyGetHitPosition,METH_NOARGS, (PY_METHODCHAR)GetHitPosition_doc}, - {"getHitNormal",(PyCFunction) KX_MouseFocusSensor::sPyGetHitNormal,METH_NOARGS, (PY_METHODCHAR)GetHitNormal_doc}, - {"getRayDirection",(PyCFunction) KX_MouseFocusSensor::sPyGetRayDirection,METH_NOARGS, (PY_METHODCHAR)GetRayDirection_doc}, + {"getRayTarget", (PyCFunction) KX_MouseFocusSensor::sPyGetRayTarget, METH_NOARGS, (const char *)GetRayTarget_doc}, + {"getRaySource", (PyCFunction) KX_MouseFocusSensor::sPyGetRaySource, METH_NOARGS, (const char *)GetRaySource_doc}, + {"getHitObject",(PyCFunction) KX_MouseFocusSensor::sPyGetHitObject,METH_NOARGS, (const char *)GetHitObject_doc}, + {"getHitPosition",(PyCFunction) KX_MouseFocusSensor::sPyGetHitPosition,METH_NOARGS, (const char *)GetHitPosition_doc}, + {"getHitNormal",(PyCFunction) KX_MouseFocusSensor::sPyGetHitNormal,METH_NOARGS, (const char *)GetHitNormal_doc}, + {"getRayDirection",(PyCFunction) KX_MouseFocusSensor::sPyGetRayDirection,METH_NOARGS, (const char *)GetRayDirection_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index 6871aeebc76..f7baacdfa61 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -252,13 +252,7 @@ bool KX_NearSensor::NewHandleCollision(void* obj1,void* obj2,const PHY_CollData /* ------------------------------------------------------------------------- */ PyTypeObject KX_NearSensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_NearSensor", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h index 6d63dd77683..a32d027be9c 100644 --- a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h +++ b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h @@ -67,6 +67,13 @@ public: void AddInterpolator(KX_IInterpolator* interp); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_ObColorIpoSGController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // KX_OBCOLORIPOSGCONTROLLER_H diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index ae340d12be4..2ee30ee0bfa 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -325,13 +325,7 @@ bool KX_ObjectActuator::isValid(KX_ObjectActuator::KX_OBJECT_ACT_VEC_TYPE type) /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_ObjectActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_ObjectActuator", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.h b/source/gameengine/Ketsji/KX_OrientationInterpolator.h index 2bd9f69d824..d8ecc74277c 100644 --- a/source/gameengine/Ketsji/KX_OrientationInterpolator.h +++ b/source/gameengine/Ketsji/KX_OrientationInterpolator.h @@ -50,6 +50,13 @@ public: private: MT_Matrix3x3& m_target; KX_IScalarInterpolator *m_ipos[3]; + + +#ifdef WITH_CXX_GUARDEDALLOC +private: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_OrientationInterpolator"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index befa2aaff56..621aeea87be 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -140,13 +140,7 @@ bool KX_ParentActuator::Update() /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_ParentActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_ParentActuator", sizeof(PyObjectPlus_Proxy), 0, @@ -169,8 +163,8 @@ PyTypeObject KX_ParentActuator::Type = { PyMethodDef KX_ParentActuator::Methods[] = { // Deprecated -----> - {"setObject", (PyCFunction) KX_ParentActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc}, - {"getObject", (PyCFunction) KX_ParentActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc}, + {"setObject", (PyCFunction) KX_ParentActuator::sPySetObject, METH_O, (const char *)SetObject_doc}, + {"getObject", (PyCFunction) KX_ParentActuator::sPyGetObject, METH_VARARGS, (const char *)GetObject_doc}, // <----- {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp index 7bce311f1b6..edb19002671 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp @@ -113,31 +113,25 @@ PyAttributeDef KX_PhysicsObjectWrapper::Attributes[] = { //python specific stuff PyTypeObject KX_PhysicsObjectWrapper::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_PhysicsObjectWrapper", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &PyObjectPlus::Type, - 0,0,0,0,0,0, - py_base_new + "KX_PhysicsObjectWrapper", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &PyObjectPlus::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef KX_PhysicsObjectWrapper::Methods[] = { diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index a1571b17756..eae1894428c 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -39,13 +39,7 @@ #include "KX_PyMath.h" PyTypeObject KX_PolyProxy::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_PolyProxy", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index a48d3f15bce..5b4322ae4cd 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -148,7 +148,7 @@ void KX_PolygonMaterial::DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& c if (GetCachingInfo() != cachingInfo) { if (!cachingInfo) - GPU_set_tpage(NULL); + GPU_set_tpage(NULL, 0); cachingInfo = GetCachingInfo(); @@ -156,10 +156,10 @@ void KX_PolygonMaterial::DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& c { Image *ima = (Image*)m_tface->tpage; GPU_update_image_time(ima, rasty->GetTime()); - GPU_set_tpage(m_tface); + GPU_set_tpage(m_tface, 1); } else - GPU_set_tpage(NULL); + GPU_set_tpage(NULL, 0); if(m_drawingmode & RAS_IRasterizer::KX_TWOSIDE) rasty->SetCullFace(false); @@ -238,31 +238,25 @@ PyAttributeDef KX_PolygonMaterial::Attributes[] = { }; PyTypeObject KX_PolygonMaterial::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_PolygonMaterial", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &PyObjectPlus::Type, - 0,0,0,0,0,0, - py_base_new + "KX_PolygonMaterial", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &PyObjectPlus::Type, + 0,0,0,0,0,0, + py_base_new }; KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setCustomMaterial, "setCustomMaterial(material)") @@ -303,7 +297,7 @@ KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setTexture, "setTexture(tface)") if (PyArg_ParseTuple(args, "O!:setTexture", &PyCObject_Type, &pytface)) { MTFace *tface = (MTFace*) PyCObject_AsVoidPtr(pytface); - GPU_set_tpage(tface); + GPU_set_tpage(tface, 1); Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h index 266b4d7e789..dc42bd2f81b 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.h +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h @@ -35,6 +35,10 @@ #include "RAS_IRasterizer.h" #include "DNA_ID.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + struct MTFace; struct Material; struct MTex; @@ -57,6 +61,7 @@ private: mutable int m_pass; public: + KX_PolygonMaterial(); void Initialize(const STR_String &texname, Material* ma, diff --git a/source/gameengine/Ketsji/KX_PositionInterpolator.h b/source/gameengine/Ketsji/KX_PositionInterpolator.h index bff0b4201c2..f6c6fa98a0e 100644 --- a/source/gameengine/Ketsji/KX_PositionInterpolator.h +++ b/source/gameengine/Ketsji/KX_PositionInterpolator.h @@ -50,6 +50,13 @@ public: private: MT_Point3& m_target; KX_IScalarInterpolator *m_ipos[3]; + + +#ifdef WITH_CXX_GUARDEDALLOC +private: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_PositionInterpolator"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index 94e8d1fd583..04cec3c9106 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -542,62 +542,60 @@ static PyObject* gPyRemoveConstraint(PyObject* self, static struct PyMethodDef physicsconstraints_methods[] = { {"setGravity",(PyCFunction) gPySetGravity, - METH_VARARGS, (PY_METHODCHAR)gPySetGravity__doc__}, + METH_VARARGS, (const char *)gPySetGravity__doc__}, {"setDebugMode",(PyCFunction) gPySetDebugMode, - METH_VARARGS, (PY_METHODCHAR)gPySetDebugMode__doc__}, + METH_VARARGS, (const char *)gPySetDebugMode__doc__}, /// settings that influence quality of the rigidbody dynamics {"setNumIterations",(PyCFunction) gPySetNumIterations, - METH_VARARGS, (PY_METHODCHAR)gPySetNumIterations__doc__}, + METH_VARARGS, (const char *)gPySetNumIterations__doc__}, {"setNumTimeSubSteps",(PyCFunction) gPySetNumTimeSubSteps, - METH_VARARGS, (PY_METHODCHAR)gPySetNumTimeSubSteps__doc__}, + METH_VARARGS, (const char *)gPySetNumTimeSubSteps__doc__}, {"setDeactivationTime",(PyCFunction) gPySetDeactivationTime, - METH_VARARGS, (PY_METHODCHAR)gPySetDeactivationTime__doc__}, + METH_VARARGS, (const char *)gPySetDeactivationTime__doc__}, {"setDeactivationLinearTreshold",(PyCFunction) gPySetDeactivationLinearTreshold, - METH_VARARGS, (PY_METHODCHAR)gPySetDeactivationLinearTreshold__doc__}, + METH_VARARGS, (const char *)gPySetDeactivationLinearTreshold__doc__}, {"setDeactivationAngularTreshold",(PyCFunction) gPySetDeactivationAngularTreshold, - METH_VARARGS, (PY_METHODCHAR)gPySetDeactivationAngularTreshold__doc__}, + METH_VARARGS, (const char *)gPySetDeactivationAngularTreshold__doc__}, {"setContactBreakingTreshold",(PyCFunction) gPySetContactBreakingTreshold, - METH_VARARGS, (PY_METHODCHAR)gPySetContactBreakingTreshold__doc__}, + METH_VARARGS, (const char *)gPySetContactBreakingTreshold__doc__}, {"setCcdMode",(PyCFunction) gPySetCcdMode, - METH_VARARGS, (PY_METHODCHAR)gPySetCcdMode__doc__}, + METH_VARARGS, (const char *)gPySetCcdMode__doc__}, {"setSorConstant",(PyCFunction) gPySetSorConstant, - METH_VARARGS, (PY_METHODCHAR)gPySetSorConstant__doc__}, + METH_VARARGS, (const char *)gPySetSorConstant__doc__}, {"setSolverTau",(PyCFunction) gPySetSolverTau, - METH_VARARGS, (PY_METHODCHAR)gPySetSolverTau__doc__}, + METH_VARARGS, (const char *)gPySetSolverTau__doc__}, {"setSolverDamping",(PyCFunction) gPySetSolverDamping, - METH_VARARGS, (PY_METHODCHAR)gPySetSolverDamping__doc__}, + METH_VARARGS, (const char *)gPySetSolverDamping__doc__}, {"setLinearAirDamping",(PyCFunction) gPySetLinearAirDamping, - METH_VARARGS, (PY_METHODCHAR)gPySetLinearAirDamping__doc__}, + METH_VARARGS, (const char *)gPySetLinearAirDamping__doc__}, {"setUseEpa",(PyCFunction) gPySetUseEpa, - METH_VARARGS, (PY_METHODCHAR)gPySetUseEpa__doc__}, + METH_VARARGS, (const char *)gPySetUseEpa__doc__}, {"setSolverType",(PyCFunction) gPySetSolverType, - METH_VARARGS, (PY_METHODCHAR)gPySetSolverType__doc__}, + METH_VARARGS, (const char *)gPySetSolverType__doc__}, {"createConstraint",(PyCFunction) gPyCreateConstraint, - METH_VARARGS, (PY_METHODCHAR)gPyCreateConstraint__doc__}, + METH_VARARGS, (const char *)gPyCreateConstraint__doc__}, {"getVehicleConstraint",(PyCFunction) gPyGetVehicleConstraint, - METH_VARARGS, (PY_METHODCHAR)gPyGetVehicleConstraint__doc__}, + METH_VARARGS, (const char *)gPyGetVehicleConstraint__doc__}, {"removeConstraint",(PyCFunction) gPyRemoveConstraint, - METH_VARARGS, (PY_METHODCHAR)gPyRemoveConstraint__doc__}, + METH_VARARGS, (const char *)gPyRemoveConstraint__doc__}, {"getAppliedImpulse",(PyCFunction) gPyGetAppliedImpulse, - METH_VARARGS, (PY_METHODCHAR)gPyGetAppliedImpulse__doc__}, + METH_VARARGS, (const char *)gPyGetAppliedImpulse__doc__}, //sentinel { NULL, (PyCFunction) NULL, 0, NULL } }; - -#if (PY_VERSION_HEX >= 0x03000000) static struct PyModuleDef PhysicsConstraints_module_def = { {}, /* m_base */ "PhysicsConstraints", /* m_name */ @@ -609,7 +607,6 @@ static struct PyModuleDef PhysicsConstraints_module_def = { 0, /* m_clear */ 0, /* m_free */ }; -#endif PyObject* initPythonConstraintBinding() { @@ -627,15 +624,9 @@ PyObject* initPythonConstraintBinding() } else { PyErr_Clear(); - -#if (PY_VERSION_HEX >= 0x03000000) + m = PyModule_Create(&PhysicsConstraints_module_def); PyDict_SetItemString(PySys_GetObject("modules"), PhysicsConstraints_module_def.m_name, m); -#else - m = Py_InitModule4("PhysicsConstraints", physicsconstraints_methods, - PhysicsConstraints_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); -#endif } // Add some symbolic constants to the module diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index c4110760228..de3dcd0ebf8 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -79,7 +79,6 @@ extern "C" { #include "ListValue.h" #include "InputParser.h" #include "KX_Scene.h" -#include "SND_DeviceManager.h" #include "NG_NetworkScene.h" //Needed for sendMessage() @@ -93,6 +92,7 @@ extern "C" { /* we only need this to get a list of libraries from the main struct */ #include "DNA_ID.h" +#include "DNA_scene_types.h" #include "marshal.h" /* python header for loading/saving dicts */ @@ -207,74 +207,24 @@ static PyObject* gPySendMessage(PyObject*, PyObject* args) Py_RETURN_NONE; } -static bool usedsp = false; - // this gets a pointer to an array filled with floats static PyObject* gPyGetSpectrum(PyObject*) { - SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance(); - PyObject* resultlist = PyList_New(512); - if (audiodevice) - { - if (!usedsp) - { - audiodevice->StartUsingDSP(); - usedsp = true; - } - - float* spectrum = audiodevice->GetSpectrum(); - - for (int index = 0; index < 512; index++) - { - PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(spectrum[index])); - } - } - else { - for (int index = 0; index < 512; index++) - { - PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(0.0)); - } - } + for (int index = 0; index < 512; index++) + { + PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(0.0)); + } return resultlist; } -#if 0 // unused -static PyObject* gPyStartDSP(PyObject*, PyObject* args) -{ - SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance(); - - if (!audiodevice) { - PyErr_SetString(PyExc_RuntimeError, "no audio device available"); - return NULL; - } - - if (!usedsp) { - audiodevice->StartUsingDSP(); - usedsp = true; - } - - Py_RETURN_NONE; -} -#endif - - static PyObject* gPyStopDSP(PyObject*, PyObject* args) { - SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance(); - - if (!audiodevice) { - PyErr_SetString(PyExc_RuntimeError, "no audio device available"); - return NULL; - } - - if (usedsp) { - audiodevice->StopUsingDSP(); - usedsp = true; - } + PyErr_SetString(PyExc_RuntimeError, "no audio device available"); + return NULL; Py_RETURN_NONE; } @@ -525,34 +475,34 @@ static PyObject *gEvalExpression(PyObject*, PyObject* value) static struct PyMethodDef game_methods[] = { - {"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, (PY_METHODCHAR)gPyExpandPath_doc}, - {"sendMessage", (PyCFunction)gPySendMessage, METH_VARARGS, (PY_METHODCHAR)gPySendMessage_doc}, + {"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, (const char *)gPyExpandPath_doc}, + {"sendMessage", (PyCFunction)gPySendMessage, METH_VARARGS, (const char *)gPySendMessage_doc}, {"getCurrentController", (PyCFunction) SCA_PythonController::sPyGetCurrentController, - METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::sPyGetCurrentController__doc__}, + METH_NOARGS, (const char *)SCA_PythonController::sPyGetCurrentController__doc__}, {"getCurrentScene", (PyCFunction) gPyGetCurrentScene, - METH_NOARGS, (PY_METHODCHAR)gPyGetCurrentScene_doc.Ptr()}, + METH_NOARGS, (const char *)gPyGetCurrentScene_doc.Ptr()}, {"getSceneList", (PyCFunction) gPyGetSceneList, - METH_NOARGS, (PY_METHODCHAR)gPyGetSceneList_doc.Ptr()}, + METH_NOARGS, (const char *)gPyGetSceneList_doc.Ptr()}, {"addActiveActuator",(PyCFunction) SCA_PythonController::sPyAddActiveActuator, - METH_VARARGS, (PY_METHODCHAR)SCA_PythonController::sPyAddActiveActuator__doc__}, + METH_VARARGS, (const char *)SCA_PythonController::sPyAddActiveActuator__doc__}, {"getRandomFloat",(PyCFunction) gPyGetRandomFloat, - METH_NOARGS, (PY_METHODCHAR)gPyGetRandomFloat_doc.Ptr()}, - {"setGravity",(PyCFunction) gPySetGravity, METH_O, (PY_METHODCHAR)"set Gravitation"}, - {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_NOARGS, (PY_METHODCHAR)"get audio spectrum"}, - {"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS, (PY_METHODCHAR)"stop using the audio dsp (for performance reasons)"}, - {"getMaxLogicFrame", (PyCFunction) gPyGetMaxLogicFrame, METH_NOARGS, (PY_METHODCHAR)"Gets the max number of logic frame per render frame"}, - {"setMaxLogicFrame", (PyCFunction) gPySetMaxLogicFrame, METH_VARARGS, (PY_METHODCHAR)"Sets the max number of logic frame per render frame"}, - {"getMaxPhysicsFrame", (PyCFunction) gPyGetMaxPhysicsFrame, METH_NOARGS, (PY_METHODCHAR)"Gets the max number of physics frame per render frame"}, - {"setMaxPhysicsFrame", (PyCFunction) gPySetMaxPhysicsFrame, METH_VARARGS, (PY_METHODCHAR)"Sets the max number of physics farme per render frame"}, - {"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_NOARGS, (PY_METHODCHAR)"Gets the logic tic rate"}, - {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, (PY_METHODCHAR)"Sets the logic tic rate"}, - {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, (PY_METHODCHAR)"Gets the physics tic rate"}, - {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, (PY_METHODCHAR)"Sets the physics tic rate"}, - {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (PY_METHODCHAR)"Gets the estimated average frame rate"}, - {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, (PY_METHODCHAR)"Gets a list of blend files in the same directory as the current blend file"}, - {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (PY_METHODCHAR)"Prints GL Extension Info"}, - {"EvalExpression", (PyCFunction)gEvalExpression, METH_O, (PY_METHODCHAR)"Evaluate a string as a game logic expression"}, + METH_NOARGS, (const char *)gPyGetRandomFloat_doc.Ptr()}, + {"setGravity",(PyCFunction) gPySetGravity, METH_O, (const char *)"set Gravitation"}, + {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_NOARGS, (const char *)"get audio spectrum"}, + {"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS, (const char *)"stop using the audio dsp (for performance reasons)"}, + {"getMaxLogicFrame", (PyCFunction) gPyGetMaxLogicFrame, METH_NOARGS, (const char *)"Gets the max number of logic frame per render frame"}, + {"setMaxLogicFrame", (PyCFunction) gPySetMaxLogicFrame, METH_VARARGS, (const char *)"Sets the max number of logic frame per render frame"}, + {"getMaxPhysicsFrame", (PyCFunction) gPyGetMaxPhysicsFrame, METH_NOARGS, (const char *)"Gets the max number of physics frame per render frame"}, + {"setMaxPhysicsFrame", (PyCFunction) gPySetMaxPhysicsFrame, METH_VARARGS, (const char *)"Sets the max number of physics farme per render frame"}, + {"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_NOARGS, (const char *)"Gets the logic tic rate"}, + {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, (const char *)"Sets the logic tic rate"}, + {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, (const char *)"Gets the physics tic rate"}, + {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, (const char *)"Sets the physics tic rate"}, + {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (const char *)"Gets the estimated average frame rate"}, + {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, (const char *)"Gets a list of blend files in the same directory as the current blend file"}, + {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (const char *)"Prints GL Extension Info"}, + {"EvalExpression", (PyCFunction)gEvalExpression, METH_O, (const char *)"Evaluate a string as a game logic expression"}, {NULL, (PyCFunction) NULL, 0, NULL } }; @@ -818,17 +768,17 @@ static PyObject* gPyDisableMotionBlur(PyObject*) int getGLSLSettingFlag(char *setting) { if(strcmp(setting, "lights") == 0) - return G_FILE_GLSL_NO_LIGHTS; + return GAME_GLSL_NO_LIGHTS; else if(strcmp(setting, "shaders") == 0) - return G_FILE_GLSL_NO_SHADERS; + return GAME_GLSL_NO_SHADERS; else if(strcmp(setting, "shadows") == 0) - return G_FILE_GLSL_NO_SHADOWS; + return GAME_GLSL_NO_SHADOWS; else if(strcmp(setting, "ramps") == 0) - return G_FILE_GLSL_NO_RAMPS; + return GAME_GLSL_NO_RAMPS; else if(strcmp(setting, "nodes") == 0) - return G_FILE_GLSL_NO_NODES; + return GAME_GLSL_NO_NODES; else if(strcmp(setting, "extra_textures") == 0) - return G_FILE_GLSL_NO_EXTRA_TEX; + return GAME_GLSL_NO_EXTRA_TEX; else return -1; } @@ -837,8 +787,9 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, PyObject* args, PyObject*) { + GameData *gm= &(gp_KetsjiScene->GetBlenderScene()->gm); char *setting; - int enable, flag, fileflags; + int enable, flag, sceneflag; if (!PyArg_ParseTuple(args,"si:setGLSLMaterialSetting",&setting,&enable)) return NULL; @@ -850,15 +801,15 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, return NULL; } - fileflags = G.fileflags; + sceneflag= gm->flag; if (enable) - G.fileflags &= ~flag; + gm->flag &= ~flag; else - G.fileflags |= flag; + gm->flag |= flag; /* display lists and GLSL materials need to be remade */ - if(G.fileflags != fileflags) { + if(sceneflag != gm->flag) { GPU_materials_free(); if(gp_KetsjiEngine) { KX_SceneList *scenes = gp_KetsjiEngine->CurrentScenes(); @@ -879,6 +830,7 @@ static PyObject* gPyGetGLSLMaterialSetting(PyObject*, PyObject* args, PyObject*) { + GameData *gm= &(gp_KetsjiScene->GetBlenderScene()->gm); char *setting; int enabled = 0, flag; @@ -892,7 +844,7 @@ static PyObject* gPyGetGLSLMaterialSetting(PyObject*, return NULL; } - enabled = ((G.fileflags & flag) != 0); + enabled = ((gm->flag & flag) != 0); return PyLong_FromSsize_t(enabled); } @@ -904,35 +856,34 @@ static PyObject* gPySetMaterialType(PyObject*, PyObject* args, PyObject*) { - int flag, type; + GameData *gm= &(gp_KetsjiScene->GetBlenderScene()->gm); + int type; if (!PyArg_ParseTuple(args,"i:setMaterialType",&type)) return NULL; if(type == KX_BLENDER_GLSL_MATERIAL) - flag = G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL; + gm->matmode= GAME_MAT_GLSL; else if(type == KX_BLENDER_MULTITEX_MATERIAL) - flag = G_FILE_GAME_MAT; + gm->matmode= GAME_MAT_MULTITEX; else if(type == KX_TEXFACE_MATERIAL) - flag = 0; + gm->matmode= GAME_MAT_TEXFACE; else { PyErr_SetString(PyExc_ValueError, "Rasterizer.setMaterialType(int): material type is not known"); return NULL; } - G.fileflags &= ~(G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL); - G.fileflags |= flag; - Py_RETURN_NONE; } static PyObject* gPyGetMaterialType(PyObject*) { + GameData *gm= &(gp_KetsjiScene->GetBlenderScene()->gm); int flag; - if(G.fileflags & G_FILE_GAME_MAT_GLSL) + if(gm->matmode == GAME_MAT_GLSL) flag = KX_BLENDER_GLSL_MATERIAL; - else if(G.fileflags & G_FILE_GAME_MAT) + else if(gm->matmode == GAME_MAT_MULTITEX) flag = KX_BLENDER_MULTITEX_MATERIAL; else flag = KX_TEXFACE_MATERIAL; @@ -1019,7 +970,6 @@ static char Rasterizer_module_documentation[] = "This is the Python API for the game engine of Rasterizer" ; -#if (PY_VERSION_HEX >= 0x03000000) static struct PyModuleDef GameLogic_module_def = { {}, /* m_base */ "GameLogic", /* m_name */ @@ -1031,7 +981,6 @@ static struct PyModuleDef GameLogic_module_def = { 0, /* m_clear */ 0, /* m_free */ }; -#endif PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack to get gravity hook { @@ -1055,16 +1004,9 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack } else { PyErr_Clear(); - // Create the module and add the functions -#if (PY_VERSION_HEX >= 0x03000000) m = PyModule_Create(&GameLogic_module_def); PyDict_SetItemString(PySys_GetObject("modules"), GameLogic_module_def.m_name, m); -#else - m = Py_InitModule4("GameLogic", game_methods, - GameLogic_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); -#endif } // Add some symbolic constants to the module @@ -1346,18 +1288,11 @@ PyObject *KXpy_import(PyObject *self, PyObject *args) PyObject *locals = NULL; PyObject *fromlist = NULL; PyObject *l, *m, *n; - -#if (PY_VERSION_HEX >= 0x02060000) - int dummy_val; /* what does this do?*/ + int level; /* not used yet */ if (!PyArg_ParseTuple(args, "s|OOOi:m_import", - &name, &globals, &locals, &fromlist, &dummy_val)) + &name, &globals, &locals, &fromlist, &level)) return NULL; -#else - if (!PyArg_ParseTuple(args, "s|OOO:m_import", - &name, &globals, &locals, &fromlist)) - return NULL; -#endif /* check for builtin modules */ m = PyImport_AddModule("sys"); @@ -1614,7 +1549,7 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur */ static bool first_time = true; -#if (PY_VERSION_HEX < 0x03000000) +#if 0 // TODO - py3 STR_String pname = progname; Py_SetProgramName(pname.Ptr()); #endif @@ -1623,9 +1558,8 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur Py_Initialize(); if(argv && first_time) { /* browser plugins dont currently set this */ -#if (PY_VERSION_HEX < 0x03000000) - PySys_SetArgv(argc, argv); -#else + // Until python support ascii again, we use our own. + // PySys_SetArgv(argc, argv); int i; PyObject *py_argv= PyList_New(argc); @@ -1634,9 +1568,7 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur PySys_SetObject("argv", py_argv); Py_DECREF(py_argv); -#endif } - //importBlenderModules() setSandbox(level); initPyTypes(); @@ -1670,7 +1602,7 @@ void exitGamePlayerPythonScripting() */ PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level, Main *maggie) { -#if (PY_VERSION_HEX < 0x03000000) +#if 0 // XXX TODO Py3 STR_String pname = progname; Py_SetProgramName(pname.Ptr()); #endif @@ -1698,7 +1630,6 @@ void exitGamePythonScripting() } -#if (PY_VERSION_HEX >= 0x03000000) static struct PyModuleDef Rasterizer_module_def = { {}, /* m_base */ "Rasterizer", /* m_name */ @@ -1710,7 +1641,6 @@ static struct PyModuleDef Rasterizer_module_def = { 0, /* m_clear */ 0, /* m_free */ }; -#endif PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) { @@ -1733,14 +1663,8 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) PyErr_Clear(); // Create the module and add the functions -#if (PY_VERSION_HEX >= 0x03000000) m = PyModule_Create(&Rasterizer_module_def); PyDict_SetItemString(PySys_GetObject("modules"), Rasterizer_module_def.m_name, m); -#else - m = Py_InitModule4("Rasterizer", rasterizer_methods, - Rasterizer_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); -#endif } // Add some symbolic constants to the module @@ -1791,12 +1715,7 @@ static PyObject* gPyEventToString(PyObject*, PyObject* value) dict = PyModule_GetDict(mod); while (PyDict_Next(dict, &pos, &key, &val)) { -#if (PY_VERSION_HEX >= 0x03000000) if (PyObject_RichCompareBool(value, val, Py_EQ)) { -#else - if (PyObject_Compare(value, val)==0) { -#endif - ret = key; break; } @@ -1832,13 +1751,11 @@ static PyObject* gPyEventToCharacter(PyObject*, PyObject* args) static struct PyMethodDef gamekeys_methods[] = { - {"EventToCharacter", (PyCFunction)gPyEventToCharacter, METH_VARARGS, (PY_METHODCHAR)gPyEventToCharacter_doc}, - {"EventToString", (PyCFunction)gPyEventToString, METH_O, (PY_METHODCHAR)gPyEventToString_doc}, + {"EventToCharacter", (PyCFunction)gPyEventToCharacter, METH_VARARGS, (const char *)gPyEventToCharacter_doc}, + {"EventToString", (PyCFunction)gPyEventToString, METH_O, (const char *)gPyEventToString_doc}, { NULL, (PyCFunction) NULL, 0, NULL } }; - -#if (PY_VERSION_HEX >= 0x03000000) static struct PyModuleDef GameKeys_module_def = { {}, /* m_base */ "GameKeys", /* m_name */ @@ -1850,7 +1767,6 @@ static struct PyModuleDef GameKeys_module_def = { 0, /* m_clear */ 0, /* m_free */ }; -#endif PyObject* initGameKeys() { @@ -1868,14 +1784,8 @@ PyObject* initGameKeys() PyErr_Clear(); // Create the module and add the functions -#if (PY_VERSION_HEX >= 0x03000000) m = PyModule_Create(&GameKeys_module_def); PyDict_SetItemString(PySys_GetObject("modules"), GameKeys_module_def.m_name, m); -#else - m = Py_InitModule4("GameKeys", gamekeys_methods, - GameKeys_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); -#endif } // Add some symbolic constants to the module @@ -2007,17 +1917,17 @@ PyObject* initGameKeys() PyObject* initMathutils() { - return Mathutils_Init("Mathutils"); // Use as a top level module in BGE + return Mathutils_Init(); } PyObject* initGeometry() { - return Geometry_Init("Geometry"); // Use as a top level module in BGE + return Geometry_Init(); } PyObject* initBGL() { - return BGL_Init("BGL"); // Use as a top level module in BGE + return BGL_Init(); } void KX_SetActiveScene(class KX_Scene* scene) @@ -2053,13 +1963,8 @@ int saveGamePythonConfig( char **marshal_buffer) // PyObject_Print(pyGlobalDictMarshal, stderr, 0); char *marshal_cstring; -#if PY_VERSION_HEX < 0x03000000 - marshal_cstring = _PyUnicode_AsString(pyGlobalDictMarshal); - marshal_length= PyString_Size(pyGlobalDictMarshal); -#else // py3 uses byte arrays - marshal_cstring = PyBytes_AsString(pyGlobalDictMarshal); + marshal_cstring = PyBytes_AsString(pyGlobalDictMarshal); // py3 uses byte arrays marshal_length= PyBytes_Size(pyGlobalDictMarshal); -#endif *marshal_buffer = new char[marshal_length + 1]; memcpy(*marshal_buffer, marshal_cstring, marshal_length); Py_DECREF(pyGlobalDictMarshal); diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp index 8ff0bfd5379..5260c0bb01a 100644 --- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp +++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp @@ -36,7 +36,6 @@ #include "BL_BlenderShader.h" #include "BL_ShapeActionActuator.h" #include "KX_BlenderMaterial.h" -#include "KX_CDActuator.h" #include "KX_CameraActuator.h" #include "KX_ConstraintActuator.h" #include "KX_ConstraintWrapper.h" @@ -158,7 +157,6 @@ void initPyTypes(void) PyType_Ready_Attr(dict, CListValue, init_getset); PyType_Ready_Attr(dict, CValue, init_getset); PyType_Ready_Attr(dict, KX_BlenderMaterial, init_getset); - PyType_Ready_Attr(dict, KX_CDActuator, init_getset); PyType_Ready_Attr(dict, KX_Camera, init_getset); PyType_Ready_Attr(dict, KX_CameraActuator, init_getset); PyType_Ready_Attr(dict, KX_ConstraintActuator, init_getset); diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp index 5b4d77156db..4fc5252de60 100644 --- a/source/gameengine/Ketsji/KX_PythonSeq.cpp +++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp @@ -362,13 +362,7 @@ static PyObject *KX_PythonSeq_repr( KX_PythonSeq * self ) /* Python KX_PythonSeq_Type structure definition: */ /*****************************************************************************/ PyTypeObject KX_PythonSeq_Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif /* For printing, in format "." */ "KX_PythonSeq", /* char *tp_name; */ sizeof( KX_PythonSeq ), /* int tp_basicsize; */ @@ -380,11 +374,8 @@ PyTypeObject KX_PythonSeq_Type = { NULL, /* printfunc tp_print; */ NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ -#if PY_VERSION_HEX >= 0x03000000 // TODO - richcmp - NULL, -#else - ( cmpfunc ) KX_PythonSeq_compare, /* cmpfunc tp_compare; */ -#endif + /* TODO, richcmp */ + NULL, /* ( cmpfunc ) KX_PythonSeq_compare, /* cmpfunc tp_compare; */ ( reprfunc ) KX_PythonSeq_repr, /* reprfunc tp_repr; */ /* Method suites for standard classes */ diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 8ac94a324f2..d020a2544d2 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -226,13 +226,7 @@ PyObject* KX_RadarSensor::PyGetConeHeight() { /* Python Integration Hooks */ /* ------------------------------------------------------------------------- */ PyTypeObject KX_RadarSensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_RadarSensor", sizeof(PyObjectPlus_Proxy), 0, @@ -256,11 +250,11 @@ PyTypeObject KX_RadarSensor::Type = { PyMethodDef KX_RadarSensor::Methods[] = { //Deprecated -----> {"getConeOrigin", (PyCFunction) KX_RadarSensor::sPyGetConeOrigin, - METH_VARARGS, (PY_METHODCHAR)GetConeOrigin_doc}, + METH_VARARGS, (const char *)GetConeOrigin_doc}, {"getConeTarget", (PyCFunction) KX_RadarSensor::sPyGetConeTarget, - METH_VARARGS, (PY_METHODCHAR)GetConeTarget_doc}, + METH_VARARGS, (const char *)GetConeTarget_doc}, {"getConeHeight", (PyCFunction) KX_RadarSensor::sPyGetConeHeight, - METH_VARARGS, (PY_METHODCHAR)GetConeHeight_doc}, + METH_VARARGS, (const char *)GetConeHeight_doc}, //<----- {NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_RayCast.h b/source/gameengine/Ketsji/KX_RayCast.h index c3084c997a1..cdafc894f6c 100644 --- a/source/gameengine/Ketsji/KX_RayCast.h +++ b/source/gameengine/Ketsji/KX_RayCast.h @@ -89,6 +89,12 @@ public: const MT_Point3& topoint, KX_RayCast& callback); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_RayCast"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; template class KX_RayCast::Callback : public KX_RayCast @@ -121,7 +127,13 @@ public: } return self->NeedRayCast(info); } - + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_RayCast::Callback"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; diff --git a/source/gameengine/Ketsji/KX_RayEventManager.h b/source/gameengine/Ketsji/KX_RayEventManager.h index b816d4d5250..27c9be14d1f 100644 --- a/source/gameengine/Ketsji/KX_RayEventManager.h +++ b/source/gameengine/Ketsji/KX_RayEventManager.h @@ -45,6 +45,13 @@ public: m_logicmgr(logicmgr) {} virtual void NextFrame(); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_RayEventManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_RAYEVENTMGR diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 3f27496df71..8616145d709 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -319,13 +319,7 @@ bool KX_RaySensor::Evaluate() /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_RaySensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_RaySensor", sizeof(PyObjectPlus_Proxy), 0, @@ -349,10 +343,10 @@ PyTypeObject KX_RaySensor::Type = { PyMethodDef KX_RaySensor::Methods[] = { // Deprecated -----> - {"getHitObject",(PyCFunction) KX_RaySensor::sPyGetHitObject,METH_NOARGS, (PY_METHODCHAR)GetHitObject_doc}, - {"getHitPosition",(PyCFunction) KX_RaySensor::sPyGetHitPosition,METH_NOARGS, (PY_METHODCHAR)GetHitPosition_doc}, - {"getHitNormal",(PyCFunction) KX_RaySensor::sPyGetHitNormal,METH_NOARGS, (PY_METHODCHAR)GetHitNormal_doc}, - {"getRayDirection",(PyCFunction) KX_RaySensor::sPyGetRayDirection,METH_NOARGS, (PY_METHODCHAR)GetRayDirection_doc}, + {"getHitObject",(PyCFunction) KX_RaySensor::sPyGetHitObject,METH_NOARGS, (const char *)GetHitObject_doc}, + {"getHitPosition",(PyCFunction) KX_RaySensor::sPyGetHitPosition,METH_NOARGS, (const char *)GetHitPosition_doc}, + {"getHitNormal",(PyCFunction) KX_RaySensor::sPyGetHitNormal,METH_NOARGS, (const char *)GetHitNormal_doc}, + {"getRayDirection",(PyCFunction) KX_RaySensor::sPyGetRayDirection,METH_NOARGS, (const char *)GetRayDirection_doc}, // <----- {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index 239c4a0be67..fffb0ac1220 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -170,13 +170,7 @@ void KX_SCA_AddObjectActuator::Relink(GEN_Map *obj_map) /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_SCA_AddObjectActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_SCA_AddObjectActuator", sizeof(PyObjectPlus_Proxy), 0, @@ -199,16 +193,16 @@ PyTypeObject KX_SCA_AddObjectActuator::Type = { PyMethodDef KX_SCA_AddObjectActuator::Methods[] = { // ---> deprecated - {"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_O, (PY_METHODCHAR)SetTime_doc}, - {"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_NOARGS, (PY_METHODCHAR)GetTime_doc}, - {"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_NOARGS, (PY_METHODCHAR)GetLinearVelocity_doc}, - {"setLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetLinearVelocity, METH_VARARGS, (PY_METHODCHAR)SetLinearVelocity_doc}, - {"getAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetAngularVelocity, METH_NOARGS, (PY_METHODCHAR)GetAngularVelocity_doc}, - {"setAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetAngularVelocity, METH_VARARGS, (PY_METHODCHAR)SetAngularVelocity_doc}, + {"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_O, (const char *)SetTime_doc}, + {"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_NOARGS, (const char *)GetTime_doc}, + {"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_NOARGS, (const char *)GetLinearVelocity_doc}, + {"setLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetLinearVelocity, METH_VARARGS, (const char *)SetLinearVelocity_doc}, + {"getAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetAngularVelocity, METH_NOARGS, (const char *)GetAngularVelocity_doc}, + {"setAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetAngularVelocity, METH_VARARGS, (const char *)SetAngularVelocity_doc}, {"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_NOARGS,"getLastCreatedObject() : get the object handle to the last created object\n"}, {"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_NOARGS,"instantAddObject() : immediately add object without delay\n"}, - {"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc}, - {"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc}, + {"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_O, (const char *)SetObject_doc}, + {"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, (const char *)GetObject_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp index 423fd0db7f2..196c1915f72 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp @@ -48,13 +48,7 @@ /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_SCA_DynamicActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_SCA_DynamicActuator", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp index 47c5c3aeeeb..dd9d8015724 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp @@ -91,13 +91,7 @@ CValue* KX_SCA_EndObjectActuator::GetReplica() /* ------------------------------------------------------------------------- */ PyTypeObject KX_SCA_EndObjectActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_SCA_EndObjectActuator", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index a19b18bf0e0..0819ad99633 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -51,13 +51,7 @@ /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_SCA_ReplaceMeshActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_SCA_ReplaceMeshActuator", sizeof(PyObjectPlus_Proxy), 0, @@ -81,7 +75,7 @@ PyTypeObject KX_SCA_ReplaceMeshActuator::Type = { PyMethodDef KX_SCA_ReplaceMeshActuator::Methods[] = { KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, instantReplaceMesh), // Deprecated -----> - {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_O, (PY_METHODCHAR)SetMesh_doc}, + {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_O, (const char *)SetMesh_doc}, KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, getMesh), {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h index c9baf228855..dd4419543a2 100644 --- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h +++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h @@ -59,7 +59,6 @@ class KX_BoneParentRelation : public SG_ParentRelation { public : - /** * Allocate and construct a new KX_SG_BoneParentRelation * on the heap. @@ -101,6 +100,12 @@ private : KX_BoneParentRelation(Bone* bone ); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BoneParentRelation"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h index d8fb9211f21..c1640f3e0a0 100644 --- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h +++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h @@ -53,7 +53,6 @@ class KX_NormalParentRelation : public SG_ParentRelation { public : - /** * Allocate and construct a new KX_NormalParentRelation * on the heap. @@ -91,6 +90,12 @@ private : KX_NormalParentRelation( ); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_NormalParentRelation"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; @@ -142,6 +147,12 @@ private : KX_VertexParentRelation( ); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_VertexParentRelation"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; @@ -219,6 +230,12 @@ private : bool m_initialized; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_SlowParentRelation"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Ketsji/KX_ScalarInterpolator.h b/source/gameengine/Ketsji/KX_ScalarInterpolator.h index 8835c98c184..ca011ab5db0 100644 --- a/source/gameengine/Ketsji/KX_ScalarInterpolator.h +++ b/source/gameengine/Ketsji/KX_ScalarInterpolator.h @@ -55,6 +55,13 @@ public: private: MT_Scalar* m_target; KX_IScalarInterpolator *m_ipo; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_ScalarInterpolator"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Ketsji/KX_ScalingInterpolator.h b/source/gameengine/Ketsji/KX_ScalingInterpolator.h index a7b5d7e559a..460563d4135 100644 --- a/source/gameengine/Ketsji/KX_ScalingInterpolator.h +++ b/source/gameengine/Ketsji/KX_ScalingInterpolator.h @@ -50,6 +50,13 @@ public: private: MT_Vector3& m_target; KX_IScalarInterpolator *m_ipos[3]; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_ScalingInterpolator"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 8c88d55f24c..5c19911fe58 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -34,7 +34,6 @@ #include "KX_Scene.h" #include "MT_assert.h" -#include "SND_Scene.h" #include "KX_KetsjiEngine.h" #include "KX_BlenderMaterial.h" #include "RAS_IPolygonMaterial.h" @@ -135,7 +134,6 @@ extern bool gUseVisibilityTemp; KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, class SCA_IInputDevice* mousedevice, class NG_NetworkDeviceInterface *ndi, - class SND_IAudioDevice* adi, const STR_String& sceneName, Scene *scene): PyObjectPlus(), @@ -144,7 +142,6 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, m_sceneConverter(NULL), m_physicsEnvironment(0), m_sceneName(sceneName), - m_adi(adi), m_networkDeviceInterface(ndi), m_active_camera(NULL), m_ueberExecutionPriority(0), @@ -200,7 +197,6 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, m_logicmgr->RegisterEventManager(joymgr); } - m_soundScene = new SND_Scene(adi); MT_assert (m_networkDeviceInterface != NULL); m_networkScene = new NG_NetworkScene(m_networkDeviceInterface); @@ -250,9 +246,6 @@ KX_Scene::~KX_Scene() if (m_physicsEnvironment) delete m_physicsEnvironment; - if (m_soundScene) - delete m_soundScene; - if (m_networkScene) delete m_networkScene; @@ -364,12 +357,6 @@ class KX_WorldInfo* KX_Scene::GetWorldInfo() } - -SND_Scene* KX_Scene::GetSoundScene() -{ - return m_soundScene; -} - const STR_String& KX_Scene::GetName() { return m_sceneName; @@ -1008,8 +995,12 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) // in case this is a camera m_cameras.remove((KX_Camera*)newobj); + /* currently does nothing, keep incase we need to Unregister something */ +#if 0 if (m_sceneConverter) m_sceneConverter->UnregisterGameObject(newobj); +#endif + // return value will be 0 if the object is actually deleted (all reference gone) return ret; @@ -1579,11 +1570,6 @@ void KX_Scene::SetGravity(const MT_Vector3& gravity) GetPhysicsEnvironment()->setGravity(gravity[0],gravity[1],gravity[2]); } -void KX_Scene::SetNodeTree(SG_Tree* root) -{ - m_objecttree = root; -} - void KX_Scene::SetSceneConverter(class KX_BlenderSceneConverter* sceneConverter) { m_sceneConverter = sceneConverter; @@ -1619,31 +1605,25 @@ double KX_Scene::getSuspendedDelta() //Python PyTypeObject KX_Scene::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_Scene", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &CValue::Type, - 0,0,0,0,0,0, - py_base_new + "KX_Scene", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &CValue::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef KX_Scene::Methods[] = { diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index d94eac0c6e2..f48e9520f53 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -63,8 +63,6 @@ class SCA_TimeEventManager; class SCA_MouseManager; class SCA_ISystem; class SCA_IInputDevice; -class SND_Scene; -class SND_IAudioDevice; class NG_NetworkDeviceInterface; class NG_NetworkScene; class SG_IObject; @@ -119,10 +117,6 @@ protected: // the Qlist is for objects that needs to be rescheduled // for updates after udpate is over (slow parent, bone parent) - /** - * The tree of objects in the scene. - */ - SG_Tree* m_objecttree; /** * The set of cameras for this scene @@ -164,14 +158,7 @@ protected: * @section Different scenes, linked to ketsji scene */ - /** - * Sound scenes - */ - SND_Scene* m_soundScene; - SND_IAudioDevice* m_adi; - - /** * Network scene. */ NG_NetworkDeviceInterface* m_networkDeviceInterface; @@ -287,7 +274,6 @@ public: KX_Scene(class SCA_IInputDevice* keyboarddevice, class SCA_IInputDevice* mousedevice, class NG_NetworkDeviceInterface* ndi, - class SND_IAudioDevice* adi, const STR_String& scenename, struct Scene* scene); @@ -484,7 +470,6 @@ public: void CalculateVisibleMeshes(RAS_IRasterizer* rasty, KX_Camera *cam, int layer=0); void UpdateMeshTransformations(); KX_Camera* GetpCamera(); - SND_Scene* GetSoundScene(); NG_NetworkDeviceInterface* GetNetworkDeviceInterface(); NG_NetworkScene* GetNetworkScene(); diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index 5528e58ef77..a0b7664d63a 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -222,42 +222,36 @@ KX_Scene* KX_SceneActuator::FindScene(char * sceneName) /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_SceneActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_SceneActuator", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &SCA_IActuator::Type, - 0,0,0,0,0,0, - py_base_new + "KX_SceneActuator", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &SCA_IActuator::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef KX_SceneActuator::Methods[] = { //Deprecated functions ------> - {"setUseRestart", (PyCFunction) KX_SceneActuator::sPySetUseRestart, METH_VARARGS, (PY_METHODCHAR)SetUseRestart_doc}, - {"setScene", (PyCFunction) KX_SceneActuator::sPySetScene, METH_VARARGS, (PY_METHODCHAR)SetScene_doc}, - {"setCamera", (PyCFunction) KX_SceneActuator::sPySetCamera, METH_O, (PY_METHODCHAR)SetCamera_doc}, - {"getUseRestart", (PyCFunction) KX_SceneActuator::sPyGetUseRestart, METH_NOARGS, (PY_METHODCHAR)GetUseRestart_doc}, - {"getScene", (PyCFunction) KX_SceneActuator::sPyGetScene, METH_NOARGS, (PY_METHODCHAR)GetScene_doc}, - {"getCamera", (PyCFunction) KX_SceneActuator::sPyGetCamera, METH_NOARGS, (PY_METHODCHAR)GetCamera_doc}, + {"setUseRestart", (PyCFunction) KX_SceneActuator::sPySetUseRestart, METH_VARARGS, (const char *)SetUseRestart_doc}, + {"setScene", (PyCFunction) KX_SceneActuator::sPySetScene, METH_VARARGS, (const char *)SetScene_doc}, + {"setCamera", (PyCFunction) KX_SceneActuator::sPySetCamera, METH_O, (const char *)SetCamera_doc}, + {"getUseRestart", (PyCFunction) KX_SceneActuator::sPyGetUseRestart, METH_NOARGS, (const char *)GetUseRestart_doc}, + {"getScene", (PyCFunction) KX_SceneActuator::sPyGetScene, METH_NOARGS, (const char *)GetScene_doc}, + {"getCamera", (PyCFunction) KX_SceneActuator::sPyGetCamera, METH_NOARGS, (const char *)GetCamera_doc}, //<----- Deprecated {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index 39381182944..024c51cabc1 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -31,10 +31,7 @@ */ #include "KX_SoundActuator.h" -#include "SND_SoundObject.h" #include "KX_GameObject.h" -#include "SND_SoundObject.h" -#include "SND_Scene.h" // needed for replication #include "KX_PyMath.h" // needed for PyObjectFrom() #include @@ -46,37 +43,94 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj, - SND_SoundObject* sndobj, - SND_Scene* sndscene, - KX_SOUNDACT_TYPE type, - short start, - short end) + AUD_Sound* sound, + float volume, + float pitch, + bool is3d, + KX_3DSoundSettings settings, + KX_SOUNDACT_TYPE type)//, : SCA_IActuator(gameobj) { - m_soundObject = sndobj; - m_soundScene = sndscene; + m_sound = sound; + m_volume = volume; + m_pitch = pitch; + m_is3d = is3d; + m_3d = settings; + m_handle = NULL; m_type = type; - m_lastEvent = true; m_isplaying = false; - m_startFrame = start; - m_endFrame = end; - m_pino = false; - - } KX_SoundActuator::~KX_SoundActuator() { - if (m_soundObject) - { - m_soundScene->RemoveActiveObject(m_soundObject); - m_soundScene->DeleteObject(m_soundObject); - } + if(m_handle) + AUD_stop(m_handle); } +void KX_SoundActuator::play() +{ + if(m_handle) + AUD_stop(m_handle); + if(!m_sound) + return; + + // this is the sound that will be played and not deleted afterwards + AUD_Sound* sound = m_sound; + // this sounds are for temporary stacked sounds, will be deleted if not NULL + AUD_Sound* sound2 = NULL; + AUD_Sound* sound3 = NULL; + + switch (m_type) + { + case KX_SOUNDACT_LOOPBIDIRECTIONAL: + case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP: + // create a ping pong sound on sound2 stacked on the orignal sound + sound2 = AUD_pingpongSound(sound); + // create a loop sound on sound3 stacked on the pingpong sound and let that one play (save it to sound) + sound = sound3 = AUD_loopSound(sound2); + break; + case KX_SOUNDACT_LOOPEND: + case KX_SOUNDACT_LOOPSTOP: + // create a loop sound on sound2 stacked on the pingpong sound and let that one play (save it to sound) + sound = sound2 = AUD_loopSound(sound); + break; + case KX_SOUNDACT_PLAYSTOP: + case KX_SOUNDACT_PLAYEND: + default: + break; + } + + if(m_is3d) + { + // sound shall be played 3D + m_handle = AUD_play3D(sound, 0); + + AUD_set3DSourceSetting(m_handle, AUD_3DSS_MAX_GAIN, m_3d.max_gain); + AUD_set3DSourceSetting(m_handle, AUD_3DSS_MIN_GAIN, m_3d.min_gain); + AUD_set3DSourceSetting(m_handle, AUD_3DSS_REFERENCE_DISTANCE, m_3d.reference_distance); + AUD_set3DSourceSetting(m_handle, AUD_3DSS_MAX_DISTANCE, m_3d.max_distance); + AUD_set3DSourceSetting(m_handle, AUD_3DSS_ROLLOFF_FACTOR, m_3d.rolloff_factor); + AUD_set3DSourceSetting(m_handle, AUD_3DSS_CONE_INNER_ANGLE, m_3d.cone_inner_angle); + AUD_set3DSourceSetting(m_handle, AUD_3DSS_CONE_OUTER_ANGLE, m_3d.cone_outer_angle); + AUD_set3DSourceSetting(m_handle, AUD_3DSS_CONE_OUTER_GAIN, m_3d.cone_outer_gain); + } + else + m_handle = AUD_play(sound, 0); + + AUD_setSoundPitch(m_handle, m_pitch); + AUD_setSoundVolume(m_handle, m_volume); + m_isplaying = true; + + // now we unload the pingpong and loop sounds, as we don't need them anymore + // the started sound will continue playing like it was created, don't worry! + if(sound3) + AUD_unload(sound3); + if(sound2) + AUD_unload(sound2); +} CValue* KX_SoundActuator::GetReplica() { @@ -88,13 +142,8 @@ CValue* KX_SoundActuator::GetReplica() void KX_SoundActuator::ProcessReplica() { SCA_IActuator::ProcessReplica(); - if (m_soundObject) - { - SND_SoundObject* soundobj = new SND_SoundObject(*m_soundObject); - setSoundObject(soundobj); - m_soundScene->AddObject(soundobj); - } -} + m_handle = 0; +} bool KX_SoundActuator::Update(double curtime, bool frame) { @@ -108,22 +157,16 @@ bool KX_SoundActuator::Update(double curtime, bool frame) RemoveAllEvents(); - if (!m_soundObject) + if(!m_sound) return false; // actual audio device playing state - bool isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED && m_soundObject->GetPlaystate() != SND_INITIAL) ? true : false; - - if (m_pino) - { - bNegativeEvent = true; - m_pino = false; - } + bool isplaying = AUD_getStatus(m_handle) == AUD_STATUS_PLAYING; if (bNegativeEvent) - { + { // here must be a check if it is still playing - if (m_isplaying && isplaying) + if (m_isplaying && isplaying) { switch (m_type) { @@ -131,19 +174,20 @@ bool KX_SoundActuator::Update(double curtime, bool frame) case KX_SOUNDACT_LOOPSTOP: case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP: { - m_soundScene->RemoveActiveObject(m_soundObject); + // stop immediately + AUD_stop(m_handle); break; } case KX_SOUNDACT_PLAYEND: { - m_soundObject->SetPlaystate(SND_MUST_STOP_WHEN_FINISHED); + // do nothing, sound will stop anyway when it's finished break; } case KX_SOUNDACT_LOOPEND: case KX_SOUNDACT_LOOPBIDIRECTIONAL: { - m_soundObject->SetLoopMode(SND_LOOP_OFF); - m_soundObject->SetPlaystate(SND_MUST_STOP_WHEN_FINISHED); + // stop the looping so that the sound stops when it finished + AUD_stopLoop(m_handle); break; } default: @@ -166,50 +210,49 @@ bool KX_SoundActuator::Update(double curtime, bool frame) // the negative pulse is done continuesly #endif if (!m_isplaying) - { - switch (m_type) - { - case KX_SOUNDACT_LOOPBIDIRECTIONAL: - case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP: - { - m_soundObject->SetLoopMode(SND_LOOP_BIDIRECTIONAL); - m_soundScene->AddActiveObject(m_soundObject, curtime); - m_isplaying = true; - result = true; - break; - } - case KX_SOUNDACT_LOOPEND: - case KX_SOUNDACT_LOOPSTOP: - { - m_soundObject->SetLoopMode(SND_LOOP_NORMAL); - m_soundScene->AddActiveObject(m_soundObject, curtime); - m_isplaying = true; - result = true; - break; - } - case KX_SOUNDACT_PLAYSTOP: - case KX_SOUNDACT_PLAYEND: - { - m_soundObject->SetLoopMode(SND_LOOP_OFF); - m_soundScene->AddActiveObject(m_soundObject, curtime); - m_isplaying = true; - result = true; - break; - } - default: - // implement me !! - break; - } - } + play(); } // verify that the sound is still playing - isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED && m_soundObject->GetPlaystate() != SND_INITIAL) ? true : false; + isplaying = AUD_getStatus(m_handle) == AUD_STATUS_PLAYING ? true : false; if (isplaying) { - m_soundObject->SetPosition(((KX_GameObject*)this->GetParent())->NodeGetWorldPosition()); - m_soundObject->SetVelocity(((KX_GameObject*)this->GetParent())->GetLinearVelocity()); - m_soundObject->SetOrientation(((KX_GameObject*)this->GetParent())->NodeGetWorldOrientation()); + if(m_is3d) + { + AUD_3DData data; + float f; + ((KX_GameObject*)this->GetParent())->NodeGetWorldPosition().getValue(data.position); + ((KX_GameObject*)this->GetParent())->GetLinearVelocity().getValue(data.velocity); + ((KX_GameObject*)this->GetParent())->NodeGetWorldOrientation().getValue3x3(data.orientation); + + /* + * The 3D data from blender has to be transformed for OpenAL: + * - In blender z is up and y is forwards + * - In OpenAL y is up and z is backwards + * We have to do that for all 5 vectors. + */ + f = data.position[1]; + data.position[1] = data.position[2]; + data.position[2] = -f; + + f = data.velocity[1]; + data.velocity[1] = data.velocity[2]; + data.velocity[2] = -f; + + f = data.orientation[1]; + data.orientation[1] = data.orientation[2]; + data.orientation[2] = -f; + + f = data.orientation[4]; + data.orientation[4] = data.orientation[5]; + data.orientation[5] = -f; + + f = data.orientation[7]; + data.orientation[7] = data.orientation[8]; + data.orientation[8] = -f; + + AUD_update3DSource(m_handle, &data); + } result = true; } else @@ -217,23 +260,11 @@ bool KX_SoundActuator::Update(double curtime, bool frame) m_isplaying = false; result = false; } - /* - if (result && (m_soundObject->IsLifeSpanOver(curtime)) && ((m_type == KX_SOUNDACT_PLAYEND) || (m_type == KX_SOUNDACT_PLAYSTOP))) - { - m_pino = true; - } - */ return result; } -void KX_SoundActuator::setSoundObject(class SND_SoundObject* soundobject) -{ - m_soundObject = soundobject; -} - - /* ------------------------------------------------------------------------- */ /* Python functions */ @@ -243,48 +274,35 @@ void KX_SoundActuator::setSoundObject(class SND_SoundObject* soundobject) /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_SoundActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_SoundActuator", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &SCA_IActuator::Type, - 0,0,0,0,0,0, - py_base_new + "KX_SoundActuator", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &SCA_IActuator::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef KX_SoundActuator::Methods[] = { // Deprecated -----> - {"setFilename", (PyCFunction) KX_SoundActuator::sPySetFilename, METH_VARARGS,NULL}, - {"getFilename", (PyCFunction) KX_SoundActuator::sPyGetFilename, METH_NOARGS,NULL}, {"setGain",(PyCFunction) KX_SoundActuator::sPySetGain,METH_VARARGS,NULL}, {"getGain",(PyCFunction) KX_SoundActuator::sPyGetGain,METH_NOARGS,NULL}, {"setPitch",(PyCFunction) KX_SoundActuator::sPySetPitch,METH_VARARGS,NULL}, {"getPitch",(PyCFunction) KX_SoundActuator::sPyGetPitch,METH_NOARGS,NULL}, {"setRollOffFactor",(PyCFunction) KX_SoundActuator::sPySetRollOffFactor,METH_VARARGS,NULL}, {"getRollOffFactor",(PyCFunction) KX_SoundActuator::sPyGetRollOffFactor,METH_NOARGS,NULL}, - {"setLooping",(PyCFunction) KX_SoundActuator::sPySetLooping,METH_VARARGS,NULL}, - {"getLooping",(PyCFunction) KX_SoundActuator::sPyGetLooping,METH_NOARGS,NULL}, - {"setPosition",(PyCFunction) KX_SoundActuator::sPySetPosition,METH_VARARGS,NULL}, - {"setVelocity",(PyCFunction) KX_SoundActuator::sPySetVelocity,METH_VARARGS,NULL}, - {"setOrientation",(PyCFunction) KX_SoundActuator::sPySetOrientation,METH_VARARGS,NULL}, {"setType",(PyCFunction) KX_SoundActuator::sPySetType,METH_VARARGS,NULL}, {"getType",(PyCFunction) KX_SoundActuator::sPyGetType,METH_NOARGS,NULL}, // <----- @@ -296,171 +314,91 @@ PyMethodDef KX_SoundActuator::Methods[] = { }; PyAttributeDef KX_SoundActuator::Attributes[] = { - KX_PYATTRIBUTE_RW_FUNCTION("fileName", KX_SoundActuator, pyattr_get_filename, pyattr_set_filename), KX_PYATTRIBUTE_RW_FUNCTION("volume", KX_SoundActuator, pyattr_get_gain, pyattr_set_gain), KX_PYATTRIBUTE_RW_FUNCTION("pitch", KX_SoundActuator, pyattr_get_pitch, pyattr_set_pitch), KX_PYATTRIBUTE_RW_FUNCTION("rollOffFactor", KX_SoundActuator, pyattr_get_rollOffFactor, pyattr_set_rollOffFactor), - KX_PYATTRIBUTE_RW_FUNCTION("looping", KX_SoundActuator, pyattr_get_looping, pyattr_set_looping), - KX_PYATTRIBUTE_RW_FUNCTION("position", KX_SoundActuator, pyattr_get_position, pyattr_set_position), - KX_PYATTRIBUTE_RW_FUNCTION("velocity", KX_SoundActuator, pyattr_get_velocity, pyattr_set_velocity), - KX_PYATTRIBUTE_RW_FUNCTION("orientation", KX_SoundActuator, pyattr_get_orientation, pyattr_set_orientation), KX_PYATTRIBUTE_ENUM_RW("mode",KX_SoundActuator::KX_SOUNDACT_NODEF+1,KX_SoundActuator::KX_SOUNDACT_MAX-1,false,KX_SoundActuator,m_type), { NULL } //Sentinel }; /* Methods ----------------------------------------------------------------- */ -KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound, +KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound, "startSound()\n" "\tStarts the sound.\n") { - if (m_soundObject) - // This has no effect if the actuator is not active. - // To start the sound you must activate the actuator. - // This function is to restart the sound. - m_soundObject->StartSound(); + switch(AUD_getStatus(m_handle)) + { + case AUD_STATUS_PLAYING: + break; + case AUD_STATUS_PAUSED: + AUD_resume(m_handle); + break; + default: + play(); + } Py_RETURN_NONE; -} +} KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, pauseSound, "pauseSound()\n" "\tPauses the sound.\n") { - if (m_soundObject) - // unfortunately, openal does not implement pause correctly, it is equivalent to a stop - m_soundObject->PauseSound(); + AUD_pause(m_handle); Py_RETURN_NONE; -} +} KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound, "stopSound()\n" "\tStops the sound.\n") { - if (m_soundObject) - m_soundObject->StopSound(); + AUD_stop(m_handle); Py_RETURN_NONE; } /* Atribute setting and getting -------------------------------------------- */ -PyObject* KX_SoundActuator::pyattr_get_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) -{ - KX_SoundActuator * actuator = static_cast (self); - if (!actuator->m_soundObject) - { - return PyUnicode_FromString(""); - } - STR_String objectname = actuator->m_soundObject->GetObjectName(); - char* name = objectname.Ptr(); - - if (!name) { - PyErr_SetString(PyExc_RuntimeError, "value = actuator.fileName: KX_SoundActuator, unable to get sound fileName"); - return NULL; - } else - return PyUnicode_FromString(name); -} - PyObject* KX_SoundActuator::pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast (self); - float gain = (actuator->m_soundObject) ? actuator->m_soundObject->GetGain() : 1.0f; + float gain = actuator->m_volume; PyObject* result = PyFloat_FromDouble(gain); - + return result; } PyObject* KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast (self); - float pitch = (actuator->m_soundObject) ? actuator->m_soundObject->GetPitch() : 1.0; + float pitch = actuator->m_pitch; + PyObject* result = PyFloat_FromDouble(pitch); - + return result; } PyObject* KX_SoundActuator::pyattr_get_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast (self); - float rollofffactor = (actuator->m_soundObject) ? actuator->m_soundObject->GetRollOffFactor() : 1.0; + float rollofffactor = actuator->m_3d.rolloff_factor; PyObject* result = PyFloat_FromDouble(rollofffactor); - + return result; } -PyObject* KX_SoundActuator::pyattr_get_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) -{ - KX_SoundActuator * actuator = static_cast (self); - int looping = (actuator->m_soundObject) ? actuator->m_soundObject->GetLoopMode() : (int)SND_LOOP_OFF; - PyObject* result = PyLong_FromSsize_t(looping); - - return result; -} - -PyObject* KX_SoundActuator::pyattr_get_position(void * self, const struct KX_PYATTRIBUTE_DEF *attrdef) -{ - KX_SoundActuator * actuator = static_cast (self); - MT_Vector3 pos(0.0, 0.0, 0.0); - - if (actuator->m_soundObject) - pos = actuator->m_soundObject->GetPosition(); - - PyObject * result = PyObjectFrom(pos); - return result; -} - -PyObject* KX_SoundActuator::pyattr_get_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) -{ - KX_SoundActuator * actuator = static_cast (self); - MT_Vector3 vel; - - if (actuator->m_soundObject) - vel = actuator->m_soundObject->GetVelocity(); - - PyObject * result = PyObjectFrom(vel); - return result; -} - -PyObject* KX_SoundActuator::pyattr_get_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) -{ - KX_SoundActuator * actuator = static_cast (self); - MT_Matrix3x3 ori; - - if (actuator->m_soundObject) - ori = actuator->m_soundObject->GetOrientation(); - - PyObject * result = PyObjectFrom(ori); - return result; -} - -int KX_SoundActuator::pyattr_set_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) -{ - char *soundName = NULL; - KX_SoundActuator * actuator = static_cast (self); - // void *soundPointer = NULL; /*unused*/ - - if (!PyArg_Parse(value, "s", &soundName)) - return PY_SET_ATTR_FAIL; - - if (actuator->m_soundObject) { - actuator->m_soundObject->SetObjectName(soundName); - } - - return PY_SET_ATTR_SUCCESS; -} - - int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { float gain = 1.0; KX_SoundActuator * actuator = static_cast (self); if (!PyArg_Parse(value, "f", &gain)) return PY_SET_ATTR_FAIL; - - if (actuator->m_soundObject) - actuator->m_soundObject->SetGain(gain); - + + actuator->m_volume = gain; + if(actuator->m_handle) + AUD_setSoundVolume(actuator->m_handle, gain); + return PY_SET_ATTR_SUCCESS; -} +} int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { @@ -468,12 +406,13 @@ int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_D KX_SoundActuator * actuator = static_cast (self); if (!PyArg_Parse(value, "f", &pitch)) return PY_SET_ATTR_FAIL; - - if (actuator->m_soundObject) - actuator->m_soundObject->SetPitch(pitch); - + + actuator->m_pitch = pitch; + if(actuator->m_handle) + AUD_setSoundPitch(actuator->m_handle, pitch); + return PY_SET_ATTR_SUCCESS; -} +} int KX_SoundActuator::pyattr_set_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { @@ -481,104 +420,12 @@ int KX_SoundActuator::pyattr_set_rollOffFactor(void *self, const struct KX_PYATT float rollofffactor = 1.0; if (!PyArg_Parse(value, "f", &rollofffactor)) return PY_SET_ATTR_FAIL; - - if (actuator->m_soundObject) - actuator->m_soundObject->SetRollOffFactor(rollofffactor); + + actuator->m_3d.rolloff_factor = rollofffactor; + if(actuator->m_handle) + AUD_set3DSourceSetting(actuator->m_handle, AUD_3DSS_ROLLOFF_FACTOR, rollofffactor); return PY_SET_ATTR_SUCCESS; -} - -int KX_SoundActuator::pyattr_set_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) -{ - KX_SoundActuator * actuator = static_cast (self); - int looping = 1; - if (!PyArg_Parse(value, "i", &looping)) - return PY_SET_ATTR_FAIL; - - if (actuator->m_soundObject) - actuator->m_soundObject->SetLoopMode(looping); - - return PY_SET_ATTR_SUCCESS; -} - -int KX_SoundActuator::pyattr_set_position(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) -{ - float pos[3]; - - KX_SoundActuator * actuator = static_cast (self); - - if (!PyArg_ParseTuple(value, "fff", &pos[0], &pos[1], &pos[2])) - return PY_SET_ATTR_FAIL; - - if (actuator->m_soundObject) - actuator->m_soundObject->SetPosition(MT_Vector3(pos)); - - return PY_SET_ATTR_SUCCESS; -} - -int KX_SoundActuator::pyattr_set_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) -{ - float vel[3]; - KX_SoundActuator * actuator = static_cast (self); - - - if (!PyArg_ParseTuple(value, "fff", &vel[0], &vel[1], &vel[2])) - return PY_SET_ATTR_FAIL; - - if (actuator->m_soundObject) - actuator->m_soundObject->SetVelocity(MT_Vector3(vel)); - - return PY_SET_ATTR_SUCCESS; - -} - -int KX_SoundActuator::pyattr_set_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) -{ - - MT_Matrix3x3 rot; - KX_SoundActuator * actuator = static_cast (self); - - /* if value is not a sequence PyOrientationTo makes an error */ - if (!PyOrientationTo(value, rot, "actuator.orientation = value: KX_SoundActuator")) - return PY_SET_ATTR_FAIL; - - /* Since not having m_soundObject didn't do anything in the old version, - * it probably should be kept that way */ - if (!actuator->m_soundObject) - return PY_SET_ATTR_SUCCESS; - - actuator->m_soundObject->SetOrientation(rot); - return PY_SET_ATTR_SUCCESS; -} - -// Deprecated -----> -PyObject* KX_SoundActuator::PySetFilename(PyObject* args) -{ - char *soundName = NULL; - ShowDeprecationWarning("setFilename()", "the fileName property"); - // void *soundPointer = NULL; /*unused*/ - - if (!PyArg_ParseTuple(args, "s", &soundName)) - return NULL; - - Py_RETURN_NONE; -} - -PyObject* KX_SoundActuator::PyGetFilename() -{ - ShowDeprecationWarning("getFilename()", "the fileName property"); - if (!m_soundObject) - { - return PyUnicode_FromString(""); - } - STR_String objectname = m_soundObject->GetObjectName(); - char* name = objectname.Ptr(); - - if (!name) { - PyErr_SetString(PyExc_RuntimeError, "Unable to get sound fileName"); - return NULL; - } else - return PyUnicode_FromString(name); } PyObject* KX_SoundActuator::PySetGain(PyObject* args) @@ -587,21 +434,22 @@ PyObject* KX_SoundActuator::PySetGain(PyObject* args) float gain = 1.0; if (!PyArg_ParseTuple(args, "f:setGain", &gain)) return NULL; - - if (m_soundObject) - m_soundObject->SetGain(gain); - + + m_volume = gain; + if(m_handle) + AUD_setSoundVolume(m_handle, gain); + Py_RETURN_NONE; -} +} PyObject* KX_SoundActuator::PyGetGain() { ShowDeprecationWarning("getGain()", "the volume property"); - float gain = (m_soundObject) ? m_soundObject->GetGain() : 1.0f; + float gain = m_volume; PyObject* result = PyFloat_FromDouble(gain); - + return result; } @@ -613,21 +461,22 @@ PyObject* KX_SoundActuator::PySetPitch(PyObject* args) float pitch = 1.0; if (!PyArg_ParseTuple(args, "f:setPitch", &pitch)) return NULL; - - if (m_soundObject) - m_soundObject->SetPitch(pitch); - + + m_pitch = pitch; + if(m_handle) + AUD_setSoundPitch(m_handle, pitch); + Py_RETURN_NONE; -} +} PyObject* KX_SoundActuator::PyGetPitch() { ShowDeprecationWarning("getPitch()", "the pitch property"); - float pitch = (m_soundObject) ? m_soundObject->GetPitch() : 1.0; + float pitch = m_pitch; PyObject* result = PyFloat_FromDouble(pitch); - + return result; } @@ -639,113 +488,27 @@ PyObject* KX_SoundActuator::PySetRollOffFactor(PyObject* args) float rollofffactor = 1.0; if (!PyArg_ParseTuple(args, "f:setRollOffFactor", &rollofffactor)) return NULL; - - if (m_soundObject) - m_soundObject->SetRollOffFactor(rollofffactor); + + m_3d.rolloff_factor = rollofffactor; + if(m_handle) + AUD_set3DSourceSetting(m_handle, AUD_3DSS_ROLLOFF_FACTOR, rollofffactor); Py_RETURN_NONE; -} +} PyObject* KX_SoundActuator::PyGetRollOffFactor() { ShowDeprecationWarning("getRollOffFactor()", "the rollOffFactor property"); - float rollofffactor = (m_soundObject) ? m_soundObject->GetRollOffFactor() : 1.0; + float rollofffactor = m_3d.rolloff_factor; PyObject* result = PyFloat_FromDouble(rollofffactor); - + return result; } -PyObject* KX_SoundActuator::PySetLooping(PyObject* args) -{ - ShowDeprecationWarning("setLooping()", "the looping property"); - bool looping = 1; - if (!PyArg_ParseTuple(args, "i:setLooping", &looping)) - return NULL; - - if (m_soundObject) - m_soundObject->SetLoopMode(looping); - - Py_RETURN_NONE; -} - - - -PyObject* KX_SoundActuator::PyGetLooping() -{ - ShowDeprecationWarning("getLooping()", "the looping property"); - int looping = (m_soundObject) ? m_soundObject->GetLoopMode() : (int)SND_LOOP_OFF; - PyObject* result = PyLong_FromSsize_t(looping); - - return result; -} - - - -PyObject* KX_SoundActuator::PySetPosition(PyObject* args) -{ - MT_Point3 pos; - ShowDeprecationWarning("setPosition()", "the position property"); - pos[0] = 0.0; - pos[1] = 0.0; - pos[2] = 0.0; - - if (!PyArg_ParseTuple(args, "fff:setPosition", &pos[0], &pos[1], &pos[2])) - return NULL; - - if (m_soundObject) - m_soundObject->SetPosition(pos); - - Py_RETURN_NONE; -} - - - -PyObject* KX_SoundActuator::PySetVelocity(PyObject* args) -{ - MT_Vector3 vel; - ShowDeprecationWarning("setVelocity()", "the velocity property"); - vel[0] = 0.0; - vel[1] = 0.0; - vel[2] = 0.0; - - if (!PyArg_ParseTuple(args, "fff:setVelocity", &vel[0], &vel[1], &vel[2])) - return NULL; - - if (m_soundObject) - m_soundObject->SetVelocity(vel); - - Py_RETURN_NONE; -} - - - -PyObject* KX_SoundActuator::PySetOrientation(PyObject* args) -{ - MT_Matrix3x3 ori; - ShowDeprecationWarning("setOrientation()", "the orientation property"); - ori[0][0] = 1.0; - ori[0][1] = 0.0; - ori[0][2] = 0.0; - ori[1][0] = 0.0; - ori[1][1] = 1.0; - ori[1][2] = 0.0; - ori[2][0] = 0.0; - ori[2][1] = 0.0; - ori[2][2] = 1.0; - - if (!PyArg_ParseTuple(args, "fffffffff:setOrientation", &ori[0][0], &ori[0][1], &ori[0][2], &ori[1][0], &ori[1][1], &ori[1][2], &ori[2][0], &ori[2][1], &ori[2][2])) - return NULL; - - if (m_soundObject) - m_soundObject->SetOrientation(ori); - - Py_RETURN_NONE; -} - PyObject* KX_SoundActuator::PySetType(PyObject* args) { int typeArg; diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h index adafee0a30b..bc0293ed2b4 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.h +++ b/source/gameengine/Ketsji/KX_SoundActuator.h @@ -34,17 +34,34 @@ #include "SCA_IActuator.h" +#include "AUD_C-API.h" +#include "BKE_sound.h" + +typedef struct KX_3DSoundSettings +{ + float min_gain; + float max_gain; + float reference_distance; + float max_distance; + float rolloff_factor; + float cone_inner_angle; + float cone_outer_angle; + float cone_outer_gain; +} KX_3DSoundSettings; + class KX_SoundActuator : public SCA_IActuator { - Py_Header; - bool m_lastEvent; - bool m_isplaying; - /* just some handles to the audio-data... */ - class SND_SoundObject* m_soundObject; - class SND_Scene* m_soundScene; - short m_startFrame; - short m_endFrame; - bool m_pino; + Py_Header; + bool m_isplaying; + AUD_Sound* m_sound; + float m_volume; + float m_pitch; + bool m_is3d; + KX_3DSoundSettings m_3d; + AUD_Handle* m_handle; + + void play(); + public: enum KX_SOUNDACT_TYPE @@ -62,15 +79,15 @@ public: KX_SOUNDACT_TYPE m_type; KX_SoundActuator(SCA_IObject* gameobj, - class SND_SoundObject* sndobj, - class SND_Scene* sndscene, - KX_SOUNDACT_TYPE type, - short start, - short end); + AUD_Sound* sound, + float volume, + float pitch, + bool is3d, + KX_3DSoundSettings settings, + KX_SOUNDACT_TYPE type); ~KX_SoundActuator(); - void setSoundObject(class SND_SoundObject* soundobject); virtual bool Update(double curtime, bool frame); CValue* GetReplica(); @@ -84,40 +101,23 @@ public: KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, pauseSound); KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, stopSound); - static int pyattr_set_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static int pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static int pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static int pyattr_set_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - static int pyattr_set_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - static int pyattr_set_position(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - static int pyattr_set_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - static int pyattr_set_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static int pyattr_set_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - static PyObject* pyattr_get_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_position(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); // Deprecated -----> - KX_PYMETHOD_VARARGS(KX_SoundActuator,SetFilename); - KX_PYMETHOD_NOARGS(KX_SoundActuator,GetFilename); KX_PYMETHOD_VARARGS(KX_SoundActuator,SetGain); KX_PYMETHOD_NOARGS(KX_SoundActuator,GetGain); KX_PYMETHOD_VARARGS(KX_SoundActuator,SetPitch); KX_PYMETHOD_NOARGS(KX_SoundActuator,GetPitch); KX_PYMETHOD_VARARGS(KX_SoundActuator,SetRollOffFactor); KX_PYMETHOD_NOARGS(KX_SoundActuator,GetRollOffFactor); - KX_PYMETHOD_VARARGS(KX_SoundActuator,SetLooping); - KX_PYMETHOD_NOARGS(KX_SoundActuator,GetLooping); - KX_PYMETHOD_VARARGS(KX_SoundActuator,SetPosition); - KX_PYMETHOD_VARARGS(KX_SoundActuator,SetVelocity); - KX_PYMETHOD_VARARGS(KX_SoundActuator,SetOrientation); KX_PYMETHOD_VARARGS(KX_SoundActuator,SetType); KX_PYMETHOD_NOARGS(KX_SoundActuator,GetType); // <----- diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp index 9815d6274aa..09d95612cbb 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.cpp +++ b/source/gameengine/Ketsji/KX_StateActuator.cpp @@ -137,13 +137,7 @@ void KX_StateActuator::Activate(SG_DList& head) /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_StateActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_StateActuator", sizeof(PyObjectPlus_Proxy), 0, @@ -167,9 +161,9 @@ PyTypeObject KX_StateActuator::Type = { PyMethodDef KX_StateActuator::Methods[] = { // deprecated --> {"setOperation", (PyCFunction) KX_StateActuator::sPySetOperation, - METH_VARARGS, (PY_METHODCHAR)SetOperation_doc}, + METH_VARARGS, (const char *)SetOperation_doc}, {"setMask", (PyCFunction) KX_StateActuator::sPySetMask, - METH_VARARGS, (PY_METHODCHAR)SetMask_doc}, + METH_VARARGS, (const char *)SetMask_doc}, // <-- {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_TimeCategoryLogger.h b/source/gameengine/Ketsji/KX_TimeCategoryLogger.h index 0cc34b53736..fe15967f93c 100644 --- a/source/gameengine/Ketsji/KX_TimeCategoryLogger.h +++ b/source/gameengine/Ketsji/KX_TimeCategoryLogger.h @@ -125,6 +125,12 @@ protected: /** Maximum number of measurements. */ unsigned int m_maxNumMeasurements; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_TimeCategoryLogger"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // __KX_TIME_CATEGORY_LOGGER_H diff --git a/source/gameengine/Ketsji/KX_TimeLogger.h b/source/gameengine/Ketsji/KX_TimeLogger.h index 0962f02a877..2e73abc75b5 100644 --- a/source/gameengine/Ketsji/KX_TimeLogger.h +++ b/source/gameengine/Ketsji/KX_TimeLogger.h @@ -36,6 +36,10 @@ #include +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + /** * Stores and manages time measurements. */ @@ -98,6 +102,13 @@ protected: /** State of logging. */ bool m_logging; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_TimeLogger"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // __KX_TIME_LOGGER_H diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.h b/source/gameengine/Ketsji/KX_TouchEventManager.h index cc77bccfc31..6da37d615a4 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.h +++ b/source/gameengine/Ketsji/KX_TouchEventManager.h @@ -76,6 +76,12 @@ public: SCA_LogicManager* GetLogicManager() { return m_logicmgr;} PHY_IPhysicsEnvironment *GetPhysicsEnvironment() { return m_physEnv; } + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_TouchEventManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_TOUCHEVENTMANAGER diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index b0cf172c27a..bf8469f1ec9 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -294,13 +294,7 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll /* ------------------------------------------------------------------------- */ /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_TouchSensor::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_TouchSensor", sizeof(PyObjectPlus_Proxy), 0, @@ -324,13 +318,13 @@ PyTypeObject KX_TouchSensor::Type = { PyMethodDef KX_TouchSensor::Methods[] = { //Deprecated -----> {"setProperty", - (PyCFunction) KX_TouchSensor::sPySetProperty, METH_O, (PY_METHODCHAR)SetProperty_doc}, + (PyCFunction) KX_TouchSensor::sPySetProperty, METH_O, (const char *)SetProperty_doc}, {"getProperty", - (PyCFunction) KX_TouchSensor::sPyGetProperty, METH_NOARGS, (PY_METHODCHAR)GetProperty_doc}, + (PyCFunction) KX_TouchSensor::sPyGetProperty, METH_NOARGS, (const char *)GetProperty_doc}, {"getHitObject", - (PyCFunction) KX_TouchSensor::sPyGetHitObject, METH_NOARGS, (PY_METHODCHAR)GetHitObject_doc}, + (PyCFunction) KX_TouchSensor::sPyGetHitObject, METH_NOARGS, (const char *)GetHitObject_doc}, {"getHitObjectList", - (PyCFunction) KX_TouchSensor::sPyGetHitObjectList, METH_NOARGS, (PY_METHODCHAR)GetHitObjectList_doc}, + (PyCFunction) KX_TouchSensor::sPyGetHitObjectList, METH_NOARGS, (const char *)GetHitObjectList_doc}, //<----- {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index e8a06d8d619..b5b7e9de444 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -431,13 +431,7 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_TrackToActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_TrackToActuator", sizeof(PyObjectPlus_Proxy), 0, @@ -460,12 +454,12 @@ PyTypeObject KX_TrackToActuator::Type = { PyMethodDef KX_TrackToActuator::Methods[] = { // ---> deprecated - {"setTime", (PyCFunction) KX_TrackToActuator::sPySetTime, METH_VARARGS, (PY_METHODCHAR)SetTime_doc}, - {"getTime", (PyCFunction) KX_TrackToActuator::sPyGetTime, METH_NOARGS, (PY_METHODCHAR)GetTime_doc}, - {"setUse3D", (PyCFunction) KX_TrackToActuator::sPySetUse3D, METH_VARARGS, (PY_METHODCHAR)SetUse3D_doc}, - {"getUse3D", (PyCFunction) KX_TrackToActuator::sPyGetUse3D, METH_NOARGS, (PY_METHODCHAR)GetUse3D_doc}, - {"setObject", (PyCFunction) KX_TrackToActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc}, - {"getObject", (PyCFunction) KX_TrackToActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc}, + {"setTime", (PyCFunction) KX_TrackToActuator::sPySetTime, METH_VARARGS, (const char *)SetTime_doc}, + {"getTime", (PyCFunction) KX_TrackToActuator::sPyGetTime, METH_NOARGS, (const char *)GetTime_doc}, + {"setUse3D", (PyCFunction) KX_TrackToActuator::sPySetUse3D, METH_VARARGS, (const char *)SetUse3D_doc}, + {"getUse3D", (PyCFunction) KX_TrackToActuator::sPyGetUse3D, METH_NOARGS, (const char *)GetUse3D_doc}, + {"setObject", (PyCFunction) KX_TrackToActuator::sPySetObject, METH_O, (const char *)SetObject_doc}, + {"getObject", (PyCFunction) KX_TrackToActuator::sPyGetObject, METH_VARARGS, (const char *)GetObject_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp index 7001bfc8b7e..1f46cbf53be 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp @@ -273,31 +273,25 @@ PyObject* KX_VehicleWrapper::PyGetConstraintType(PyObject* args) //python specific stuff PyTypeObject KX_VehicleWrapper::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif - "KX_VehicleWrapper", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &PyObjectPlus::Type, - 0,0,0,0,0,0, - py_base_new + "KX_VehicleWrapper", + sizeof(PyObjectPlus_Proxy), + 0, + py_base_dealloc, + 0, + 0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0,0,0,0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + 0,0,0,0,0,0,0, + Methods, + 0, + 0, + &PyObjectPlus::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef KX_VehicleWrapper::Methods[] = { diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index cb8c891969d..6a47dec181b 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -37,13 +37,7 @@ #include "KX_PyMath.h" PyTypeObject KX_VertexProxy::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_VertexProxy", sizeof(PyObjectPlus_Proxy), 0, diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index 3561ccde9d9..97c893c6caa 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -91,13 +91,7 @@ KX_VisibilityActuator::Update() /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_VisibilityActuator::Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /* ob_size */ -#endif "KX_VisibilityActuator", sizeof(PyObjectPlus_Proxy), 0, @@ -121,7 +115,7 @@ PyTypeObject KX_VisibilityActuator::Type = { PyMethodDef KX_VisibilityActuator::Methods[] = { // Deprecated -----> {"set", (PyCFunction) KX_VisibilityActuator::sPySetVisible, METH_VARARGS, - (PY_METHODCHAR) SetVisible_doc}, + (const char *) SetVisible_doc}, // <----- {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_WorldInfo.h b/source/gameengine/Ketsji/KX_WorldInfo.h index fe4e0c51b24..2c2346ca38e 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.h +++ b/source/gameengine/Ketsji/KX_WorldInfo.h @@ -31,6 +31,10 @@ #include "MT_Scalar.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class MT_CmMatrix4x4; class KX_WorldInfo @@ -59,6 +63,13 @@ public: virtual void setMistColorRed(float)=0; virtual void setMistColorGreen(float)=0; virtual void setMistColorBlue(float)=0; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_WorldInfo"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_WORLDINFO_H diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.h b/source/gameengine/Ketsji/KX_WorldIpoController.h index d90c03d09ee..8622d80a35f 100644 --- a/source/gameengine/Ketsji/KX_WorldIpoController.h +++ b/source/gameengine/Ketsji/KX_WorldIpoController.h @@ -90,6 +90,13 @@ public: }; void AddInterpolator(KX_IInterpolator* interp); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_WorldIpoController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // KX_LIGHTIPOSGCONTROLLER_H diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile index 8e91eb6ff9a..0e9e657cc16 100644 --- a/source/gameengine/Ketsji/Makefile +++ b/source/gameengine/Ketsji/Makefile @@ -43,10 +43,10 @@ CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) CPPFLAGS += -I../../blender/python CPPFLAGS += -I../../blender/python/generic CPPFLAGS += -I$(NAN_STRING)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include -CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_MOTO)/include -CPPFLAGS += -I$(NAN_SOLID)/include +CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_BULLET2)/include +CPPFLAGS += -I$(NAN_AUDASPACE)/include + CPPFLAGS += -I../Rasterizer/RAS_OpenGLRasterizer CPPFLAGS += -I../Rasterizer -I../GameLogic -I../SceneGraph CPPFLAGS += -I../BlenderRoutines -I../Expressions diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index 1edffe0e587..d3b67cfdb11 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -10,8 +10,7 @@ incs = '. #source/blender/python/generic' # Only for Mathutils! and bpy_internal incs += ' #source/kernel/gen_system #intern/string #intern/guardedalloc' incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer' -incs += ' #intern/SoundSystem #intern/SoundSystem/include #intern/SoundSystem/openal' -incs += ' #intern/SoundSystem/dummy #intern/SoundSystem/intern #source/gameengine/Converter' +incs += ' #intern/audaspace/intern #source/gameengine/Converter' incs += ' #source/gameengine/BlenderRoutines #source/blender/imbuf #intern/moto/include' incs += ' #source/gameengine/Ketsji #source/gameengine/Ketsji/KXNetwork #source/blender/blenlib' incs += ' #source/blender/blenkernel #source/blender #source/blender/editors/include' diff --git a/source/gameengine/Makefile b/source/gameengine/Makefile index 51bc0f7d39f..bcb4b9098e7 100644 --- a/source/gameengine/Makefile +++ b/source/gameengine/Makefile @@ -38,7 +38,7 @@ DIRS += Expressions GameLogic Ketsji Rasterizer SceneGraph DIRS += Network Physics VideoTexture ifeq ($(WITH_BF_BLENDERGAMEENGINE),true) - DIRS += GamePlayer +# DIRS += GamePlayer endif include nan_subdirs.mk diff --git a/source/gameengine/Network/NG_NetworkDeviceInterface.h b/source/gameengine/Network/NG_NetworkDeviceInterface.h index 4a47774a762..2a2a909a04d 100644 --- a/source/gameengine/Network/NG_NetworkDeviceInterface.h +++ b/source/gameengine/Network/NG_NetworkDeviceInterface.h @@ -76,6 +76,13 @@ public: */ virtual STR_String GetNetworkVersion(void)=0; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:NG_NetworkDeviceInterface"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //NG_NETWORKDEVICEINTERFACE_H diff --git a/source/gameengine/Network/NG_NetworkMessage.h b/source/gameengine/Network/NG_NetworkMessage.h index 687c8120eca..a2f76dc1fae 100644 --- a/source/gameengine/Network/NG_NetworkMessage.h +++ b/source/gameengine/Network/NG_NetworkMessage.h @@ -32,6 +32,10 @@ #include "STR_HashedString.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class NG_NetworkMessage { static int s_nextID; @@ -122,6 +126,13 @@ public: int GetMessageID() { return m_uniqueMessageID; } + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:NG_NetworkMessage"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //NG_NETWORKMESSAGE_H diff --git a/source/gameengine/Network/NG_NetworkObject.h b/source/gameengine/Network/NG_NetworkObject.h index c01d76a47fc..4bf636bf011 100644 --- a/source/gameengine/Network/NG_NetworkObject.h +++ b/source/gameengine/Network/NG_NetworkObject.h @@ -32,6 +32,10 @@ #include "STR_String.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class NG_NetworkObject { STR_String m_name; @@ -39,6 +43,13 @@ public: NG_NetworkObject(); ~NG_NetworkObject(); const STR_String& GetName(); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:NG_NetworkObject"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //NG_NETWORKOBJECT_H diff --git a/source/gameengine/Network/NG_NetworkScene.h b/source/gameengine/Network/NG_NetworkScene.h index fc6367c3526..d5d6e8e0534 100644 --- a/source/gameengine/Network/NG_NetworkScene.h +++ b/source/gameengine/Network/NG_NetworkScene.h @@ -34,6 +34,10 @@ #include "STR_HashedString.h" #include +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + //MSVC defines SendMessage as a win api function, even though we aren't using it #ifdef SendMessage #undef SendMessage @@ -52,7 +56,7 @@ class NG_NetworkScene TMessageMap m_messagesBySenderName; TMessageMap m_messagesBySubject; -public: +public: NG_NetworkScene(NG_NetworkDeviceInterface *nic); ~NG_NetworkScene(); @@ -100,6 +104,13 @@ protected: * @param map Message map with messages. */ void ClearMessageMap(TMessageMap& map); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:NG_NetworkScene"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__NG_NETWORKSCENE_H diff --git a/source/gameengine/Physics/Bullet/CMakeLists.txt b/source/gameengine/Physics/Bullet/CMakeLists.txt index 02f2aa635af..7b7fb508ebd 100644 --- a/source/gameengine/Physics/Bullet/CMakeLists.txt +++ b/source/gameengine/Physics/Bullet/CMakeLists.txt @@ -35,7 +35,6 @@ SET(INC ../../../../intern/guardedalloc ../../../kernel/gen_system ../../../../intern/string - ../../../../intern/SoundSystem ../../Rasterizer ../../Ketsji ../../Expressions diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.h b/source/gameengine/Physics/Bullet/CcdGraphicController.h index b0626f902c2..99885eb99ee 100644 --- a/source/gameengine/Physics/Bullet/CcdGraphicController.h +++ b/source/gameengine/Physics/Bullet/CcdGraphicController.h @@ -75,6 +75,12 @@ private: btBroadphaseProxy* m_handle; void* m_newClientInfo; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CcdGraphicController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //BULLET2_PHYSICSCONTROLLER_H diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 8eb2e616ecf..69b16ca35bd 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -58,8 +58,6 @@ class btCollisionShape; class CcdShapeConstructionInfo { public: - - static CcdShapeConstructionInfo* FindMesh(class RAS_MeshObject* mesh, struct DerivedMesh* dm, bool polytope, bool gimpact); CcdShapeConstructionInfo() : @@ -191,6 +189,13 @@ protected: bool m_forceReInstance; //use gimpact for concave dynamic/moving collision detection float m_weldingThreshold1; //welding closeby vertices together can improve softbody stability etc. CcdShapeConstructionInfo* m_shapeProxy; // only used for PHY_SHAPE_PROXY, pointer to actual shape info + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CcdShapeConstructionInfo"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; struct CcdConstructionInfo @@ -559,7 +564,11 @@ protected: } - +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CcdPhysicsController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; @@ -587,7 +596,13 @@ class DefaultMotionState : public PHY_IMotionState btTransform m_worldTransform; btVector3 m_localScaling; - + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:DefaultMotionState"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index bc5491e00cc..e087eac32c5 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -275,7 +275,11 @@ protected: bool m_scalingPropagated; - +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CcdPhysicsEnvironment"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //CCDPHYSICSENVIRONMENT diff --git a/source/gameengine/Physics/Bullet/Makefile b/source/gameengine/Physics/Bullet/Makefile index 19b17de275a..433d1df3d2f 100644 --- a/source/gameengine/Physics/Bullet/Makefile +++ b/source/gameengine/Physics/Bullet/Makefile @@ -41,7 +41,6 @@ CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I../../../kernel/gen_system CPPFLAGS += -I../../Physics/common CPPFLAGS += -I../../Physics/Dummy diff --git a/source/gameengine/Physics/Bullet/SConscript b/source/gameengine/Physics/Bullet/SConscript index b6d0a75fd04..44b75402630 100644 --- a/source/gameengine/Physics/Bullet/SConscript +++ b/source/gameengine/Physics/Bullet/SConscript @@ -16,7 +16,6 @@ incs += ' #source/gameengine/SceneGraph' incs += ' #source/blender/makesdna' incs += ' #source/blender/blenkernel' incs += ' #source/blender/blenlib' -incs += ' #intern/SoundSystem' incs += ' #intern/guardedalloc' incs += ' ' + env['BF_BULLET_INC'] diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h index 8dbd137f9de..28440ebdad4 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h @@ -93,6 +93,12 @@ public: return 0.f; } + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:DummyPhysicsEnvironment"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //_DUMMYPHYSICSENVIRONMENT diff --git a/source/gameengine/Physics/Dummy/Makefile b/source/gameengine/Physics/Dummy/Makefile index c016a0bebcb..0e36266ae09 100644 --- a/source/gameengine/Physics/Dummy/Makefile +++ b/source/gameengine/Physics/Dummy/Makefile @@ -39,7 +39,7 @@ CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_MOTO)/include +CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include CPPFLAGS += -I../../Physics/common CPPFLAGS += -I../../Physics/Dummy diff --git a/source/gameengine/Physics/common/Makefile b/source/gameengine/Physics/common/Makefile index f2dd0134b71..f87da383520 100644 --- a/source/gameengine/Physics/common/Makefile +++ b/source/gameengine/Physics/common/Makefile @@ -37,10 +37,9 @@ CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_MOTO)/include +CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../../blender # these two needed because of blenkernel CPPFLAGS += -I../../blender/makesdna diff --git a/source/gameengine/Physics/common/PHY_IController.h b/source/gameengine/Physics/common/PHY_IController.h index 45e93f9d24e..a053a9679b8 100644 --- a/source/gameengine/Physics/common/PHY_IController.h +++ b/source/gameengine/Physics/common/PHY_IController.h @@ -31,7 +31,9 @@ #include "PHY_DynamicTypes.h" - +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif /** PHY_IController is the abstract simplified Interface to objects @@ -41,12 +43,17 @@ class PHY_IController { public: - virtual ~PHY_IController(); // clientinfo for raycasts for example virtual void* getNewClientInfo()=0; virtual void setNewClientInfo(void* clientinfo)=0; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //PHY_ICONTROLLER_H diff --git a/source/gameengine/Physics/common/PHY_IGraphicController.h b/source/gameengine/Physics/common/PHY_IGraphicController.h index 470d42cb84a..aae971ff42a 100644 --- a/source/gameengine/Physics/common/PHY_IGraphicController.h +++ b/source/gameengine/Physics/common/PHY_IGraphicController.h @@ -39,9 +39,7 @@ */ class PHY_IGraphicController : public PHY_IController { - public: - virtual ~PHY_IGraphicController(); /** SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding') @@ -53,6 +51,11 @@ class PHY_IGraphicController : public PHY_IController virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate) {return 0;} + +#ifdef WITH_CXX_GUARDEDALLOC + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //PHY_IGRAPHICCONTROLLER_H diff --git a/source/gameengine/Physics/common/PHY_IMotionState.h b/source/gameengine/Physics/common/PHY_IMotionState.h index f7bcbd4f2d0..c3d01c010ff 100644 --- a/source/gameengine/Physics/common/PHY_IMotionState.h +++ b/source/gameengine/Physics/common/PHY_IMotionState.h @@ -29,6 +29,10 @@ #ifndef PHY__MOTIONSTATE_H #define PHY__MOTIONSTATE_H +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + /** PHY_IMotionState is the Interface to explicitly synchronize the world transformation. Default implementations for mayor graphics libraries like OpenGL and DirectX can be provided. @@ -36,8 +40,7 @@ class PHY_IMotionState { - public: - + public: virtual ~PHY_IMotionState(); virtual void getWorldPosition(float& posX,float& posY,float& posZ)=0; @@ -52,6 +55,13 @@ class PHY_IMotionState virtual void calculateWorldTransformations()=0; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IMotionState"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //PHY__MOTIONSTATE_H diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h index d7b8cb0b54f..664e5fddd83 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsController.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h @@ -41,7 +41,6 @@ class PHY_IPhysicsController : public PHY_IController { public: - virtual ~PHY_IPhysicsController(); /** SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding') @@ -99,6 +98,11 @@ class PHY_IPhysicsController : public PHY_IController PHY__Vector3 GetWorldPosition(PHY__Vector3& localpos); +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IPhysicsController"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //PHY_IPHYSICSCONTROLLER_H diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index c76e9d175ce..291dac298dc 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -32,6 +32,11 @@ #include #include "PHY_DynamicTypes.h" + +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class PHY_IVehicle; class RAS_MeshObject; class PHY_IPhysicsController; @@ -76,6 +81,12 @@ public: m_faceNormal(faceNormal) { } + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IRayCastFilterCallback"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; /** @@ -160,6 +171,13 @@ class PHY_IPhysicsEnvironment virtual void setConstraintParam(int constraintId,int param,float value,float value1) = 0; virtual float getConstraintParam(int constraintId,int param) = 0; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IPhysicsEnvironment"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //_IPHYSICSENVIRONMENT diff --git a/source/gameengine/Physics/common/PHY_IVehicle.h b/source/gameengine/Physics/common/PHY_IVehicle.h index 498df0dd840..261bae480f5 100644 --- a/source/gameengine/Physics/common/PHY_IVehicle.h +++ b/source/gameengine/Physics/common/PHY_IVehicle.h @@ -6,10 +6,13 @@ class PHY_IMotionState; #include "PHY_DynamicTypes.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class PHY_IVehicle { public: - virtual ~PHY_IVehicle(); virtual void AddWheel( @@ -52,6 +55,12 @@ public: virtual void SetCoordinateSystem(int rightIndex,int upIndex,int forwardIndex) =0; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IVehicle"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //PHY_IVEHICLE_H diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py index 46f00fa7ea6..72e2c3ed7f5 100644 --- a/source/gameengine/PyDoc/GameLogic.py +++ b/source/gameengine/PyDoc/GameLogic.py @@ -52,7 +52,6 @@ Documentation for the GameLogic Module. - L{ActionActuator} - L{AddObjectActuator} - L{CameraActuator} - - L{CDActuator} - L{ConstraintActuator} - L{DynamicActuator} - L{EndObjectActuator} diff --git a/source/gameengine/PyDoc/GameTypes.py b/source/gameengine/PyDoc/GameTypes.py index b1d1ce71173..054b2cb4daf 100644 --- a/source/gameengine/PyDoc/GameTypes.py +++ b/source/gameengine/PyDoc/GameTypes.py @@ -12,7 +12,7 @@ Documentation for the GameTypes Module. @group Sensors: SCA_ActuatorSensor, SCA_AlwaysSensor, SCA_DelaySensor, SCA_JoystickSensor, SCA_KeyboardSensor, KX_MouseFocusSensor, SCA_MouseSensor, KX_NearSensor, KX_NetworkMessageSensor, SCA_PropertySensor, KX_RadarSensor, SCA_RandomSensor, KX_RaySensor, KX_TouchSensor -@group Actuators: SCA_2DFilterActuator, BL_ActionActuator, KX_SCA_AddObjectActuator, KX_CameraActuator, KX_CDActuator, KX_ConstraintActuator, KX_SCA_DynamicActuator, KX_SCA_EndObjectActuator, KX_GameActuator, KX_IpoActuator, KX_NetworkMessageActuator, KX_ObjectActuator, KX_ParentActuator, SCA_PropertyActuator, SCA_RandomActuator, KX_SCA_ReplaceMeshActuator, KX_SceneActuator, BL_ShapeActionActuator, KX_SoundActuator, KX_StateActuator, KX_TrackToActuator, KX_VisibilityActuator +@group Actuators: SCA_2DFilterActuator, BL_ActionActuator, KX_SCA_AddObjectActuator, KX_CameraActuator, KX_ConstraintActuator, KX_SCA_DynamicActuator, KX_SCA_EndObjectActuator, KX_GameActuator, KX_IpoActuator, KX_NetworkMessageActuator, KX_ObjectActuator, KX_ParentActuator, SCA_PropertyActuator, SCA_RandomActuator, KX_SCA_ReplaceMeshActuator, KX_SceneActuator, BL_ShapeActionActuator, KX_SoundActuator, KX_StateActuator, KX_TrackToActuator, KX_VisibilityActuator @group Controllers: SCA_ANDController, SCA_NANDController, SCA_NORController, SCA_ORController, SCA_PythonController, SCA_XNORController, SCA_XORController """ @@ -1106,59 +1106,6 @@ class KX_BlenderMaterial(PyObjectPlus): # , RAS_IPolyMaterial) @return: the material's index """ -class KX_CDActuator(SCA_IActuator): - """ - CD Controller actuator. - @ivar volume: controls the volume to set the CD to. 0.0 = silent, 1.0 = max volume. - @type volume: float - @ivar track: the track selected to be played - @type track: integer - @ivar gain: the gain (volume) of the CD between 0.0 and 1.0. - @type gain: float - """ - def startCD(): - """ - Starts the CD playing. - """ - def stopCD(): - """ - Stops the CD playing. - """ - def pauseCD(): - """ - Pauses the CD. - """ - def resumeCD(): - """ - Resumes the CD after a pause. - """ - def playAll(): - """ - Plays the CD from the beginning. - """ - def playTrack(trackNumber): - """ - Plays the track selected. - """ -#{ Deprecated - def setGain(gain): - """ - Sets the gain (volume) of the CD. - - @deprecated: Use the L{volume} property. - @type gain: float - @param gain: the gain to set the CD to. 0.0 = silent, 1.0 = max volume. - """ - def getGain(): - """ - Gets the current gain (volume) of the CD. - - @deprecated: Use the L{volume} property. - @rtype: float - @return: Between 0.0 (silent) and 1.0 (max volume) - """ -#} - class KX_CameraActuator(SCA_IActuator): """ Applies changes to a camera. diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h index 6a420a974d4..99d4ea595ab 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h @@ -30,6 +30,10 @@ #define MAX_RENDER_PASS 100 +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class RAS_2DFilterManager { private: @@ -97,5 +101,12 @@ public: void RenderFilters(RAS_ICanvas* canvas); void EnableFilter(vector& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_2DFilterManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 200b1c6c89f..8b3c4990a7a 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -126,10 +126,7 @@ void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList RAS_MaterialBucket* bucket = *bit; RAS_MeshSlot* ms; // remove the mesh slot form the list, it culls them automatically for next frame - for(ms = bucket->GetNextActiveMeshSlot(); - ms!= NULL; - ms = bucket->GetNextActiveMeshSlot()) - { + while((ms = bucket->GetNextActiveMeshSlot())) { slots[i++].set(ms, bucket, pnorm); } } @@ -179,9 +176,7 @@ void RAS_BucketManager::RenderSolidBuckets( RAS_MaterialBucket* bucket = *bit; RAS_MeshSlot* ms; // remove the mesh slot form the list, it culls them automatically for next frame - for(ms = bucket->GetNextActiveMeshSlot(); - ms!= NULL; - ms = bucket->GetNextActiveMeshSlot()) + while((ms = bucket->GetNextActiveMeshSlot())) { rendertools->SetClientObject(rasty, ms->m_clientObj); while (bucket->ActivateMaterial(cameratrans, rasty, rendertools)) diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h index 2b81ddd3c82..dcac41ab6e9 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.h +++ b/source/gameengine/Rasterizer/RAS_BucketManager.h @@ -67,6 +67,12 @@ private: RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools); void RenderAlphaBuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_BucketManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__RAS_BUCKETMANAGER diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h index 75c0dcd1eeb..6f4cd425c6c 100644 --- a/source/gameengine/Rasterizer/RAS_Deformer.h +++ b/source/gameengine/Rasterizer/RAS_Deformer.h @@ -37,6 +37,10 @@ #include #include "GEN_Map.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + struct DerivedMesh; class RAS_MeshObject; @@ -82,6 +86,12 @@ public: protected: class RAS_MeshObject *m_pMesh; bool m_bDynamic; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_Deformer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.h b/source/gameengine/Rasterizer/RAS_FramingManager.h index 4398e2d00c3..3ae794c430a 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.h +++ b/source/gameengine/Rasterizer/RAS_FramingManager.h @@ -29,6 +29,10 @@ #ifndef RAS_FRAMINGMANAGER_H #define RAS_FRAMINGMANAGER_H +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class RAS_Rect; /** @@ -55,7 +59,6 @@ class RAS_Rect; class RAS_FrameSettings { public : - /** * enum defining the policy to use * in each axis. @@ -154,6 +157,13 @@ private : float m_bar_b; unsigned int m_design_aspect_width; unsigned int m_design_aspect_height; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_FrameSettings"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; struct RAS_FrameFrustum @@ -274,6 +284,13 @@ private : RAS_FramingManager( const RAS_FramingManager & ); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_FramingManager"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h index f3f817a943d..dae4fb3f4d2 100644 --- a/source/gameengine/Rasterizer/RAS_ICanvas.h +++ b/source/gameengine/Rasterizer/RAS_ICanvas.h @@ -33,6 +33,10 @@ * 2D rendering device context. The connection from 3d rendercontext to 2d surface. */ +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class RAS_Rect; @@ -173,6 +177,13 @@ public: MakeScreenShot( const char* filename )=0; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_ICanvas"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__RAS_ICANVAS diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index a01196ef307..af909dfa731 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -38,6 +38,10 @@ #include "MT_Vector3.h" #include "STR_HashedString.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class RAS_IRasterizer; struct MTFace; struct Material; @@ -82,7 +86,6 @@ protected: unsigned int m_flag;//MaterialProps int m_multimode; // sum of values public: - MT_Vector3 m_diffuse; float m_shininess; MT_Vector3 m_specular; @@ -165,6 +168,13 @@ public: * PreCalculate texture gen */ virtual void OnConstruction(int layer){} + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_IPolyMaterial"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; inline bool operator ==( const RAS_IPolyMaterial & rhs,const RAS_IPolyMaterial & lhs) diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index dc8c3c1ebf8..05406413941 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -43,6 +43,10 @@ #include using namespace std; +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class RAS_ICanvas; class RAS_IPolyMaterial; @@ -57,7 +61,6 @@ typedef vector< KX_IndexArray* > vecIndexArrays; class RAS_IRasterizer { public: - RAS_IRasterizer(RAS_ICanvas* canv){}; virtual ~RAS_IRasterizer(){}; /** @@ -407,6 +410,13 @@ public: virtual void SetBlendingMode(int blendmode)=0; virtual void SetFrontFace(bool ccw)=0; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_IRasterizer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__RAS_IRASTERIZER diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index 52f6397cf6c..5d52ddc9688 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -36,6 +36,10 @@ #include #include +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class RAS_IPolyMaterial; struct RAS_LightObject; @@ -180,6 +184,13 @@ public: virtual void Render2DFilters(RAS_ICanvas* canvas)=0; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_IRenderTools"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__RAS_IRENDERTOOLS diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index 8db75b8b735..207763392b2 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -169,6 +169,13 @@ public: bool IsCulled() { return m_bCulled; } #endif void SetCulled(bool culled) { m_bCulled = culled; } + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_MeshSlot"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; /* Used by RAS_MeshObject, to point to it's slots in a bucket */ @@ -179,6 +186,13 @@ public: RAS_MeshSlot *m_baseslot; class RAS_MaterialBucket *m_bucket; GEN_Map m_slots; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_MeshMaterial"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; /* Contains a list of display arrays with the same material, @@ -232,6 +246,12 @@ private: RAS_IPolyMaterial* m_material; SG_DList m_activeMeshSlotsHead; // only those which must be rendered + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_MaterialBucket"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__RAS_MATERIAL_BUCKET diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index f34546a8ff7..1738423c4f3 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -173,6 +173,13 @@ public: }; vector > m_sharedvertex_map; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_MeshObject"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__RAS_MESHOBJECT diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h index fe358808e4a..cff48081f02 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h @@ -66,6 +66,13 @@ public: virtual void SetDrawingMode(int drawingmode); virtual bool QueryLists(){return true;} + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_ListRasterizer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index e3422394e9e..db0f97bf46f 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -289,6 +289,13 @@ public: virtual void SetBlendingMode(int blendmode); virtual void SetFrontFace(bool ccw); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_OpenGLRasterizer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__RAS_OPENGLRASTERIZER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h index 766bbfbed0e..6112c1a4d98 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h @@ -58,6 +58,12 @@ private: //virtual bool QueryArrays(){return true;} //virtual bool QueryLists(){return m_Lock;} + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_VAOpenGLRasterizer"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__KX_VERTEXARRAYOPENGLRASTERIZER diff --git a/source/gameengine/Rasterizer/RAS_Polygon.h b/source/gameengine/Rasterizer/RAS_Polygon.h index 41eaa6bdd4a..a5b77738026 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.h +++ b/source/gameengine/Rasterizer/RAS_Polygon.h @@ -35,6 +35,10 @@ #include using namespace std; +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + /* polygon flags */ class RAS_Polygon @@ -85,6 +89,12 @@ public: RAS_MaterialBucket* GetMaterial(); RAS_DisplayArray* GetDisplayArray(); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_Polygon"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/Rasterizer/RAS_Rect.h b/source/gameengine/Rasterizer/RAS_Rect.h index 4cd0c636cfd..ca7435673c9 100644 --- a/source/gameengine/Rasterizer/RAS_Rect.h +++ b/source/gameengine/Rasterizer/RAS_Rect.h @@ -30,6 +30,10 @@ #ifndef _RAS_RECT #define _RAS_RECT +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + /** * @section interface class. * RAS_Rect just encodes a simple rectangle. @@ -89,6 +93,12 @@ public: { m_y2 = y2; } + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_Rect"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif // _RAS_RECT diff --git a/source/gameengine/Rasterizer/RAS_TexVert.h b/source/gameengine/Rasterizer/RAS_TexVert.h index 811867f3579..b93078f4712 100644 --- a/source/gameengine/Rasterizer/RAS_TexVert.h +++ b/source/gameengine/Rasterizer/RAS_TexVert.h @@ -34,6 +34,10 @@ #include "MT_Point2.h" #include "MT_Transform.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + static MT_Point3 g_pt3; static MT_Point2 g_pt2; @@ -134,6 +138,12 @@ public: // compare two vertices, to test if they can be shared, used for // splitting up based on uv's, colors, etc bool closeTo(const RAS_TexVert* other); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_TexVert"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__RAS_TEXVERT diff --git a/source/gameengine/SceneGraph/SG_BBox.h b/source/gameengine/SceneGraph/SG_BBox.h index c39ad268e25..8dbb9869dae 100644 --- a/source/gameengine/SceneGraph/SG_BBox.h +++ b/source/gameengine/SceneGraph/SG_BBox.h @@ -38,6 +38,10 @@ #include +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class SG_Node; /** @@ -128,6 +132,12 @@ public: friend class SG_Tree; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_BBox"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif /* __SG_BBOX_H__ */ diff --git a/source/gameengine/SceneGraph/SG_Controller.h b/source/gameengine/SceneGraph/SG_Controller.h index c32885b915f..db9d7bdb464 100644 --- a/source/gameengine/SceneGraph/SG_Controller.h +++ b/source/gameengine/SceneGraph/SG_Controller.h @@ -40,6 +40,12 @@ class SG_Controller { public: + +#ifdef WITH_CXX_GUARDEDALLOC + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "SG_Controller"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif + SG_Controller( ) : m_pObject(NULL) { diff --git a/source/gameengine/SceneGraph/SG_DList.h b/source/gameengine/SceneGraph/SG_DList.h index 7bef13cc9e3..3e17fb55dc0 100644 --- a/source/gameengine/SceneGraph/SG_DList.h +++ b/source/gameengine/SceneGraph/SG_DList.h @@ -31,6 +31,10 @@ #include +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + /** * Double circular linked list */ @@ -155,6 +159,13 @@ public: { return this; } + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_DList"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__SG_DLIST diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h index 8f448a0e890..23e6c1e9c99 100644 --- a/source/gameengine/SceneGraph/SG_IObject.h +++ b/source/gameengine/SceneGraph/SG_IObject.h @@ -160,8 +160,6 @@ private : SGControllerList m_SGcontrollers; public: - - virtual ~SG_IObject(); @@ -338,6 +336,11 @@ protected : ); +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_IObject"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__SG_IOBJECT diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index 7c6ef92f670..4281bcd11f6 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -40,7 +40,6 @@ typedef std::vector NodeList; class SG_Node : public SG_Spatial { public: - SG_Node( void* clientobj, void* clientinfo, @@ -260,6 +259,12 @@ private: */ SG_Node* m_SGparent; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_Node"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__SG_NODE_H diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h index 8f45df09b27..a6a43c19115 100644 --- a/source/gameengine/SceneGraph/SG_ParentRelation.h +++ b/source/gameengine/SceneGraph/SG_ParentRelation.h @@ -55,7 +55,6 @@ class SG_Spatial; class SG_ParentRelation { public : - /** * Update the childs local and global coordinates * based upon the parents global coordinates. @@ -128,6 +127,13 @@ protected : SG_ParentRelation( const SG_ParentRelation & ); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_ParentRelation"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/SceneGraph/SG_QList.h b/source/gameengine/SceneGraph/SG_QList.h index d8afc33ea4f..6399111d80b 100644 --- a/source/gameengine/SceneGraph/SG_QList.h +++ b/source/gameengine/SceneGraph/SG_QList.h @@ -151,6 +151,13 @@ public: { return m_bqlink; } + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_QList"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__SG_QLIST diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h index 6e274487c9d..a818c8c81f7 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.h +++ b/source/gameengine/SceneGraph/SG_Spatial.h @@ -66,7 +66,6 @@ protected: bool m_ogldirty; // true if the openGL matrix for this object must be recomputed public: - inline void ClearModified() { m_modified = false; @@ -284,6 +283,12 @@ protected: bool& parentUpdated ); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_Spatial"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__SG_SPATIAL_H diff --git a/source/gameengine/SceneGraph/SG_Tree.h b/source/gameengine/SceneGraph/SG_Tree.h index 4741af83aae..6ca3307920e 100644 --- a/source/gameengine/SceneGraph/SG_Tree.h +++ b/source/gameengine/SceneGraph/SG_Tree.h @@ -111,6 +111,13 @@ public: } }; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_Tree"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; @@ -148,6 +155,12 @@ public: SG_Tree* MakeTree(); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_TreeFactory"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif /* __SG_BBOX_H__ */ diff --git a/source/gameengine/VideoTexture/CMakeLists.txt b/source/gameengine/VideoTexture/CMakeLists.txt index 9d1bb89d2ca..255d0907101 100644 --- a/source/gameengine/VideoTexture/CMakeLists.txt +++ b/source/gameengine/VideoTexture/CMakeLists.txt @@ -47,7 +47,6 @@ SET(INC ../../../intern/string ../../../intern/moto/include ../../../intern/guardedalloc - ../../../intern/SoundSystem ../../../extern/glew/include ${PYTHON_INC} ) diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.cpp b/source/gameengine/VideoTexture/FilterBlueScreen.cpp index 6d26e5b6d35..2a624b2ccaa 100644 --- a/source/gameengine/VideoTexture/FilterBlueScreen.cpp +++ b/source/gameengine/VideoTexture/FilterBlueScreen.cpp @@ -135,13 +135,7 @@ static PyGetSetDef filterBSGetSets[] = // define python type PyTypeObject FilterBlueScreenType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.FilterBlueScreen", /*tp_name*/ sizeof(PyFilter), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp index eb86f520e02..e5d479747c4 100644 --- a/source/gameengine/VideoTexture/FilterColor.cpp +++ b/source/gameengine/VideoTexture/FilterColor.cpp @@ -41,13 +41,7 @@ static PyGetSetDef filterGrayGetSets[] = // define python type PyTypeObject FilterGrayType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.FilterGray", /*tp_name*/ sizeof(PyFilter), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -178,13 +172,7 @@ static PyGetSetDef filterColorGetSets[] = // define python type PyTypeObject FilterColorType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.FilterColor", /*tp_name*/ sizeof(PyFilter), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -317,13 +305,7 @@ static PyGetSetDef filterLevelGetSets[] = // define python type PyTypeObject FilterLevelType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.FilterLevel", /*tp_name*/ sizeof(PyFilter), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp index 002be6c3189..d755e6294c9 100644 --- a/source/gameengine/VideoTexture/FilterNormal.cpp +++ b/source/gameengine/VideoTexture/FilterNormal.cpp @@ -124,13 +124,7 @@ static PyGetSetDef filterNormalGetSets[] = // define python type PyTypeObject FilterNormalType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.FilterNormal", /*tp_name*/ sizeof(PyFilter), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/source/gameengine/VideoTexture/FilterSource.cpp b/source/gameengine/VideoTexture/FilterSource.cpp index 4c75e14bbac..4b67785edb3 100644 --- a/source/gameengine/VideoTexture/FilterSource.cpp +++ b/source/gameengine/VideoTexture/FilterSource.cpp @@ -36,13 +36,7 @@ http://www.gnu.org/copyleft/lesser.txt. // define python type PyTypeObject FilterRGB24Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.FilterRGB24", /*tp_name*/ sizeof(PyFilter), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -87,13 +81,7 @@ PyTypeObject FilterRGB24Type = // define python type PyTypeObject FilterRGBA32Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.FilterRGBA32", /*tp_name*/ sizeof(PyFilter), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -138,13 +126,7 @@ PyTypeObject FilterRGBA32Type = // define python type PyTypeObject FilterBGR24Type = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.FilterBGR24", /*tp_name*/ sizeof(PyFilter), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp index c7185660e83..9cd661a2422 100644 --- a/source/gameengine/VideoTexture/ImageBuff.cpp +++ b/source/gameengine/VideoTexture/ImageBuff.cpp @@ -122,13 +122,7 @@ static PyGetSetDef imageBuffGetSets[] = // define python type PyTypeObject ImageBuffType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.ImageBuff", /*tp_name*/ sizeof(PyImage), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp index 067143e57bb..2560467c3db 100644 --- a/source/gameengine/VideoTexture/ImageMix.cpp +++ b/source/gameengine/VideoTexture/ImageMix.cpp @@ -166,13 +166,7 @@ static PyGetSetDef imageMixGetSets[] = // define python type PyTypeObject ImageMixType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.ImageMix", /*tp_name*/ sizeof(PyImage), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index d8be08e0eb5..6e70bfb14a0 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -376,13 +376,7 @@ static PyGetSetDef imageRenderGetSets[] = // define python type PyTypeObject ImageRenderType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.ImageRender", /*tp_name*/ sizeof(PyImage), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -715,13 +709,7 @@ ImageRender::ImageRender (KX_Scene * scene, KX_GameObject * observer, KX_GameObj // define python type PyTypeObject ImageMirrorType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.ImageMirror", /*tp_name*/ sizeof(PyImage), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index 55b14396280..691a983970a 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -289,13 +289,7 @@ static PyGetSetDef imageViewportGetSets[] = // define python type PyTypeObject ImageViewportType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.ImageViewport", /*tp_name*/ sizeof(PyImage), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/source/gameengine/VideoTexture/Makefile b/source/gameengine/VideoTexture/Makefile index 8677ed5c177..90457df720f 100644 --- a/source/gameengine/VideoTexture/Makefile +++ b/source/gameengine/VideoTexture/Makefile @@ -42,7 +42,6 @@ CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) CPPFLAGS += -I../../blender/python CPPFLAGS += -I$(NAN_STRING)/include -CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../Rasterizer/RAS_OpenGLRasterizer CPPFLAGS += -I../Rasterizer -I../GameLogic -I../SceneGraph diff --git a/source/gameengine/VideoTexture/SConscript b/source/gameengine/VideoTexture/SConscript index fdf46f70ad7..d6b78f6d1a6 100644 --- a/source/gameengine/VideoTexture/SConscript +++ b/source/gameengine/VideoTexture/SConscript @@ -12,8 +12,7 @@ incs += ' #source/gameengine/BlenderRoutines' incs += ' #source/blender/editors/include #source/blender/blenlib #source/blender/blenkernel' incs += ' #source/blender/makesdna #source/blender/imbuf #source/blender/python' incs += ' #source/blender/gpu #source/kernel/gen_system #intern/string #intern/moto/include' -incs += ' #intern/guardedalloc #intern/SoundSystem' -incs += ' #extern/glew/include' +incs += ' #intern/guardedalloc #extern/glew/include' defs = [] cxxflags = [] diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index f4105652f80..04b39f0b05c 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -434,13 +434,7 @@ static PyGetSetDef textureGetSets[] = // class Texture declaration PyTypeObject TextureType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.Texture", /*tp_name*/ sizeof(Texture), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index cf4ea88c1b5..f21555a95c9 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -1160,13 +1160,7 @@ static PyGetSetDef videoGetSets[] = // python type declaration PyTypeObject VideoFFmpegType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.VideoFFmpeg", /*tp_name*/ sizeof(PyImage), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -1284,13 +1278,7 @@ static PyGetSetDef imageGetSets[] = // python type declaration PyTypeObject ImageFFmpegType = { -#if (PY_VERSION_HEX >= 0x02060000) PyVarObject_HEAD_INIT(NULL, 0) -#else - /* python 2.5 and below */ - PyObject_HEAD_INIT( NULL ) /* required py macro */ - 0, /*ob_size*/ -#endif "VideoTexture.ImageFFmpeg", /*tp_name*/ sizeof(PyImage), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index 22171f69321..998d63506b0 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -159,8 +159,6 @@ static void registerAllTypes(void) pyFilterTypes.add(&FilterBGR24Type, "FilterBGR24"); } - -#if (PY_VERSION_HEX >= 0x03000000) static struct PyModuleDef VideoTexture_module_def = { {}, /* m_base */ "VideoTexture", /* m_name */ @@ -172,7 +170,6 @@ static struct PyModuleDef VideoTexture_module_def = { 0, /* m_clear */ 0, /* m_free */ }; -#endif PyObject* initVideoTexture(void) { @@ -202,14 +199,8 @@ PyObject* initVideoTexture(void) else { PyErr_Clear(); -#if (PY_VERSION_HEX >= 0x03000000) m = PyModule_Create(&VideoTexture_module_def); PyDict_SetItemString(PySys_GetObject("modules"), VideoTexture_module_def.m_name, m); -#else - m = Py_InitModule4("VideoTexture", moduleMethods, - "Module that allows to play video files on textures in GameBlender.", - (PyObject*)NULL,PYTHON_API_VERSION); -#endif } if (m == NULL) diff --git a/source/kernel/gen_system/SYS_SingletonSystem.cpp b/source/kernel/gen_system/SYS_SingletonSystem.cpp index 47e35cf84d8..43d70a94ae1 100644 --- a/source/kernel/gen_system/SYS_SingletonSystem.cpp +++ b/source/kernel/gen_system/SYS_SingletonSystem.cpp @@ -95,6 +95,6 @@ void SYS_SingletonSystem::SYS_WriteCommandLineString(const char *paramname, cons m_string_commandlineparms.insert(paramname, value); } -SYS_SingletonSystem::SYS_SingletonSystem() : m_soundfilecache(NULL) +SYS_SingletonSystem::SYS_SingletonSystem() { } diff --git a/source/kernel/gen_system/SYS_SingletonSystem.h b/source/kernel/gen_system/SYS_SingletonSystem.h index 175656ac4ed..b72070c4e23 100644 --- a/source/kernel/gen_system/SYS_SingletonSystem.h +++ b/source/kernel/gen_system/SYS_SingletonSystem.h @@ -56,7 +56,6 @@ private: GEN_Map m_int_commandlineparms; GEN_Map m_float_commandlineparms; GEN_Map m_string_commandlineparms; - void* m_soundfilecache; }; #endif //__SINGLETONSYSTEM_H diff --git a/source/nan_compile.mk b/source/nan_compile.mk index bc264fe5c1d..c62b4f2681b 100644 --- a/source/nan_compile.mk +++ b/source/nan_compile.mk @@ -39,11 +39,9 @@ CPPFLAGS ?= $(NAN_CPPFLAGS) # Uncomment next lines to enable integrated game engine ifneq ($(NAN_NO_KETSJI), true) CFLAGS += -DGAMEBLENDER=1 - CFLAGS += -DUSE_SUMO_SOLID - CCFLAGS += -DUSE_SUMO_SOLID ifeq ($(NAN_USE_BULLET), true) - CFLAGS += -DUSE_BULLET -DWITH_BULLET - CCFLAGS += -DUSE_BULLET -DWITH_BULLET + CFLAGS += -DUSE_BULLET + CCFLAGS += -DUSE_BULLET endif else CPPFLAGS += -DNO_KETSJI diff --git a/source/nan_definitions.mk b/source/nan_definitions.mk index 019362737c7..b3f36dd3b5c 100644 --- a/source/nan_definitions.mk +++ b/source/nan_definitions.mk @@ -81,24 +81,15 @@ ifndef CONFIG_GUESS endif export NAN_MOTO ?= $(LCGDIR)/moto -ifeq ($(FREE_WINDOWS), true) - export NAN_SOLID ?= $(LCGDIR)/gcc/solid - export NAN_QHULL ?= $(LCGDIR)/gcc/qhull -else - export NAN_SOLID ?= $(LCGDIR)/solid - export NAN_QHULL ?= $(LCGDIR)/qhull -endif export BF_PROFILE ?= false export NAN_USE_BULLET ?= true export NAN_BULLET2 ?= $(LCGDIR)/bullet2 - export NAN_FUZZICS ?= $(SRCHOME)/gameengine/Physics/Sumo/Fuzzics - export NAN_BLENKEY ?= $(LCGDIR)/blenkey export NAN_DECIMATION ?= $(LCGDIR)/decimation export NAN_GUARDEDALLOC ?= $(LCGDIR)/guardedalloc export NAN_IKSOLVER ?= $(LCGDIR)/iksolver export NAN_BSP ?= $(LCGDIR)/bsp export NAN_BOOLOP ?= $(LCGDIR)/boolop - export NAN_SOUNDSYSTEM ?= $(LCGDIR)/SoundSystem + export NAN_AUDASPACE ?= $(LCGDIR)/audaspace export NAN_STRING ?= $(LCGDIR)/string export NAN_MEMUTIL ?= $(LCGDIR)/memutil export NAN_CONTAINER ?= $(LCGDIR)/container @@ -140,7 +131,7 @@ endif ifeq ($(NAN_PYTHON_VERSION),3.1) export PY_FRAMEWORK ?= 0 - export NAN_PYTHON ?= $(LCGDIR)/python + export NAN_PYTHON ?= $(LCGDIR)/python export NAN_PYTHON_LIB ?= $(NAN_PYTHON)/lib/python$(NAN_PYTHON_VERSION)/libpython$(NAN_PYTHON_VERSION).a else export PY_FRAMEWORK ?= 1 @@ -160,7 +151,6 @@ endif export NAN_JPEG ?= $(LCGDIR)/jpeg export NAN_PNG ?= $(LCGDIR)/png export NAN_TIFF ?= $(LCGDIR)/tiff - export NAN_ODE ?= $(LCGDIR)/ode export NAN_TERRAPLAY ?= $(LCGDIR)/terraplay export NAN_MESA ?= /usr/src/Mesa-3.1 export NAN_ZLIB ?= $(LCGDIR)/zlib @@ -185,8 +175,6 @@ endif export NAN_NO_OPENAL=true endif - # Uncomment the following line to use Mozilla inplace of netscape - # CPPFLAGS +=-DMOZ_NOT_NET # Location of MOZILLA/Netscape header files... export NAN_MOZILLA_INC ?= $(LCGDIR)/mozilla/include export NAN_MOZILLA_LIB ?= $(LCGDIR)/mozilla/lib/ @@ -203,6 +191,9 @@ endif # enable l10n export INTERNATIONAL ?= true + export NAN_SAMPLERATE ?= $(LCGDIR)/samplerate + export NAN_SAMPLERATE_LIBS ?= $(NAN_SAMPLERATE)/lib/libsamplerate.a + else ifeq ($(OS),freebsd) @@ -218,7 +209,6 @@ endif export NAN_JPEG ?= /usr/local export NAN_PNG ?= /usr/local export NAN_TIFF ?= /usr/local - export NAN_ODE ?= $(LCGDIR)/ode export NAN_TERRAPLAY ?= $(LCGDIR)/terraplay export NAN_MESA ?= /usr/src/Mesa-3.1 export NAN_ZLIB ?= /usr @@ -229,8 +219,6 @@ endif export NAN_SDLLIBS ?= $(shell sdl-config --libs) export NAN_SDLCFLAGS ?= $(shell sdl-config --cflags) - # Uncomment the following line to use Mozilla inplace of netscape - # CPPFLAGS +=-DMOZ_NOT_NET # Location of MOZILLA/Netscape header files... export NAN_MOZILLA_INC ?= $(LCGDIR)/mozilla/include export NAN_MOZILLA_LIB ?= $(LCGDIR)/mozilla/lib/ @@ -263,7 +251,6 @@ endif export NAN_JPEG ?= $(LCGDIR)/jpeg export NAN_PNG ?= $(LCGDIR)/png export NAN_TIFF ?= $(LCGDIR)/tiff - export NAN_ODE ?= $(LCGDIR)/ode export NAN_TERRAPLAY ?= $(LCGDIR)/terraplay export NAN_MESA ?= /usr/src/Mesa-3.1 export NAN_ZLIB ?= $(LCGDIR)/zlib @@ -287,8 +274,6 @@ endif export NAN_OPENEXR_INC ?= -I$(NAN_OPENEXR)/include -I$(NAN_OPENEXR)/include/OpenEXR export NAN_OPENEXR_LIBS ?= $(NAN_OPENEXR)/lib/libIlmImf.a $(NAN_OPENEXR)/lib/libHalf.a $(NAN_OPENEXR)/lib/libIex.a $(NAN_OPENEXR)/lib/libIlmThread.a - # Uncomment the following line to use Mozilla inplace of netscape - # CPPFLAGS +=-DMOZ_NOT_NET # Location of MOZILLA/Netscape header files... export NAN_MOZILLA_INC ?= $(LCGDIR)/mozilla/include export NAN_MOZILLA_LIB ?= $(LCGDIR)/mozilla/lib/ @@ -312,12 +297,12 @@ endif export NAN_PYTHON ?= /usr export NAN_PYTHON_VERSION ?= 3.1 export NAN_PYTHON_BINARY ?= $(NAN_PYTHON)/bin/python$(NAN_PYTHON_VERSION) - export NAN_PYTHON_LIB ?= $(NAN_PYTHON)/lib/python$(NAN_PYTHON_VERSION)/config/libpython$(NAN_PYTHON_VERSION).a + # Next line if for static python, nan_link.mk uses -lpython$(NAN_PYTHON_VERSION) + #export NAN_PYTHON_LIB ?= $(NAN_PYTHON)/lib/python$(NAN_PYTHON_VERSION)/config/libpython$(NAN_PYTHON_VERSION).a export NAN_OPENAL ?= /usr export NAN_JPEG ?= /usr export NAN_PNG ?= /usr export NAN_TIFF ?= /usr - export NAN_ODE ?= $(LCGDIR)/ode export NAN_TERRAPLAY ?= $(LCGDIR)/terraplay export NAN_MESA ?= /usr export NAN_ZLIB ?= /usr @@ -327,6 +312,7 @@ endif export NAN_SDL ?= $(shell sdl-config --prefix) export NAN_SDLLIBS ?= $(shell sdl-config --libs) export NAN_SDLCFLAGS ?= $(shell sdl-config --cflags) + export NAN_SAMPLERATE ?= /usr ifneq ($(NAN_USE_FFMPEG_CONFIG), true) export NAN_FFMPEG ?= /usr @@ -341,7 +327,7 @@ endif endif # Uncomment the following line to use Mozilla inplace of netscape - export CPPFLAGS += -DMOZ_NOT_NET + # Location of MOZILLA/Netscape header files... export NAN_MOZILLA_INC ?= /usr/include/mozilla export NAN_MOZILLA_LIB ?= $(LCGDIR)/mozilla/lib/ @@ -377,7 +363,6 @@ endif export NAN_JPEG ?= $(LCGDIR)/jpeg export NAN_PNG ?= $(LCGDIR)/png export NAN_TIFF ?= $(LCGDIR)/tiff - export NAN_ODE ?= $(LCGDIR)/ode export NAN_TERRAPLAY ?= $(LCGDIR)/terraplay export NAN_MESA ?= /usr/src/Mesa-3.1 export NAN_ZLIB ?= $(LCGDIR)/zlib @@ -388,8 +373,6 @@ endif export NAN_SDLLIBS ?= $(shell sdl-config --libs) export NAN_SDLCFLAGS ?= $(shell sdl-config --cflags) - # Uncomment the following line to use Mozilla inplace of netscape - # CPPFLAGS +=-DMOZ_NOT_NET # Location of MOZILLA/Netscape header files... export NAN_MOZILLA_INC ?= $(LCGDIR)/mozilla/include export NAN_MOZILLA_LIB ?= $(LCGDIR)/mozilla/lib/ @@ -416,7 +399,6 @@ endif export NAN_JPEG ?= $(LCGDIR)/jpeg export NAN_PNG ?= $(LCGDIR)/png export NAN_TIFF ?= /usr - export NAN_ODE ?= $(LCGDIR)/ode export NAN_TERRAPLAY ?= export NAN_MESA ?= /usr/X11 export NAN_ZLIB ?= $(LCGDIR)/zlib @@ -433,8 +415,6 @@ endif export NAN_OPENEXR_INC ?= -I$(NAN_OPENEXR)/include -I$(NAN_OPENEXR)/include/OpenEXR export NAN_OPENEXR_LIBS ?= $(NAN_OPENEXR)/lib/libIlmImf.a $(NAN_OPENEXR)/lib/libHalf.a $(NAN_OPENEXR)/lib/libIex.a $(NAN_OPENEXR)/lib/libIlmThread.a -lrt - # Uncomment the following line to use Mozilla inplace of netscape - # CPPFLAGS +=-DMOZ_NOT_NET # Location of MOZILLA/Netscape header files... export NAN_MOZILLA_INC ?= $(LCGDIR)/mozilla/include export NAN_MOZILLA_LIB ?= $(LCGDIR)/mozilla/lib/ @@ -469,7 +449,6 @@ endif export NAN_PYTHON_BINARY ?= $(NAN_PYTHON)/bin/python$(NAN_PYTHON_VERSION) export NAN_PYTHON_LIB ?= $(NAN_PYTHON)/lib/lib25_vs2005/libpython25.a export NAN_FREETYPE ?= $(LCGDIR)/gcc/freetype - export NAN_ODE ?= $(LCGDIR)/gcc/ode export NAN_SDL ?= $(LCGDIR)/gcc/sdl export NAN_OPENEXR ?= $(LCGDIR)/gcc/openexr export NAN_OPENEXR_INC ?= -I$(NAN_OPENEXR)/include -I$(NAN_OPENEXR)/include/OpenEXR @@ -480,7 +459,6 @@ endif export NAN_PYTHON_BINARY ?= python export NAN_PYTHON_LIB ?= $(NAN_PYTHON)/lib/python23.lib export NAN_FREETYPE ?= $(LCGDIR)/freetype - export NAN_ODE ?= $(LCGDIR)/ode export NAN_SDL ?= $(LCGDIR)/sdl export NAN_OPENEXR ?= $(LCGDIR)/openexr export NAN_OPENEXR_INC ?= -I$(NAN_OPENEXR)/include -I$(NAN_OPENEXR)/include/IlmImf -I$(NAN_OPENEXR)/include/Imath -I$(NAN_OPENEXR)/include/Iex @@ -489,8 +467,7 @@ endif export NAN_SDLCFLAGS ?= -I$(NAN_SDL)/include export NAN_WINTAB ?= $(LCGDIR)/wintab - # Uncomment the following line to use Mozilla inplace of netscape - # CPPFLAGS +=-DMOZ_NOT_NET + # Location of MOZILLA/Netscape header files... export NAN_MOZILLA_INC ?= $(LCGDIR)/mozilla/include export NAN_MOZILLA_LIB ?= $(LCGDIR)/mozilla/lib/ @@ -519,7 +496,6 @@ endif export NAN_PNG ?= $(LCGDIR)/png export NAN_TIFF ?= $(LCGDIR)/tiff export NAN_SDL ?= $(LCGDIR)/sdl - export NAN_ODE ?= $(LCGDIR)/ode export NAN_TERRAPLAY ?= $(LCGDIR)/terraplay export NAN_MESA ?= /usr/src/Mesa-3.1 export NAN_ZLIB ?= $(LCGDIR)/zlib @@ -530,8 +506,6 @@ endif export NAN_SDLLIBS ?= $(shell sdl-config --libs) export NAN_SDLCFLAGS ?= $(shell sdl-config --cflags) - # Uncomment the following line to use Mozilla inplace of netscape - # CPPFLAGS +=-DMOZ_NOT_NET # Location of MOZILLA/Netscape header files... export NAN_MOZILLA_INC ?= $(LCGDIR)/mozilla/include export NAN_MOZILLA_LIB ?= $(LCGDIR)/mozilla/lib/ diff --git a/source/nan_link.mk b/source/nan_link.mk index 63c9a578498..7211ba21e48 100644 --- a/source/nan_link.mk +++ b/source/nan_link.mk @@ -36,7 +36,7 @@ ifdef NAN_DEBUG LDFLAGS += $(NAN_DEBUG) endif -DBG_LDFLAGS += -g +DBG_LDFLAGS += -g ifneq (x$(DEBUG_DIR), x) LDFLAGS+=$(DBG_LDFLAGS) @@ -97,7 +97,7 @@ ifeq ($(OS),linux) COMMENT = "MESA 3.1" LLIBS = -L$(NAN_MESA)/lib -L/usr/X11R6/lib -lXmu -lXext -lX11 -lXi LLIBS += -lutil -lc -lm -ldl -lpthread -# LLIBS += -L$(NAN_ODE)/lib -lode + LLIBS += -lpython$(NAN_PYTHON_VERSION) LOPTS = -export-dynamic DADD = -lGL -lGLU SADD = $(NAN_MESA)/lib/libGL.a $(NAN_MESA)/lib/libGLU.a @@ -126,28 +126,28 @@ endif ifeq ($(OS),windows) EXT = .exe - SOEXT = .dll - ifeq ($(FREE_WINDOWS),true) - MINGWLIB = /usr/lib/w32api - LDFLAGS += -mwindows -mno-cygwin -mconsole - DADD += -L/usr/lib/w32api -lnetapi32 -lopengl32 -lglu32 -lshfolder - DADD += -L/usr/lib/w32api -lwinmm -lwsock32 + SOEXT = .dll + ifeq ($(FREE_WINDOWS),true) + MINGWLIB = /usr/lib/w32api + LDFLAGS += -mwindows -mno-cygwin -mconsole + DADD += -L/usr/lib/w32api -lnetapi32 -lopengl32 -lglu32 -lshfolder + DADD += -L/usr/lib/w32api -lwinmm -lwsock32 else - DADD = kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib - DADD += advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib - DADD += vfw32.lib winmm.lib opengl32.lib glu32.lib largeint.lib dxguid.lib - DADD += libcmt.lib - LOPTS = /link - LOPTS += /NODEFAULTLIB:"libc" - LOPTS += /NODEFAULTLIB:"libcd" - LOPTS += /NODEFAULTLIB:"libcp" - LOPTS += /NODEFAULTLIB:"libcpd" - LOPTS += /NODEFAULTLIB:"python20" - LOPTS += /NODEFAULTLIB:"msvcrt" - LOPTS += /SUBSYSTEM:CONSOLE - LDFLAGS += /MT - DYNLDFLAGS = /LD - endif + DADD = kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib + DADD += advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib + DADD += vfw32.lib winmm.lib opengl32.lib glu32.lib largeint.lib dxguid.lib + DADD += libcmt.lib + LOPTS = /link + LOPTS += /NODEFAULTLIB:"libc" + LOPTS += /NODEFAULTLIB:"libcd" + LOPTS += /NODEFAULTLIB:"libcp" + LOPTS += /NODEFAULTLIB:"libcpd" + LOPTS += /NODEFAULTLIB:"python20" + LOPTS += /NODEFAULTLIB:"msvcrt" + LOPTS += /SUBSYSTEM:CONSOLE + LDFLAGS += /MT + DYNLDFLAGS = /LD + endif endif ifneq ($(OS), irix) diff --git a/tools/Blender.py b/tools/Blender.py index 5b2a3600b62..797900343ee 100644 --- a/tools/Blender.py +++ b/tools/Blender.py @@ -116,6 +116,7 @@ def setup_staticlibs(lenv): lenv['BF_JPEG_LIBPATH'], lenv['BF_PNG_LIBPATH'], lenv['BF_ZLIB_LIBPATH'], + lenv['BF_LIBSAMPLERATE_LIBPATH'], lenv['BF_ICONV_LIBPATH'] ] @@ -129,10 +130,14 @@ def setup_staticlibs(lenv): libincs += Split(lenv['BF_SDL_LIBPATH']) if lenv['WITH_BF_FFMPEG']: libincs += Split(lenv['BF_FFMPEG_LIBPATH']) + if lenv['WITH_BF_JACK']: + libincs += Split(lenv['BF_JACK_LIBPATH']) if lenv['WITH_BF_OPENEXR']: libincs += Split(lenv['BF_OPENEXR_LIBPATH']) if lenv['WITH_BF_STATICOPENEXR']: statlibs += Split(lenv['BF_OPENEXR_LIB_STATIC']) + if lenv['WITH_BF_FFTW3']: + libincs += Split(lenv['BF_FFTW3_LIBPATH']) if lenv['WITH_BF_INTERNATIONAL']: libincs += Split(lenv['BF_GETTEXT_LIBPATH']) if lenv['WITH_BF_OPENAL']: @@ -157,7 +162,8 @@ def setup_syslibs(lenv): lenv['BF_JPEG_LIB'], lenv['BF_PNG_LIB'], - lenv['BF_ZLIB_LIB'] + lenv['BF_ZLIB_LIB'], + lenv['BF_LIBSAMPLERATE_LIB'] ] syslibs += Split(lenv['BF_FREETYPE_LIB']) @@ -187,6 +193,10 @@ def setup_syslibs(lenv): syslibs += Split(lenv['BF_FFMPEG_LIB']) if lenv['WITH_BF_OGG']: syslibs += Split(lenv['BF_OGG_LIB']) + if lenv['WITH_BF_JACK']: + syslibs += Split(lenv['BF_JACK_LIB']) + if lenv['WITH_BF_FFTW3']: + syslibs += Split(lenv['BF_FFTW3_LIB']) if lenv['WITH_BF_SDL']: syslibs += Split(lenv['BF_SDL_LIB']) if not lenv['WITH_BF_STATICOPENGL']: @@ -377,6 +387,48 @@ def AppIt(target=None, source=None, env=None): cmd = 'find %s/%s.app -name .DS_Store -exec rm -rf {} \;'%(builddir, binary) commands.getoutput(cmd) +# extract copy system python, be sure to update other build systems +# when making changes to the files that are copied. +def my_pyinst_print(target, source, env): + pass + +def PyInstall(target=None, source=None, env=None): + # Any Unix except osx + #-- .blender/python/lib/python3.1 + + import commands + + def run(cmd): + print 'Install command:', cmd + commands.getoutput(cmd) + + py_src = env.subst( env['BF_PYTHON_LIBPATH'] + '/python'+env['BF_PYTHON_VERSION'] ) + py_target = env.subst( env['BF_INSTALLDIR'] + '/.blender/python/lib/python'+env['BF_PYTHON_VERSION'] ) + + # Copied from source/creator/CMakeLists.txt, keep in sync. + print 'Install python from:' + print '\t"%s" into...' % py_src + print '\t"%s"\n' % py_target + + run('rm -rf "%s"' % py_target) + try: os.makedirs(os.path.dirname(py_target)) # the final part is copied + except:pass + + run('cp -R "%s" "%s"' % (py_src, os.path.dirname(py_target))) + run('rm -rf "%s/distutils"' % py_target) + run('rm -rf "%s/lib2to3"' % py_target) + run('rm -rf "%s/idlelib"' % py_target) + run('rm -rf "%s/tkinter"' % py_target) + run('rm -rf "%s/config"' % py_target) + + run('rm -rf "%s/site-packages"' % py_target) + run('mkdir "%s/site-packages"' % py_target) # python needs it.' + + run('rm "%s/lib-dynload/_tkinter.so"' % py_target) + run('find "%s" -name "test" -prune -exec rm -rf {} \;' % py_target) + run('find "%s" -name "*.py?" -exec rm -rf {} \;' % py_target) + run('find "%s" -name "*.so"-exec strip -s {} \;' % py_target) + #### END ACTION STUFF ######### def bsc(env, target, source): @@ -537,6 +589,11 @@ class BlenderEnvironment(SConsEnvironment): if lenv['OURPLATFORM']=='darwin': lenv['BINARYKIND'] = binarykind lenv.AddPostAction(prog,Action(AppIt,strfunction=my_appit_print)) + elif os.sep == '/': # any unix + if lenv['WITH_BF_PYTHON']: + if not lenv['WITHOUT_BF_INSTALL'] and not lenv['WITHOUT_BF_PYTHON_INSTALL']: + lenv.AddPostAction(prog,Action(PyInstall,strfunction=my_pyinst_print)) + return prog def Glob(lenv, pattern): diff --git a/tools/btools.py b/tools/btools.py index 521596eca97..c910cfeac55 100755 --- a/tools/btools.py +++ b/tools/btools.py @@ -30,6 +30,8 @@ def validate_arguments(args, bc): 'WITH_BF_PYTHON', 'BF_PYTHON', 'BF_PYTHON_VERSION', 'BF_PYTHON_INC', 'BF_PYTHON_BINARY', 'BF_PYTHON_LIB', 'BF_PYTHON_LIBPATH', 'WITH_BF_STATICPYTHON', 'BF_PYTHON_LIB_STATIC', 'WITH_BF_OPENAL', 'BF_OPENAL', 'BF_OPENAL_INC', 'BF_OPENAL_LIB', 'BF_OPENAL_LIBPATH', 'WITH_BF_STATICOPENAL', 'BF_OPENAL_LIB_STATIC', 'WITH_BF_SDL', 'BF_SDL', 'BF_SDL_INC', 'BF_SDL_LIB', 'BF_SDL_LIBPATH', + 'BF_LIBSAMPLERATE', 'BF_LIBSAMPLERATE_INC', 'BF_LIBSAMPLERATE_LIB', 'BF_LIBSAMPLERATE_LIBPATH', + 'WITH_BF_JACK', 'BF_JACK', 'BF_JACK_INC', 'BF_JACK_LIB', 'BF_JACK_LIBPATH', 'BF_PTHREADS', 'BF_PTHREADS_INC', 'BF_PTHREADS_LIB', 'BF_PTHREADS_LIBPATH', 'WITH_BF_OPENEXR', 'BF_OPENEXR', 'BF_OPENEXR_INC', 'BF_OPENEXR_LIB', 'BF_OPENEXR_LIBPATH', 'WITH_BF_STATICOPENEXR', 'BF_OPENEXR_LIB_STATIC', 'WITH_BF_DDS', @@ -48,6 +50,7 @@ def validate_arguments(args, bc): 'BF_WINTAB', 'BF_WINTAB_INC', 'WITH_BF_FREETYPE', 'BF_FREETYPE', 'BF_FREETYPE_INC', 'BF_FREETYPE_LIB', 'BF_FREETYPE_LIBPATH', 'WITH_BF_QUICKTIME', 'BF_QUICKTIME', 'BF_QUICKTIME_INC', 'BF_QUICKTIME_LIB', 'BF_QUICKTIME_LIBPATH', + 'WITH_BF_FFTW3', 'BF_FFTW3', 'BF_FFTW3_INC', 'BF_FFTW3_LIB', 'BF_FFTW3_LIBPATH', 'WITH_BF_STATICOPENGL', 'BF_OPENGL', 'BF_OPENGL_INC', 'BF_OPENGL_LIB', 'BF_OPENGL_LIBPATH', 'BF_OPENGL_LIB_STATIC', 'WITH_BF_PLAYER', 'WITH_BF_NOBLENDER', @@ -56,8 +59,8 @@ def validate_arguments(args, bc): 'BF_CXX', 'WITH_BF_STATICCXX', 'BF_CXX_LIB_STATIC', 'BF_TWEAK_MODE', 'BF_SPLIT_SRC', 'WITHOUT_BF_INSTALL', + 'WITHOUT_BF_PYTHON_INSTALL', 'WITH_BF_OPENMP', - 'WITHOUT_BF_INSTALL', 'BF_FANCY', 'BF_QUIET', 'BF_X264_CONFIG', 'BF_XVIDCORE_CONFIG', @@ -175,6 +178,17 @@ def read_opts(cfg, args): ('BF_SDL_LIB', 'SDL library', ''), #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer ('BF_SDL_LIBPATH', 'SDL library path', ''), + ('BF_LIBSAMPLERATE', 'libsamplerate aka SRC base path', ''), + ('BF_LIBSAMPLERATE_INC', 'libsamplerate aka SRC include path', ''), #$(shell $(BF_SDL)/bin/sdl-config --cflags) + ('BF_LIBSAMPLERATE_LIB', 'libsamplerate aka SRC library', ''), #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer + ('BF_LIBSAMPLERATE_LIBPATH', 'libsamplerate aka SRC library path', ''), + + (BoolVariable('WITH_BF_JACK', 'Enable jack support if true', True)), + ('BF_JACK', 'jack base path', ''), + ('BF_JACK_INC', 'jack include path', ''), + ('BF_JACK_LIB', 'jack library', ''), + ('BF_JACK_LIBPATH', 'jack library path', ''), + ('BF_PTHREADS', 'Pthreads base path', ''), ('BF_PTHREADS_INC', 'Pthreads include path', ''), ('BF_PTHREADS_LIB', 'Pthreads library', ''), @@ -294,6 +308,12 @@ def read_opts(cfg, args): ('BF_QUICKTIME_INC', 'QuickTime include path', ''), ('BF_QUICKTIME_LIB', 'QuickTime library', ''), ('BF_QUICKTIME_LIBPATH', 'QuickTime library path', ''), + + (BoolVariable('WITH_BF_FFTW3', 'Use FFTW3 if true', False)), + ('BF_FFTW3', 'FFTW3 base path', ''), + ('BF_FFTW3_INC', 'FFTW3 include path', ''), + ('BF_FFTW3_LIB', 'FFTW3 library', ''), + ('BF_FFTW3_LIBPATH', 'FFTW3 library path', ''), (BoolVariable('WITH_BF_STATICOPENGL', 'Use MESA if true', True)), ('BF_OPENGL', 'OpenGL base path', ''), @@ -346,6 +366,7 @@ def read_opts(cfg, args): (BoolVariable('BF_TWEAK_MODE', 'Enable tweak mode if true', False)), (BoolVariable('BF_SPLIT_SRC', 'Split src lib into several chunks if true', False)), (BoolVariable('WITHOUT_BF_INSTALL', 'dont install if true', False)), + (BoolVariable('WITHOUT_BF_PYTHON_INSTALL', 'dont install Python modules if true', False)), (BoolVariable('BF_FANCY', 'Enable fancy output if true', True)), (BoolVariable('BF_QUIET', 'Enable silent output if true', True)), (BoolVariable('WITH_BF_BINRELOC', 'Enable relocatable binary (linux only)', False)),