diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-09-18 04:50:13 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-09-18 04:50:13 +0400 |
commit | 28d618e41b33fe1f351af4fa7100c84ed68a4b13 (patch) | |
tree | 6b15f23f128c65cb46101864c667dd81cd073b2b | |
parent | 56303415e4d534d4f2f4075a818a2aa19ea19fbd (diff) | |
parent | 3e1ff2e590970c6db02859df0f73531692767cbf (diff) |
Merged changes in the trunk up to revision 31987.
216 files changed, 2009 insertions, 2704 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fdc6b9ebf6..4966c1d0bf5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ OPTION(WITH_LCMS "Enable color correction with lcms" OFF) OPTION(WITH_PYTHON "Enable Embedded Python API" ON) OPTION(WITH_BUILDINFO "Include extra build details" ON) OPTION(WITH_FLUID "Enable Elbeem (Fluid Simulation)" ON) +OPTION(WITH_IK_ITASC "Enable ITASC IK solver" ON) OPTION(WITH_FFTW3 "Enable FFTW3 support (Used for smoke and audio effects)" OFF) OPTION(WITH_BULLET "Enable Bullet (Physics Engine)" ON) OPTION(WITH_GAMEENGINE "Enable Game Engine" ON) @@ -314,7 +315,7 @@ IF(UNIX AND NOT APPLE) ENDIF(WITH_OPENMP) - SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -Wno-char-subscripts") + SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing") SET(PLATFORM_LINKFLAGS "-pthread") @@ -363,15 +364,6 @@ IF(WIN32) SET(WINTAB_INC ${LIBDIR}/wintab/include) - IF(WITH_PYTHON) - SET(PYTHON ${LIBDIR}/python) - SET(PYTHON_VERSION 3.1) - SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}") - # SET(PYTHON_BINARY python) # not used yet - SET(PYTHON_LIB python31) - SET(PYTHON_LIBPATH ${PYTHON}/lib) - ENDIF(WITH_PYTHON) - IF(WITH_OPENAL) SET(OPENAL ${LIBDIR}/openal) SET(OPENAL_INCLUDE_DIR ${OPENAL}/include) @@ -528,6 +520,15 @@ IF(WIN32) SET(JACK_LIBPATH ${JACK}/lib) ENDIF(WITH_JACK) + IF(WITH_PYTHON) + SET(PYTHON ${LIBDIR}/python) + SET(PYTHON_VERSION 3.1) + SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}") + # SET(PYTHON_BINARY python) # not used yet + SET(PYTHON_LIB python31) + SET(PYTHON_LIBPATH ${PYTHON}/lib) + ENDIF(WITH_PYTHON) + # MSVC only, Mingw doesnt need IF(CMAKE_CL_64) SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ") @@ -539,19 +540,12 @@ IF(WIN32) ELSE(MSVC) # MINGW SET(LLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid") + SET(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing") - SET(CMAKE_CXX_FLAGS "-pipe -funsigned-char -fno-strict-aliasing" CACHE STRING "Mingw C++ flags ") - SET(CMAKE_C_FLAGS "-pipe -funsigned-char -fno-strict-aliasing" CACHE STRING "Mingw C flags ") - - SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "Mingw debug C++ flags ") - SET(CMAKE_CXX_FLAGS_RELEASE " -O2" CACHE STRING "Mingw release C++ flags ") - SET(CMAKE_CXX_FLAGS_MINSIZEREL " -Os" CACHE STRING "Mingw minsize release C++ flags ") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Mingw release, debug C++ flags ") + # Better warnings + SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas") + SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare") - SET(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE STRING "Mingw debug C flags ") - SET(CMAKE_C_FLAGS_RELEASE "-O2" CACHE STRING "Mingw release C flags ") - SET(CMAKE_C_FLAGS_MINSIZEREL "-Os" CACHE STRING "Mingw minsize release C flags ") - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Mingw release, debug C++ flags ") ADD_DEFINITIONS(-DFREE_WINDOWS) IF(WITH_OPENMP) @@ -615,6 +609,9 @@ IF(WIN32) SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR) SET(OPENEXR_LIB Half IlmImf Imath IlmThread) SET(OPENEXR_LIBPATH ${OPENEXR}/lib) + + # TODO, gives linking errors, force off + SET(WITH_IMAGE_OPENEXR OFF) ENDIF(WITH_IMAGE_OPENEXR) IF(WITH_IMAGE_TIFF) @@ -634,6 +631,15 @@ IF(WIN32) SET(WITH_JACK OFF) ENDIF(WITH_JACK) + IF(WITH_PYTHON) + SET(PYTHON ${LIBDIR}/python) + SET(PYTHON_VERSION 3.1) + SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}") + # SET(PYTHON_BINARY python) # not used yet + SET(PYTHON_LIB python31mw) + SET(PYTHON_LIBPATH ${PYTHON}/lib) + ENDIF(WITH_PYTHON) + ENDIF(MSVC) ENDIF(WIN32) diff --git a/SConstruct b/SConstruct index 11493511ffa..032b1eb1ea8 100644 --- a/SConstruct +++ b/SConstruct @@ -492,6 +492,9 @@ if env['OURPLATFORM']!='darwin': dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):] source=[os.path.join(dp, f) for f in df if f[-3:]!='pyc'] + # To ensure empty dirs are created too + if len(source)==0: + env.Execute(Mkdir(dir)) scriptinstall.append(env.Install(dir=dir,source=source)) #-- icons diff --git a/build_files/package_spec/pacman/PKGBUILD b/build_files/package_spec/pacman/PKGBUILD new file mode 100644 index 00000000000..c419ce9096e --- /dev/null +++ b/build_files/package_spec/pacman/PKGBUILD @@ -0,0 +1,48 @@ +# Maintainer: Campbell Barton <ideasman42 at gmail dot com> + +# custom blender vars +blender_srcdir=$srcdir/../../../.. +blender_version=$(grep BLENDER_VERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9) +blender_subversion=$(grep BLENDER_SUBVERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9) +blender_ver_string=$(expr $blender_version / 100).$(expr $blender_version % 100).$blender_subversion + +pkgname=blender-beta +pkgver=$blender_ver_string +pkgrel=1 +pkgdesc="A fully integrated 3D graphics creation suite" +arch=('i686' 'x86_64') +url="www.blender.org" +license=('GPL') +groups=() +depends=('libjpeg' 'libpng' 'openexr' 'python3>=3.1' 'gettext' 'libxi' 'libxmu' 'mesa' 'freetype2' 'openal' 'sdl' 'libsndfile' 'libsamplerate' 'ffmpeg') +makedepends=('cmake' 'svn') +optdepends=() +provides=('blender') +conflicts=('blender') +replaces=() +backup=() +options=() +install=blender.install +# use current svn to make the package. +# source=(http://download.blender.org/source/$pkgname-$pkgver.tar.gz) +# md5sums=('27edb80c82c25252d43d6a01980d953a') #generate with 'makepkg -g' +source=() +md5sums=() +noextract=() + +build() { + mkdir -p $srcdir/build + cd $srcdir/build + cmake $blender_srcdir \ + -DCMAKE_INSTALL_PREFIX:PATH=/usr \ + -DCMAKE_BUILD_TYPE:STRING=Release \ + -DWITH_PYTHON_INSTALL:BOOL=OFF \ + -DWITH_OPENCOLLADA:BOOL=OFF + + make +} + +package() { + cd $srcdir/build + make DESTDIR="$pkgdir" install +} diff --git a/build_files/package_spec/pacman/blender.install b/build_files/package_spec/pacman/blender.install new file mode 100644 index 00000000000..f2d37ec7a2b --- /dev/null +++ b/build_files/package_spec/pacman/blender.install @@ -0,0 +1,29 @@ +post_install() { + cat << EOF + +NOTE +---- +Happy blending! + +EOF + echo "update desktop mime database..." + update-desktop-database +} + +post_upgrade() { + post_install $1 +} + +pre_remove() { + /bin/true +} + +post_remove() { + echo "update desktop mime database..." + update-desktop-database +} + +op=$1 +shift + +$op $* diff --git a/extern/libopenjpeg/CMakeLists.txt b/extern/libopenjpeg/CMakeLists.txt index d7b25ed1412..8cdd804dfba 100644 --- a/extern/libopenjpeg/CMakeLists.txt +++ b/extern/libopenjpeg/CMakeLists.txt @@ -24,9 +24,7 @@ # # ***** END GPL LICENSE BLOCK ***** -SET(INC . src) +SET(INC .) -FILE(GLOB SRC *.c except t1_generate_luts.c) -ADD_DEFINITIONS(-DWITH_OPENJPEG) +FILE(GLOB SRC *.c) BLENDERLIB(extern_openjpeg "${SRC}" "${INC}") -#, libtype=['international','player'], priority=[5, 210]) diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt index d64029a6671..acc13fb0e33 100644 --- a/intern/CMakeLists.txt +++ b/intern/CMakeLists.txt @@ -33,7 +33,6 @@ ADD_SUBDIRECTORY(container) ADD_SUBDIRECTORY(memutil) ADD_SUBDIRECTORY(decimation) ADD_SUBDIRECTORY(iksolver) -ADD_SUBDIRECTORY(itasc) ADD_SUBDIRECTORY(boolop) ADD_SUBDIRECTORY(opennl) ADD_SUBDIRECTORY(smoke) @@ -42,4 +41,8 @@ IF(WITH_FLUID) ADD_SUBDIRECTORY(elbeem) ENDIF(WITH_FLUID) +IF(WITH_IK_ITASC) + ADD_SUBDIRECTORY(itasc) +ENDIF(WITH_IK_ITASC) + ADD_SUBDIRECTORY(bsp) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index ec81ddf8ef2..559d160cba2 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -33,35 +33,35 @@ SET(INC ) SET(SRC - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_Buttons.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_CallbackEventConsumer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_C-api.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_DisplayManager.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_EventManager.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_EventPrinter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_ISystem.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_ModifierKeys.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_NDOFManager.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_Path-api.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_Rect.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_System.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_TimerManager.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_Window.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_WindowManager.cpp + ./intern/GHOST_Buttons.cpp + ./intern/GHOST_CallbackEventConsumer.cpp + ./intern/GHOST_C-api.cpp + ./intern/GHOST_DisplayManager.cpp + ./intern/GHOST_EventManager.cpp + ./intern/GHOST_EventPrinter.cpp + ./intern/GHOST_ISystem.cpp + ./intern/GHOST_ModifierKeys.cpp + ./intern/GHOST_NDOFManager.cpp + ./intern/GHOST_Path-api.cpp + ./intern/GHOST_Rect.cpp + ./intern/GHOST_System.cpp + ./intern/GHOST_TimerManager.cpp + ./intern/GHOST_Window.cpp + ./intern/GHOST_WindowManager.cpp ) IF(APPLE) IF(WITH_COCOA) LIST(APPEND SRC - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_DisplayManagerCocoa.mm - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_SystemCocoa.mm - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_WindowCocoa.mm + ./intern/GHOST_DisplayManagerCocoa.mm + ./intern/GHOST_SystemCocoa.mm + ./intern/GHOST_WindowCocoa.mm ) ELSE(WITH_COCOA) LIST(APPEND SRC - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_DisplayManagerCarbon.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_SystemCarbon.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_WindowCarbon.cpp + ./intern/GHOST_DisplayManagerCarbon.cpp + ./intern/GHOST_SystemCarbon.cpp + ./intern/GHOST_WindowCarbon.cpp ) ENDIF(WITH_COCOA) @@ -72,18 +72,18 @@ ELSEIF(WIN32) LIST(APPEND INC ${WINTAB_INC}) LIST(APPEND SRC - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_DisplayManagerWin32.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_SystemWin32.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_WindowWin32.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_DropTargetWin32.cpp + ./intern/GHOST_DisplayManagerWin32.cpp + ./intern/GHOST_SystemWin32.cpp + ./intern/GHOST_WindowWin32.cpp + ./intern/GHOST_DropTargetWin32.cpp ) ELSEIF(UNIX) LIST(APPEND INC ${X11_X11_INCLUDE_PATH}) LIST(APPEND SRC - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_DisplayManagerX11.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_SystemX11.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_WindowX11.cpp + ./intern/GHOST_DisplayManagerX11.cpp + ./intern/GHOST_SystemX11.cpp + ./intern/GHOST_WindowX11.cpp ) ADD_DEFINITIONS(-DPREFIX="${CMAKE_INSTALL_PREFIX}") diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index f7d0425aec8..f926e72119f 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -283,8 +283,8 @@ typedef enum { GHOST_kKeyRightControl, GHOST_kKeyLeftAlt, GHOST_kKeyRightAlt, - GHOST_kKeyCommand, // APPLE only! - GHOST_kKeyGrLess , // German PC only! + GHOST_kKeyCommand, // Command key on Apple, Windows key(s) on Windows + GHOST_kKeyGrLess , // German PC only! GHOST_kKeyCapsLock, GHOST_kKeyNumLock, diff --git a/intern/ghost/intern/GHOST_Debug.h b/intern/ghost/intern/GHOST_Debug.h index 9903ed7cc35..d402aed63db 100644 --- a/intern/ghost/intern/GHOST_Debug.h +++ b/intern/ghost/intern/GHOST_Debug.h @@ -34,7 +34,7 @@ #ifndef _GHOST_DEBUG_H_ #define _GHOST_DEBUG_H_ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #ifdef _DEBUG #pragma warning (disable:4786) // suppress stl-MSVC debug info warning // #define GHOST_DEBUG diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 33c7a7f15a2..dceecb53dd2 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -287,17 +287,6 @@ GHOST_TSuccess GHOST_SystemWin32::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys& keys) const { - /* - GetKeyState and GetAsyncKeyState only work with Win95, Win98, NT4, - Terminal Server and Windows 2000. - But on WinME it always returns zero. These two functions are simply - skipped by Millenium Edition! - - Official explanation from Microsoft: - Intentionally disabled. - It didn't work all that well on some newer hardware, and worked less - well with the passage of time, so it was fully disabled in ME. - */ if (m_separateLeftRight && m_separateLeftRightInitialized) { bool down = HIBYTE(::GetKeyState(VK_LSHIFT)) != 0; keys.set(GHOST_kModifierKeyLeftShift, down); @@ -311,6 +300,12 @@ GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys& keys) cons keys.set(GHOST_kModifierKeyLeftControl, down); down = HIBYTE(::GetKeyState(VK_RCONTROL)) != 0; keys.set(GHOST_kModifierKeyRightControl, down); + bool lwindown = HIBYTE(::GetKeyState(VK_LWIN)) != 0; + bool rwindown = HIBYTE(::GetKeyState(VK_RWIN)) != 0; + if(lwindown || rwindown) + keys.set(GHOST_kModifierKeyCommand, true); + else + keys.set(GHOST_kModifierKeyCommand, false); } else { bool down = HIBYTE(::GetKeyState(VK_SHIFT)) != 0; @@ -322,6 +317,12 @@ GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys& keys) cons down = HIBYTE(::GetKeyState(VK_CONTROL)) != 0; keys.set(GHOST_kModifierKeyLeftControl, down); keys.set(GHOST_kModifierKeyRightControl, down); + bool lwindown = HIBYTE(::GetKeyState(VK_LWIN)) != 0; + bool rwindown = HIBYTE(::GetKeyState(VK_RWIN)) != 0; + if(lwindown || rwindown) + keys.set(GHOST_kModifierKeyCommand, true); + else + keys.set(GHOST_kModifierKeyCommand, false); } return GHOST_kSuccess; } @@ -376,8 +377,8 @@ GHOST_TSuccess GHOST_SystemWin32::init() wc.cbClsExtra= 0; wc.cbWndExtra= 0; wc.hInstance= ::GetModuleHandle(0); - wc.hIcon = ::LoadIcon(wc.hInstance, "APPICON"); - + wc.hIcon = ::LoadIcon(wc.hInstance, "APPICON"); + if (!wc.hIcon) { ::LoadIcon(NULL, IDI_APPLICATION); } @@ -670,6 +671,8 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, case VK_SHIFT: case VK_CONTROL: case VK_MENU: + case VK_LWIN: + case VK_RWIN: if (!system->m_separateLeftRightInitialized) { // Check whether this system supports separate left and right keys switch (wParam) { @@ -691,6 +694,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, (HIBYTE(::GetKeyState(VK_RMENU)) != 0) ? true : false; break; + case VK_LWIN: + case VK_RWIN: + system->m_separateLeftRight = true; + break; } system->m_separateLeftRightInitialized = true; } @@ -714,6 +721,8 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, case VK_SHIFT: case VK_CONTROL: case VK_MENU: + case VK_LWIN: + case VK_RWIN: system->processModifierKeys(window); // Bypass call to DefWindowProc return 0; diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 961a637e616..b07dba7319f 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -851,6 +851,8 @@ getModifierKeys( const KeyCode control_r = XKeysymToKeycode(m_display,XK_Control_R); const KeyCode alt_l = XKeysymToKeycode(m_display,XK_Alt_L); const KeyCode alt_r = XKeysymToKeycode(m_display,XK_Alt_R); + const KeyCode super_l = XKeysymToKeycode(m_display,XK_Super_L); + const KeyCode super_r = XKeysymToKeycode(m_display,XK_Super_R); // Shift if ((m_keyboard_vector[shift_l >> 3] >> (shift_l & 7)) & 1) { @@ -888,6 +890,15 @@ getModifierKeys( } else { keys.set(GHOST_kModifierKeyRightAlt,false); } + + // Super (Windows) - only one GHOST-kModifierKeyCommand, so mapping + // to either + if ( ((m_keyboard_vector[super_l >> 3] >> (super_l & 7)) & 1) || + ((m_keyboard_vector[super_r >> 3] >> (super_r & 7)) & 1) ) { + keys.set(GHOST_kModifierKeyCommand,true); + } else { + keys.set(GHOST_kModifierKeyCommand,false); + } return GHOST_kSuccess; } @@ -1095,6 +1106,8 @@ convertXKey( GXMAP(type,XK_Control_R, GHOST_kKeyRightControl); GXMAP(type,XK_Alt_L, GHOST_kKeyLeftAlt); GXMAP(type,XK_Alt_R, GHOST_kKeyRightAlt); + GXMAP(type,XK_Super_L, GHOST_kKeyCommand); + GXMAP(type,XK_Super_R, GHOST_kKeyCommand); GXMAP(type,XK_Insert, GHOST_kKeyInsert); GXMAP(type,XK_Delete, GHOST_kKeyDelete); diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index a97f7621bb0..83f86840eb4 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -783,9 +783,9 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state) break; case GHOST_kWindowStateNormal: default: + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; if (m_fullScreen) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; m_fullScreen = false; //Exit fullscreen @@ -835,15 +835,15 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state) //Tell WM of view new size m_systemCocoa->handleWindowEvent(GHOST_kEventWindowSize, this); - - [pool drain]; } else if ([m_window isMiniaturized]) [m_window deminiaturize:nil]; else if ([m_window isZoomed]) [m_window zoom:nil]; + [pool drain]; break; } + return GHOST_kSuccess; } diff --git a/release/scripts/io/netrender/client.py b/release/scripts/io/netrender/client.py index b6fc66590df..c17944725b0 100644 --- a/release/scripts/io/netrender/client.py +++ b/release/scripts/io/netrender/client.py @@ -20,6 +20,7 @@ import bpy import sys, os, re import http, http.client, http.server, urllib import subprocess, shutil, time, hashlib +import json import netrender import netrender.model @@ -169,7 +170,7 @@ def clientSendJob(conn, scene, anim = False): job.priority = netsettings.priority # try to send path first - conn.request("POST", "/job", repr(job.serialize())) + conn.request("POST", "/job", json.dumps(job.serialize())) response = conn.getresponse() response.read() diff --git a/release/scripts/io/netrender/master.py b/release/scripts/io/netrender/master.py index 6deb925420b..749046fc9e1 100644 --- a/release/scripts/io/netrender/master.py +++ b/release/scripts/io/netrender/master.py @@ -21,6 +21,7 @@ import http, http.client, http.server, urllib, socket, socketserver, threading import subprocess, shutil, time, hashlib import pickle import select # for select.error +import json from netrender.utils import * import netrender.model @@ -90,7 +91,7 @@ class MRenderJob(netrender.model.RenderJob): def save(self): if self.save_path: f = open(os.path.join(self.save_path, "job.txt"), "w") - f.write(repr(self.serialize())) + f.write(json.dumps(self.serialize())) f.close() def edit(self, info_map): @@ -384,7 +385,7 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): self.server.stats("", "Sending status") self.send_head() - self.wfile.write(bytes(repr(message), encoding='utf8')) + self.wfile.write(bytes(json.dumps(message), encoding='utf8')) # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- elif self.path == "/job": @@ -410,7 +411,7 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): message = job.serialize(frames) - self.wfile.write(bytes(repr(message), encoding='utf8')) + self.wfile.write(bytes(json.dumps(message), encoding='utf8')) self.server.stats("", "Sending job to slave") else: @@ -468,7 +469,7 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): self.send_head() - self.wfile.write(bytes(repr(message), encoding='utf8')) + self.wfile.write(bytes(json.dumps(message), encoding='utf8')) # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- else: # hand over the rest to the html section @@ -486,7 +487,7 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): length = int(self.headers['content-length']) - job_info = netrender.model.RenderJob.materialize(eval(str(self.rfile.read(length), encoding='utf8'))) + job_info = netrender.model.RenderJob.materialize(json.loads(str(self.rfile.read(length), encoding='utf8'))) job_id = self.server.nextJobID() @@ -657,7 +658,7 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): self.server.stats("", "New slave connected") - slave_info = netrender.model.RenderSlave.materialize(eval(str(self.rfile.read(length), encoding='utf8')), cache = False) + slave_info = netrender.model.RenderSlave.materialize(json.loads(str(self.rfile.read(length), encoding='utf8')), cache = False) slave_id = self.server.addSlave(slave_info.name, self.client_address, slave_info.stats) @@ -666,7 +667,7 @@ class RenderHandler(http.server.BaseHTTPRequestHandler): elif self.path == "/log": length = int(self.headers['content-length']) - log_info = netrender.model.LogFile.materialize(eval(str(self.rfile.read(length), encoding='utf8'))) + log_info = netrender.model.LogFile.materialize(json.loads(str(self.rfile.read(length), encoding='utf8'))) slave_id = log_info.slave_id diff --git a/release/scripts/io/netrender/operators.py b/release/scripts/io/netrender/operators.py index 252b1146b67..2b40cd77125 100644 --- a/release/scripts/io/netrender/operators.py +++ b/release/scripts/io/netrender/operators.py @@ -20,6 +20,7 @@ import bpy import sys, os import http, http.client, http.server, urllib, socket import webbrowser +import json import netrender from netrender.utils import * @@ -205,10 +206,10 @@ class RENDER_OT_netclientstatus(bpy.types.Operator): conn.request("GET", "/status") response = conn.getresponse() - response.read() + content = response.read() print( response.status, response.reason ) - jobs = (netrender.model.RenderJob.materialize(j) for j in eval(str(response.read(), encoding='utf8'))) + jobs = (netrender.model.RenderJob.materialize(j) for j in json.loads(str(content, encoding='utf8'))) while(len(netsettings.jobs) > 0): netsettings.jobs.remove(0) @@ -307,10 +308,10 @@ class RENDER_OT_netclientslaves(bpy.types.Operator): conn.request("GET", "/slaves") response = conn.getresponse() - response.read() + content = response.read() print( response.status, response.reason ) - slaves = (netrender.model.RenderSlave.materialize(s) for s in eval(str(response.read(), encoding='utf8'))) + slaves = (netrender.model.RenderSlave.materialize(s) for s in json.loads(str(content, encoding='utf8'))) while(len(netsettings.slaves) > 0): netsettings.slaves.remove(0) diff --git a/release/scripts/io/netrender/slave.py b/release/scripts/io/netrender/slave.py index b383481824b..1b6caa17b13 100644 --- a/release/scripts/io/netrender/slave.py +++ b/release/scripts/io/netrender/slave.py @@ -19,6 +19,7 @@ import sys, os, platform, shutil import http, http.client, http.server, urllib import subprocess, time +import json from netrender.utils import * import netrender.model @@ -111,7 +112,7 @@ def render_slave(engine, netsettings, threads): conn = clientConnection(netsettings.server_address, netsettings.server_port) if conn: - conn.request("POST", "/slave", repr(slave_Info().serialize())) + conn.request("POST", "/slave", json.dumps(slave_Info().serialize())) response = conn.getresponse() response.read() @@ -130,7 +131,7 @@ def render_slave(engine, netsettings, threads): if response.status == http.client.OK: timeout = 1 # reset timeout on new job - job = netrender.model.RenderJob.materialize(eval(str(response.read(), encoding='utf8'))) + job = netrender.model.RenderJob.materialize(json.loads(str(response.read(), encoding='utf8'))) engine.update_stats("", "Network render processing job from master") JOB_PREFIX = os.path.join(NODE_PREFIX, "job_" + job.id) @@ -156,7 +157,7 @@ def render_slave(engine, netsettings, threads): # announce log to master logfile = netrender.model.LogFile(job.id, slave_id, [frame.number for frame in job.frames]) - conn.request("POST", "/log", bytes(repr(logfile.serialize()), encoding='utf8')) + conn.request("POST", "/log", bytes(json.dumps(logfile.serialize()), encoding='utf8')) response = conn.getresponse() response.read() diff --git a/release/scripts/io/netrender/ui.py b/release/scripts/io/netrender/ui.py index 7a784af01ea..c065b95b928 100644 --- a/release/scripts/io/netrender/ui.py +++ b/release/scripts/io/netrender/ui.py @@ -119,7 +119,7 @@ class RENDER_PT_network_settings(bpy.types.Panel, RenderButtonsPanel): split = layout.split(percentage=0.7) col = split.column() - col.label(text="Server Adress:") + col.label(text="Server Address:") col.prop(netsettings, "server_address", text="") col = split.column() diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py index a5b86b917b2..92d2533c2c1 100644 --- a/release/scripts/modules/bpy/path.py +++ b/release/scripts/modules/bpy/path.py @@ -94,7 +94,7 @@ def display_name(name): name_base = name_base.replace("_", " ") if name_base.islower(): - return name_base.capitalize() + return name_base.lower().title() else: return name_base diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index f5144d6cdf5..5d5f736a33b 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -54,6 +54,11 @@ def _test_import(module_name, loaded_modules): return mod +def _sys_path_ensure(path): + if path not in _sys.path: # reloading would add twice + _sys.path.insert(0, path) + + def modules_from_path(path, loaded_modules): """ Load all modules in a path and return them as a list. @@ -108,6 +113,12 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): _bpy_types.TypeMap.clear() _bpy_types.PropertiesMap.clear() + # just unload, dont change user defaults, this means we can sync to reload. + # note that they will only actually reload of the modification time changes. + # this `wont` work for packages so... its not perfect. + for module_name in [ext.module for ext in _bpy.context.user_preferences.addons]: + addon_disable(module_name, default_set=False) + def register_module_call(mod): _bpy_types._register_module(mod.__name__) register = getattr(mod, "register", None) @@ -128,10 +139,6 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): except: traceback.print_exc() - def sys_path_ensure(path): - if path not in _sys.path: # reloading would add twice - _sys.path.insert(0, path) - def test_reload(mod): # reloading this causes internal errors # because the classes from this module are stored internally @@ -175,10 +182,10 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): user_path = user_script_path() for base_path in script_paths(): - for path_subdir in ("", "ui", "op", "io", "cfg", "keyingsets", "modules"): + for path_subdir in ("", "ui", "op", "io", "keyingsets", "modules"): path = _os.path.join(base_path, path_subdir) if _os.path.isdir(path): - sys_path_ensure(path) + _sys_path_ensure(path) # only add this to sys.modules, dont run if path_subdir == "modules": @@ -190,15 +197,17 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): for mod in modules_from_path(path, loaded_modules): test_register(mod) - # load addons - used_ext = {ext.module for ext in _bpy.context.user_preferences.addons} - paths = script_paths("addons") + script_paths("addons_contrib") - for path in paths: - sys_path_ensure(path) + _bpy_types._register_immediate = True + + # deal with addons seperately + addon_reset_all() + + + # run the active integration preset + filepath = preset_find(_bpy.context.user_preferences.inputs.active_keyconfig, "keyconfig") + if filepath: + keyconfig_set(filepath) - for module_name in sorted(used_ext): - mod = _test_import(module_name, loaded_modules) - test_register(mod) if reload_scripts: import gc @@ -207,8 +216,6 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): if _bpy.app.debug: print("Python Script Load Time %.4f" % (time.time() - t_main)) - _bpy_types._register_immediate = True - # base scripts _scripts = _os.path.join(_os.path.dirname(__file__), _os.path.pardir, _os.path.pardir) @@ -261,19 +268,23 @@ _presets = _os.path.join(_scripts[0], "presets") # FIXME - multiple paths def preset_paths(subdir): - ''' + """ Returns a list of paths for a specific preset. - ''' - - return (_os.path.join(_presets, subdir), ) + """ + dirs = [] + for path in script_paths("presets"): + directory = _os.path.join(path, subdir) + if _os.path.isdir(directory): + dirs.append(directory) + return dirs def smpte_from_seconds(time, fps=None): - ''' + """ Returns an SMPTE formatted string from the time in seconds: "HH:MM:SS:FF". If the *fps* is not given the current scene is used. - ''' + """ import math if fps is None: @@ -301,11 +312,11 @@ def smpte_from_seconds(time, fps=None): def smpte_from_frame(frame, fps=None, fps_base=None): - ''' + """ Returns an SMPTE formatted string from the frame: "HH:MM:SS:FF". If *fps* and *fps_base* are not given the current scene is used. - ''' + """ if fps is None: fps = _bpy.context.scene.render.fps @@ -314,3 +325,215 @@ def smpte_from_frame(frame, fps=None, fps_base=None): fps_base = _bpy.context.scene.render.fps_base return smpte_from_seconds((frame * fps_base) / fps, fps) + + +def addon_check(module_name): + """ + Returns the loaded state of the addon. + + :arg module_name: The name of the addon and module. + :type module_name: string + :return: (loaded_default, loaded_state) + :rtype: tuple of booleans + """ + loaded_default = module_name in _bpy.context.user_preferences.addons + + mod = _sys.modules.get(module_name) + loaded_state = mod and getattr(mod, "__addon_enabled__") + + return loaded_default, loaded_state + + +def addon_enable(module_name, default_set=True): + """ + Enables an addon by name. + + :arg module_name: The name of the addon and module. + :type module_name: string + :return: the loaded module or None on failier. + :rtype: module + """ + # note, this still gets added to _bpy_types.TypeMap + + import os + import sys + import bpy_types as _bpy_types + + + _bpy_types._register_immediate = False + + def handle_error(): + import traceback + traceback.print_exc() + _bpy_types._register_immediate = True + + + # reload if the mtime changes + mod = sys.modules.get(module_name) + if mod: + mod.__addon_enabled__ = False + mtime_orig = getattr(mod, "__time__", 0) + mtime_new = os.path.getmtime(mod.__file__) + if mtime_orig != mtime_new: + print("module changed on disk:", mod.__file__, "reloading...") + + try: + reload(mod) + except: + handle_error() + del sys.modules[module_name] + return None + mod.__addon_enabled__ = False + + # Split registering up into 3 steps so we can undo if it fails par way through + # 1) try import + try: + mod = __import__(module_name) + mod.__time__ = os.path.getmtime(mod.__file__) + mod.__addon_enabled__ = False + except: + handle_error() + return None + + # 2) try register collected modules + try: + _bpy_types._register_module(module_name) + except: + handle_error() + del sys.modules[module_name] + return None + + # 3) try run the modules register function + try: + mod.register() + except: + handle_error() + _bpy_types._unregister_module(module_name) + del sys.modules[module_name] + return None + + # * OK loaded successfully! * + if default_set: + # just incase its enabled alredy + ext = _bpy.context.user_preferences.addons.get(module_name) + if not ext: + ext = _bpy.context.user_preferences.addons.new() + ext.module = module_name + + _bpy_types._register_immediate = True + + mod.__addon_enabled__ = True + + print("\tbpy.utils.addon_enable", mod.__name__) + + return mod + + +def addon_disable(module_name, default_set=True): + """ + Disables an addon by name. + + :arg module_name: The name of the addon and module. + :type module_name: string + """ + import traceback + import bpy_types as _bpy_types + + mod = _sys.modules.get(module_name) + + if mod is None: + print("addon_disable", module_name, "not loaded, nothing to do") + return + + mod.__addon_enabled__ = False + + try: + _bpy_types._unregister_module(module_name, free=False) # dont free because we may want to enable again. + mod.unregister() + except: + traceback.print_exc() + + # could be in more then once, unlikely but better do this just incase. + addons = _bpy.context.user_preferences.addons + + if default_set: + while module_name in addons: + addon = addons.get(module_name) + if addon: + addons.remove(addon) + + print("\tbpy.utils.addon_disable", module_name) + + +def addon_reset_all(): + """ + Sets the addon state based on the user preferences. + """ + + paths = script_paths("addons") + script_paths("addons_contrib") + + for path in paths: + _sys_path_ensure(path) + for mod_name, mod_path in _bpy.path.module_names(path): + is_enabled, is_loaded = addon_check(mod_name) + if is_enabled == is_loaded: + pass + elif is_enabled: + addon_enable(mod_name) + elif is_loaded: + print("\taddon_reset_all unloading", mod_name) + addon_disable(mod_name) + +def preset_find(name, preset_path, display_name=False): + if not name: + return None + + for directory in preset_paths(preset_path): + + if display_name: + filename = "" + for fn in _os.listdir(directory): + if fn.endswith(".py") and name == _bpy.path.display_name(fn): + filename = fn + break + else: + filename = name + ".py" + + if filename: + filepath = _os.path.join(directory, filename) + if _os.path.exists(filepath): + return filepath + + +def keyconfig_set(filepath): + from os.path import basename, splitext + + print("loading preset:", filepath) + keyconfigs = _bpy.context.window_manager.keyconfigs + kc_orig = keyconfigs.active + + keyconfigs_old = keyconfigs[:] + + try: + exec(compile(open(filepath).read(), filepath, 'exec'), {"__file__": filepath}) + except: + import traceback + traceback.print_exc() + + kc_new = [kc for kc in keyconfigs if kc not in keyconfigs_old][0] + + kc_new.name = "" + + # remove duplicates + name = splitext(basename(filepath))[0] + while True: + kc_dupe = keyconfigs.get(name) + if kc_dupe: + keyconfigs.remove(kc_dupe) + else: + break + + kc_new.name = name + keyconfigs.active = kc_new + + diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 358628c001e..261165d8830 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -635,16 +635,30 @@ class OrderedMeta(RNAMeta): # Only defined so operators members can be used by accessing self.order +# with doc generation 'self.properties.bl_rna.properties' can fail class Operator(StructRNA, metaclass=OrderedMeta): __slots__ = () - - @classmethod - def easy_getsets(cls): - def bypass_attr(attr): - setattr(cls, attr, property(lambda self: getattr(self.properties, attr), lambda self, value: setattr(self.properties, attr, value))) - for attr, value in list(cls.__dict__.items()): - if type(value) == tuple and len(value) == 2 and type(value[1]) == dict: - bypass_attr(attr) + + def __getattribute__(self, attr): + properties = StructRNA.path_resolve(self, "properties") + bl_rna = getattr(properties, "bl_rna", None) + if bl_rna and attr in bl_rna.properties: + return getattr(properties, attr) + return super().__getattribute__(attr) + + def __setattr__(self, attr, value): + properties = StructRNA.path_resolve(self, "properties") + bl_rna = getattr(properties, "bl_rna", None) + if bl_rna and attr in bl_rna.properties: + setattr(properties, attr, value) + return super().__setattr__(attr, value) + + def __delattr__(self, attr): + properties = StructRNA.path_resolve(self, "properties") + bl_rna = getattr(properties, "bl_rna", None) + if bl_rna and attr in bl_rna.properties: + delattr(properties, attr) + return super().__delattr__(attr) class Macro(StructRNA, metaclass=OrderedMeta): @@ -725,6 +739,9 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): import bpy.utils layout = self.layout + + if not searchpaths: + layout.label("* Missing Paths *") # collect paths files = [] @@ -747,7 +764,6 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): props.filepath = filepath if operator == "script.execute_preset": props.menu_idname = self.bl_idname - props.preset_name = preset_name def draw_preset(self, context): """Define these on the subclass diff --git a/release/scripts/modules/io_utils.py b/release/scripts/modules/io_utils.py index 04c441100d7..adc3afce71d 100644 --- a/release/scripts/modules/io_utils.py +++ b/release/scripts/modules/io_utils.py @@ -34,6 +34,14 @@ class ExportHelper: context.window_manager.add_fileselect(self) return {'RUNNING_MODAL'} + def check(self, context): + filepath = bpy.path.ensure_ext(self.filepath, self.filename_ext) + if filepath != self.filepath: + self.filepath = filepath + return True + else: + return False + class ImportHelper: filepath = StringProperty(name="File Path", description="Filepath used for importing the file", maxlen=1024, default="", subtype='FILE_PATH') diff --git a/release/scripts/op/image.py b/release/scripts/op/image.py index 09c9f5e6881..ca7a017febd 100644 --- a/release/scripts/op/image.py +++ b/release/scripts/op/image.py @@ -121,7 +121,8 @@ class ProjectEdit(bpy.types.Operator): for image in bpy.data.images: image.tag = True - bpy.ops.paint.image_from_view() + if 'FINISHED' not in bpy.ops.paint.image_from_view(): + return {'CANCELLED'} image_new = None for image in bpy.data.images: diff --git a/release/scripts/op/io_anim_bvh/__init__.py b/release/scripts/op/io_anim_bvh/__init__.py index 6b529f87dd7..b8bdec592bc 100644 --- a/release/scripts/op/io_anim_bvh/__init__.py +++ b/release/scripts/op/io_anim_bvh/__init__.py @@ -22,7 +22,7 @@ if "bpy" in locals(): # only reload if we alredy loaded, highly annoying import sys - reload(sys.modules.get("io_mesh_ply.export_ply", sys)) + reload(sys.modules.get("io_anim_bvh.import_bvh", sys)) import bpy @@ -39,7 +39,7 @@ class BvhImporter(bpy.types.Operator, ImportHelper): scale = FloatProperty(name="Scale", description="Scale the BVH by this value", min=0.0001, max=1000000.0, soft_min=0.001, soft_max=100.0, default=0.1) frame_start = IntProperty(name="Start Frame", description="Starting frame for the animation", default=1) - loop = BoolProperty(name="Loop", description="Loop the animation playback", default=False) + use_cyclic = BoolProperty(name="Loop", description="Loop the animation playback", default=False) rotate_mode = EnumProperty(items=( ('QUATERNION', "Quaternion", "Convert rotations to quaternions"), ('NATIVE', "Euler (Native)", "Use the rotation order defined in the BVH file"), @@ -56,7 +56,13 @@ class BvhImporter(bpy.types.Operator, ImportHelper): def execute(self, context): import io_anim_bvh.import_bvh - return io_anim_bvh.import_bvh.load(self, context, **self.properties) + return io_anim_bvh.import_bvh.load(self, context, + filepath=self.filepath, + rotate_mode=self.rotate_mode, + scale=self.scale, + use_cyclic=self.use_cyclic, + frame_start=self.frame_start, + ) def menu_func(self, context): diff --git a/release/scripts/op/io_scene_obj/__init__.py b/release/scripts/op/io_scene_obj/__init__.py index 7220084cc7e..63b9e92e166 100644 --- a/release/scripts/op/io_scene_obj/__init__.py +++ b/release/scripts/op/io_scene_obj/__init__.py @@ -113,7 +113,7 @@ class ExportOBJ(bpy.types.Operator, ExportHelper): def execute(self, context): import io_scene_obj.export_obj - print(self.keys()) + print(self.properties.keys()) return io_scene_obj.export_obj.save(self, context, **self.properties) diff --git a/release/scripts/op/io_scene_obj/import_obj.py b/release/scripts/op/io_scene_obj/import_obj.py index c91eb02f4d9..61b6b4cb3c6 100644 --- a/release/scripts/op/io_scene_obj/import_obj.py +++ b/release/scripts/op/io_scene_obj/import_obj.py @@ -297,7 +297,6 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_ if has_data and image.depth == 32: # Image has alpha - # XXX bitmask won't work? mtex = blender_material.texture_slots.add() mtex.texture = texture mtex.texture_coords = 'UV' @@ -324,31 +323,27 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_ mtex.texture = texture mtex.texture_coords = 'UV' mtex.use_map_ambient = True -# blender_material.setTexture(1, texture, Texture.TexCo.UV, Texture.MapTo.CMIR) # TODO- Add AMB to BPY API elif type == 'Ks': mtex = blender_material.texture_slots.add() mtex.texture = texture mtex.texture_coords = 'UV' mtex.use_map_specular = True -# blender_material.setTexture(2, texture, Texture.TexCo.UV, Texture.MapTo.SPEC) elif type == 'Bump': mtex = blender_material.texture_slots.add() mtex.texture = texture mtex.texture_coords = 'UV' mtex.use_map_normal = True -# blender_material.setTexture(3, texture, Texture.TexCo.UV, Texture.MapTo.NOR) + elif type == 'D': mtex = blender_material.texture_slots.add() mtex.texture = texture mtex.texture_coords = 'UV' mtex.use_map_alpha = True - blender_material.z_transparency = True + blender_material.use_transparency = True + blender_material.transparency_method = 'Z_TRANSPARENCY' blender_material.alpha = 0.0 -# blender_material.setTexture(4, texture, Texture.TexCo.UV, Texture.MapTo.ALPHA) -# blender_material.mode |= Material.Modes.ZTRANSP -# blender_material.alpha = 0.0 # Todo, unset deffuse material alpha if it has an alpha channel elif type == 'refl': @@ -356,7 +351,6 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_ mtex.texture = texture mtex.texture_coords = 'UV' mtex.use_map_reflect = True -# blender_material.setTexture(5, texture, Texture.TexCo.UV, Texture.MapTo.REF) # Add an MTL with the same name as the obj if no MTLs are spesified. @@ -396,17 +390,19 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_ line_split= line.split() line_lower= line.lower().lstrip() if line_lower.startswith('ka'): - context_material.mirror_color = (float(line_split[1]), float(line_split[2]), float(line_split[3])) + context_material.mirror_color = float(line_split[1]), float(line_split[2]), float(line_split[3]) elif line_lower.startswith('kd'): - context_material.diffuse_color = (float(line_split[1]), float(line_split[2]), float(line_split[3])) + context_material.diffuse_color = float(line_split[1]), float(line_split[2]), float(line_split[3]) elif line_lower.startswith('ks'): - context_material.specular_color = (float(line_split[1]), float(line_split[2]), float(line_split[3])) + context_material.specular_color = float(line_split[1]), float(line_split[2]), float(line_split[3]) elif line_lower.startswith('ns'): - context_material.specular_hardness = int((float(line_split[1])*0.51)) + context_material.specular_hardness = int((float(line_split[1]) * 0.51)) elif line_lower.startswith('ni'): # Refraction index - context_material.raytrace_transparency.ior = max(1, min(float(line_split[1]), 3)) # Between 1 and 3 + context_material.raytrace_transparency.ior = max(1, min(float(line_split[1]), 3)) # between 1 and 3 elif line_lower.startswith('d') or line_lower.startswith('tr'): context_material.alpha = float(line_split[1]) + context_material.use_transparency = True + context_material.transparency_method = 'Z_TRANSPARENCY' elif line_lower.startswith('map_ka'): img_filepath= line_value(line.split()) if img_filepath: @@ -423,12 +419,12 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_ img_filepath= line_value(line.split()) if img_filepath: load_material_image(context_material, context_material_name, img_filepath, 'Bump') - elif line_lower.startswith('map_d') or line_lower.startswith('map_tr'): # Alpha map - Dissolve + elif line_lower.startswith('map_d') or line_lower.startswith('map_tr'): # Alpha map - Dissolve img_filepath= line_value(line.split()) if img_filepath: load_material_image(context_material, context_material_name, img_filepath, 'D') - elif line_lower.startswith('refl'): # Reflectionmap + elif line_lower.startswith('refl'): # reflectionmap img_filepath= line_value(line.split()) if img_filepath: load_material_image(context_material, context_material_name, img_filepath, 'refl') diff --git a/release/scripts/op/presets.py b/release/scripts/op/presets.py index fc2f41d2cf5..07852550ab7 100644 --- a/release/scripts/op/presets.py +++ b/release/scripts/op/presets.py @@ -31,45 +31,86 @@ class AddPresetBase(): # bl_label = "Add a Python Preset" name = bpy.props.StringProperty(name="Name", description="Name of the preset, used to make the path name", maxlen=64, default="") + remove_active = bpy.props.BoolProperty(default=False, options={'HIDDEN'}) - def _as_filename(self, name): # could reuse for other presets - for char in " !@#$%^&*(){}:\";'[]<>,./?": - name = name.replace('.', '_') - return name.lower() + @staticmethod + def as_filename(name): # could reuse for other presets + for char in " !@#$%^&*(){}:\";'[]<>,.\\/?": + name = name.replace(char, '_') + return name.lower().strip() def execute(self, context): + import os + + if hasattr(self, "pre_cb"): + self.pre_cb(context) + + preset_menu_class = getattr(bpy.types, self.preset_menu) + + if not self.remove_active: + + if not self.name: + return {'FINISHED'} + + filename = self.as_filename(self.name) + + target_path = bpy.utils.preset_paths(self.preset_subdir)[0] # we need some way to tell the user and system preset path + + filepath = os.path.join(target_path, filename) + ".py" + + if hasattr(self, "add"): + self.add(context, filepath) + else: + file_preset = open(filepath, 'w') + file_preset.write("import bpy\n") + + for rna_path in self.preset_values: + value = eval(rna_path) + file_preset.write("%s = %s\n" % (rna_path, repr(value))) + + file_preset.close() + + preset_menu_class.bl_label = bpy.path.display_name(self.name) - if not self.name: - return {'FINISHED'} + else: + preset_active = preset_menu_class.bl_label - filename = self._as_filename(self.name) + ".py" + # fairly sloppy but convenient. + filepath = bpy.utils.preset_find(preset_active, self.preset_subdir) - target_path = bpy.utils.preset_paths(self.preset_subdir)[0] # we need some way to tell the user and system preset path + if not filepath: + filepath = bpy.utils.preset_find(preset_active, self.preset_subdir, display_name=True) - filepath = os.path.join(target_path, filename) - if getattr(self, "save_keyconfig", False): - bpy.ops.wm.keyconfig_export(filepath=filepath, kc_name=self.name) - file_preset = open(filepath, 'a') - file_preset.write("wm.keyconfigs.active = kc\n\n") - else: - file_preset = open(filepath, 'w') - file_preset.write("import bpy\n") + if not filepath: + return {'CANCELLED'} + + if hasattr(self, "remove"): + self.remove(context, filepath) + else: + try: + os.remove(filepath) + except: + import traceback + traceback.print_exc() - for rna_path in self.preset_values: - value = eval(rna_path) - file_preset.write("%s = %s\n" % (rna_path, repr(value))) + # XXX, stupid! + preset_menu_class.bl_label = "Presets" - file_preset.close() + if hasattr(self, "post_cb"): + self.post_cb(context) return {'FINISHED'} def invoke(self, context, event): - wm = context.window_manager - #crashes, TODO - fix - #return wm.invoke_props_popup(self, event) + if not self.remove_active: + wm = context.window_manager + #crashes, TODO - fix + #return wm.invoke_props_popup(self, event) - wm.invoke_props_popup(self, event) - return {'RUNNING_MODAL'} + wm.invoke_props_popup(self, event) + return {'RUNNING_MODAL'} + else: + return self.execute(context) class ExecutePreset(bpy.types.Operator): @@ -78,16 +119,18 @@ class ExecutePreset(bpy.types.Operator): bl_label = "Execute a Python Preset" filepath = bpy.props.StringProperty(name="Path", description="Path of the Python file to execute", maxlen=512, default="") - preset_name = bpy.props.StringProperty(name="Preset Name", description="Name of the Preset being executed", default="") menu_idname = bpy.props.StringProperty(name="Menu ID Name", description="ID name of the menu this was called from", default="") def execute(self, context): + from os.path import basename + filepath = self.filepath + # change the menu title to the most recently chosen option preset_class = getattr(bpy.types, self.menu_idname) - preset_class.bl_label = self.preset_name + preset_class.bl_label = bpy.path.display_name(basename(filepath)) # execute the preset using script.python_file_run - bpy.ops.script.python_file_run(filepath=self.filepath) + bpy.ops.script.python_file_run(filepath=filepath) return {'FINISHED'} @@ -95,7 +138,7 @@ class AddPresetRender(AddPresetBase, bpy.types.Operator): '''Add a Render Preset''' bl_idname = "render.preset_add" bl_label = "Add Render Preset" - name = AddPresetBase.name + preset_menu = "RENDER_MT_presets" preset_values = [ "bpy.context.scene.render.field_order", @@ -117,7 +160,7 @@ class AddPresetSSS(AddPresetBase, bpy.types.Operator): '''Add a Subsurface Scattering Preset''' bl_idname = "material.sss_preset_add" bl_label = "Add SSS Preset" - name = AddPresetBase.name + preset_menu = "MATERIAL_MT_sss_presets" preset_values = [ "bpy.context.material.subsurface_scattering.back", @@ -142,7 +185,7 @@ class AddPresetCloth(AddPresetBase, bpy.types.Operator): '''Add a Cloth Preset''' bl_idname = "cloth.preset_add" bl_label = "Add Cloth Preset" - name = AddPresetBase.name + preset_menu = "CLOTH_MT_presets" preset_values = [ "bpy.context.cloth.settings.air_damping", @@ -160,7 +203,7 @@ class AddPresetSunSky(AddPresetBase, bpy.types.Operator): '''Add a Sky & Atmosphere Preset''' bl_idname = "lamp.sunsky_preset_add" bl_label = "Add Sunsky Preset" - name = AddPresetBase.name + preset_menu = "LAMP_MT_sunsky_presets" preset_values = [ "bpy.context.object.data.sky.atmosphere_extinction", @@ -185,8 +228,7 @@ class AddPresetInteraction(AddPresetBase, bpy.types.Operator): '''Add an Application Interaction Preset''' bl_idname = "wm.interaction_preset_add" bl_label = "Add Interaction Preset" - name = AddPresetBase.name - save_keyconfig = True + preset_menu = "USERPREF_MT_interaction_presets" preset_values = [ "bpy.context.user_preferences.edit.use_drag_immediately", @@ -204,6 +246,29 @@ class AddPresetInteraction(AddPresetBase, bpy.types.Operator): preset_subdir = "interaction" +class AddPresetKeyconfig(AddPresetBase, bpy.types.Operator): + '''Add a Keyconfig Preset''' + bl_idname = "wm.keyconfig_preset_add" + bl_label = "Add Keyconfig Preset" + preset_menu = "PREFS_MT_keyconfigs" + preset_subdir = "keyconfig" + + def add(self, context, filepath): + bpy.ops.wm.keyconfig_export(filepath=filepath) + bpy.utils.keyconfig_set(filepath) + + def pre_cb(self, context): + keyconfigs = bpy.context.window_manager.keyconfigs + if self.remove_active: + preset_menu_class = getattr(bpy.types, self.preset_menu) + preset_menu_class.bl_label = keyconfigs.active.name + + def post_cb(self, context): + keyconfigs = bpy.context.window_manager.keyconfigs + if self.remove_active: + keyconfigs.remove(keyconfigs.active) + + def register(): pass diff --git a/release/scripts/op/uv.py b/release/scripts/op/uv.py index cd0c2acf75c..d01ef070d87 100644 --- a/release/scripts/op/uv.py +++ b/release/scripts/op/uv.py @@ -343,6 +343,15 @@ class ExportUVLayout(bpy.types.Operator): return {'FINISHED'} + def check(self, context): + filepath = bpy.path.ensure_ext(self.filepath, "." + self.mode.lower()) + if filepath != self.filepath: + self.filepath = filepath + return True + else: + return False + + def invoke(self, context, event): self.size = self._image_size(context) wm = context.window_manager diff --git a/release/scripts/op/wm.py b/release/scripts/op/wm.py index 51304bdc3eb..af752d69ae9 100644 --- a/release/scripts/op/wm.py +++ b/release/scripts/op/wm.py @@ -632,7 +632,7 @@ class WM_OT_doc_edit(bpy.types.Operator): def draw(self, context): layout = self.layout - props = self + props = self.properties # XXX, this should not be needed, api problem! layout.label(text="Descriptor ID: '%s'" % props.doc_id) layout.prop(props, "doc_new", text="") @@ -641,6 +641,7 @@ class WM_OT_doc_edit(bpy.types.Operator): return wm.invoke_props_dialog(self, width=600) + from bpy.props import * @@ -768,6 +769,17 @@ class WM_OT_properties_remove(bpy.types.Operator): return {'FINISHED'} +class WM_OT_keyconfig_activate(bpy.types.Operator): + bl_idname = "wm.keyconfig_activate" + bl_label = "Activate Keyconfig" + + filepath = StringProperty(name="File Path", maxlen=1024) + + def execute(self, context): + bpy.utils.keyconfig_set(self.filepath) + return {'FINISHED'} + + def register(): pass diff --git a/release/scripts/ui/properties_data_curve.py b/release/scripts/ui/properties_data_curve.py index f6b73e03091..1d8034c6add 100644 --- a/release/scripts/ui/properties_data_curve.py +++ b/release/scripts/ui/properties_data_curve.py @@ -108,12 +108,13 @@ class DATA_PT_shape_curve(CurveButtonsPanel, bpy.types.Panel): sub.prop(curve, "resolution_v", text="Preview V") sub.prop(curve, "render_resolution_v", text="Render V") - if is_curve or is_text: + if (is_curve or is_text): sub = col.column() - sub.label(text="Caps:") + sub.active = (curve.bevel_object is None) + sub.label(text="Fill:") sub.prop(curve, "use_fill_front") sub.prop(curve, "use_fill_back") - sub.prop(curve, "use_fill_deform") + sub.prop(curve, "use_fill_deform", text="Use Deformed") col.label(text="Textures:") col.prop(curve, "use_map_on_length") diff --git a/release/scripts/ui/properties_data_lamp.py b/release/scripts/ui/properties_data_lamp.py index 228a70d1b48..72e95989b06 100644 --- a/release/scripts/ui/properties_data_lamp.py +++ b/release/scripts/ui/properties_data_lamp.py @@ -134,6 +134,7 @@ class DATA_PT_sunsky(DataButtonsPanel, bpy.types.Panel): row.prop(lamp, "use_sky") row.menu("LAMP_MT_sunsky_presets", text=bpy.types.LAMP_MT_sunsky_presets.bl_label) row.operator("lamp.sunsky_preset_add", text="", icon="ZOOMIN") + row.operator("lamp.sunsky_preset_add", text="", icon="ZOOMOUT").remove_active = True row = layout.row() row.active = lamp.use_sky or lamp.use_atmosphere diff --git a/release/scripts/ui/properties_material.py b/release/scripts/ui/properties_material.py index 37284847dd1..82a52214b69 100644 --- a/release/scripts/ui/properties_material.py +++ b/release/scripts/ui/properties_material.py @@ -448,6 +448,7 @@ class MATERIAL_PT_sss(MaterialButtonsPanel, bpy.types.Panel): sub = row.row(align=True).split(percentage=0.75) sub.menu("MATERIAL_MT_sss_presets", text=bpy.types.MATERIAL_MT_sss_presets.bl_label) sub.operator("material.sss_preset_add", text="", icon="ZOOMIN") + sub.operator("material.sss_preset_add", text="", icon="ZOOMOUT").remove_active = True split = layout.split() diff --git a/release/scripts/ui/properties_particle.py b/release/scripts/ui/properties_particle.py index c2bc761d39c..bd6d2e13c88 100644 --- a/release/scripts/ui/properties_particle.py +++ b/release/scripts/ui/properties_particle.py @@ -512,6 +512,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, bpy.types.Panel): col = row.column() col.label(text="Misc:") col.prop(boids, "bank", slider=True) + col.prop(boids, "pitch", slider=True) col.prop(boids, "height", slider=True) if part.physics_type == 'KEYED' or part.physics_type == 'BOIDS' or part.physics_type == 'FLUID': @@ -863,7 +864,7 @@ class PARTICLE_PT_draw(ParticleButtonsPanel, bpy.types.Panel): if part.draw_percentage != 100: if part.type == 'HAIR': - if psys.hair_dynamics and psys.point_cache.is_baked == False: + if psys.use_hair_dynamics and psys.point_cache.is_baked == False: layout.row().label(text="Display percentage makes dynamics inaccurate without baking!") else: phystype = part.physics_type diff --git a/release/scripts/ui/properties_physics_cloth.py b/release/scripts/ui/properties_physics_cloth.py index 2e50babfcfd..26670438b3f 100644 --- a/release/scripts/ui/properties_physics_cloth.py +++ b/release/scripts/ui/properties_physics_cloth.py @@ -87,6 +87,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, bpy.types.Panel): sub = col.row(align=True) sub.menu("CLOTH_MT_presets", text=bpy.types.CLOTH_MT_presets.bl_label) sub.operator("cloth.preset_add", text="", icon="ZOOMIN") + sub.operator("cloth.preset_add", text="", icon="ZOOMOUT").remove_active = True col.label(text="Quality:") col.prop(cloth, "quality", text="Steps", slider=True) diff --git a/release/scripts/ui/properties_render.py b/release/scripts/ui/properties_render.py index 7f55f44d1d2..1da77a431b6 100644 --- a/release/scripts/ui/properties_render.py +++ b/release/scripts/ui/properties_render.py @@ -769,7 +769,7 @@ class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel): row = layout.row(align=True) row.menu("RENDER_MT_presets", text=bpy.types.RENDER_MT_presets.bl_label) row.operator("render.preset_add", text="", icon="ZOOMIN") - + row.operator("render.preset_add", text="", icon="ZOOMOUT").remove_active = True split = layout.split() col = split.column() diff --git a/release/scripts/ui/space_dopesheet.py b/release/scripts/ui/space_dopesheet.py index fae7f5f7b4b..19f64268481 100644 --- a/release/scripts/ui/space_dopesheet.py +++ b/release/scripts/ui/space_dopesheet.py @@ -20,7 +20,7 @@ import bpy - +# used for DopeSheet, NLA, and Graph Editors def dopesheet_filter(layout, context): dopesheet = context.space_data.dopesheet is_nla = context.area.type == 'NLA_EDITOR' @@ -185,6 +185,9 @@ class DOPESHEET_MT_channel(bpy.types.Menu): layout.operator_context = 'INVOKE_REGION_CHANNELS' layout.column() + layout.operator("anim.channels_delete") + + layout.separator() layout.operator("anim.channels_setting_toggle") layout.operator("anim.channels_setting_enable") layout.operator("anim.channels_setting_disable") diff --git a/release/scripts/ui/space_graph.py b/release/scripts/ui/space_graph.py index 9b08da801c9..fe4f2cc1bfd 100644 --- a/release/scripts/ui/space_graph.py +++ b/release/scripts/ui/space_graph.py @@ -142,6 +142,9 @@ class GRAPH_MT_channel(bpy.types.Menu): layout.operator_context = 'INVOKE_REGION_CHANNELS' layout.column() + layout.operator("anim.channels_delete") + + layout.separator() layout.operator("anim.channels_setting_toggle") layout.operator("anim.channels_setting_enable") layout.operator("anim.channels_setting_disable") diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py index 3ab5ac1641f..74e1d758eea 100644 --- a/release/scripts/ui/space_userpref.py +++ b/release/scripts/ui/space_userpref.py @@ -732,8 +732,10 @@ class USERPREF_PT_input(InputKeyMapPanel): sub = col.column() sub.label(text="Presets:") subrow = sub.row(align=True) + subrow.menu("USERPREF_MT_interaction_presets", text=bpy.types.USERPREF_MT_interaction_presets.bl_label) subrow.operator("wm.interaction_preset_add", text="", icon='ZOOMIN') + subrow.operator("wm.interaction_preset_add", text="", icon='ZOOMOUT').remove_active = True sub.separator() sub.label(text="Mouse:") @@ -812,6 +814,7 @@ class USERPREF_PT_addons(bpy.types.Panel): bl_region_type = 'WINDOW' bl_options = {'HIDE_HEADER'} + _addons_cats = None _addons_fake_modules = {} @classmethod @@ -846,7 +849,7 @@ class USERPREF_PT_addons(bpy.types.Panel): ModuleType = type(ast) if speedy: lines = [] - line_iter = iter(open(mod_path, "r")) + line_iter = iter(open(mod_path, "r", encoding='UTF-8')) l = "" while not l.startswith("bl_addon_info"): l = line_iter.readline() @@ -917,12 +920,10 @@ class USERPREF_PT_addons(bpy.types.Panel): cats = {info["category"] for mod, info in addons} cats.discard("") - cats = ["All", "Enabled", "Disabled"] + sorted(cats) - - # use window manager ID since it wont be saved with the file - # defining every draw is stupid *FIXME* - bpy.types.WindowManager.addon_filter = bpy.props.EnumProperty(items=[(cat, cat, cat + " addons") for cat in cats], name="Category", description="Filter add-ons by category") - bpy.types.WindowManager.addon_search = bpy.props.StringProperty(name="Search", description="Search within the selected filter") + if USERPREF_PT_addons._addons_cats != cats: + bpy.types.WindowManager.addon_filter = bpy.props.EnumProperty(items=[(cat, cat, "") for cat in ["All", "Enabled", "Disabled"] + sorted(cats)], name="Category", description="Filter add-ons by category") + bpy.types.WindowManager.addon_search = bpy.props.StringProperty(name="Search", description="Search within the selected filter") + USERPREF_PT_addons._addons_cats = cats split = layout.split(percentage=0.2) col = split.column() @@ -1056,80 +1057,18 @@ class WM_OT_addon_enable(bpy.types.Operator): module = StringProperty(name="Module", description="Module name of the addon to enable") def execute(self, context): - module_name = self.module - - # note, this still gets added to _bpy_types.TypeMap - - import sys - import bpy_types as _bpy_types - - - _bpy_types._register_immediate = False + mod = bpy.utils.addon_enable(self.module) - def handle_error(): - import traceback - traceback.print_exc() - _bpy_types._register_immediate = True - - - # reload if the mtime changes - mod = sys.modules.get(module_name) if mod: - mtime_orig = getattr(mod, "__time__", 0) - mtime_new = os.path.getmtime(mod.__file__) - if mtime_orig != mtime_new: - print("module changed on disk:", mod.__file__, "reloading...") - - try: - reload(mod) - except: - handle_error() - del sys.modules[module_name] - return {'CANCELLED'} - - # Split registering up into 3 steps so we can undo if it fails par way through - # 1) try import - try: - mod = __import__(module_name) - mod.__time__ = os.path.getmtime(mod.__file__) - except: - handle_error() - return {'CANCELLED'} - - # 2) try register collected modules - try: - _bpy_types._register_module(module_name) - except: - handle_error() - del sys.modules[module_name] - return {'CANCELLED'} + # check if add-on is written for current blender version, or raise a warning + info = addon_info_get(mod) - # 3) try run the modules register function - try: - mod.register() - except: - handle_error() - _bpy_types._unregister_module(module_name) - del sys.modules[module_name] + if info.get("blender", (0, 0, 0)) > bpy.app.version: + self.report("WARNING','This script was written for a newer version of Blender and might not function (correctly).\nThe script is enabled though.") + return {'FINISHED'} + else: return {'CANCELLED'} - # * OK loaded successfully! * - # just incase its enabled alredy - ext = context.user_preferences.addons.get(module_name) - if not ext: - ext = context.user_preferences.addons.new() - ext.module = module_name - - # check if add-on is written for current blender version, or raise a warning - info = addon_info_get(mod) - - if info.get("blender", (0, 0, 0)) > bpy.app.version: - self.report("WARNING','This script was written for a newer version of Blender and might not function (correctly).\nThe script is enabled though.") - - _bpy_types._register_immediate = True - - return {'FINISHED'} - class WM_OT_addon_disable(bpy.types.Operator): "Disable an addon" @@ -1139,25 +1078,7 @@ class WM_OT_addon_disable(bpy.types.Operator): module = StringProperty(name="Module", description="Module name of the addon to disable") def execute(self, context): - import bpy_types as _bpy_types - module_name = self.module - - try: - mod = __import__(module_name) - _bpy_types._unregister_module(module_name, free=False) # dont free because we may want to enable again. - mod.unregister() - except: - import traceback - traceback.print_exc() - - # could be in more then once, unlikely but better do this just incase. - addons = context.user_preferences.addons - - while module_name in addons: - addon = addons.get(module_name) - if addon: - addons.remove(addon) - + bpy.utils.addon_disable(self.module) return {'FINISHED'} diff --git a/release/scripts/ui/space_userpref_keymap.py b/release/scripts/ui/space_userpref_keymap.py index 8064e74fa01..3c104b67ad3 100644 --- a/release/scripts/ui/space_userpref_keymap.py +++ b/release/scripts/ui/space_userpref_keymap.py @@ -124,6 +124,19 @@ def _merge_keymaps(kc1, kc2): return merged_keymaps +class PREFS_MT_keyconfigs(bpy.types.Menu): + bl_label = "KeyPresets" + preset_subdir = "keyconfig" + preset_operator = "wm.keyconfig_activate" + def draw(self, context): + props = self.layout.operator("wm.context_set_value", text="Blender (default)") + props.data_path = "window_manager.keyconfigs.active" + props.value = "context.window_manager.keyconfigs.default" + + # now draw the presets + bpy.types.Menu.draw_preset(self, context) + + class InputKeyMapPanel(bpy.types.Panel): bl_space_type = 'USER_PREFERENCES' bl_label = "Input" @@ -365,10 +378,18 @@ class InputKeyMapPanel(bpy.types.Panel): subsplit = sub.split() subcol = subsplit.column() - row = subcol.row() - row.prop_search(wm.keyconfigs, "active", wm, "keyconfigs", text="Key Config:") - layout.context_pointer_set("keyconfig", wm.keyconfigs.active) - row.operator("wm.keyconfig_remove", text="", icon='X') + row = subcol.row(align=True) + + #row.prop_search(wm.keyconfigs, "active", wm, "keyconfigs", text="Key Config:") + text = bpy.path.display_name(context.window_manager.keyconfigs.active.name) + if not text: + text = "Blender (default)" + row.menu("PREFS_MT_keyconfigs", text=text) + row.operator("wm.keyconfig_preset_add", text="", icon="ZOOMIN") + row.operator("wm.keyconfig_preset_add", text="", icon="ZOOMOUT").remove_active = True + +# layout.context_pointer_set("keyconfig", wm.keyconfigs.active) +# row.operator("wm.keyconfig_remove", text="", icon='X') row.prop(context.space_data, "filter_text", icon="VIEWZOOM") @@ -389,8 +410,9 @@ def export_properties(prefix, properties, lines=None): if lines is None: lines = [] - for pname, value in properties.items(): + for pname in properties.keys(): if not properties.is_property_hidden(pname): + value = getattr(properties, pname) if isinstance(value, bpy.types.OperatorProperties): export_properties(prefix + "." + pname, value, lines) elif properties.is_property_set(pname): @@ -501,7 +523,7 @@ def _string_value(value): if isinstance(value, str) or isinstance(value, bool) or isinstance(value, float) or isinstance(value, int): result = repr(value) elif getattr(value, '__len__', False): - repr(list(value)) + return repr(list(value)) else: print("Export key configuration: can't write ", value) @@ -521,6 +543,7 @@ class WM_OT_keyconfig_import(bpy.types.Operator): keep_original = BoolProperty(name="Keep original", description="Keep original file after copying to configuration folder", default=True) def execute(self, context): + from os.path import basename import shutil if not self.filepath: raise Exception("Filepath not set") @@ -529,24 +552,16 @@ class WM_OT_keyconfig_import(bpy.types.Operator): if not f: raise Exception("Could not open file") - config_name = None - for line in f: - if line.startswith("kc = wm.keyconfigs.new("): - config_name = line[24:-3] - break + config_name = basename(self.filepath) - if config_name is None: - raise Exception("config name not found") - - path = os.path.join(__file__, "..", "..", "cfg") # remove ui/space_userpref.py - path = os.path.normpath(path) + path = bpy.utils.preset_paths("keyconfig")[0] # we need some way to tell the user and system preset path print(path) # create config folder if needed if not os.path.exists(path): os.mkdir(path) - path = os.path.join(path, config_name + ".py") + path = os.path.join(path, config_name) if self.keep_original: shutil.copy(self.filepath, path) @@ -554,18 +569,7 @@ class WM_OT_keyconfig_import(bpy.types.Operator): shutil.move(self.filepath, path) # sneaky way to check we're actually running the code. - wm = context.window_manager - while config_name in wm.keyconfigs: - wm.keyconfigs.remove(wm.keyconfigs[config_name]) - - wm = context.window_manager - totmap = len(wm.keyconfigs) - mod = __import__(config_name) - if totmap == len(wm.keyconfigs): - reload(mod) - - wm = bpy.context.window_manager - wm.keyconfigs.active = wm.keyconfigs[config_name] + bpy.utils.keyconfig_set(path) return {'FINISHED'} @@ -586,7 +590,6 @@ class WM_OT_keyconfig_export(bpy.types.Operator): filter_folder = BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'}) filter_text = BoolProperty(name="Filter text", description="", default=True, options={'HIDDEN'}) filter_python = BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'}) - kc_name = StringProperty(name="KeyConfig Name", description="Name to save the key config as") def execute(self, context): if not self.filepath: @@ -599,18 +602,10 @@ class WM_OT_keyconfig_export(bpy.types.Operator): wm = context.window_manager kc = wm.keyconfigs.active - if self.kc_name != '': - name = self.kc_name - elif kc.name == 'Blender': - name = os.path.splitext(os.path.basename(self.filepath))[0] - else: - name = kc.name - - f.write("# Configuration %s\n" % name) - - f.write("import bpy\n\n") + f.write("import bpy\n") + f.write("import os\n\n") f.write("wm = bpy.context.window_manager\n") - f.write("kc = wm.keyconfigs.new('%s')\n\n" % name) + f.write("kc = wm.keyconfigs.new(os.path.splitext(os.path.basename(__file__))[0])\n\n") # keymap must be created by caller # Generate a list of keymaps to export: # @@ -775,21 +770,7 @@ class WM_OT_keyconfig_remove(bpy.types.Operator): def execute(self, context): import sys wm = context.window_manager - keyconfig = wm.keyconfigs.active - - module = sys.modules.get(keyconfig.name) - - if module: - path = module.__file__ - if os.path.exists(path): - os.remove(path) - - path = module.__file__ + "c" # for .pyc - - if os.path.exists(path): - os.remove(path) - wm.keyconfigs.remove(keyconfig) return {'FINISHED'} diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 16cb544e065..67363d3a7c0 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -151,6 +151,11 @@ class VIEW3D_MT_transform(bpy.types.Menu): layout.operator("transform.shear", text="Shear") layout.operator("transform.warp", text="Warp") layout.operator("transform.push_pull", text="Push/Pull") + + obj = context.object + if obj.type == 'ARMATURE' and obj.mode in ('EDIT', 'POSE') and obj.data.draw_type in ('BBONE', 'ENVELOPE'): + layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE' + if context.edit_object and context.edit_object.type == 'ARMATURE': layout.operator("armature.align") else: @@ -1108,8 +1113,6 @@ class VIEW3D_MT_pose(bpy.types.Menu): layout.menu("VIEW3D_MT_transform") layout.menu("VIEW3D_MT_snap") - if arm.draw_type in ('BBONE', 'ENVELOPE'): - layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONESIZE' layout.menu("VIEW3D_MT_pose_transform") @@ -1490,7 +1493,7 @@ class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu): layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("mesh.merge") - layout.operator("mesh.rip") + layout.operator("mesh.rip_move") layout.operator("mesh.split") layout.operator("mesh.separate") @@ -1849,11 +1852,6 @@ class VIEW3D_MT_edit_armature(bpy.types.Menu): layout.menu("VIEW3D_MT_snap") layout.menu("VIEW3D_MT_edit_armature_roll") - if arm.draw_type == 'ENVELOPE': - layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONESIZE' - else: - layout.operator("transform.transform", text="Scale B-Bone Width").mode = 'BONESIZE' - layout.separator() layout.operator("armature.extrude_move") diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 4c7e6410585..04f40ac825b 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -200,9 +200,14 @@ void blf_font_buffer(FontBLF *font, char *str) } chx= pen_x + ((int)g->pos_x); + chy= (int)font->pos[1] + g->height; - pen_y= (int)font->pos[1] - (g->height - ((int)g->pos_y)); - chy= pen_y - ((int)g->pos_y); + if (g->pitch < 0) { + pen_y = (int)font->pos[1] + (g->height - (int)g->pos_y); + } + else { + pen_y = (int)font->pos[1] - (g->height - (int)g->pos_y); + } if ((chx + g->width) >= 0 && chx < font->bw && (pen_y + g->height) >= 0 && pen_y < font->bh) { /* dont draw beyond the buffer bounds */ diff --git a/source/blender/blenkernel/BKE_exotic.h b/source/blender/blenkernel/BKE_exotic.h index bd5af66c6a8..740a94b6169 100644 --- a/source/blender/blenkernel/BKE_exotic.h +++ b/source/blender/blenkernel/BKE_exotic.h @@ -34,9 +34,6 @@ struct Mesh; struct Scene; -void mcol_to_rgba(unsigned int col, float *r, float *g, float *b, float *a); -unsigned int *mcol_to_vcol(struct Mesh *me); // used in py_main.c - /** * Reads all 3D fileformats other than Blender fileformat * @retval 0 The file could not be read. @@ -46,7 +43,6 @@ unsigned int *mcol_to_vcol(struct Mesh *me); // used in py_main.c int BKE_read_exotic(struct Scene *scene, char *name); void write_dxf(struct Scene *scene, char *str); -void write_vrml(struct Scene *scene, char *str); void write_stl(struct Scene *scene, char *str); #endif diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index c842efaa3b2..e246b51af09 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -48,7 +48,7 @@ void BKE_stamp_info(struct Scene *scene, struct ImBuf *ibuf); void BKE_stamp_buf(struct Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels); int BKE_write_ibuf(struct Scene *scene, struct ImBuf *ibuf, char *name, int imtype, int subimtype, int quality); void BKE_makepicstring(char *string, char *base, int frame, int imtype, int use_ext); -void BKE_add_image_extension(char *string, int imtype); +int BKE_add_image_extension(char *string, int imtype); int BKE_ftype_to_imtype(int ftype); int BKE_imtype_to_ftype(int imtype); int BKE_imtype_is_movie(int imtype); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 4bd4cc3792f..7b4925b7a46 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -192,7 +192,7 @@ int nodeSetActiveID(struct bNodeTree *ntree, short idtype, struct ID *id); void nodeClearActiveID(struct bNodeTree *ntree, short idtype); void NodeTagChanged(struct bNodeTree *ntree, struct bNode *node); -void NodeTagIDChanged(struct bNodeTree *ntree, struct ID *id); +int NodeTagIDChanged(struct bNodeTree *ntree, struct ID *id); /* ************** Groups ****************** */ diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h index 36ccc1f1497..7461d43e721 100644 --- a/source/blender/blenkernel/BKE_unit.h +++ b/source/blender/blenkernel/BKE_unit.h @@ -36,12 +36,18 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system, /* 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); +/* make string keyboard-friendly: 10µm --> 10um */ +void bUnit_ToUnitAltName(char *str, int len_max, char *orig_str, 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); +/* return true is the unit system exists */ +int bUnit_IsValid(int system, int type); + /* loop over scales, coudl add names later */ //double bUnit_Iter(void **unit, char **name, int system, int type); @@ -60,6 +66,7 @@ double bUnit_GetScaler(void *usys_pt, int index); #define B_UNIT_TIME 6 #define B_UNIT_VELOCITY 7 #define B_UNIT_ACCELERATION 8 +#define B_UNIT_MAXDEF 9 #ifdef __cplusplus } diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 4b9ffb1e374..98bdf3b2e9f 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1357,19 +1357,25 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p VECCOPY(vec, obmat[3]); obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f; - copy_m4_m4(mat, pamat); + /* Normal particles and cached hair live in global space so we need to + * remove the real emitter's transformation before 2nd order duplication. + */ + if(par_space_mat) + mul_m4_m4m4(mat, pamat, psys->imat); + else + copy_m4_m4(mat, pamat); mul_m4_m4m4(tmat, obmat, mat); mul_mat3_m4_fl(tmat, size*scale); - if(part->draw & PART_DRAW_GLOBAL_OB) - VECADD(tmat[3], tmat[3], vec); - if(par_space_mat) mul_m4_m4m4(mat, tmat, par_space_mat); else copy_m4_m4(mat, tmat); + if(part->draw & PART_DRAW_GLOBAL_OB) + VECADD(mat[3], mat[3], vec); + dob= new_dupli_object(lb, ob, mat, ob->lay, counter, OB_DUPLIPARTS, animated); copy_m4_m4(dob->omat, oldobmat); if(G.rendering) diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 54ffda6c0a9..69a42e52247 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -240,6 +240,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * mul_v3_fl(bbd->wanted_co, (1.0f - t) * val->personal_space * pa->size); bbd->wanted_speed = sqrt(t) * len_v3(pa->prev_state.vel); + bbd->wanted_speed = MAX2(bbd->wanted_speed, val->min_speed); return 1; } @@ -736,6 +737,7 @@ static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData * val->jump_speed = 0.0f; /* no jumping in air */ } } + static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *ground_co, float *ground_nor) { BoidParticle *bpa = pa->boid; @@ -765,16 +767,15 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro if(!bbd->sim->colliders) return NULL; + /* first try to find below boid */ copy_v3_v3(col.co1, pa->state.co); - copy_v3_v3(col.co2, pa->state.co); - add_v3_v3(col.co1, zvec); + sub_v3_v3v3(col.co2, pa->state.co, zvec); sub_v3_v3(col.co2, zvec); sub_v3_v3v3(ray_dir, col.co2, col.co1); col.t = 0.0f; hit.index = -1; hit.dist = col.ray_len = len_v3(ray_dir); - /* find out upmost deflector object */ for(coll = bbd->sim->colliders->first; coll; coll = coll->next){ col.ob = coll->ob; col.md = coll->collmd; @@ -789,14 +790,37 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro normalize_v3_v3(ground_nor, col.nor); return col.hit_ob; } - else { - /* default to z=0 */ - VECCOPY(ground_co, pa->state.co); - ground_co[2] = 0; - ground_nor[0] = ground_nor[1] = 0.0f; - ground_nor[2] = 1.0f; - return NULL; + + /* couldn't find below, so find upmost deflector object */ + add_v3_v3v3(col.co1, pa->state.co, zvec); + sub_v3_v3v3(col.co2, pa->state.co, zvec); + sub_v3_v3(col.co2, zvec); + sub_v3_v3v3(ray_dir, col.co2, col.co1); + col.t = 0.0f; + hit.index = -1; + hit.dist = col.ray_len = len_v3(ray_dir); + + for(coll = bbd->sim->colliders->first; coll; coll = coll->next){ + col.ob = coll->ob; + col.md = coll->collmd; + + if(col.md && col.md->bvhtree) + BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, particle_intersect_face, &col); + } + /* then use that object */ + if(hit.index>=0) { + t = hit.dist/col.ray_len; + interp_v3_v3v3(ground_co, col.co1, col.co2, t); + normalize_v3_v3(ground_nor, col.nor); + return col.hit_ob; } + + /* default to z=0 */ + VECCOPY(ground_co, pa->state.co); + ground_co[2] = 0; + ground_nor[0] = ground_nor[1] = 0.0f; + ground_nor[2] = 1.0f; + return NULL; } } static int boid_rule_applies(ParticleData *pa, BoidSettings *boids, BoidRule *rule) @@ -1226,8 +1250,8 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) VECADDFAC(pa->state.vel, pa->state.vel, acc, dtime); - if(bpa->data.mode != eBoidMode_InAir) - bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor); + //if(bpa->data.mode != eBoidMode_InAir) + bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor); /* change modes, constrain movement & keep track of down vector */ switch(bpa->data.mode) { @@ -1255,11 +1279,18 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) boid_find_ground(bbd, pa, ground_co, ground_nor); boid_climb(boids, pa, ground_co, ground_nor); } - /* land boid when belowg ground */ - else if(boids->options & BOID_ALLOW_LAND && pa->state.co[2] <= ground_co[2] + pa->size * boids->height) { - pa->state.co[2] = ground_co[2] + pa->size * boids->height; - pa->state.vel[2] = 0.0f; - bpa->data.mode = eBoidMode_OnLand; + else if(pa->state.co[2] <= ground_co[2] + pa->size * boids->height) { + /* land boid when below ground */ + if(boids->options & BOID_ALLOW_LAND) { + pa->state.co[2] = ground_co[2] + pa->size * boids->height; + pa->state.vel[2] = 0.0f; + bpa->data.mode = eBoidMode_OnLand; + } + /* fly above ground */ + else { + pa->state.co[2] = ground_co[2] + pa->size * boids->height; + pa->state.vel[2] = 0.0f; + } } break; } @@ -1355,7 +1386,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* save direction to state.ave unless the boid is falling */ /* (boids can't effect their direction when falling) */ if(bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1*pa->size) { - normalize_v3_v3(pa->state.ave, pa->state.vel); + copy_v3_v3(pa->state.ave, pa->state.vel); + pa->state.ave[2] *= bbd->part->boids->pitch; + normalize_v3(pa->state.ave); } /* apply damping */ @@ -1440,6 +1473,7 @@ void boid_default_settings(BoidSettings *boids) boids->landing_smoothness = 3.0f; boids->banking = 1.0f; + boids->pitch = 1.0f; boids->height = 1.0f; boids->health = 1.0f; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 05fcabd371f..0da5e0da2c4 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -29,6 +29,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include <stddef.h> #include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include <math.h> diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index cdefbb54ecf..9dac409226b 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -29,12 +29,14 @@ * * ***** END GPL LICENSE BLOCK *****/ +#include <stddef.h> #include "BLI_storage.h" +#include <stdlib.h> #include <ctype.h> /* isdigit, isspace */ #include <math.h> #include <stdio.h> -#include <stdlib.h> + #include <fcntl.h> #include <string.h> #include <errno.h> @@ -449,1328 +451,10 @@ static void read_stl_mesh_ascii(Scene *scene, char *str) #undef STLREADLINE #undef STLREADVERT -/* ***************** INVENTOR ******************* */ - - -#define IV_MAXSTACK 3000000 -#define IV_MAXFIELD 10 -#define IV_MAXCOL 16 - -static float *iv_data_stack; -static float ivcolors[IV_MAXCOL][3]; -static Object *ivsurf; -static ListBase ivbase; - -struct IvNode { - struct IvNode *next, *prev; - char *nodename; - char *fieldname[IV_MAXFIELD]; - int datalen[IV_MAXFIELD]; - float *data[IV_MAXFIELD]; -}; - -static int iv_curcol=0; - -static int iv_colornumber(struct IvNode *iv) -{ - float *fp, fr = 0.0, fg = 0.0, fb = 0.0; - int a; - char *cp; - - /* search back to last material */ - while(iv) { - if( strcmp(iv->nodename, "Material")==0) { - fp= iv->data[0]; - if(fp==0) fp= iv->data[1]; - if(fp) { - fr= fp[0]; - fg= fp[1]; - fb= fp[2]; - } - break; - } - else if( strcmp(iv->nodename, "BaseColor")==0) { - fp= iv->data[0]; - fr= fp[0]; - fg= fp[1]; - fb= fp[2]; - break; - } - else if( strcmp(iv->nodename, "PackedColor")==0) { - cp= (char *)iv->data[0]; - fr= cp[3]/255.0f; - fg= cp[2]/255.0f; - fb= cp[1]/255.0f; - break; - } - iv= iv->prev; - - } - if(iv==0) return 0; - if(iv->datalen[0]<3) return 0; - - for(a=0; a<iv_curcol; a++) { - - if(ivcolors[a][0]== fr) - if(ivcolors[a][1]== fg) - if(ivcolors[a][2]== fb) return a+1 - ; - } - - if(a>=IV_MAXCOL) a= IV_MAXCOL-1; - iv_curcol= a+1; - ivcolors[a][0]= fr; - ivcolors[a][1]= fg; - ivcolors[a][2]= fb; - - return iv_curcol; -} - -static int iv_finddata(struct IvNode *iv, char *field, int fieldnr) -{ - /* search for "field", count data size and make datablock. return skipdata */ - float *fp; - int len, stackcount, skipdata=0; - char *cpa, terminator, str[64]; - intptr_t i; - - len= strlen(field); - - cpa= iv->nodename+1; - while( *cpa != '}' ) { - - if( *cpa == *field ) { - if( strncmp(cpa, field, len)==0 ) { - iv->fieldname[fieldnr]= cpa; - - /* read until first character */ - cpa+= len; - skipdata+= len; - *cpa= 0; - cpa++; - skipdata++; - - while( *cpa==32 || *cpa==13 || *cpa==10 || *cpa==9) cpa++; - if( *cpa=='[' ) { - terminator= ']'; - cpa++; - skipdata++; - } - else terminator= 13; - - stackcount= 0; - fp= iv_data_stack; - - while( *cpa!=terminator && *cpa != '}' ) { - - /* in fact, isdigit should include the dot and minus */ - if( (isdigit(*cpa) || *cpa=='.' || *cpa=='-') && (isspace(cpa[-1]) || cpa[-1]==0 || cpa[-1]==',') ) { - if(cpa[1]=='x') { - memcpy(str, cpa, 16); - str[16]= 0; - - sscanf(str, "%x", (int *)fp); - } - else { - /* atof doesn't stop after the first float - * in a long string at Windows... so we copy - * the float to a new string then atof... */ - char *cpa_temp = strpbrk(cpa, ", \n"); - i = cpa_temp - cpa; - - if (i>63) *fp= 0.0; - else { - memcpy(str, cpa, i); - str[i]=0; - - *fp= (float) atof(str); - } - } - - stackcount++; - if(stackcount>=IV_MAXSTACK) { - printf("stackoverflow in IV read\n"); - break; - } - fp++; - } - cpa++; - skipdata++; - } - - iv->datalen[fieldnr]= stackcount; - if(stackcount) { - iv->data[fieldnr]= MEM_mallocN(sizeof(float)*stackcount, "iv_finddata"); - memcpy(iv->data[fieldnr], iv_data_stack, sizeof(float)*stackcount); - } - else iv->data[fieldnr]= 0; - - return skipdata; - } - } - cpa++; - skipdata++; - } - - return skipdata; -} - -static void read_iv_index(float *data, float *baseadr, float *index, int nr, int coordtype) -{ - /* write in data: baseadr with offset index (and number nr) */ - float *fp; - int ofs; - - while(nr--) { - ofs= (int) *index; - fp= baseadr+coordtype*ofs; - VECCOPY(data, fp); - data+= 3; - index++; - } -} - - - -static void read_inventor(Scene *scene, char *str, struct ListBase *listb) -{ - struct IvNode *iv, *ivp, *ivn; - char *maindata, *md, *cpa; - float *index, *data, *fp; - int file, filelen, count, lll, face, nr = 0; - int skipdata, ok, a, b, tot, first, colnr, coordtype, polytype, *idata; - struct DispList *dl; - ReportList *reports= NULL; /* XXX */ - - ivbase.first= ivbase.last= 0; - iv_curcol= 0; - ivsurf= 0; - - file= open(str, O_BINARY|O_RDONLY); - if(file== -1) { - BKE_reportf(reports, RPT_ERROR, "Can't read file: %s.", strerror(errno)); - return; - } - - filelen= BLI_filesize(file); - if(filelen < 1) { - close(file); - return; - } - - maindata= MEM_mallocN(filelen, "leesInventor"); - if(read(file, maindata, filelen) < filelen) { - BKE_reportf(reports, RPT_ERROR, "Failed reading file: premature end of file."); - close(file); - return; - } - close(file); - - iv_data_stack= MEM_mallocN(sizeof(float)*IV_MAXSTACK, "ivstack"); - - /* preprocess: remove comments */ - md= maindata+20; - count= 20; - while(count<filelen) { - if( *md=='#' ) { /* comment */ - while( *md!=13 && *md!=10) { /* enters */ - *md= 32; - md++; - count++; - if(count>=filelen) break; - } - } - md++; - count++; - } - - - /* now time to collect: which are the nodes and fields? */ - md= maindata; - count= 0; - while(count<filelen) { - if( *md=='{' ) { /* read back */ - - cpa= md-1; - while( *cpa==32 || *cpa==13 || *cpa==10 || *cpa==9) { /* remove spaces/enters/tab */ - *cpa= 0; - cpa--; - } - - while( *cpa>32 && *cpa<128) cpa--; - cpa++; - *md= 0; - - ok= 0; - skipdata= 0; - iv= MEM_callocN(sizeof(struct IvNode), "leesInventor"); - iv->nodename= cpa; - - if(strcmp(cpa, "Coordinate3")==0 || strcmp(cpa, "Coordinate4")==0) { - skipdata= iv_finddata(iv, "point", 0); - ok= 1; - } - else if(strcmp(cpa, "VertexProperty")==0) { - skipdata= iv_finddata(iv, "vertex", 0); - ok= 1; - } - else if(strcmp(cpa, "IndexedLineSet")==0) { - skipdata= iv_finddata(iv, "coordIndex", 0); - ok= 1; - } - else if(strcmp(cpa, "IndexedTriangleMesh")==0) { - skipdata= iv_finddata(iv, "coordIndex", 0); - ok= 1; - } - else if(strcmp(cpa, "IndexedFaceSet")==0) { - skipdata= iv_finddata(iv, "coordIndex", 0); - ok= 1; - } - else if(strcmp(cpa, "FaceSet")==0) { - skipdata= iv_finddata(iv, "numVertices", 0); - ok= 1; - } - else if(strcmp(cpa, "Material")==0) { - iv_finddata(iv, "diffuseColor", 0); - iv_finddata(iv, "ambientColor", 1); - ok= 1; - } - else if(strcmp(cpa, "BaseColor")==0) { - iv_finddata(iv, "rgb", 0); - ok= 1; - } - else if(strcmp(cpa, "PackedColor")==0) { - iv_finddata(iv, "rgba", 0); - ok= 1; - } - else if(strcmp(cpa, "QuadMesh")==0) { - iv_finddata(iv, "verticesPerColumn", 0); - iv_finddata(iv, "verticesPerRow", 1); - - ok= 1; - } - else if(strcmp(cpa, "IndexedTriangleStripSet")==0) { - skipdata= iv_finddata(iv, "coordIndex", 0); - ok= 1; - } - else if(strcmp(cpa, "TriangleStripSet")==0) { - skipdata= iv_finddata(iv, "numVertices", 0); - ok= 1; - } - else if(strcmp(cpa, "IndexedNurbsSurface")==0 || strcmp(cpa, "NurbsSurface")==0) { - iv_finddata(iv, "numUControlPoints", 0); - iv_finddata(iv, "numVControlPoints", 1); - iv_finddata(iv, "uKnotVector", 2); - iv_finddata(iv, "vKnotVector", 3); - ok= 1; - } - else { - /* to the end */ - while( *md != '}') { - md++; - count++; - if(count<filelen) break; - } - } - - - if(ok) { - BLI_addtail(&ivbase, iv); - md+= skipdata; - count+= skipdata; - } - else MEM_freeN(iv); - - } - md++; - count++; - } - - /* join nodes */ - iv= ivbase.first; - - while(iv) { - ivn= iv->next; - - if( strncmp(iv->nodename, "Indexed", 7)==0) { - /* seek back: same name? */ - - ivp= iv->prev; - while(ivp) { - if(strcmp(iv->nodename, ivp->nodename)==0) break; - - if(strcmp(ivp->nodename, "Coordinate3")==0 || - strcmp(ivp->nodename, "Coordinate4")==0 || - strcmp(ivp->nodename, "VertexProperty")==0) { - ivp= 0; - break; - } - ivp= ivp->prev; - } - - if(ivp) { - /* add iv to ivp */ - - tot= iv->datalen[0] + ivp->datalen[0]; - if(tot) { - data= MEM_mallocN(tot*sizeof(float), "samenvoeg iv"); - memcpy(data, ivp->data[0], sizeof(float)*ivp->datalen[0]); - memcpy(data+ivp->datalen[0], iv->data[0], sizeof(float)*iv->datalen[0]); - - ivp->datalen[0]+= iv->datalen[0]; - MEM_freeN(ivp->data[0]); - ivp->data[0]= data; - - BLI_remlink(&ivbase, iv); - MEM_freeN(iv->data[0]); - MEM_freeN(iv); - } - } - } - - iv= ivn; - } - - - /* convert Nodes to DispLists */ - iv= ivbase.first; - while(iv) { - - /* printf(" Node: %s\n", iv->nodename); */ - /* if(iv->fieldname[0]) printf(" Field: %s len %d\n", iv->fieldname[0], iv->datalen[0]); */ - coordtype= 3; - - if( strcmp(iv->nodename, "IndexedLineSet")==0 ) { - - colnr= iv_colornumber(iv); - - /* seek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - if(ivp) { - - /* count the nr of lines */ - tot= 0; - index= iv->data[0]; - lll = iv->datalen[0]-1; - for(a=0; a<lll; a++) { - if(index[0]!= -1 && index[1]!= -1) tot++; - index++; - } - - tot*= 2; /* nr of vertices */ - dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor1"); - BLI_addtail(listb, dl); - dl->type= DL_SEGM; - dl->nr= 2; - dl->parts= tot/2; - dl->col= colnr; - data= (float *)(dl+1); - - index= iv->data[0]; - for(a=0; a<lll; a++) { - if(index[0]!= -1 && index[1]!= -1) { - read_iv_index(data, ivp->data[0], index, 2, coordtype); - data+= 6; - } - index++; - } - } - } - else if( strcmp(iv->nodename, "FaceSet")==0 ) { - - colnr= iv_colornumber(iv); - - /* seek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - - if(ivp) { - /* count triangles */ - tot= 0; - - index= iv->data[0]; - polytype= (int) index[0]; - - for(a=0; a<iv->datalen[0]; a++) { - if(index[0]== polytype) tot++; /* one kind? */ - index++; - } - - - tot*= polytype; /* nr of vertices */ - dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor4"); - BLI_addtail(listb, dl); - dl->type= DL_POLY; - dl->nr= polytype; - dl->parts= tot/polytype; - dl->col= colnr; - data= (float *)(dl+1); - - index= ivp->data[0]; - first= 1; - for(a=0; a<iv->datalen[0]; a++) { - - VECCOPY(data, index); - data+= 3; - index+= 3; - - VECCOPY(data, index); - data+= 3; - index+= 3; - - VECCOPY(data, index); - data+= 3; - index+= 3; - - if(polytype==4) { - VECCOPY(data, index); - data+= 3; - index+= 3; - } - } - } - } - else if( strcmp(iv->nodename, "TriangleStripSet")==0 ) { - - colnr= iv_colornumber(iv); - - /* seek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - - if(ivp) { - /* count triangles */ - tot= 0; - face= 0; - - index= iv->data[0]; /* strip size */ - - for(a=0; a<iv->datalen[0]; a++) { - tot+= (int) index[0]; - face+= ((int) index[0]) - 2; - index++; - } - - dl= MEM_callocN(sizeof(struct DispList), "leesInventor4"); - dl->verts= MEM_callocN( tot*3*sizeof(float), "dl verts"); - dl->index= MEM_callocN( face*3*sizeof(int), "dl index"); - - dl->type= DL_INDEX3; - dl->nr= tot; - dl->parts= face; - - BLI_addtail(listb, dl); - dl->col= colnr; - - index= iv->data[0]; /* strip size */ - fp= ivp->data[0]; /* vertices */ - data= dl->verts; - idata= dl->index; - first= 0; - - for(a=0; a<iv->datalen[0]; a++) { - - /* vertices */ - for(b=0; b<index[0]; b++) { - VECCOPY(data, fp); - data+= 3; - fp+= coordtype; - } - - /* indices */ - lll = index[0] - 2; - for(b=0; b<lll; b++) { - idata[0]= first; - idata[1]= first+1; - idata[2]= first+2; - first++; - idata+= 3; - } - first+= 2; - - index++; - } - } - } - else if( strcmp(iv->nodename, "IndexedFaceSet")==0 ) { - - colnr= iv_colornumber(iv); - - /* seek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - if(ivp) { - - /* count triangles */ - face= 0; - index= iv->data[0]; - lll = iv->datalen[0]-2; - for(a=0; a<lll; a++) { - if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) face++; - index++; - } - - /*number of vertices */ - tot= ivp->datalen[0]/coordtype; - - if(tot) { - dl= MEM_callocN(sizeof(struct DispList), "leesInventor5"); - BLI_addtail(listb, dl); - dl->type= DL_INDEX3; - dl->nr= tot; - dl->parts= face; - dl->col= colnr; - - dl->verts= MEM_callocN( tot*3*sizeof(float), "dl verts"); - dl->index= MEM_callocN(sizeof(int)*3*face, "dl index"); - - /* vertices */ - fp= ivp->data[0]; - data= dl->verts; - for(b=tot; b>0; b--) { - VECCOPY(data, fp); - data+= 3; - fp+= coordtype; - } - - /* indices */ - index= iv->data[0]; - idata= dl->index; - first= 1; - lll=iv->datalen[0]-2; - for(a=0; a<lll; a++) { - - if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) { - - /* this trick is to fill poly's with more than 3 vertices correctly */ - if(first) { - nr= (int) index[0]; - first= 0; - } - idata[0]= nr; - idata[1]= (int) index[1]; - idata[2]= (int) index[2]; - idata+= 3; - } - else first= 1; - - index++; - } - } - } - } - else if( strcmp(iv->nodename, "IndexedTriangleMesh")==0 || - strcmp(iv->nodename, "IndexedTriangleStripSet")==0 ) { - - colnr= iv_colornumber(iv); - - /* seek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - if(ivp) { - - /* count triangles */ - face= 0; - index= iv->data[0]; - lll=iv->datalen[0]-2; - for(a=0; a<lll; a++) { - if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) face++; - index++; - } - - /* nr of vertices */ - tot= ivp->datalen[0]/coordtype; - - dl= MEM_callocN(sizeof(struct DispList), "leesInventor6"); - BLI_addtail(listb, dl); - dl->type= DL_INDEX3; - dl->nr= tot; - dl->parts= face; - dl->col= colnr; - - dl->verts= MEM_callocN( tot*3*sizeof(float), "dl verts"); - dl->index= MEM_callocN(sizeof(int)*3*face, "dl index"); - - /* vertices */ - fp= ivp->data[0]; - data= dl->verts; - for(b=tot; b>0; b--) { - VECCOPY(data, fp); - data+= 3; - fp+= coordtype; - } - - /* indices */ - index= iv->data[0]; - idata= dl->index; - - lll=iv->datalen[0]-2; - for(a=lll; a>0; a--) { - - if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) { - idata[0]= (int) index[0]; - idata[1]= (int) index[1]; - idata[2]= (int) index[2]; - idata+= 3; - } - index++; - } - } - } - else if( strcmp(iv->nodename, "QuadMesh")==0 ) { - - colnr= iv_colornumber(iv); - - /* seek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "VertexProperty")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - - if(ivp) { - tot= (int) (floor(*(iv->data[0])+0.5) * floor(*(iv->data[1])+0.5)); - - if(tot>0) { - dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor8"); - BLI_addtail(listb, dl); - dl->type= DL_SURF; - dl->parts= (int) floor(*(iv->data[0])+0.5); - dl->nr= (int) floor(*(iv->data[1])+0.5); - dl->col= colnr; - data= (float *)(dl+1); - memcpy(data, ivp->data[0], tot*3*sizeof(float)); - } - } - } - else if(strcmp(iv->nodename, "IndexedNurbsSurface")==0 || strcmp(iv->nodename, "NurbsSurface")==0) { - - colnr= iv_colornumber(iv); - - /* sek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - if(ivp) { - a= (int) *(iv->data[0]); - b= (int) *(iv->data[1]); - - tot= a*b; - - if( (a>=4 || b>=4) && tot>6) { - Object *ob; - Curve *cu; - Nurb *nu; - BPoint *bp; - - if(ivsurf==0) { - ob= add_object(scene, OB_SURF); - ivsurf= ob; - } - else ob= ivsurf; - cu= ob->data; - nu = (Nurb*) MEM_callocN(sizeof(Nurb),"addNurbprim") ; - BLI_addtail(&cu->nurb, nu); - nu->type= CU_NURBS; - - nu->pntsu= a; - nu->pntsv= b; - nu->resolu= 2*a; - nu->resolv= 2*b; - - nu->flagu= 0; - nu->flagv= 0; - - nu->bp = bp = - (BPoint*)MEM_callocN(tot * sizeof(BPoint), "addNurbprim3"); - a= tot; - data= ivp->data[0]; - while(a--) { - VECCOPY(bp->vec, data); - if(coordtype==4) { - bp->vec[3]= data[3]; - mul_v3_fl(bp->vec, 1.0f/data[3]); - } - else bp->vec[3]= 1.0; - data+= coordtype; - bp++; - } - - /* iv->datalen[2] / [3] is number of knots */ - nu->orderu= iv->datalen[2] - nu->pntsu; - nu->orderv= iv->datalen[3] - nu->pntsv; - - nu->knotsu= MEM_mallocN( sizeof(float)*(iv->datalen[2]), "knots"); - memcpy(nu->knotsu, iv->data[2], sizeof(float)*(iv->datalen[2])); - nu->knotsv= MEM_mallocN( sizeof(float)*(iv->datalen[3]), "knots"); - memcpy(nu->knotsv, iv->data[3], sizeof(float)*(iv->datalen[3])); - - switchdirectionNurb(nu); - - } - else { - dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor3"); - BLI_addtail(listb, dl); - dl->type= DL_SURF; - dl->nr= (int) *(iv->data[0]); - dl->parts= (int) *(iv->data[1]); - dl->col= colnr; - data= (float *)(dl+1); - - a= tot; - fp= ivp->data[0]; - while(a--) { - VECCOPY(data, fp); - fp+= coordtype; - data+= 3; - } - } - } - } - iv= iv->next; - } - - /* free */ - iv= ivbase.first; - while(iv) { - for(a=0; a<IV_MAXFIELD; a++) { - if(iv->data[a]) MEM_freeN(iv->data[a]); - } - iv= iv->next; - } - - BLI_freelistN(&ivbase); - MEM_freeN(maindata); - MEM_freeN(iv_data_stack); - -} - /* ************************************************************ */ -static void displist_to_mesh(Scene *scene, DispList *dlfirst) -{ - Object *ob; - Mesh *me; - Material *ma; - DispList *dl; - MVert *mvert; - MFace *mface; - float *data, vec[3], min[3], max[3]; - int a, b, startve, *idata, totedge=0, tottria=0, totquad=0, totvert=0, totface, totcol=0, colnr; - int p1, p2, p3, p4; - unsigned int maxvertidx; - - /* count first */ - INIT_MINMAX(min, max); - - dl= dlfirst; - while(dl) { - - /* PATCH 1 (polyfill) can't be done, there's no listbase here. do that first! */ - /* PATCH 2 */ - if(dl->type==DL_SEGM && dl->nr>2) { - data= (float *)(dl+1); - if(data[0]==data[3*(dl->nr-1)]) { - if(data[1]==data[3*(dl->nr-1)+1]) { - if(data[2]==data[3*(dl->nr-1)+2]) { - dl->type= DL_POLY; - dl->nr--; - } - } - } - } - - /* colors */ - if(dl->col > totcol) totcol= dl->col; - - /* size and count */ - if(dl->type==DL_SURF) { - a= dl->nr; - b= dl->parts; - if(dl->flag & DL_CYCL_U) a++; - if(dl->flag & DL_CYCL_V) b++; - - totquad+= a*b; - - totvert+= dl->nr*dl->parts; - - data= (float *)(dl+1); - for(a= dl->nr*dl->parts; a>0; a--) { - DO_MINMAX(data, min, max); - data+= 3; - } - } - else if(dl->type==DL_POLY) { - if(dl->nr==3 || dl->nr==4) { - if(dl->nr==3) tottria+= dl->parts; - else totquad+= dl->parts; - - totvert+= dl->nr*dl->parts; - - data= (float *)(dl+1); - for(a= dl->nr*dl->parts; a>0; a--) { - DO_MINMAX(data, min, max); - data+= 3; - } - } - else if(dl->nr>4) { - - tottria+= dl->nr*dl->parts; - totvert+= dl->nr*dl->parts; - - data= (float *)(dl+1); - for(a= dl->nr*dl->parts; a>0; a--) { - DO_MINMAX(data, min, max); - data+= 3; - } - - } - } - else if(dl->type==DL_INDEX3) { - tottria+= dl->parts; - totvert+= dl->nr; - - data= dl->verts; - for(a= dl->nr; a>0; a--) { - DO_MINMAX(data, min, max); - data+= 3; - } - } - else if(dl->type==DL_SEGM) { - - tottria+= (dl->nr-1)*dl->parts; - totvert+= dl->nr*dl->parts; - - data= (float *)(dl+1); - for(a= dl->nr*dl->parts; a>0; a--) { - DO_MINMAX(data, min, max); - data+= 3; - } - } - - dl= dl->next; - } - - if(totvert==0) { - return; - } - - vec[0]= (min[0]+max[0])/2; - vec[1]= (min[1]+max[1])/2; - vec[2]= (min[2]+max[2])/2; - - ob= add_object(scene, OB_MESH); - VECCOPY(ob->loc, vec); - where_is_object(scene, ob); - - me= ob->data; - - /* colors */ - if(totcol) { - ob->mat= MEM_callocN(sizeof(void *)*totcol, "ob->mat"); - ob->matbits= MEM_callocN(sizeof(char)*totcol, "ob->matbits"); - me->mat= MEM_callocN(sizeof(void *)*totcol, "me->mat"); - me->totcol= totcol; - ob->totcol= (unsigned char) me->totcol; - ob->actcol= 1; - } - - /* materials */ - for(a=0; a<totcol; a++) { - ma= G.main->mat.first; - while(ma) { - if(ma->mtex[0]==0) { - if(ivcolors[a][0]==ma->r && ivcolors[a][1]==ma->g && ivcolors[a][2]==ma->b) { - me->mat[a]= ma; - ma->id.us++; - break; - } - } - ma= ma->id.next; - } - if(ma==0) { - ma= add_material("ext"); - me->mat[a]= ma; - ma->r= ivcolors[a][0]; - ma->g= ivcolors[a][1]; - ma->b= ivcolors[a][2]; - automatname(ma); - } - } - - totface= totquad+tottria+totedge; - - printf("Import: %d vertices %d faces\n", totvert, totface); - - me->totvert= totvert; - me->totface= totface; - me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, - NULL, me->totvert); - me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, - NULL, me->totface); - maxvertidx= totvert-1; - - mvert= me->mvert; - mface= me->mface; - - startve= 0; - - dl= dlfirst; - while(dl) { - - colnr= dl->col; - if(colnr) colnr--; - - if(dl->type==DL_SURF) { - data= (float *)(dl+1); - - for(a=dl->parts*dl->nr; a>0; a--) { - mvert->co[0]= data[0] -vec[0]; - mvert->co[1]= data[1] -vec[1]; - mvert->co[2]= data[2] -vec[2]; - - data+=3; - mvert++; - } - - for(a=0; a<dl->parts; a++) { - - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0) - break; - - p1+= startve; - p2+= startve; - p3+= startve; - p4+= startve; - - for(; b<dl->nr; b++) { - - mface->v1= p1; - mface->v2= p2; - mface->v3= p4; - mface->v4= p3; - - mface->mat_nr= colnr; - test_index_face(mface, NULL, 0, 4); - - mface++; - - p4= p3; - p3++; - p2= p1; - p1++; - } - } - - startve += dl->parts*dl->nr; - - } - else if(dl->type==DL_POLY) { - - if(dl->nr==3 || dl->nr==4) { - data= (float *)(dl+1); - - for(a=dl->parts*dl->nr; a>0; a--) { - mvert->co[0]= data[0] -vec[0]; - mvert->co[1]= data[1] -vec[1]; - mvert->co[2]= data[2] -vec[2]; - data+=3; - mvert++; - } - - for(a=0; a<dl->parts; a++) { - if(dl->nr==3) { - mface->v1= startve+a*dl->nr; - mface->v2= startve+a*dl->nr+1; - mface->v3= startve+a*dl->nr+2; - mface->mat_nr= colnr; - test_index_face(mface, NULL, 0, 3); - mface++; - } - else { - mface->v1= startve+a*dl->nr; - mface->v2= startve+a*dl->nr+1; - mface->v3= startve+a*dl->nr+2; - mface->v4= startve+a*dl->nr+3; - mface->mat_nr= colnr; - test_index_face(mface, NULL, 0, 4); - mface++; - } - } - startve += dl->parts*dl->nr; - } - else if(dl->nr>4) { - data= (float *)(dl+1); - - for(a=dl->parts*dl->nr; a>0; a--) { - mvert->co[0]= data[0] -vec[0]; - mvert->co[1]= data[1] -vec[1]; - mvert->co[2]= data[2] -vec[2]; - - data+=3; - mvert++; - } - - for(b=0; b<dl->parts; b++) { - for(a=0; a<dl->nr; a++) { - mface->v1= startve+a; - - if(a==dl->nr-1) mface->v2= startve; - else mface->v2= startve+a+1; - - mface->mat_nr= colnr; - - mface++; - } - startve += dl->nr; - } - } - } - else if(dl->type==DL_INDEX3) { - data= dl->verts; - - for(a=dl->nr; a>0; a--) { - mvert->co[0]= data[0] -vec[0]; - mvert->co[1]= data[1] -vec[1]; - mvert->co[2]= data[2] -vec[2]; - data+=3; - mvert++; - } - - idata= dl->index; - for(b=dl->parts; b>0; b--) { - mface->v1= startve+idata[0]; - mface->v2= startve+idata[1]; - mface->v3= startve+idata[2]; - mface->mat_nr= colnr; - - if (mface->v1>maxvertidx) mface->v1= maxvertidx; - if (mface->v2>maxvertidx) mface->v2= maxvertidx; - if (mface->v3>maxvertidx) mface->v3= maxvertidx; - - test_index_face(mface, NULL, 0, 3); - mface++; - idata+= 3; - } - startve += dl->nr; - } - else if(dl->type==DL_SEGM) { - data= (float *)(dl+1); - - for(a=dl->parts*dl->nr; a>0; a--) { - mvert->co[0]= data[0] -vec[0]; - mvert->co[1]= data[1] -vec[1]; - mvert->co[2]= data[2] -vec[2]; - data+=3; - mvert++; - } - - for(b=0; b<dl->parts; b++) { - for(a=0; a<dl->nr-1; a++) { - mface->v1= startve+a; - mface->v2= startve+a+1; - mface->mat_nr= colnr; - mface++; - } - startve += dl->nr; - } - } - dl= dl->next; - } - - mesh_add_normals_flags(me); - make_edges(me, 0); -} - -static void displist_to_objects(Scene *scene, ListBase *lbase) -{ - DispList *dl, *first, *prev, *next; - ListBase tempbase; - int maxaantal, curcol, totvert=0, vert; - - /* irst this: is still active */ - if(ivsurf) { - where_is_object(scene, ivsurf); -// XXX docenter_new(); - } - - dl= lbase->first; - while(dl) { - next= dl->next; - - /* PATCH 1: polyfill */ - if(dl->type==DL_POLY && dl->nr>4) { - /* solution: put them together in separate listbase */ - ; - } - /* PATCH 2: poly's of 2 points */ - if(dl->type==DL_POLY && dl->nr==2) dl->type= DL_SEGM; - - dl= next; - } - - /* count vertices */ - - dl= lbase->first; - while(dl) { - - if(dl->type==DL_SURF) totvert+= dl->nr*dl->parts; - else if(dl->type==DL_POLY) { - if(dl->nr==3 || dl->nr==4) totvert+= dl->nr*dl->parts; - else if(dl->nr>4) totvert+= dl->nr*dl->parts; - } - else if(dl->type==DL_INDEX3) totvert+= dl->nr; - else if(dl->type==DL_SEGM) totvert+= dl->nr*dl->parts; - - dl= dl->next; - } - - if(totvert==0) { - - if(ivsurf==0) {}; //XXX error("Found no data"); - if(lbase->first) BLI_freelistN(lbase); - - return; - } - - maxaantal= 32000; - - if(totvert>maxaantal) { - - /* try to put colors together */ - curcol= 0; - tempbase.first= tempbase.last= 0; - - while(lbase->first) { - dl= lbase->first; - while(dl) { - next= dl->next; - if(dl->col==curcol) { - BLI_remlink(lbase, dl); - BLI_addtail(&tempbase, dl); - dl->col= 0; - } - - dl= next; - } - - /* in tempbase are all 'curcol' */ - totvert= 0; - dl= first= tempbase.first; - while(dl) { - vert= 0; - - if(dl->type==DL_SURF) vert= dl->nr*dl->parts; - else if(dl->type==DL_POLY) { - if(dl->nr==3 || dl->nr==4) vert= dl->nr*dl->parts; - else if(dl->nr>4) vert= dl->nr*dl->parts; - } - else if(dl->type==DL_INDEX3) totvert+= dl->nr; - else if(dl->type==DL_SEGM) vert= dl->nr*dl->parts; - - totvert+= vert; - if(totvert > maxaantal || dl->next==0) { - if(dl->next==0) { - displist_to_mesh(scene, first); - } - else if(dl->prev) { - prev= dl->prev; - prev->next= 0; - displist_to_mesh(scene, first); - prev->next= dl; - first= dl; - totvert= 0; - } - } - - dl= dl->next; - } - - freedisplist(&tempbase); - - curcol++; - } - } - else displist_to_mesh(scene, lbase->first); - - freedisplist(lbase); - -} - int BKE_read_exotic(Scene *scene, char *name) { - ListBase lbase={0, 0}; int len; gzFile gzfile; char str[32]; @@ -1793,21 +477,7 @@ int BKE_read_exotic(Scene *scene, char *name) if ((*s0 != FORM) && (strncmp(str, "BLEN", 4) != 0) && !BLI_testextensie(name,".blend.gz")) { //XXX waitcursor(1); - if(strncmp(str, "#Inventor V1.0", 14)==0) { - if( strncmp(str+15, "ascii", 5)==0) { - read_inventor(scene, name, &lbase); - displist_to_objects(scene, &lbase); - retval = 1; - } else { - //XXX error("Can only read Inventor 1.0 ascii"); - } - } - else if((strncmp(str, "#VRML V1.0 asc", 14)==0)) { - read_inventor(scene, name, &lbase); - displist_to_objects(scene, &lbase); - retval = 1; - } - else if(is_dxf(name)) { + if(is_dxf(name)) { dxf_read(scene, name); retval = 1; } @@ -1907,15 +577,8 @@ void write_stl(Scene *scene, char *str) FILE *fpSTL; int numfacets = 0; ReportList *reports= NULL; /* XXX */ - - if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0; - if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0; - if(BLI_testextensie(str,".stl")==0) strcat(str, ".stl"); - if (BLI_exists(str)) { - ; //XXX if(saveover(str)==0) - //XXX return; - } + /* XXX, operator needs to manage filename extension */ fpSTL= fopen(str, "wb"); @@ -1965,7 +628,6 @@ void write_stl(Scene *scene, char *str) //XXX waitcursor(0); } -/* ******************************* WRITE VRML ***************************** */ static void replace_chars(char *str1, char *str2) { @@ -1978,354 +640,6 @@ static void replace_chars(char *str1, char *str2) } } - -static void write_material_vrml(FILE *fp, Material *ma) -{ - char str[32]; - - replace_chars(str, ma->id.name+2); - - fprintf(fp, "\tDEF %s\n", str); - fprintf(fp, "\tMaterial {\n"); - - fprintf(fp, "\t\tdiffuseColor %f %f %f\n", ma->r, ma->g, ma->b); - fprintf(fp, "\t\tspecularColor %f %f %f\n", ma->specr, ma->specg, ma->specb); - fprintf(fp, "\t\tshininess %f \n", ((float)ma->har)/100.0); - fprintf(fp, "\t\ttransparency %f \n", 1.0-ma->alpha); - - fprintf(fp, "\t}\n"); - -} - -unsigned int *mcol_to_vcol(Mesh *me) -{ - MFace *mface; - unsigned int *mcol, *mcoln, *mcolmain; - int a; - - if(me->totface==0 || me->mcol==0) return 0; - - mcoln= mcolmain= MEM_mallocN(sizeof(int)*me->totvert, "mcoln"); - mcol = (unsigned int *)me->mcol; - mface= me->mface; - - for(a=me->totface; a>0; a--, mface++) { - mcoln[mface->v1]= mcol[0]; - mcoln[mface->v2]= mcol[1]; - mcoln[mface->v3]= mcol[2]; - if(mface->v4) mcoln[mface->v4]= mcol[3]; - - mcol+= 4; - } - - return mcolmain; -} - -void mcol_to_rgba(unsigned int col, float *r, float *g, float *b, float *a) -{ - char *cp; - - cp = (char *)&col; - - *r= cp[3]; - *r /= 255.0; - - *g= cp[2]; - *g /= 255.0; - - *b= cp[1]; - *b /= 255.0; - - *a= cp[0]; - *a /= 255.0; -} - -static void write_mesh_vrml(FILE *fp, Mesh *me) -{ - Material *ma; - MVert *mvert; - MFace *mface; - MTFace *tface; - Image *ima; - int a, b, totcol, texind; - char str[32]; - - replace_chars(str, me->id.name+2); - - fprintf(fp, "\tDEF %s\n", str); - fprintf(fp, "\tSeparator {\n"); - - if(me->mtface) { - ima= ((MTFace *)me->mtface)->tpage; - if(ima) { - fprintf(fp, "\t\tTexture2 {\n"); - fprintf(fp, "\t\t\tfilename %s\n", ima->name); - fprintf(fp, "\t\t\twrapS REPEAT \n"); - fprintf(fp, "\t\t\twrapT REPEAT \n"); - fprintf(fp, "\t\t}\n"); - } - } - - if(me->mcol) { - unsigned int *mcol, *mcolmain; - float r, g, b, cola; - - fprintf(fp, "\t\tMaterial {\n"); - fprintf(fp, "\t\t\tdiffuseColor [\n"); - - a= me->totvert; - mcol= mcolmain= mcol_to_vcol(me); - if(mcol) { - while(a--) { - mcol_to_rgba(*mcol, &r, &g, &b, &cola); - fprintf(fp, "\t\t\t\t %f %f %f,\n", r, g, b); - mcol++; - } - MEM_freeN(mcolmain); - } - fprintf(fp, "\t\t\t]\n"); - fprintf(fp, "\t\t}\n"); - - fprintf(fp, "\t\tMaterialBinding { value PER_VERTEX_INDEXED }\n"); - } - - - fprintf(fp, "\t\tCoordinate3 {\n"); - fprintf(fp, "\t\t\tpoint [\n"); - - a= me->totvert; - mvert= me->mvert; - while(a--) { - fprintf(fp, "\t\t\t\t %f %f %f,\n", mvert->co[0], mvert->co[1], mvert->co[2]); - mvert++; - } - fprintf(fp, "\t\t\t]\n"); - fprintf(fp, "\t\t}\n"); - - - totcol= me->totcol; - if(totcol==0) totcol= 1; - texind= 0; // index for uv coords - - for(b=0; b<totcol; b++) { - - if(me->mcol==0) { - if(me->mat) { - ma= me->mat[b]; - if(ma) { - replace_chars(str, ma->id.name+2); - - fprintf(fp, "\t\tUSE %s\n\n", str); - } - } - } - - if(me->mtface) { - fprintf(fp, "\t\tTextureCoordinate2 {\n"); - fprintf(fp, "\t\t\tpoint [\n"); - - a= me->totface; - mface= me->mface; - tface= me->mtface; - while(a--) { - if(mface->mat_nr==b) { - fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[0][0], tface->uv[0][1]); - fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[1][0], tface->uv[1][1]); - fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[2][0], tface->uv[2][1]); - if(mface->v4) fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[3][0], tface->uv[3][1]); - } - mface++; - tface++; - } - fprintf(fp, "\t\t\t]\n"); - fprintf(fp, "\t\t}\n"); - } - - fprintf(fp, "\t\tIndexedFaceSet {\n"); - fprintf(fp, "\t\t\tcoordIndex [\n"); - - a= me->totface; - mface= me->mface; - while(a--) { - if(mface->mat_nr==b) { - if(mface->v4) fprintf(fp, "\t\t\t\t %d, %d, %d, %d, -1,\n", mface->v1, mface->v2, mface->v3, mface->v4); - else fprintf(fp, "\t\t\t\t %d, %d, %d, -1,\n", mface->v1, mface->v2, mface->v3); - } - mface++; - } - fprintf(fp, "\t\t\t]\n"); - - if(me->mtface) { - fprintf(fp, "\t\t\ttextureCoordIndex [\n"); - - a= me->totface; - mface= me->mface; - while(a--) { - if(mface->mat_nr==b) { - if(mface->v4) { - fprintf(fp, "\t\t\t\t %d, %d, %d, %d, -1,\n", texind, texind+1, texind+2, texind+3); - texind+= 4; - } - else { - fprintf(fp, "\t\t\t\t %d, %d, %d, -1,\n", texind, texind+1, texind+2); - texind+= 3; - } - } - mface++; - } - fprintf(fp, "\t\t\t]\n"); - } - fprintf(fp, "\t\t}\n"); - } - - fprintf(fp, "\t}\n"); -} - -static void write_camera_vrml(FILE *fp, Object *ob) -{ - Camera *cam; - - if(ob==0) return; - invert_m4_m4(ob->imat, ob->obmat); - - fprintf(fp, "\tMatrixTransform {\n"); - - fprintf(fp, "\tmatrix \n"); - - fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[0][0], ob->imat[0][1], ob->imat[0][2], ob->imat[0][3]); - fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[1][0], ob->imat[1][1], ob->imat[1][2], ob->imat[1][3]); - fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[2][0], ob->imat[2][1], ob->imat[2][2], ob->imat[2][3]); - fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[3][0], ob->imat[3][1], ob->imat[3][2], ob->imat[3][3]); - - fprintf(fp, "\t}\n"); - - cam= ob->data; - - fprintf(fp, "\tPerspectiveCamera {\n"); - fprintf(fp, "\t\tfocalDistance %f\n", cam->lens/10.0); - - fprintf(fp, "\t}\n"); - -} - -static void write_object_vrml(FILE *fp, Object *ob) -{ - ID *id; - char str[32]; - - fprintf(fp, "\tSeparator {\n"); - fprintf(fp, "\t\tMatrixTransform {\n"); - - fprintf(fp, "\t\tmatrix \n"); - - fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[0][0], ob->obmat[0][1], ob->obmat[0][2], ob->obmat[0][3]); - fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[1][0], ob->obmat[1][1], ob->obmat[1][2], ob->obmat[1][3]); - fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[2][0], ob->obmat[2][1], ob->obmat[2][2], ob->obmat[2][3]); - fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[3][0], ob->obmat[3][1], ob->obmat[3][2], ob->obmat[3][3]); - - fprintf(fp, "\t\t}\n"); - - id= ob->data; - - replace_chars(str, id->name+2); - - fprintf(fp, "\t\tUSE %s\n", str); - fprintf(fp, "\t}\n"); -} - - -void write_vrml(Scene *scene, char *str) -{ - Mesh *me; - Material *ma; - Base *base; - FILE *fp; - - if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0; - if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0; - if(BLI_testextensie(str,".wrl")==0) strcat(str, ".wrl"); - //XXX saveover() if(saveover(str)==0) return; - - fp= fopen(str, "w"); - - if(fp==NULL) { - //XXX error("Can't write file"); - return; - } - strcpy(temp_dir, str); - - //XXX waitcursor(1); - - /* FIRST: write all the datablocks */ - - fprintf(fp, "#VRML V1.0 ascii\n\n# Blender V%d\n\n# 'Switch' is used as a hack, to ensure it is not part of the drawing\n\n", BLENDER_VERSION); - fprintf(fp, "Separator {\n"); - fprintf(fp, "Switch {\n"); - - ma= G.main->mat.first; - while(ma) { - if(ma->id.us) { - write_material_vrml(fp, ma); - } - ma= ma->id.next; - } - - /* only write meshes we're using in this scene */ - flag_listbase_ids(&G.main->mesh, LIB_DOIT, 0); - - for(base= scene->base.first; base; base= base->next) - if(base->object->type== OB_MESH) - ((ID *)base->object->data)->flag |= LIB_DOIT; - - me= G.main->mesh.first; - while(me) { - if(me->id.flag & LIB_DOIT) { /* is the mesh used in this scene ? */ - write_mesh_vrml(fp, me); - } - me= me->id.next; - } - - /* THEN:Hidden Objects */ - fprintf(fp, "\n\t# Hidden Objects, in invisible layers\n\n"); - base= scene->base.first; - while(base) { - if(base->object->type== OB_MESH) { - if( (base->lay & scene->lay)==0 ) { - write_object_vrml(fp, base->object); - } - } - base= base->next; - } - - fprintf(fp, "}\n"); - fprintf(fp, "\n# Visible Objects\n\n"); - fprintf(fp, "Separator {\n"); - - /* The camera */ - - write_camera_vrml(fp, scene->camera); - - /* THEN:The Objects */ - - base= scene->base.first; - while(base) { - if(base->object->type== OB_MESH) { - if(base->lay & scene->lay) { - write_object_vrml(fp, base->object); - } - } - base= base->next; - } - - fprintf(fp, "}\n"); - fprintf(fp, "}\n"); - - fclose(fp); - - //XXX waitcursor(0); -} - - /* ******************************* WRITE DXF ***************************** */ #define write_group(id,data) fprintf(fp, "%d\n%s\n", id, data) @@ -2551,15 +865,7 @@ void write_dxf(struct Scene *scene, char *str) Base *base; FILE *fp; - if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0; - if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0; - if(BLI_testextensie(str,".dxf")==0) strcat(str, ".dxf"); - - - if (BLI_exists(str)) { - ; //XXX if(saveover(str)==0) - // return; - } + /* XXX, operator needs to handle overwrite & rename */ fp= fopen(str, "w"); diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 04ce6c39694..ef89d39864a 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -28,6 +28,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include <stddef.h> #include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 0e282aa6449..f3dfd4292c6 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -69,6 +69,7 @@ #include "BKE_main.h" #include "BKE_packedFile.h" #include "BKE_scene.h" +#include "BKE_node.h" //XXX #include "BIF_editseq.h" @@ -756,9 +757,9 @@ int BKE_imtype_is_movie(int imtype) return 0; } -void BKE_add_image_extension(char *string, int imtype) +int BKE_add_image_extension(char *string, int imtype) { - char *extension=""; + char *extension= NULL; if(imtype== R_IRIS) { if(!BLI_testextensie(string, ".rgb")) @@ -829,7 +830,12 @@ void BKE_add_image_extension(char *string, int imtype) extension= ".jpg"; } - strcat(string, extension); + if(extension) { + return BLI_replace_extension(string, FILE_MAX, extension); + } + else { + return FALSE; + } } /* could allow access externally - 512 is for long names, 64 is for id names */ @@ -1447,6 +1453,17 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) } break; } + + /* dont use notifiers because they are not 100% sure to succseed + * this also makes sure all scenes are accounted for. */ + { + Scene *scene; + for(scene= G.main->scene.first; scene; scene= scene->id.next) { + if(scene->nodetree) { + NodeTagIDChanged(scene->nodetree, &ima->id); + } + } + } } /* if layer or pass changes, we need an index for the imbufs list */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 5af2c64da18..135ddbab2b7 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1787,18 +1787,25 @@ void NodeTagChanged(bNodeTree *ntree, bNode *node) } } -void NodeTagIDChanged(bNodeTree *ntree, ID *id) +int NodeTagIDChanged(bNodeTree *ntree, ID *id) { + int change = FALSE; + if(id==NULL) - return; + return change; if(ntree->type==NTREE_COMPOSIT) { bNode *node; - for(node= ntree->nodes.first; node; node= node->next) - if(node->id==id) + for(node= ntree->nodes.first; node; node= node->next) { + if(node->id==id) { + change= TRUE; NodeTagChanged(ntree, node); + } + } } + + return change; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 94a316a2c94..07b712c4330 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -384,9 +384,6 @@ void free_hair(Object *ob, ParticleSystem *psys, int dynamics) { PARTICLE_P; - if(psys->part->type != PART_HAIR) - return; - LOOP_PARTICLES { if(pa->hair) MEM_freeN(pa->hair); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 0d14c3cb9f6..5318754951f 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -29,6 +29,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include <stddef.h> #include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include <stdlib.h> @@ -3440,7 +3441,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) else if(part->phystype == PART_PHYS_NO) reset_particle(sim, pa, dtime, cfra); - if(dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){ + if(pa_dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){ switch(part->phystype){ case PART_PHYS_NEWTON: /* do global forces & effectors */ diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index a35e40d7cf7..741580048cf 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1454,7 +1454,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) if(!pm && !pf) { if(pid->cache->flag & PTCACHE_DISK_CACHE) { pf=NULL; - while(cfrai > pid->cache->startframe && !pf) { + while(cfrai >= pid->cache->startframe && !pf) { cfrai--; pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); cfra1 = cfrai; diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 4d58ec8212a..487ec78b2bd 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -68,7 +68,7 @@ static unsigned int HashHash(void *key_) rval ^= *(unsigned int*) &key->cfra; rval += key->type; - rval ^= ((unsigned int) key->seq) << 6; + rval ^= ((intptr_t) key->seq) << 6; return rval; } diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 11012843131..d2d8d5a6e07 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1350,7 +1350,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM if(framenr > endframe) return; - if(!smd->domain->fluid && (framenr != startframe)) + if(!smd->domain->fluid && (framenr != startframe) && (cache->flag & PTCACHE_BAKED)==0) return; // printf("startframe: %d, framenr: %d\n", startframe, framenr); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 4c85656dd91..d6486c3ee4d 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1421,7 +1421,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, v DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); } - if(!doDraw || (setDrawOptions && !setDrawOptions(userData, origIndex))) { + if(!doDraw || (setDrawOptions && (origIndex != ORIGINDEX_NONE) && !setDrawOptions(userData, origIndex))) { a += gridFaces*gridFaces*numVerts; continue; } diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 133f858e9ea..36a4cfea7a0 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -24,6 +24,8 @@ #include <stdio.h> #include <ctype.h> #include <string.h> +#include "BKE_unit.h" + #ifdef WIN32 #define _USE_MATH_DEFINES #endif @@ -31,6 +33,7 @@ #include "BLI_winstuff.h" + #define TEMP_STR_SIZE 256 #define SEP_CHR '#' @@ -44,7 +47,8 @@ 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_alt; /* keyboard-friendly ASCII-only version of name_short, can be NULL */ + /* if name_short has non-ASCII chars, name_alt should be present */ char *name_display; /* can be NULL */ @@ -76,7 +80,7 @@ static struct bUnitCollection buDummyCollecton = {buDummyDef, 0, 0, sizeof(buDum static struct bUnitDef buMetricLenDef[] = { {"kilometer", "kilometers", "km", NULL, "Kilometers", 1000.0, 0.0, B_UNIT_DEF_NONE}, {"hectometer", "hectometers", "hm", NULL, "100 Meters", 100.0, 0.0, B_UNIT_DEF_SUPPRESS}, - {"dekameter", "dekameters", "dkm",NULL, "10 Meters", 10.0, 0.0, B_UNIT_DEF_SUPPRESS}, + {"dekameter", "dekameters", "dam",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}, @@ -126,7 +130,8 @@ static struct bUnitDef buNaturalRotDef[] = { }; static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)}; -#define UNIT_SYSTEM_MAX 3 +#define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 8) / sizeof(void *)) - 1) + static struct bUnitCollection *bUnitSystems[][8] = { {0,0,0,0,0,&buNaturalRotCollection,&buNaturalTimeCollecton,0}, {0,&buMetricLenCollecton, 0,0,0, &buNaturalRotCollection, &buNaturalTimeCollecton,0}, /* metric */ @@ -134,6 +139,8 @@ static struct bUnitCollection *bUnitSystems[][8] = { {0,0,0,0,0,0,0,0} }; + + /* internal, has some option not exposed */ static bUnitCollection *unit_get_system(int system, int type) { @@ -458,7 +465,7 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre bUnitCollection *usys_iter; int system_iter; - for(system_iter= 0; system_iter<UNIT_SYSTEM_MAX; system_iter++) { + for(system_iter= 0; system_iter<UNIT_SYSTEM_TOT; system_iter++) { if (system_iter != system) { usys_iter= unit_get_system(system_iter, type); if (usys_iter) { @@ -543,6 +550,49 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre return change; } +/* 45µm --> 45um */ +void bUnit_ToUnitAltName(char *str, int len_max, char *orig_str, int system, int type) +{ + bUnitCollection *usys = unit_get_system(system, type); + + bUnitDef *unit; + bUnitDef *unit_def= unit_default(usys); + + /* find and substitute all units */ + for(unit= usys->units; unit->name; unit++) { + if(len_max > 0 && (unit->name_alt || unit == unit_def)) + { + char *found= NULL; + + found= unit_find_str(orig_str, unit->name_short); + if(found) { + int offset= found - orig_str; + int len_name= 0; + + /* copy everything before the unit */ + offset= (offset<len_max? offset: len_max); + strncpy(str, orig_str, offset); + + str+= offset; + orig_str+= offset + strlen(unit->name_short); + len_max-= offset; + + /* print the alt_name */ + if(unit->name_alt) + len_name= snprintf(str, len_max, "%s", unit->name_alt); + else + len_name= 0; + + len_name= (len_name<len_max? len_name: len_max); + str+= len_name; + len_max-= len_name; + } + } + } + + /* finally copy the rest of the string */ + strncpy(str, orig_str, len_max); +} double bUnit_ClosestScalar(double value, int system, int type) { @@ -566,6 +616,12 @@ double bUnit_BaseScalar(int system, int type) } /* external access */ +int bUnit_IsValid(int system, int type) +{ + return !(type < 0 || type >= B_UNIT_MAXDEF || system < 0 || system > UNIT_SYSTEM_TOT); +} + + void bUnit_GetSystem(void **usys_pt, int *len, int system, int type) { bUnitCollection *usys = unit_get_system(system, type); diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 8ebf98ef930..6cd207f628c 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -515,6 +515,7 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex if (codec_id == CODEC_ID_XVID) { /* arghhhh ... */ c->pix_fmt = PIX_FMT_YUV420P; + c->codec_tag = (('D'<<24) + ('I'<<16) + ('V'<<8) + 'X'); } if (codec_id == CODEC_ID_H264) { diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index a297878ec20..2f40520e59a 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -86,7 +86,10 @@ void linearrgb_to_srgb_rgba_rgba_buf(float *col_to, float *col_from, int tot); int constrain_rgb(float *r, float *g, float *b); void minmax_rgb(short c[3]); - + +void rgb_float_set_hue_float_offset(float * rgb, float hue_offset); +void rgb_byte_set_hue_float_offset(char * rgb, float hue_offset); + /***************** lift/gamma/gain / ASC-CDL conversion *****************/ void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power); diff --git a/source/blender/blenlib/BLI_storage.h b/source/blender/blenlib/BLI_storage.h index 0d9db40fc97..83537e4f3c4 100644 --- a/source/blender/blenlib/BLI_storage.h +++ b/source/blender/blenlib/BLI_storage.h @@ -42,12 +42,13 @@ struct direntry; + void BLI_adddirstrings(void); void BLI_builddir(char *dirname, char *relname); int BLI_compare(struct direntry *entry1, struct direntry *entry2); -int BLI_filesize(int file); -int BLI_filepathsize(const char *path); +size_t BLI_filesize(int file); +size_t BLI_filepathsize(const char *path); double BLI_diskfree(char *dir); char *BLI_getwdN(char *dir); diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 1e0359d1847..0ef2346ded4 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -39,11 +39,12 @@ SET(INC ${ZLIB_INC} ) +# unused +LIST(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/intern/BLI_bfile.c") + + IF(CMAKE_SYSTEM_NAME MATCHES "Linux") -SET(INC - ${INC} - ${BINRELOC_INC} -) + LIST(APPEND INC "${BINRELOC_INC}") ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") IF(WIN32) @@ -51,7 +52,7 @@ IF(WIN32) ENDIF(WIN32) IF(WITH_OPENMP) - ADD_DEFINITIONS(-DPARALLEL=1) + ADD_DEFINITIONS(-DPARALLEL=1) ENDIF(WITH_OPENMP) BLENDERLIB(bf_blenlib "${SRC}" "${INC}") diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index d1a8de14181..cf7eb873409 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -633,7 +633,7 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char if (S_ISREG(status.st_mode)) { /* is file */ if (strncmp(filename, de->d_name, FILE_MAX)==0) { /* name matches */ /* open the file to read its size */ - size = BLI_filepathsize(path); + size = status.st_size; if ((size > 0) && (size > *filesize)) { /* find the biggest file */ *filesize = size; BLI_strncpy(filename_new, path, FILE_MAX); diff --git a/source/blender/blenlib/intern/dynlib.c b/source/blender/blenlib/intern/dynlib.c index f42b342e326..55d6ce7a241 100644 --- a/source/blender/blenlib/intern/dynlib.c +++ b/source/blender/blenlib/intern/dynlib.c @@ -87,7 +87,7 @@ char *PIL_dynlib_get_error_as_string(PILdynlib* lib) { return buf; } - return err; + return NULL; } void PIL_dynlib_close(PILdynlib *lib) { diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index fde770c238c..06b427240ba 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -41,12 +41,12 @@ #ifdef WIN32 #include <io.h> #include "BLI_winstuff.h" +#include "BLI_callbacks.h" #else #include <unistd.h> // for read close #include <sys/param.h> #endif - #include "BLI_blenlib.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 693fd885b50..787e126a42b 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -464,3 +464,28 @@ void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *o } } +/* ******************************************** other ************************************************* */ + +/* Applies an hue offset to a float rgb color */ +void rgb_float_set_hue_float_offset(float rgb[3], float hue_offset) +{ + float hsv[3]; + + rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); + + hsv[0]+= hue_offset; + if(hsv[0]>1.0) hsv[0]-=1.0; + else if(hsv[0]<0.0) hsv[0]+= 1.0; + + hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); +} + +/* Applies an hue offset to a byte rgb color */ +void rgb_byte_set_hue_float_offset(char rgb[3], float hue_offset) +{ + float rgb_float[3]; + + rgb_byte_to_float(rgb, rgb_float); + rgb_float_set_hue_float_offset(rgb_float, hue_offset); + rgb_float_to_byte(rgb_float, rgb); +} diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 64c3e746982..3b5ffa2d442 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -998,7 +998,7 @@ void rotate_m4(float mat[][4], const char axis, const float angle) void blend_m3_m3m3(float out[][3], float dst[][3], float src[][3], float srcweight) { float squat[4], dquat[4], fquat[4]; - float ssize[3], dsize[3], fsize[4]; + float ssize[3], dsize[3], fsize[3]; float rmat[3][3], smat[3][3]; mat3_to_quat(dquat,dst); @@ -1020,7 +1020,7 @@ void blend_m3_m3m3(float out[][3], float dst[][3], float src[][3], float srcweig void blend_m4_m4m4(float out[][4], float dst[][4], float src[][4], float srcweight) { float squat[4], dquat[4], fquat[4]; - float ssize[3], dsize[3], fsize[4]; + float ssize[3], dsize[3], fsize[3]; float sloc[3], dloc[3], floc[3]; mat4_to_quat(dquat,dst); diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index cf773d575e5..50c5095afe7 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -311,10 +311,17 @@ void BLI_cleanup_file(const char *relabase, char *dir) dir[0]= '/'; dir[1]= 0; return; - } + } + + /* support for odd paths: eg /../home/me --> /home/me + * this is a valid path in blender but we cant handle this the useual way below + * simply strip this prefix then evaluate the path as useual. pythons os.path.normpath() does this */ + while((strncmp(dir, "/../", 4)==0)) { + memmove( dir, dir + 4, strlen(dir + 4) + 1 ); + } while ( (start = strstr(dir, "/../")) ) { - eind = start + strlen("/../") - 1; + eind = start + (4 - 1) /* strlen("/../") - 1 */; a = start-dir-1; while (a>0) { if (dir[a] == '/') break; @@ -328,12 +335,12 @@ void BLI_cleanup_file(const char *relabase, char *dir) } while ( (start = strstr(dir,"/./")) ){ - eind = start + strlen("/./") - 1; + eind = start + (3 - 1) /* strlen("/./") - 1 */; memmove( start, eind, strlen(eind)+1 ); } while ( (start = strstr(dir,"//" )) ){ - eind = start + strlen("//") - 1; + eind = start + (2 - 1) /* strlen("//") - 1 */; memmove( start, eind, strlen(eind)+1 ); } diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 80310b1ef8a..9c31557619b 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -421,7 +421,7 @@ unsigned int BLI_getdir(char *dirname, struct direntry **filelist) } -int BLI_filesize(int file) +size_t BLI_filesize(int file) { struct stat buf; @@ -430,11 +430,11 @@ int BLI_filesize(int file) return (buf.st_size); } -int BLI_filepathsize(const char *path) +size_t BLI_filepathsize(const char *path) { int size, file = open(path, O_BINARY|O_RDONLY); - if (file < 0) + if (file == -1) return -1; size = BLI_filesize(file); diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 81a635205f9..b3438590321 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -33,7 +33,7 @@ #include <stdlib.h> #include <stdio.h> - +#include "MEM_guardedalloc.h" #include "BLI_path_util.h" #include "BLI_string.h" #define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index da441214b37..b637d538b91 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -28,6 +28,7 @@ * .blend file reading entry point */ +#include <stddef.h> #include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include <stdlib.h> diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a03634e0625..46caab94ce7 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -10836,6 +10836,15 @@ static void do_versions(FileData *fd, Library *lib, Main *main) SEQ_END } + /* particle brush strength factor was changed from int to float */ + for(sce= main->scene.first; sce; sce=sce->id.next) { + ParticleEditSettings *pset= &sce->toolsettings->particle; + int a; + + for(a=0; a<PE_TOT_BRUSH; a++) + pset->brush[a].strength /= 100.0; + } + for(ma = main->mat.first; ma; ma=ma->id.next) if(ma->mode & MA_TRACEBLE) ma->shade_flag |= MA_APPROX_OCCLUSION; @@ -11247,6 +11256,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + { + ParticleSettings *part; + for(part = main->particle.first; part; part = part->id.next) { + if(part->boids) + part->boids->pitch = 1.0f; + } + } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index b9201a6cdfa..9fdc07f391b 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -1640,13 +1640,13 @@ public: if (ma->spec_shader == MA_SPEC_BLINN) { ep.setShaderType(COLLADASW::EffectProfile::BLINN); // shininess - ep.setShininess(ma->spec); + ep.setShininess(ma->har); } else if (ma->spec_shader == MA_SPEC_PHONG) { ep.setShaderType(COLLADASW::EffectProfile::PHONG); // shininess // XXX not sure, stolen this from previous Collada plugin - ep.setShininess(ma->har / 4); + ep.setShininess(ma->har); } else { // XXX write warning "Current shader type is not supported" @@ -1663,17 +1663,19 @@ public: COLLADASW::ColorOrTexture cot; // transparency - // Tod: because we are in A_ONE mode transparency is calculated like this: - ep.setTransparency(1.0f); - cot = getcol(0.0f, 0.0f, 0.0f, ma->alpha); - ep.setTransparent(cot); + if (ma->mode & MA_TRANSP) { + // Tod: because we are in A_ONE mode transparency is calculated like this: + ep.setTransparency(ma->alpha); + // cot = getcol(1.0f, 1.0f, 1.0f, 1.0f); + // ep.setTransparent(cot); + } // emission cot=getcol(ma->emit, ma->emit, ma->emit, 1.0f); ep.setEmission(cot); - // diffuse - cot = getcol(ma->r, ma->g, ma->b, 1.0f); + // diffuse multiplied by diffuse intensity + cot = getcol(ma->r * ma->ref, ma->g * ma->ref, ma->b * ma->ref, 1.0f); ep.setDiffuse(cot); // ambient @@ -1686,15 +1688,15 @@ public: ep.setReflective(cot); ep.setReflectivity(ma->ray_mirror); } - else { - cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f); - ep.setReflective(cot); - ep.setReflectivity(ma->spec); - } + // else { + // cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f); + // ep.setReflective(cot); + // ep.setReflectivity(ma->spec); + // } // specular if (ep.getShaderType() != COLLADASW::EffectProfile::LAMBERT) { - cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f); + cot = getcol(ma->specr * ma->spec, ma->specg * ma->spec, ma->specb * ma->spec, 1.0f); ep.setSpecular(cot); } @@ -1720,12 +1722,15 @@ public: // create only one <sampler>/<surface> pair for each unique image if (im_samp_map.find(key) == im_samp_map.end()) { - //<newparam> <surface> <init_from> - // COLLADASW::Surface surface(COLLADASW::Surface::SURFACE_TYPE_2D, -// key + COLLADASW::Surface::SURFACE_SID_SUFFIX); -// COLLADASW::SurfaceInitOption sio(COLLADASW::SurfaceInitOption::INIT_FROM); -// sio.setImageReference(key); -// surface.setInitOption(sio); + // //<newparam> <surface> <init_from> + // COLLADASW::Surface surface(COLLADASW::Surface::SURFACE_TYPE_2D, + // key + COLLADASW::Surface::SURFACE_SID_SUFFIX); + // COLLADASW::SurfaceInitOption sio(COLLADASW::SurfaceInitOption::INIT_FROM); + // sio.setImageReference(key); + // surface.setInitOption(sio); + + // COLLADASW::NewParamSurface surface(mSW); + // surface->setParamType(COLLADASW::CSW_SURFACE_TYPE_2D); //<newparam> <sampler> <source> COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D, diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 09fbdf2d70d..3fb8e441d6f 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -83,11 +83,6 @@ } -/* 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) */ @@ -115,7 +110,7 @@ static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, floa /* 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); + uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); } @@ -405,7 +400,7 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi * - special hack: make the top a bit higher, since we are first... */ uiSetRoundBox((1|8)); - gl_round_box(GL_POLYGON, 0, yminc-2, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); + uiDrawBox(GL_POLYGON, 0, yminc-2, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); } /* name for summary entries */ @@ -755,7 +750,7 @@ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc /* 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); + uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); } /* name for group entries */ diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 6bda6b5069c..f2bc4b3d46a 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -178,18 +178,37 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone eBone->flag = curBone->flag; /* fix selection flags */ + if (eBone->flag & BONE_SELECTED) { + /* if the bone is selected the copy its root selection to the parents tip */ eBone->flag |= BONE_TIPSEL; - if (eBone->parent && (eBone->flag & BONE_CONNECTED)) + if (eBone->parent && (eBone->flag & BONE_CONNECTED)) { eBone->parent->flag |= BONE_TIPSEL; - else + eBone->flag &= ~BONE_ROOTSEL; /* this is ignored when there is a connected parent, so unset it */ + } + else { eBone->flag |= BONE_ROOTSEL; + } } - else - eBone->flag &= ~BONE_ROOTSEL; - - VECCOPY(eBone->head, curBone->arm_head); - VECCOPY(eBone->tail, curBone->arm_tail); + else { + /* if the bone is not selected, but connected to its parent + * copy the parents tip selection state */ + if(eBone->parent && (eBone->flag & BONE_CONNECTED)) { + /* selecting with the mouse gives this behavior */ + if(eBone->parent->flag & BONE_TIPSEL) { + eBone->flag |= BONE_ROOTSEL; + } + else { + eBone->flag &= ~BONE_ROOTSEL; + } + + /* probably not selected but just incase */ + eBone->flag &= ~BONE_TIPSEL; + } + } + + copy_v3_v3(eBone->head, curBone->arm_head); + copy_v3_v3(eBone->tail, curBone->arm_tail); eBone->roll= 0.0f; @@ -570,8 +589,8 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) curbone= editbone_name_exists(arm->edbo, pchan->name); /* simply copy the head/tail values from pchan over to curbone */ - VECCOPY(curbone->head, pchan->pose_head); - VECCOPY(curbone->tail, pchan->pose_tail); + copy_v3_v3(curbone->head, pchan->pose_head); + copy_v3_v3(curbone->tail, pchan->pose_tail); /* fix roll: * 1. find auto-calculated roll value for this bone now @@ -2056,7 +2075,7 @@ float ED_rollBoneToVector(EditBone *bone, float new_up_axis[3]) sub_v3_v3v3(nor, bone->tail, bone->head); vec_roll_to_mat3(nor, 0, mat); - VECCOPY(up_axis, mat[2]); + copy_v3_v3(up_axis, mat[2]); roll = angle_normalized_v3v3(new_up_axis, up_axis); @@ -2083,12 +2102,12 @@ static void auto_align_ebone_zaxisup(Scene *scene, View3D *v3d, EditBone *ebone) vec_roll_to_mat3(delta, 0.0f, curmat); /* Make new matrix based on y axis & z-up */ - VECCOPY(yaxis, curmat[1]); + copy_v3_v3(yaxis, curmat[1]); unit_m3(targetmat); - VECCOPY(targetmat[0], xaxis); - VECCOPY(targetmat[1], yaxis); - VECCOPY(targetmat[2], zaxis); + copy_v3_v3(targetmat[0], xaxis); + copy_v3_v3(targetmat[1], yaxis); + copy_v3_v3(targetmat[2], zaxis); normalize_m3(targetmat); /* Find the difference between the two matrices */ @@ -2111,7 +2130,7 @@ void auto_align_ebone_topoint(EditBone *ebone, float *cursor) sub_v3_v3v3(delta, ebone->tail, ebone->head); vec_roll_to_mat3(delta, ebone->roll, curmat); copy_m4_m3(mat, curmat); - VECCOPY(mat[3], ebone->head); + copy_v3_v3(mat[3], ebone->head); /* multiply bone-matrix by object matrix (so that bone-matrix is in WorldSpace) */ invert_m4_m4(imat, mat); @@ -2416,19 +2435,19 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *op) arm->act_edbone= newbone; if (to_root) { - VECCOPY(newbone->head, ebone->head); + copy_v3_v3(newbone->head, ebone->head); newbone->rad_head= ebone->rad_tail; newbone->parent= ebone->parent; } else { - VECCOPY(newbone->head, ebone->tail); + copy_v3_v3(newbone->head, ebone->tail); newbone->rad_head= ebone->rad_tail; newbone->parent= ebone; newbone->flag |= BONE_CONNECTED; } curs= give_cursor(scene, v3d); - VECCOPY(newbone->tail, curs); + copy_v3_v3(newbone->tail, curs); sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]); if (a==1) @@ -2472,7 +2491,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e fp= give_cursor(scene, v3d); - VECCOPY(oldcurs, fp); + copy_v3_v3(oldcurs, fp); mx= event->x - ar->winrct.xmin; my= event->y - ar->winrct.ymin; @@ -2502,7 +2521,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e retv= armature_click_extrude_exec(C, op); /* restore previous 3d cursor position */ - VECCOPY(fp, oldcurs); + copy_v3_v3(fp, oldcurs); return retv; } @@ -2531,8 +2550,8 @@ static EditBone *add_points_bone (Object *obedit, float head[], float tail[]) ebo= ED_armature_edit_bone_add(obedit->data, "Bone"); - VECCOPY(ebo->head, head); - VECCOPY(ebo->tail, tail); + copy_v3_v3(ebo->head, head); + copy_v3_v3(ebo->tail, tail); return ebo; } @@ -2859,10 +2878,10 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) short found= 0; if (eb_tail) { - VECCOPY(vec, ebo->tail); + copy_v3_v3(vec, ebo->tail); } else { - VECCOPY(vec, ebo->head); + copy_v3_v3(vec, ebo->head); } for (ebp= points->first; ebp; ebp= ebp->next) { @@ -2891,11 +2910,11 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) ebp= MEM_callocN(sizeof(EditBonePoint), "EditBonePoint"); if (eb_tail) { - VECCOPY(ebp->vec, ebo->tail); + copy_v3_v3(ebp->vec, ebo->tail); ebp->tail_owner= ebo; } else { - VECCOPY(ebp->vec, ebo->head); + copy_v3_v3(ebp->vec, ebo->head); ebp->head_owner= ebo; } @@ -3107,8 +3126,8 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone /* step 2a: parent children of in-between bones to newbone */ for (chain= chains->first; chain; chain= chain->next) { /* ick: we need to check if parent of each bone in chain is one of the bones in the */ + short found= 0; for (ebo= chain->data; ebo; ebo= ebo->parent) { - short found= 0; /* try to find which bone from the list to be removed, is the parent */ for (ebone= end; ebone; ebone= ebone->parent) { @@ -3124,6 +3143,9 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone break; } } + if (found) { + break; + } } /* step 2b: parent child of end to newbone (child from this chain) */ @@ -3135,6 +3157,9 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone ebone= (ebo == start) ? (NULL) : (ebo->parent); bone_free(arm, ebo); } + + newbone->flag |= (BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED); + ED_armature_sync_selection(arm->edbo); } @@ -5688,7 +5713,7 @@ void transform_armature_mirror_update(Object *obedit) /* Also move connected children, in case children's name aren't mirrored properly */ for (children=arm->edbo->first; children; children=children->next) { if (children->parent == eboflip && children->flag & BONE_CONNECTED) { - VECCOPY(children->head, eboflip->tail); + copy_v3_v3(children->head, eboflip->tail); children->rad_head = ebo->rad_tail; } } @@ -5703,7 +5728,7 @@ void transform_armature_mirror_update(Object *obedit) if (eboflip->parent && eboflip->flag & BONE_CONNECTED) { EditBone *parent = eboflip->parent; - VECCOPY(parent->tail, eboflip->head); + copy_v3_v3(parent->tail, eboflip->head); parent->rad_tail = ebo->rad_head; } } @@ -5744,7 +5769,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode parent = ED_armature_edit_bone_add(arm, "Bone"); parent->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; - VECCOPY(parent->head, head->p); + copy_v3_v3(parent->head, head->p); root = parent; @@ -5769,17 +5794,17 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode if (len1 > 0.0f && len2 > 0.0f && dot_v3v3(vec1, vec2) < angleLimit) { - VECCOPY(parent->tail, previous); + copy_v3_v3(parent->tail, previous); child = ED_armature_edit_bone_add(arm, "Bone"); - VECCOPY(child->head, parent->tail); + copy_v3_v3(child->head, parent->tail); child->parent = parent; child->flag |= BONE_CONNECTED|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; parent = child; /* new child is next parent */ } } - VECCOPY(parent->tail, tail->p); + copy_v3_v3(parent->tail, tail->p); /* If the bone wasn't subdivided, delete it and return NULL * to let subsequent subdivision methods do their thing. @@ -5898,7 +5923,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) obedit= scene->basact->object; /* Copy orientation from source */ - VECCOPY(dst->loc, src->obmat[3]); + copy_v3_v3(dst->loc, src->obmat[3]); mat4_to_eul( dst->rot,src->obmat); mat4_to_size( dst->size,src->obmat); @@ -5980,8 +6005,8 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) bone = ED_armature_edit_bone_add(obedit->data, "Bone"); bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; - VECCOPY(bone->head, head->p); - VECCOPY(bone->tail, tail->p); + copy_v3_v3(bone->head, head->p); + copy_v3_v3(bone->tail, tail->p); /* set first and last bone, since there's only one */ lastBone = bone; diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 3bbbb271bda..b8c945f0d77 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -157,7 +157,7 @@ static short pose_has_protected_selected(Object *ob, short only_selected, short } /* only for real IK, not for auto-IK */ -int ED_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan) +static int pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level) { bConstraint *con; Bone *bone; @@ -167,18 +167,25 @@ int ED_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan) for(con= pchan->constraints.first; con; con= con->next) { if(con->type==CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data= con->data; - if((data->flag & CONSTRAINT_IK_AUTO)==0) - return 1; + if(data->rootbone == 0 || data->rootbone > level) { + if((data->flag & CONSTRAINT_IK_AUTO)==0) + return 1; + } } } for(bone= pchan->bone->childbase.first; bone; bone= bone->next) { pchan= get_pose_channel(ob->pose, bone->name); - if(pchan && ED_pose_channel_in_IK_chain(ob, pchan)) + if(pchan && pose_channel_in_IK_chain(ob, pchan, level + 1)) return 1; } return 0; } +int ED_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan) +{ + return pose_channel_in_IK_chain(ob, pchan, 0); +} + /* ********************************************** */ /* Motion Paths */ diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 52db36e188d..5df04435abe 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -78,12 +78,12 @@ typedef struct EditBone short segments; } EditBone; -#define BONESEL_ROOT 0x10000000 -#define BONESEL_TIP 0x20000000 -#define BONESEL_BONE 0x40000000 +#define BONESEL_ROOT (1<<28) +#define BONESEL_TIP (1<<29) +#define BONESEL_BONE (1<<30) #define BONESEL_ANY (BONESEL_TIP|BONESEL_ROOT|BONESEL_BONE) -#define BONESEL_NOSEL 0x80000000 /* Indicates a negative number */ +#define BONESEL_NOSEL (1<<31) /* Indicates a negative number */ /* useful macros */ #define EBONE_VISIBLE(arm, ebone) ((arm->layer & ebone->layer) && !(ebone->flag & BONE_HIDDEN_A)) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 40985a918d4..7d56698f7b9 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -146,15 +146,16 @@ typedef struct uiLayout uiLayout; #define UI_BUT_ANIMATED (1<<20) #define UI_BUT_ANIMATED_KEY (1<<21) #define UI_BUT_DRIVEN (1<<22) -#define UI_BUT_INACTIVE (1<<23) -#define UI_BUT_LAST_ACTIVE (1<<24) -#define UI_BUT_UNDO (1<<25) -#define UI_BUT_IMMEDIATE (1<<26) -#define UI_BUT_NO_TOOLTIP (1<<27) -#define UI_BUT_NO_UTF8 (1<<28) +#define UI_BUT_REDALERT (1<<23) +#define UI_BUT_INACTIVE (1<<24) +#define UI_BUT_LAST_ACTIVE (1<<25) +#define UI_BUT_UNDO (1<<26) +#define UI_BUT_IMMEDIATE (1<<27) +#define UI_BUT_NO_TOOLTIP (1<<28) +#define UI_BUT_NO_UTF8 (1<<29) -#define UI_BUT_VEC_SIZE_LOCK (1<<29) /* used to flag if color hsv-circle should keep luminance */ -#define UI_BUT_COLOR_CUBIC (1<<30) /* cubic saturation for the color wheel */ +#define UI_BUT_VEC_SIZE_LOCK (1<<30) /* used to flag if color hsv-circle should keep luminance */ +#define UI_BUT_COLOR_CUBIC (1<<31) /* cubic saturation for the color wheel */ #define UI_PANEL_WIDTH 340 #define UI_COMPACT_PANEL_WIDTH 160 @@ -250,6 +251,9 @@ int uiGetRoundBox(void); void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad); void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction); void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy); +void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float rad); +void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown); +void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight); /* state for scrolldrawing */ #define UI_SCROLL_PRESSED 1 diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 021dcc940e6..f6ba948db7d 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1234,11 +1234,13 @@ int ui_is_but_unit(uiBut *but) if(but->rnaprop==NULL) return 0; - + unit_type = RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop)); - + +#if 0 // removed so angle buttons get correct snapping if (scene->unit.flag & USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION) return 0; +#endif /* for now disable time unit conversion */ if (unit_type == PROP_UNIT_TIME) @@ -1443,6 +1445,23 @@ static double ui_get_but_scale_unit(uiBut *but, double value) } } +/* str will be overwritten */ +void ui_convert_to_unit_alt_name(uiBut *but, char *str, int maxlen) +{ + if(ui_is_but_unit(but)) { + int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + char *orig_str; + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + + orig_str= MEM_callocN(sizeof(char)*maxlen + 1, "textedit sub str"); + memcpy(orig_str, str, maxlen); + + bUnit_ToUnitAltName(str, maxlen, orig_str, scene->unit.system, unit_type); + + MEM_freeN(orig_str); + } +} + 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); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 2a9a1335b1f..cf6970dc59f 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -48,6 +48,7 @@ #include "UI_interface.h" +/* own include */ #include "interface_intern.h" #define UI_RB_ALPHA 16 @@ -76,7 +77,7 @@ int uiGetRoundBox(void) return roundboxtype; } -void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad) +void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float rad) { float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293}, {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; @@ -146,7 +147,7 @@ static void round_box_shade_col(float *col1, float *col2, float fac) /* linear horizontal shade within button or in outline */ /* view2d scrollers use it */ -void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown) +void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown) { float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293}, {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; @@ -253,7 +254,7 @@ void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy /* linear vertical shade within button or in outline */ /* view2d scrollers use it */ -void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight) +void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight) { float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293}, {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; @@ -371,7 +372,7 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad) glEnable( GL_LINE_SMOOTH ); glEnable( GL_BLEND ); - gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad); + uiDrawBox(GL_LINE_LOOP, minx, miny, maxx, maxy, rad); glDisable( GL_BLEND ); glDisable( GL_LINE_SMOOTH ); @@ -397,7 +398,7 @@ void uiRoundRectFakeAA(float minx, float miny, float maxx, float maxy, float rad /* draw lots of lines on top of each other */ for (i=passes; i>=(-passes); i--) { - gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad+(i*raddiff)); + uiDrawBox(GL_LINE_LOOP, minx, miny, maxx, maxy, rad+(i*raddiff)); } glDisable( GL_BLEND ); @@ -419,13 +420,13 @@ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad) } /* solid part */ - gl_round_box(GL_POLYGON, minx, miny, maxx, maxy, rad); + uiDrawBox(GL_POLYGON, minx, miny, maxx, maxy, rad); /* set antialias line */ glEnable( GL_LINE_SMOOTH ); glEnable( GL_BLEND ); - gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad); + uiDrawBox(GL_LINE_LOOP, minx, miny, maxx, maxy, rad); glDisable( GL_BLEND ); glDisable( GL_LINE_SMOOTH ); @@ -710,7 +711,7 @@ static void draw_scope_end(rctf *rect, GLint *scissor) /* outline */ glColor4f(0.f, 0.f, 0.f, 0.5f); uiSetRoundBox(15); - gl_round_box(GL_LINE_LOOP, rect->xmin-1, rect->ymin, rect->xmax+1, rect->ymax+1, 3.0f); + uiDrawBox(GL_LINE_LOOP, rect->xmin-1, rect->ymin, rect->xmax+1, rect->ymax+1, 3.0f); } void histogram_draw_one(float r, float g, float b, float alpha, float x, float y, float w, float h, float *data, int res) @@ -771,7 +772,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti * glColor4f(0.f, 0.f, 0.f, 0.3f); uiSetRoundBox(15); - gl_round_box(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); + uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); glColor4f(1.f, 1.f, 1.f, 0.08f); /* draw grid lines here */ @@ -840,7 +841,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *r glColor4f(0.f, 0.f, 0.f, 0.3f); uiSetRoundBox(15); - gl_round_box(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); + uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); /* need scissor test, waveform can draw outside of boundary */ @@ -1051,7 +1052,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti glColor4f(0.f, 0.f, 0.f, 0.3f); uiSetRoundBox(15); - gl_round_box(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); + uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); /* need scissor test, hvectorscope can draw outside of boundary */ glGetIntegerv(GL_VIEWPORT, scissor); @@ -1237,7 +1238,7 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect) /* backdrop */ glColor3ubv((unsigned char*)wcol->inner); uiSetRoundBox(15); - gl_round_box(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f); + uiDrawBox(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f); /* sphere color */ glMaterialfv(GL_FRONT, GL_DIFFUSE, diffn); @@ -1584,13 +1585,13 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, int select) glColor4ub(0, 0, 0, alpha); alpha+= 2; - gl_round_box(GL_POLYGON, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax-10.0f + a, rad+a); + uiDrawBox(GL_POLYGON, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax-10.0f + a, rad+a); } /* outline emphasis */ glEnable( GL_LINE_SMOOTH ); glColor4ub(0, 0, 0, 100); - gl_round_box(GL_LINE_LOOP, rct->xmin-0.5f, rct->ymin-0.5f, rct->xmax+0.5f, rct->ymax+0.5f, radius); + uiDrawBox(GL_LINE_LOOP, rct->xmin-0.5f, rct->ymin-0.5f, rct->xmax+0.5f, rct->ymax+0.5f, radius); glDisable( GL_LINE_SMOOTH ); glDisable(GL_BLEND); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 484c78cd831..fea152bb4a7 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -44,6 +44,7 @@ #include "BKE_idprop.h" #include "BKE_report.h" #include "BKE_texture.h" +#include "BKE_unit.h" #include "ED_screen.h" #include "ED_util.h" @@ -1555,7 +1556,8 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) int i; for(i=0; data->str[i]; i++) { if(!isascii(data->str[i])) { - data->str[i]= '\0'; + /* no stripping actually: just convert to alt name */ + ui_convert_to_unit_alt_name(but, data->str, data->maxlen); break; } } @@ -2194,26 +2196,47 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE } /* var names match ui_numedit_but_NUM */ -static float ui_numedit_apply_snapf(float tempf, float softmin, float softmax, float softrange, int snap) +static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, float softmax, float softrange, int snap) { - if(tempf==softmin || tempf==softmax) - return tempf; + if(tempf==softmin || tempf==softmax || snap==0) { + /* pass */ + } + else { + float fac= 1.0f; + + if(ui_is_but_unit(but)) { + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + int unit_type = RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + + if(bUnit_IsValid(scene->unit.system, unit_type)) { + fac= (float)bUnit_BaseScalar(scene->unit.system, unit_type); + if(ELEM3(unit_type, B_UNIT_LENGTH, B_UNIT_AREA, B_UNIT_VOLUME)) { + fac /= scene->unit.scale_length; + } + } + } - switch(snap) { - case 0: - break; - case 1: - if(tempf==softmin || tempf==softmax) { } - else if(softrange < 2.10) tempf= 0.1*floor(10*tempf); - else if(softrange < 21.0) tempf= floor(tempf); - else tempf= 10.0*floor(tempf/10.0); - break; - case 2: - if(tempf==softmin || tempf==softmax) { } - else if(softrange < 2.10) tempf= 0.01*floor(100.0*tempf); - else if(softrange < 21.0) tempf= 0.1*floor(10.0*tempf); - else tempf= floor(tempf); - break; + if(fac != 1.0f) { + /* snap in unit-space */ + tempf /= fac; + softmin /= fac; + softmax /= fac; + softrange /= fac; + } + + if(snap==1) { + if(softrange < 2.10) tempf= 0.1*floor(10*tempf); + else if(softrange < 21.0) tempf= floor(tempf); + else tempf= 10.0*floor(tempf/10.0); + } + else if(snap==2) { + if(softrange < 2.10) tempf= 0.01*floor(100.0*tempf); + else if(softrange < 21.0) tempf= 0.1*floor(10.0*tempf); + else tempf= floor(tempf); + } + + if(fac != 1.0f) + tempf *= fac; } return tempf; @@ -2266,7 +2289,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i if(ui_is_but_float(but)) { fac *= 0.01*but->a1; tempf = data->startvalue + ((mx - data->dragstartx) * fac); - tempf= ui_numedit_apply_snapf(tempf, softmin, softmax, softrange, snap); + tempf= ui_numedit_apply_snapf(but, tempf, softmin, softmax, softrange, snap); #if 1 /* fake moving the click start, nicer for dragging back after passing the limit */ if(tempf < softmin) { @@ -2359,7 +2382,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i } else { temp= 0; - tempf= ui_numedit_apply_snapf(tempf, softmin, softmax, softrange, snap); + tempf= ui_numedit_apply_snapf(but, tempf, softmin, softmax, softrange, snap); CLAMP(tempf, softmin, softmax); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 84d6605651b..d5f6b089544 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -356,6 +356,7 @@ extern void ui_set_but_vectorf(uiBut *but, float *vec); extern void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my); extern void ui_get_but_string(uiBut *but, char *str, int maxlen); +extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, int maxlen); extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str); extern int ui_get_but_string_max_length(uiBut *but); @@ -440,10 +441,6 @@ extern void ui_draw_aligned_panel(struct ARegion *ar, struct uiStyle *style, uiB /* interface_draw.c */ extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select); -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); -extern void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight); - void ui_draw_gradient(rcti *rect, float *rgb, int type, float alpha); void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index c5f0913e35d..08ce130a300 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1437,6 +1437,11 @@ static void widget_state(uiWidgetType *wt, int state) wt->wcol.inner[2]= wt->wcol.inner[2]>=240? 255 : wt->wcol.inner[2]+15; } } + + if(state & UI_BUT_REDALERT) { + char red[4]= {255, 0, 0}; + widget_state_blend(wt->wcol.inner, red, 0.4f); + } } /* sliders use special hack which sets 'item' as inner when drawing filling */ diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index e6ba228c260..ff2fad3f551 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1526,6 +1526,11 @@ static int mesh_separate_exec(bContext *C, wmOperator *op) if(retval) { WM_event_add_notifier(C, NC_GEOM|ND_DATA, base->object->data); + + // XXX: new object was created, but selection wasn't actually changed + // need this for outliner update without adding new ND. nazgul. + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + return OPERATOR_FINISHED; } return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index de4a931e069..baf71cb21d6 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -805,6 +805,8 @@ static int constraint_delete_exec (bContext *C, wmOperator *op) /* there's no active constraint now, so make sure this is the case */ constraints_set_active(lb, NULL); + ED_object_constraint_update(ob); /* needed to set the flags on posebones correctly */ + /* notifiers */ WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 87b20ab1c41..132533fc123 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3573,7 +3573,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event) RNA_collection_add(op->ptr, "stroke", &itemptr); RNA_float_set_array(&itemptr, "mouse", mouse); - RNA_boolean_set(&itemptr, "flip", event->shift != 0); // XXX hardcoded + RNA_boolean_set(&itemptr, "pen_flip", event->shift != 0); // XXX hardcoded /* apply */ brush_edit_apply(C, op, &itemptr); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 90f9d5683c2..07d1e47f74e 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1095,13 +1095,6 @@ void ED_area_prevspace(bContext *C, ScrArea *sa) { SpaceLink *sl = (sa) ? sa->spacedata.first : CTX_wm_space_data(C); - /* Special handling of filebrowser to stop background thread for - thumbnail creation - don't want to waste cpu resources if not showing - the filebrowser */ - if (sl->spacetype == SPACE_FILE) { - ED_fileselect_exit(C, (SpaceFile*)sl); - } - if(sl->next) { /* workaround for case of double prevspace, render window with a file browser on top of it */ diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 2aceabcea76..1ca8bff3193 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1090,6 +1090,10 @@ void ED_area_exit(bContext *C, ScrArea *sa) ScrArea *prevsa= CTX_wm_area(C); ARegion *ar; + if (sa->spacetype == SPACE_FILE) { + ED_fileselect_exit(C, (SpaceFile*)(sa) ? sa->spacedata.first : CTX_wm_space_data(C)); + } + CTX_wm_area_set(C, sa); for(ar= sa->regionbase.first; ar; ar= ar->next) ED_region_exit(C, ar); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index ffe61b3e4d6..0c92d6bbc6a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1415,13 +1415,17 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) ED_region_toggle_hidden(C, rmd->ar); } else { + int maxsize=0; delta= event->y - rmd->origy; if(rmd->edge=='b') delta= -delta; rmd->ar->sizey= rmd->origval + delta; CLAMP(rmd->ar->sizey, 0, rmd->maxsize); - if(rmd->ar->sizey < 24) { + if(rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) + maxsize = rmd->maxsize - ((rmd->sa->headertype==2)?48:24) - 10; + + if(rmd->ar->sizey < 24 || (maxsize > 0 && (rmd->ar->sizey > maxsize)) ) { rmd->ar->sizey= rmd->origval; if(!(rmd->ar->flag & RGN_FLAG_HIDDEN)) ED_region_toggle_hidden(C, rmd->ar); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 418bac69974..e7a06f27f67 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -4534,29 +4534,8 @@ static void paint_redraw(bContext *C, ImagePaintState *s, int final) if(s->image) GPU_free_image(s->image); + /* compositor listener deals with updating */ WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, s->image); - - // XXX node update -#if 0 - if(!s->sima && s->image) { - /* after paint, tag Image or RenderResult nodes changed */ - if(s->scene->nodetree) { - imagepaint_composite_tags(s->scene->nodetree, image, &s->sima->iuser); - } - /* signal composite (hurmf, need an allqueue?) */ - if(s->sima->lock) { - ScrArea *sa; - for(sa=s->screen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_NODE) { - if(((SpaceNode *)sa->spacedata.first)->treetype==NTREE_COMPOSIT) { - addqueue(sa->win, UI_BUT_EVENT, B_NODE_TREE_EXEC); - break; - } - } - } - } - } -#endif } else { if(!s->sima || !s->sima->lock) @@ -5156,11 +5135,40 @@ static int sample_color_invoke(bContext *C, wmOperator *op, wmEvent *event) ARegion *ar= CTX_wm_region(C); int location[2]; - location[0]= event->x - ar->winrct.xmin; - location[1]= event->y - ar->winrct.ymin; - RNA_int_set_array(op->ptr, "location", location); + if(ar) { + location[0]= event->x - ar->winrct.xmin; + location[1]= event->y - ar->winrct.ymin; + RNA_int_set_array(op->ptr, "location", location); - return sample_color_exec(C, op); + sample_color_exec(C, op); + } + + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +static int sample_color_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + ARegion *ar= CTX_wm_region(C); + int location[2]; + + switch(event->type) { + case LEFTMOUSE: + case RIGHTMOUSE: // XXX hardcoded + return OPERATOR_FINISHED; + case MOUSEMOVE: + if(ar) { + location[0]= event->x - ar->winrct.xmin; + location[1]= event->y - ar->winrct.ymin; + RNA_int_set_array(op->ptr, "location", location); + + sample_color_exec(C, op); + } + break; + } + + return OPERATOR_RUNNING_MODAL; } void PAINT_OT_sample_color(wmOperatorType *ot) @@ -5172,6 +5180,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot) /* api callbacks */ ot->exec= sample_color_exec; ot->invoke= sample_color_invoke; + ot->modal= sample_color_modal; ot->poll= image_paint_poll; /* flags */ @@ -5515,6 +5524,13 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) if(h > maxsize) h= maxsize; ibuf= ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect); + if(!ibuf) { + /* Mostly happens when OpenGL offscreen buffer was failed to create, */ + /* but could be other reasons. Should be handled in the future. nazgul */ + BKE_report(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer."); + return OPERATOR_CANCELLED; + } + image= BKE_add_image_imbuf(ibuf); if(image) { diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 5f435aa0cbe..0f627bda3dc 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -172,6 +172,10 @@ void file_draw_buttons(const bContext *C, ARegion *ar) /* Text input fields for directory and file. */ if (available_w > 0) { + int overwrite_alert= file_draw_check_exists(sfile); + /* callbacks for operator check functions */ + uiBlockSetFunc(block, file_draw_check_cb, NULL, NULL); + but = uiDefBut(block, TEX, B_FS_DIRNAME, "", min_x, line1_y, line1_w-chan_offs, btn_h, params->dir, 0.0, (float)FILE_MAX-1, 0, 0, @@ -182,9 +186,17 @@ void file_draw_buttons(const bContext *C, ARegion *ar) but = uiDefBut(block, TEX, B_FS_FILENAME, "", min_x, line2_y, line2_w-chan_offs, btn_h, params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, - "File name."); + overwrite_alert ?"File name, overwrite existing." : "File name."); uiButSetCompleteFunc(but, autocomplete_file, NULL); uiButSetFlag(but, UI_BUT_NO_UTF8); + + /* check if this overrides a file and if the operator option is used */ + if(overwrite_alert) { + uiButSetFlag(but, UI_BUT_REDALERT); + } + + /* clear func */ + uiBlockSetFunc(block, NULL, NULL, NULL); } /* Filename number increment / decrement buttons. */ diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index c77379b39a0..07a24454520 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -46,6 +46,9 @@ void file_calc_previews(const bContext *C, ARegion *ar); void file_draw_previews(const bContext *C, ARegion *ar); void file_draw_list(const bContext *C, ARegion *ar); +void file_draw_check_cb(bContext *C, void *arg1, void *arg2); +int file_draw_check_exists(SpaceFile *sfile); + /* file_ops.h */ struct wmOperatorType; struct wmOperator; @@ -84,6 +87,9 @@ int file_delete_exec(bContext *C, struct wmOperator *unused); int file_hilight_set(struct SpaceFile *sfile, struct ARegion *ar, int mx, int my); +void file_sfile_to_operator(struct wmOperator *op, struct SpaceFile *sfile, char *filepath); +void file_operator_to_sfile(struct SpaceFile *sfile, struct wmOperator *op); + /* filesel.c */ float file_string_width(const char* str); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 2a50b505c57..7888fdeef8a 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -206,7 +206,11 @@ static FileSelect file_select(bContext* C, const rcti* rect, short selecting, sh } } - } + } + + /* update operator for name change event */ + file_draw_check_cb(C, NULL, NULL); + return retval; } @@ -503,18 +507,11 @@ void FILE_OT_highlight(struct wmOperatorType *ot) int file_cancel_exec(bContext *C, wmOperator *unused) { SpaceFile *sfile= CTX_wm_space_file(C); - - folderlist_free(sfile->folders_prev); - folderlist_free(sfile->folders_next); - - WM_event_fileselect_event(C, sfile->op, EVT_FILESELECT_CANCEL); - sfile->op = NULL; + wmOperator *op = sfile->op; - if (sfile->files) { - ED_fileselect_clear(C, sfile); - MEM_freeN(sfile->files); - sfile->files= NULL; - } + sfile->op = NULL; + + WM_event_fileselect_event(C, op, EVT_FILESELECT_CANCEL); return OPERATOR_FINISHED; } @@ -541,6 +538,118 @@ void FILE_OT_cancel(struct wmOperatorType *ot) ot->poll= file_operator_poll; } + +void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) +{ + BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file); + if(RNA_struct_find_property(op->ptr, "relative_path")) { + if(RNA_boolean_get(op->ptr, "relative_path")) { + BLI_path_rel(filepath, G.sce); + } + } + + if(RNA_struct_find_property(op->ptr, "filename")) { + RNA_string_set(op->ptr, "filename", sfile->params->file); + } + if(RNA_struct_find_property(op->ptr, "directory")) { + RNA_string_set(op->ptr, "directory", sfile->params->dir); + } + if(RNA_struct_find_property(op->ptr, "filepath")) { + RNA_string_set(op->ptr, "filepath", filepath); + } + + /* some ops have multiple files to select */ + { + PointerRNA itemptr; + int i, numfiles = filelist_numfiles(sfile->files); + struct direntry *file; + if(RNA_struct_find_property(op->ptr, "files")) { + for (i=0; i<numfiles; i++) { + file = filelist_file(sfile->files, i); + if(file->flags & ACTIVEFILE) { + if ((file->type & S_IFDIR)==0) { + RNA_collection_add(op->ptr, "files", &itemptr); + RNA_string_set(&itemptr, "name", file->relname); + } + } + } + } + + if(RNA_struct_find_property(op->ptr, "dirs")) { + for (i=0; i<numfiles; i++) { + file = filelist_file(sfile->files, i); + if(file->flags & ACTIVEFILE) { + if ((file->type & S_IFDIR)) { + RNA_collection_add(op->ptr, "dirs", &itemptr); + RNA_string_set(&itemptr, "name", file->relname); + } + } + } + } + } +} + +void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) +{ + int change= FALSE; + if(RNA_struct_find_property(op->ptr, "filename")) { + RNA_string_get(op->ptr, "filename", sfile->params->file); + change= TRUE; + } + if(RNA_struct_find_property(op->ptr, "directory")) { + RNA_string_get(op->ptr, "directory", sfile->params->dir); + change= TRUE; + } + + /* If neither of the above are set, split the filepath back */ + if(RNA_struct_find_property(op->ptr, "filepath")) { + if(change==FALSE) { + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file); + } + } + + /* XXX, files and dirs updates missing, not really so important though */ +} + +void file_draw_check_cb(bContext *C, void *dummy1, void *dummy2) +{ + SpaceFile *sfile= CTX_wm_space_file(C); + wmOperator *op= sfile->op; + if(op) { /* fail on reload */ + if(op->type->check) { + char filepath[FILE_MAX]; + file_sfile_to_operator(op, sfile, filepath); + + /* redraw */ + if(op->type->check(C, op)) { + file_operator_to_sfile(sfile, op); + + /* redraw, else the changed settings wont get updated */ + ED_area_tag_redraw(CTX_wm_area(C)); + } + } + } +} + +int file_draw_check_exists(SpaceFile *sfile) +{ + if(sfile->op) { /* fails on reload */ + if(RNA_struct_find_property(sfile->op->ptr, "check_existing")) { + if(RNA_boolean_get(sfile->op->ptr, "check_existing")) { + char filepath[FILE_MAX]; + BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file); + if(BLI_exists(filepath) && !BLI_is_dir(filepath)) { + return TRUE; + } + } + } + } + + return FALSE; +} + /* sends events now, so things get handled on windowqueue level */ int file_exec(bContext *C, wmOperator *exec_op) { @@ -568,64 +677,13 @@ int file_exec(bContext *C, wmOperator *exec_op) sfile->op = NULL; - BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file); - if(RNA_struct_find_property(op->ptr, "relative_path")) { - if(RNA_boolean_get(op->ptr, "relative_path")) { - BLI_path_rel(filepath, G.sce); - } - } - - if(RNA_struct_find_property(op->ptr, "filename")) { - RNA_string_set(op->ptr, "filename", sfile->params->file); - } - if(RNA_struct_find_property(op->ptr, "directory")) { - RNA_string_set(op->ptr, "directory", sfile->params->dir); - } - if(RNA_struct_find_property(op->ptr, "filepath")) { - RNA_string_set(op->ptr, "filepath", filepath); - } - - /* some ops have multiple files to select */ - { - PointerRNA itemptr; - int i, numfiles = filelist_numfiles(sfile->files); - struct direntry *file; - if(RNA_struct_find_property(op->ptr, "files")) { - for (i=0; i<numfiles; i++) { - file = filelist_file(sfile->files, i); - if(file->flags & ACTIVEFILE) { - if ((file->type & S_IFDIR)==0) { - RNA_collection_add(op->ptr, "files", &itemptr); - RNA_string_set(&itemptr, "name", file->relname); - } - } - } - } - - if(RNA_struct_find_property(op->ptr, "dirs")) { - for (i=0; i<numfiles; i++) { - file = filelist_file(sfile->files, i); - if(file->flags & ACTIVEFILE) { - if ((file->type & S_IFDIR)) { - RNA_collection_add(op->ptr, "dirs", &itemptr); - RNA_string_set(&itemptr, "name", file->relname); - } - } - } - } - } - - folderlist_free(sfile->folders_prev); - folderlist_free(sfile->folders_next); + file_sfile_to_operator(op, sfile, filepath); fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir,0, 1); BLI_make_file_string(G.sce, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu_get(), filepath); WM_event_fileselect_event(C, op, EVT_FILESELECT_EXEC); - ED_fileselect_clear(C, sfile); - MEM_freeN(sfile->files); - sfile->files= NULL; } return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index 4a505bc022f..33d740e18a6 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -170,7 +170,9 @@ static void file_panel_operator(const bContext *C, Panel *pa) SpaceFile *sfile= CTX_wm_space_file(C); wmOperator *op= sfile->op; int empty= 1, flag; - + + uiBlockSetFunc(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL); + if(op->type->ui) { op->layout= pa->layout; op->type->ui((bContext*)C, op); @@ -197,6 +199,8 @@ static void file_panel_operator(const bContext *C, Panel *pa) if(empty) uiItemL(pa->layout, "No properties.", 0); } + + uiBlockSetFunc(uiLayoutGetBlock(pa->layout), NULL, NULL, NULL); } void file_panels_register(ARegionType *art) diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 52d59270663..e2099be6f03 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -531,5 +531,18 @@ void ED_fileselect_clear(struct bContext *C, struct SpaceFile *sfile) void ED_fileselect_exit(struct bContext *C, struct SpaceFile *sfile) { - thumbnails_stop(sfile->files, C); + if(!sfile) return; + if(sfile->op) + WM_event_fileselect_event(C, sfile->op, EVT_FILESELECT_EXTERNAL_CANCEL); + sfile->op = NULL; + + folderlist_free(sfile->folders_prev); + folderlist_free(sfile->folders_next); + + if (sfile->files) { + ED_fileselect_clear(C, sfile); + MEM_freeN(sfile->files); + sfile->files= NULL; + } + } diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 8211257da02..a043fc8cfd1 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -280,13 +280,10 @@ void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename) void fsmenu_read_system(struct FSMenu* fsmenu) { char line[256]; - FILE *fp; - #ifdef WIN32 /* Add the drive names to the listing */ { __int64 tmp; - char folder[256]; char tmps[4]; int i; @@ -304,10 +301,10 @@ void fsmenu_read_system(struct FSMenu* fsmenu) } /* Adding Desktop and My Documents */ - SHGetSpecialFolderPath(0, folder, CSIDL_PERSONAL, 0); - fsmenu_insert_entry(fsmenu,FS_CATEGORY_BOOKMARKS, folder, 1, 0); - SHGetSpecialFolderPath(0, folder, CSIDL_DESKTOPDIRECTORY, 0); - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, folder, 1, 0); + SHGetSpecialFolderPath(0, line, CSIDL_PERSONAL, 0); + fsmenu_insert_entry(fsmenu,FS_CATEGORY_BOOKMARKS, line, 1, 0); + SHGetSpecialFolderPath(0, line, CSIDL_DESKTOPDIRECTORY, 0); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); } #else #ifdef __APPLE__ @@ -474,6 +471,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu) /* loop over mount points */ struct mntent *mnt; int len; + FILE *fp; fp = setmntent (MOUNTED, "r"); if (fp == NULL) { diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 11b39af2e03..5a7e2e6fa1b 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -960,6 +960,18 @@ static int save_as_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } + +static int save_as_check(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + if(BKE_add_image_extension(filepath, RNA_enum_get(op->ptr, "file_type"))) { + RNA_string_set(op->ptr, "filepath", filepath); + return TRUE; + } + return FALSE; +} + static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *event) { SpaceImage *sima= CTX_wm_space_image(C); @@ -1022,6 +1034,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot) /* api callbacks */ ot->exec= save_as_exec; + ot->check= save_as_check; ot->invoke= save_as_invoke; ot->poll= space_image_buffer_exists_poll; diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index fc869c4b46f..a728cc900c2 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -309,7 +309,7 @@ static void nla_panel_properties(const bContext *C, Panel *pa) /* settings */ column= uiLayoutColumn(layout, 1); - uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); + uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); uiItemL(column, "Playback Settings:", 0); uiItemR(column, &strip_ptr, "mute", 0, NULL, 0); uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, 0); diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index f489fc4774f..ef9c46c8042 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -64,9 +64,6 @@ #include "nla_intern.h" // own include -/* 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); /* *********************************************** */ /* Strips */ @@ -347,7 +344,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr /* draw 'inside' of strip itself */ glColor3fv(color); uiSetRoundBox(15); /* all corners rounded */ - gl_round_box_shade(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1); + uiDrawBoxShade(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1); /* draw strip's control 'curves' @@ -373,7 +370,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr setlinestyle(4); /* draw outline */ - gl_round_box_shade(GL_LINE_LOOP, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1); + uiDrawBoxShade(GL_LINE_LOOP, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1); /* if action-clip strip, draw lines delimiting repeats too (in the same color as outline) */ if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQ(strip->repeat, 1.0f)==0) { @@ -708,7 +705,7 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie /* 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); + uiDrawBox(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; diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index cc7c966e397..0b33196c646 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -67,7 +67,6 @@ // XXX interface.h extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select); -extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); extern void ui_draw_tria_icon(float x, float y, char dir); void ED_node_changed_update(ID *id, bNode *node) @@ -749,7 +748,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN glEnable(GL_BLEND); glColor4ub(200, 200, 200, 140); uiSetRoundBox(15-4); - gl_round_box(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD); + uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD); glDisable(GL_BLEND); } @@ -857,7 +856,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b if(node->flag & NODE_ACTIVE) { glEnable(GL_BLEND); glColor4ub(200, 200, 200, 140); - gl_round_box(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); + uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); glDisable(GL_BLEND); } @@ -1009,18 +1008,18 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN glEnable(GL_BLEND); uiSetRoundBox(3); UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); - gl_round_box(GL_POLYGON, rect.xmin, rect.ymax, rect.xmax, rect.ymax+NODE_DY, BASIS_RAD); + uiDrawBox(GL_POLYGON, rect.xmin, rect.ymax, rect.xmax, rect.ymax+NODE_DY, BASIS_RAD); /* backdrop body */ UI_ThemeColorShadeAlpha(TH_BACK, -8, -70); uiSetRoundBox(12); - gl_round_box(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, BASIS_RAD); + uiDrawBox(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, BASIS_RAD); /* selection outline */ uiSetRoundBox(15); glColor4ub(200, 200, 200, 140); glEnable( GL_LINE_SMOOTH ); - gl_round_box(GL_LINE_LOOP, rect.xmin, rect.ymin, rect.xmax, rect.ymax+NODE_DY, BASIS_RAD); + uiDrawBox(GL_LINE_LOOP, rect.xmin, rect.ymin, rect.xmax, rect.ymax+NODE_DY, BASIS_RAD); glDisable( GL_LINE_SMOOTH ); glDisable(GL_BLEND); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 829c74fd26d..5aa512ea904 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1919,33 +1919,6 @@ void NODE_OT_read_fullsamplelayers(wmOperatorType *ot) } -/* ************************* */ - -void imagepaint_composite_tags(bNodeTree *ntree, Image *image, ImageUser *iuser) -{ - bNode *node; - - if(ntree==NULL) - return; - - /* search for renderresults */ - if(image->type==IMA_TYPE_R_RESULT) { - for(node= ntree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS && node->id==NULL) { - /* imageuser comes from ImageWin, so indexes are offset 1 */ - if(node->custom1==iuser->layer-1) - NodeTagChanged(ntree, node); - } - } - } - else { - for(node= ntree->nodes.first; node; node= node->next) { - if(node->id== &image->id) - NodeTagChanged(ntree, node); - } - } -} - /* ****************** Make Group operator ******************* */ static int node_group_make_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index d9a4dda9d6e..c94fcb52e38 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -42,6 +42,7 @@ #include "BKE_context.h" #include "BKE_screen.h" +#include "BKE_node.h" #include "ED_render.h" #include "ED_screen.h" @@ -158,7 +159,10 @@ static void node_init(struct wmWindowManager *wm, ScrArea *sa) static void node_area_listener(ScrArea *sa, wmNotifier *wmn) { - + /* note, ED_area_tag_refresh will re-execute compositor */ + /* XXX, should edit some to check for the nodeTree type, especially NC_NODE|NA_EDITED which refreshes all types */ + SpaceNode *snode= sa->spacedata.first; + /* preview renders */ switch(wmn->category) { case NC_SCENE: @@ -200,6 +204,20 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) if (wmn->action == NA_EDITED) ED_area_tag_refresh(sa); break; + + case NC_IMAGE: + if (wmn->action == NA_EDITED) { + if(snode->treetype==NTREE_COMPOSIT) { + Scene *scene= wmn->window->screen->scene; + + /* note that NodeTagIDChanged is alredy called by BKE_image_signal() on all + * scenes so really this is just to know if the images is used in the compo else + * painting on images could become very slow when the compositor is open. */ + if(NodeTagIDChanged(scene->nodetree, wmn->reference)) + ED_area_tag_refresh(sa); + } + } + break; } } diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index d3db64d6d03..1a46c32713e 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -120,6 +120,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; } + break; case NC_GROUP: /* all actions now, todo: check outliner view mode? */ ED_region_tag_redraw(ar); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index afd8895edd9..7c6fd83c6aa 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -63,6 +63,7 @@ /* own include */ #include "sequencer_intern.h" + #define SEQ_LEFTHANDLE 1 #define SEQ_RIGHTHANDLE 2 @@ -75,19 +76,21 @@ static void draw_shadedstrip(Sequence *seq, char *col, float x1, float y1, float static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col) { char blendcol[3]; - float hsv[3], rgb[3]; SolidColorVars *colvars = (SolidColorVars *)seq->effectdata; switch(seq->type) { case SEQ_IMAGE: UI_GetThemeColor3ubv(TH_SEQ_IMAGE, col); break; + case SEQ_META: UI_GetThemeColor3ubv(TH_SEQ_META, col); break; + case SEQ_MOVIE: UI_GetThemeColor3ubv(TH_SEQ_MOVIE, col); break; + case SEQ_SCENE: UI_GetThemeColor3ubv(TH_SEQ_SCENE, col); @@ -95,24 +98,17 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col) UI_GetColorPtrBlendShade3ubv(col, col, col, 1.0, 20); } break; - + /* transitions */ case SEQ_CROSS: case SEQ_GAMCROSS: case SEQ_WIPE: - /* slightly offset hue to distinguish different effects */ UI_GetThemeColor3ubv(TH_SEQ_TRANSITION, col); - - rgb[0] = col[0]/255.0; rgb[1] = col[1]/255.0; rgb[2] = col[2]/255.0; - rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); - - if (seq->type == SEQ_CROSS) hsv[0]+= 0.04; - if (seq->type == SEQ_GAMCROSS) hsv[0]+= 0.08; - if (seq->type == SEQ_WIPE) hsv[0]+= 0.12; - - if(hsv[0]>1.0) hsv[0]-=1.0; else if(hsv[0]<0.0) hsv[0]+= 1.0; - hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); - col[0] = (char)(rgb[0]*255); col[1] = (char)(rgb[1]*255); col[2] = (char)(rgb[2]*255); + + /* slightly offset hue to distinguish different effects */ + if (seq->type == SEQ_CROSS) rgb_byte_set_hue_float_offset(col,0.04); + if (seq->type == SEQ_GAMCROSS) rgb_byte_set_hue_float_offset(col,0.08); + if (seq->type == SEQ_WIPE) rgb_byte_set_hue_float_offset(col,0.12); break; /* effects */ @@ -126,42 +122,37 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col) case SEQ_OVERDROP: case SEQ_GLOW: case SEQ_MULTICAM: - /* slightly offset hue to distinguish different effects */ UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col); - rgb[0] = col[0]/255.0; rgb[1] = col[1]/255.0; rgb[2] = col[2]/255.0; - rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); - - if (seq->type == SEQ_ADD) hsv[0]+= 0.04; - if (seq->type == SEQ_SUB) hsv[0]+= 0.08; - if (seq->type == SEQ_MUL) hsv[0]+= 0.12; - if (seq->type == SEQ_ALPHAOVER) hsv[0]+= 0.16; - if (seq->type == SEQ_ALPHAUNDER) hsv[0]+= 0.20; - if (seq->type == SEQ_OVERDROP) hsv[0]+= 0.24; - if (seq->type == SEQ_GLOW) hsv[0]+= 0.28; - if (seq->type == SEQ_TRANSFORM) hsv[0]+= 0.36; - - if(hsv[0]>1.0) hsv[0]-=1.0; else if(hsv[0]<0.0) hsv[0]+= 1.0; - hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); - col[0] = (char)(rgb[0]*255); col[1] = (char)(rgb[1]*255); col[2] = (char)(rgb[2]*255); + /* slightly offset hue to distinguish different effects */ + if (seq->type == SEQ_ADD) rgb_byte_set_hue_float_offset(col,0.04); + if (seq->type == SEQ_SUB) rgb_byte_set_hue_float_offset(col,0.08); + if (seq->type == SEQ_MUL) rgb_byte_set_hue_float_offset(col,0.12); + if (seq->type == SEQ_ALPHAOVER) rgb_byte_set_hue_float_offset(col,0.16); + if (seq->type == SEQ_ALPHAUNDER) rgb_byte_set_hue_float_offset(col,0.20); + if (seq->type == SEQ_OVERDROP) rgb_byte_set_hue_float_offset(col,0.24); + if (seq->type == SEQ_GLOW) rgb_byte_set_hue_float_offset(col,0.28); + if (seq->type == SEQ_TRANSFORM) rgb_byte_set_hue_float_offset(col,0.36); break; + case SEQ_COLOR: if (colvars->col) { - col[0]= (char)(colvars->col[0]*255); - col[1]= (char)(colvars->col[1]*255); - col[2]= (char)(colvars->col[2]*255); + rgb_float_to_byte(colvars->col, col); } else { col[0] = col[1] = col[2] = 128; } break; + case SEQ_PLUGIN: UI_GetThemeColor3ubv(TH_SEQ_PLUGIN, col); break; + 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); break; + default: col[0] = 10; col[1] = 255; col[2] = 40; } @@ -597,8 +588,6 @@ so wave file sample drawing precision is zoom adjusted */ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence *seq, int outline_tint, float pixelx) { - // XXX - extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown); View2D *v2d= &ar->v2d; float x1, x2, y1, y2; char col[3], background_col[3], is_single_image; @@ -655,7 +644,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence * glLineStipple(1, 0x8888); } - gl_round_box_shade(GL_LINE_LOOP, x1, y1, x2, y2, 0.0, 0.1, 0.0); + uiDrawBoxShade(GL_LINE_LOOP, x1, y1, x2, y2, 0.0, 0.1, 0.0); if (seq->flag & SEQ_MUTE) { glDisable(GL_LINE_STIPPLE); @@ -694,7 +683,6 @@ void set_special_seq_update(int val) void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs) { - extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); struct Main *bmain= CTX_data_main(C); struct ImBuf *ibuf = 0; struct ImBuf *scope = 0; @@ -855,7 +843,7 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); uiSetRoundBox(15); - gl_round_box(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); + uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 2f3abd3ba0c..de9c063f069 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -396,6 +396,7 @@ static void time_listener(ScrArea *sa, wmNotifier *wmn) switch (wmn->category) { case NC_OBJECT: switch (wmn->data) { + case ND_BONE_ACTIVE: case ND_POINTCACHE: ED_area_tag_refresh(sa); ED_area_tag_redraw(sa); diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index adff6ffdc65..c6aa4656191 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -310,7 +310,7 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize) if(displist==0) { displist= glGenLists(1); - glNewList(displist, GL_COMPILE_AND_EXECUTE); + glNewList(displist, GL_COMPILE); glBegin(GL_QUADS); n[0]= -1.0; @@ -340,19 +340,17 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize) glEndList(); } - else glCallList(displist); - + + glCallList(displist); } static void drawcube_size(float xsize, float ysize, float zsize) { static GLuint displist=0; - glScalef(xsize, ysize, zsize); - if(displist == 0) { displist= glGenLists(1); - glNewList(displist, GL_COMPILE_AND_EXECUTE); + glNewList(displist, GL_COMPILE); glBegin(GL_LINE_STRIP); glVertex3fv(cube[0]); glVertex3fv(cube[1]);glVertex3fv(cube[2]); glVertex3fv(cube[3]); @@ -368,7 +366,9 @@ static void drawcube_size(float xsize, float ysize, float zsize) glEndList(); } - else glCallList(displist); + + glScalef(xsize, ysize, zsize); + glCallList(displist); } @@ -381,7 +381,7 @@ static void draw_bonevert(void) GLUquadricObj *qobj; displist= glGenLists(1); - glNewList(displist, GL_COMPILE_AND_EXECUTE); + glNewList(displist, GL_COMPILE); glPushMatrix(); @@ -400,8 +400,8 @@ static void draw_bonevert(void) glPopMatrix(); glEndList(); } - else - glCallList(displist); + + glCallList(displist); } static void draw_bonevert_solid(void) @@ -412,7 +412,7 @@ static void draw_bonevert_solid(void) GLUquadricObj *qobj; displist= glGenLists(1); - glNewList(displist, GL_COMPILE_AND_EXECUTE); + glNewList(displist, GL_COMPILE); qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_FILL); @@ -423,8 +423,8 @@ static void draw_bonevert_solid(void) glEndList(); } - else - glCallList(displist); + + glCallList(displist); } static void draw_bone_octahedral() @@ -435,7 +435,7 @@ static void draw_bone_octahedral() float vec[6][3]; displist= glGenLists(1); - glNewList(displist, GL_COMPILE_AND_EXECUTE); + glNewList(displist, GL_COMPILE); vec[0][0]= vec[0][1]= vec[0][2]= 0.0f; vec[5][0]= vec[5][2]= 0.0f; vec[5][1]= 1.0f; @@ -467,8 +467,8 @@ static void draw_bone_octahedral() glEndList(); } - else - glCallList(displist); + + glCallList(displist); } static void draw_bone_solid_octahedral(void) @@ -479,7 +479,7 @@ static void draw_bone_solid_octahedral(void) float vec[6][3], nor[3]; displist= glGenLists(1); - glNewList(displist, GL_COMPILE_AND_EXECUTE); + glNewList(displist, GL_COMPILE); vec[0][0]= vec[0][1]= vec[0][2]= 0.0f; vec[5][0]= vec[5][2]= 0.0f; vec[5][1]= 1.0f; @@ -529,8 +529,8 @@ static void draw_bone_solid_octahedral(void) glEndList(); } - else - glCallList(displist); + + glCallList(displist); } /* *************** Armature drawing, bones ******************* */ @@ -655,6 +655,26 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], int boneflag mul_mat3_m4_v3(smat, dirvec); /* clear zcomp */ dirvec[2]= 0.0f; + + if(head != tail) { + /* correcyion when viewing along the bones axis + * it pops in and out but better then artifacts, [#23841] */ + float view_dist= len_v2(dirvec); + + if(head - view_dist > tail) { + tailvec= headvec; + tail = head; + zero_v3(dirvec); + dirvec[0]= 0.00001; // XXX. weak but ok + } + else if(tail - view_dist > head) { + headvec= tailvec; + head = tail; + zero_v3(dirvec); + dirvec[0]= 0.00001; // XXX. weak but ok + } + } + /* move vector back */ mul_mat3_m4_v3(imat, dirvec); @@ -1933,7 +1953,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - for (eBone=arm->edbo->first, index=0; eBone; eBone=eBone->next, index++) { + for (eBone=arm->edbo->first; eBone; eBone=eBone->next) { if (eBone->layer & arm->layer) { if ((eBone->flag & (BONE_HIDDEN_A|BONE_NO_DEFORM))==0) { if (eBone->flag & (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL)) @@ -1949,7 +1969,6 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) /* if solid we draw it first */ if ((dt > OB_WIRE) && (arm->drawtype!=ARM_LINE)) { - index= 0; for (eBone=arm->edbo->first, index=0; eBone; eBone=eBone->next, index++) { if (eBone->layer & arm->layer) { if ((eBone->flag & BONE_HIDDEN_A)==0) { @@ -2043,6 +2062,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) } /* restore */ + if(index!=-1) glLoadName(-1); if (arm->drawtype==ARM_LINE); else if (dt>OB_WIRE) bglPolygonOffset(rv3d->dist, 0.0f); @@ -2054,7 +2074,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - for (eBone=arm->edbo->first, index=0; eBone; eBone=eBone->next, index++) { + for (eBone=arm->edbo->first; eBone; eBone=eBone->next) { if(eBone->layer & arm->layer) { if ((eBone->flag & BONE_HIDDEN_A)==0) { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 17516f6a40c..fa394ff708a 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -974,7 +974,6 @@ static void drawviewborder_flymode(ARegion *ar) static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) { - extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); // interface_panel.c float fac, a; float x1, x2, y1, y2; float x1i, x2i, y1i, y2i; @@ -1061,7 +1060,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); uiSetRoundBox(15); - gl_round_box(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); + uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); } setlinestyle(0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 966fac1a3bd..cc1d26b136e 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -630,6 +630,7 @@ static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short m EditBone *ebone; float vec[3]; short sco1[2], sco2[2], didpoint; + int change= FALSE; /* set editdata in vc */ @@ -645,20 +646,27 @@ static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short m if(select) ebone->flag |= BONE_ROOTSEL; else ebone->flag &= ~BONE_ROOTSEL; didpoint= 1; + change= TRUE; } if(lasso_inside(mcords, moves, sco2[0], sco2[1])) { if(select) ebone->flag |= BONE_TIPSEL; else ebone->flag &= ~BONE_TIPSEL; didpoint= 1; + change= TRUE; } /* if one of points selected, we skip the bone itself */ if(didpoint==0 && lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) { if(select) ebone->flag |= BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED; else ebone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + change= TRUE; } } - ED_armature_sync_selection(arm->edbo); - ED_armature_validate_active(arm); + + if(change) { + ED_armature_sync_selection(arm->edbo); + ED_armature_validate_active(arm); + WM_main_add_notifier(NC_OBJECT|ND_BONE_SELECT, vc->obedit); + } } static void do_lasso_select_facemode(ViewContext *vc, short mcords[][2], short moves, short select) @@ -1593,6 +1601,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) } ED_armature_sync_selection(arm->edbo); + WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit); } else if(obedit->type==OB_LATTICE) { do_lattice_box_select(&vc, &rect, selecting, extend); @@ -1985,6 +1994,7 @@ static void armature_circle_select(ViewContext *vc, int selecting, short *mval, struct {ViewContext *vc; short select, mval[2]; float radius; } data; bArmature *arm= vc->obedit->data; EditBone *ebone; + int change= FALSE; /* set vc->edit data */ data.select = selecting; @@ -2023,10 +2033,14 @@ static void armature_circle_select(ViewContext *vc, int selecting, short *mval, ebone->flag |= BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED; else ebone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + change= TRUE; } } - ED_armature_validate_active(arm); + if(change) { + ED_armature_validate_active(arm); + WM_main_add_notifier(NC_OBJECT|ND_BONE_SELECT, vc->obedit); + } } /** Callbacks for circle selection in Editmode */ diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index b2d6fe4ea34..0187a3b3567 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -752,7 +752,7 @@ void TRANSFORM_OT_transform(struct wmOperatorType *ot) {TFM_PUSHPULL, "PUSHPULL", 0, "Pushpull", ""}, {TFM_CREASE, "CREASE", 0, "Crease", ""}, {TFM_MIRROR, "MIRROR", 0, "Mirror", ""}, - {TFM_BONESIZE, "BONESIZE", 0, "Bonesize", ""}, + {TFM_BONESIZE, "BONE_SIZE", 0, "Bonesize", ""}, {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""}, {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""}, {TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""}, diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h index 0f0703486a3..0f4fea89c37 100644 --- a/source/blender/ikplugin/BIK_api.h +++ b/source/blender/ikplugin/BIK_api.h @@ -73,7 +73,6 @@ int BIK_get_solver_param(struct bPose *pose, struct bPoseChannel *pchan, int id, // number of solver available // 0 = iksolver // 1 = iTaSC -#define BIK_SOLVER_COUNT 2 /* for use in BIK_get_constraint_param */ #define BIK_PARAM_CONSTRAINT_ERROR 0 diff --git a/source/blender/ikplugin/CMakeLists.txt b/source/blender/ikplugin/CMakeLists.txt index ef1f4d450b9..79f33effb87 100644 --- a/source/blender/ikplugin/CMakeLists.txt +++ b/source/blender/ikplugin/CMakeLists.txt @@ -24,12 +24,27 @@ # # ***** END GPL LICENSE BLOCK ***** -FILE(GLOB SRC intern/*.c intern/*.cpp) + +SET(SRC + ./intern/ikplugin_api.c + ./intern/iksolver_plugin.c +) SET(INC - ../../../intern/guardedalloc ../../../intern/iksolver/extern - ../../../intern/itasc ../../../extern/Eigen2 - ../blenlib ../makesdna ../blenkernel ../include ../ikplugin + ../blenlib + ../makesdna + ../blenkernel + ../include + ../ikplugin + ../../../intern/guardedalloc + ../../../intern/iksolver/extern ) +IF(WITH_IK_ITASC) + ADD_DEFINITIONS(-DWITH_IK_ITASC) + LIST(APPEND INC ../../../extern/Eigen2) + LIST(APPEND INC ../../../intern/itasc) + LIST(APPEND SRC ./intern/itasc_plugin.cpp) +ENDIF(WITH_IK_ITASC) + BLENDERLIB(bf_ikplugin "${SRC}" "${INC}") diff --git a/source/blender/ikplugin/SConscript b/source/blender/ikplugin/SConscript index a745a93077a..f60c42f8dc9 100644 --- a/source/blender/ikplugin/SConscript +++ b/source/blender/ikplugin/SConscript @@ -1,9 +1,11 @@ #!/usr/bin/python Import ('env') - +defs = [] sources = env.Glob('intern/*.c') + env.Glob('intern/*.cpp') incs = '#/intern/guardedalloc #/intern/iksolver/extern ../makesdna ../blenlib' incs += ' ../blenkernel ../include ../ikplugin #/intern/itasc #/extern/Eigen2' -env.BlenderLib ( 'bf_ikplugin', sources, Split(incs), [], libtype=['core','player'], priority=[180, 190] ) +defs.append('WITH_IK_ITASC') + +env.BlenderLib ( 'bf_ikplugin', sources, Split(incs), defs, libtype=['core','player'], priority=[180, 190] ) diff --git a/source/blender/ikplugin/intern/Makefile b/source/blender/ikplugin/intern/Makefile index 352ab90df9d..12e2366b28e 100644 --- a/source/blender/ikplugin/intern/Makefile +++ b/source/blender/ikplugin/intern/Makefile @@ -30,6 +30,9 @@ DIR = $(OCGDIR)/blender/ikplugin include nan_compile.mk +CFLAGS += -DWITH_IK_ITASC +CPPFLAGS += -DWITH_IK_ITASC + CFLAGS += $(LEVEL_1_C_WARNINGS) CFLAGS += -I$(NAN_GUARDEDALLOC)/include CFLAGS += -I../../makesdna diff --git a/source/blender/ikplugin/intern/ikplugin_api.c b/source/blender/ikplugin/intern/ikplugin_api.c index cdc4ee11518..c3310e77ad6 100644 --- a/source/blender/ikplugin/intern/ikplugin_api.c +++ b/source/blender/ikplugin/intern/ikplugin_api.c @@ -42,10 +42,12 @@ #include "ikplugin_api.h" #include "iksolver_plugin.h" -#include "itasc_plugin.h" +#ifdef WITH_IK_ITASC +#include "itasc_plugin.h" +#endif -static IKPlugin ikplugin_tab[BIK_SOLVER_COUNT] = { +static IKPlugin ikplugin_tab[] = { /* Legacy IK solver */ { iksolver_initialize_tree, @@ -55,6 +57,7 @@ static IKPlugin ikplugin_tab[BIK_SOLVER_COUNT] = { NULL, NULL, NULL, +#ifdef WITH_IK_ITASC }, /* iTaSC IK solver */ { @@ -65,13 +68,13 @@ static IKPlugin ikplugin_tab[BIK_SOLVER_COUNT] = { itasc_clear_cache, itasc_update_param, itasc_test_constraint, +#endif } }; - static IKPlugin *get_plugin(bPose *pose) { - if (!pose || pose->iksolver < 0 || pose->iksolver >= BIK_SOLVER_COUNT) + if (!pose || pose->iksolver < 0 || pose->iksolver >= (sizeof(ikplugin_tab) / sizeof(IKPlugin))) return NULL; return &ikplugin_tab[pose->iksolver]; @@ -135,3 +138,4 @@ void BIK_test_constraint(struct Object *ob, struct bConstraint *cons) if (plugin && plugin->test_constraint) plugin->test_constraint(ob, cons); } + diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index af69cb9a996..7bdc327afa1 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -32,6 +32,7 @@ #include <vector> // iTaSC headers +#ifdef WITH_IK_ITASC #include "Armature.hpp" #include "MovingFrame.hpp" #include "CopyPose.hpp" @@ -40,6 +41,7 @@ #include "Scene.hpp" #include "Cache.hpp" #include "Distance.hpp" +#endif #include "MEM_guardedalloc.h" diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 07b99dddfa5..c39c5d31f80 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -93,7 +93,7 @@ void IMB_exit(void); * * @attention Defined in readimage.c */ -struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, int size, int flags); +struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags); /** * diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index 9fd4108bee9..8529c72c7ae 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -37,9 +37,9 @@ typedef struct ImFileType { int (*is_a)(unsigned char *buf); int (*ftype)(struct ImFileType *type, struct ImBuf *ibuf); - struct ImBuf *(*load)(unsigned char *mem, int size, int flags); + struct ImBuf *(*load)(unsigned char *mem, size_t size, int flags); int (*save)(struct ImBuf *ibuf, char *name, int flags); - void (*load_tile)(struct ImBuf *ibuf, unsigned char *mem, int size, int tx, int ty, unsigned int *rect); + void (*load_tile)(struct ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect); int flag; int filetype; @@ -60,59 +60,59 @@ void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty); /* png */ int imb_is_a_png(unsigned char *buf); -struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags); +struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags); int imb_savepng(struct ImBuf *ibuf, char *name, int flags); /* targa */ int imb_is_a_targa(unsigned char *buf); -struct ImBuf *imb_loadtarga(unsigned char *mem, int size, int flags); +struct ImBuf *imb_loadtarga(unsigned char *mem, size_t size, int flags); int imb_savetarga(struct ImBuf * ibuf, char *name, int flags); /* iris */ int imb_is_a_iris(unsigned char *mem); -struct ImBuf *imb_loadiris(unsigned char *mem, int size, int flags); +struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags); int imb_saveiris(struct ImBuf * ibuf, char *name, int flags); /* jp2 */ int imb_is_a_jp2(unsigned char *buf); -struct ImBuf *imb_jp2_decode(unsigned char *mem, int size, int flags); +struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags); int imb_savejp2(struct ImBuf *ibuf, char *name, int flags); /* jpeg */ int imb_is_a_jpeg(unsigned char *mem); int imb_savejpeg(struct ImBuf * ibuf, char * name, int flags); struct ImBuf * imb_ibJpegImageFromFilename (const char * filename, int flags); -struct ImBuf * imb_load_jpeg (unsigned char * buffer, int size, int flags); +struct ImBuf * imb_load_jpeg (unsigned char * buffer, size_t size, int flags); /* bmp */ int imb_is_a_bmp(unsigned char *buf); -struct ImBuf *imb_bmp_decode(unsigned char *mem, int size, int flags); +struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags); int imb_savebmp(struct ImBuf *ibuf, char *name, int flags); /* cocoa */ -struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, int size, int flags); +struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, size_t size, int flags); short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags); /* cineon */ int imb_savecineon(struct ImBuf *buf, char *myfil, int flags); -struct ImBuf *imb_loadcineon(unsigned char *mem, int size, int flags); +struct ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags); int imb_is_cineon(unsigned char *buf); /* dpx */ int imb_save_dpx(struct ImBuf *buf, char *myfile, int flags); -struct ImBuf *imb_loaddpx(unsigned char *mem, int size, int flags); +struct ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags); int imb_is_dpx(unsigned char *buf); /* hdr */ int imb_is_a_hdr(unsigned char *buf); -struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags); +struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags); int imb_savehdr(struct ImBuf * ibuf, char *name, int flags); /* tiff */ void imb_inittiff(void); int imb_is_a_tiff(unsigned char *buf); -struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags); -void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, int size, +struct ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags); +void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect); int imb_savetiff(struct ImBuf *ibuf, char *name, int flags); void *libtiff_findsymbol(char *name); diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 3f440c0bf6f..02fc98f2d63 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -32,6 +32,8 @@ /* It's become a bit messy... Basically, only the IMB_ prefixed files * should remain. */ +#include <stddef.h> + #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index bdcf60090c3..450b09c923b 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -101,7 +101,7 @@ int imb_is_a_bmp(unsigned char *buf) { return checkbmp(buf); } -struct ImBuf *imb_bmp_decode(unsigned char *mem, int size, int flags) +struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags) { struct ImBuf *ibuf = 0; BMPINFOHEADER bmi; diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index 9a106253397..2e224893271 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -22,6 +22,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include <stddef.h> #include <dds_api.h> #include <Stream.h> #include <DirectDrawSurface.h> @@ -64,7 +65,7 @@ int imb_is_a_dds(unsigned char *mem) // note: use at most first 32 bytes return(1); } -struct ImBuf *imb_load_dds(unsigned char *mem, int size, int flags) +struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) { struct ImBuf * ibuf = 0; DirectDrawSurface dds(mem, size); /* reads header */ diff --git a/source/blender/imbuf/intern/dds/dds_api.h b/source/blender/imbuf/intern/dds/dds_api.h index 6d9fa0839dd..384570ceb72 100644 --- a/source/blender/imbuf/intern/dds/dds_api.h +++ b/source/blender/imbuf/intern/dds/dds_api.h @@ -31,7 +31,7 @@ extern "C" { int imb_save_dds(struct ImBuf *ibuf, char *name, int flags); int imb_is_a_dds(unsigned char *mem); /* use only first 32 bytes of mem */ -struct ImBuf *imb_load_dds(unsigned char *mem, int size, int flags); +struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags); #ifdef __cplusplus } diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index db2eef759dc..fb5d2f2e4d7 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -22,6 +22,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include <stddef.h> #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "IMB_filetype.h" diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index c676c401ccd..883de823745 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -244,7 +244,7 @@ int imb_is_a_iris(unsigned char *mem) * */ -struct ImBuf *imb_loadiris(unsigned char *mem, int size, int flags) +struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) { unsigned int *base, *lptr = NULL; float *fbase, *fptr = NULL; diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 558eaedf8b2..a70c154014a 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -90,7 +90,7 @@ void info_callback(const char *msg, void *client_data) { -struct ImBuf *imb_jp2_decode(unsigned char *mem, int size, int flags) +struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) { struct ImBuf *ibuf = 0; int use_float = 0; /* for precision higher then 8 use float */ diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 2bae7228220..855c0bf3433 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -58,7 +58,7 @@ static void init_source(j_decompress_ptr cinfo); static boolean fill_input_buffer(j_decompress_ptr cinfo); static void skip_input_data(j_decompress_ptr cinfo, long num_bytes); static void term_source(j_decompress_ptr cinfo); -static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, int size); +static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, size_t size); static boolean handle_app1 (j_decompress_ptr cinfo); static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int flags); @@ -167,7 +167,7 @@ static void term_source(j_decompress_ptr cinfo) { } -static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, int size) +static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, size_t size) { my_src_ptr src; @@ -459,7 +459,7 @@ ImBuf * imb_ibJpegImageFromFilename (const char * filename, int flags) return(ibuf); } -ImBuf * imb_load_jpeg (unsigned char * buffer, int size, int flags) +ImBuf * imb_load_jpeg (unsigned char * buffer, size_t size, int flags) { struct jpeg_decompress_struct _cinfo, *cinfo = &_cinfo; struct my_error_mgr jerr; diff --git a/source/blender/imbuf/intern/module.c b/source/blender/imbuf/intern/module.c index 5438066d164..f291c0de776 100644 --- a/source/blender/imbuf/intern/module.c +++ b/source/blender/imbuf/intern/module.c @@ -22,6 +22,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include <stddef.h> #include "IMB_imbuf.h" #include "IMB_filetype.h" diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 9b68e0e45eb..4107f051d73 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -93,7 +93,7 @@ class Mem_IStream: public IStream { public: - Mem_IStream (unsigned char *exrbuf, int exrsize): + Mem_IStream (unsigned char *exrbuf, size_t exrsize): IStream("dummy"), _exrpos (0), _exrsize(exrsize) { _exrbuf = exrbuf; } virtual bool read (char c[], int n); @@ -943,7 +943,7 @@ static int exr_is_renderresult(InputFile *file) return 0; } -struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags) +struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags) { struct ImBuf *ibuf = NULL; InputFile *file = NULL; diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h index c23b47d1480..c7e4c7d2f57 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.h +++ b/source/blender/imbuf/intern/openexr/openexr_api.h @@ -48,7 +48,7 @@ int imb_is_a_openexr (unsigned char *mem); int imb_save_openexr (struct ImBuf *ibuf, char *name, int flags); -struct ImBuf *imb_load_openexr (unsigned char *mem, int size, int flags); +struct ImBuf *imb_load_openexr (unsigned char *mem, size_t size, int flags); #ifdef __cplusplus } diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 6344b227174..6b21f20b3fb 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -286,7 +286,7 @@ int imb_savepng(struct ImBuf *ibuf, char *name, int flags) return(1); } -struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags) +struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) { struct ImBuf *ibuf = 0; png_structp png_ptr; @@ -317,7 +317,7 @@ struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags) return 0; } - ps.size = size; + ps.size = size; /* XXX, 4gig limit! */ ps.data = mem; ps.seek = 0; diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index c5122ebe46c..4064246c866 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -173,7 +173,7 @@ int imb_is_a_hdr(unsigned char *buf) return 0; } -struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags) +struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags) { struct ImBuf* ibuf; RGBE* sline; diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index 3f4e177c78b..a56007f15f0 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -46,7 +46,7 @@ #include "IMB_imbuf.h" #include "IMB_filetype.h" -ImBuf *IMB_ibImageFromMemory(unsigned char *mem, int size, int flags) +ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags) { ImBuf *ibuf; ImFileType *type; @@ -79,7 +79,7 @@ ImBuf *IMB_loadifffile(int file, int flags) { ImBuf *ibuf; unsigned char *mem; - int size; + size_t size; if(file == -1) return 0; @@ -166,7 +166,7 @@ static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int { ImFileType *type; unsigned char *mem; - int size; + size_t size; if(file == -1) return; diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index b5434b85b5a..ada1f448bfc 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -359,7 +359,7 @@ static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect) } } -static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, int mem_size, int psize) +static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, size_t mem_size, int psize) { unsigned char *mem_end = mem+mem_size; int count, col, size; @@ -470,7 +470,7 @@ partial_load: complete_partial_load(ibuf, rect); } -static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, int mem_size, int psize) +static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, size_t mem_size, int psize) { unsigned char *mem_end = mem+mem_size; int col,size; @@ -527,7 +527,7 @@ partial_load: } -struct ImBuf *imb_loadtarga(unsigned char *mem, int mem_size, int flags) +struct ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) { TARGA tga; struct ImBuf * ibuf; diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 6b94583f17d..5b77c6c7c36 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -262,7 +262,7 @@ static toff_t imb_tiff_SizeProc(thandle_t handle) return (toff_t)(mfile->size); } -static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, unsigned char *mem, int size) +static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, unsigned char *mem, size_t size) { /* open the TIFF client layer interface to the in-memory file */ memFile->mem = mem; @@ -464,7 +464,7 @@ void imb_inittiff(void) * * @return: A newly allocated ImBuf structure if successful, otherwise NULL. */ -ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) +ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags) { TIFF *image = NULL; ImBuf *ibuf = NULL, *hbuf; @@ -573,7 +573,7 @@ ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) return ibuf; } -void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, int size, int tx, int ty, unsigned int *rect) +void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect) { TIFF *image = NULL; uint32 width, height; diff --git a/source/blender/makesdna/DNA_boid_types.h b/source/blender/makesdna/DNA_boid_types.h index 8584b5f99e9..c4324612aff 100644 --- a/source/blender/makesdna/DNA_boid_types.h +++ b/source/blender/makesdna/DNA_boid_types.h @@ -187,8 +187,8 @@ typedef struct BoidState { typedef struct BoidSettings { int options, last_state_id; - float landing_smoothness, rt; - float banking, height; + float landing_smoothness, height; + float banking, pitch; float health, aggression; float strength, accuracy, range; diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index f2abe690218..d42cf625898 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -24,6 +24,8 @@ #include <stdlib.h> +#include "BLI_math.h" + #include "RNA_define.h" #include "rna_internal.h" @@ -37,8 +39,6 @@ #ifdef RNA_RUNTIME -#include "BLI_math.h" - #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_idprop.h" @@ -468,16 +468,18 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) RNA_def_property_ui_text(prop, "Envelope Deform Weight", "Bone deformation weight (for Envelope deform only)"); RNA_def_property_update(prop, 0, "rna_Armature_update_data"); - prop= RNA_def_property(srna, "head_radius", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "head_radius", PROP_FLOAT, PROP_UNSIGNED); if(editbone) RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); RNA_def_property_float_sdna(prop, NULL, "rad_head"); //RNA_def_property_range(prop, 0, 1000); // XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid); + RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Envelope Head Radius", "Radius of head of bone (for Envelope deform only)"); - prop= RNA_def_property(srna, "tail_radius", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "tail_radius", PROP_FLOAT, PROP_UNSIGNED); if(editbone) RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); RNA_def_property_float_sdna(prop, NULL, "rad_tail"); //RNA_def_property_range(prop, 0, 1000); // XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid); + RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Envelope Tail Radius", "Radius of tail of bone (for Envelope deform only)"); /* b-bones deform settings */ @@ -538,6 +540,16 @@ static void rna_def_bone(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_SELECTED); RNA_def_property_ui_text(prop, "Select", ""); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); + + prop= RNA_def_property(srna, "select_head", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_ROOTSEL); + RNA_def_property_ui_text(prop, "Select Head", ""); + RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); + + prop= RNA_def_property(srna, "select_tail", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_TIPSEL); + RNA_def_property_ui_text(prop, "Select Tail", ""); + RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); /* XXX better matrix descriptions possible (Arystan) */ prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); @@ -569,6 +581,8 @@ static void rna_def_bone(BlenderRNA *brna) 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"); + + RNA_api_bone(srna); } static void rna_def_edit_bone(BlenderRNA *brna) @@ -591,8 +605,9 @@ static void rna_def_edit_bone(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Parent", "Parent edit bone (in same Armature)"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - prop= RNA_def_property(srna, "roll", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "roll", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "roll"); + RNA_def_property_ui_range(prop, -M_PI * 2, M_PI * 2, 0.1, 2); RNA_def_property_ui_text(prop, "Roll", "Bone rotation around head-tail axis"); RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); diff --git a/source/blender/makesrna/intern/rna_armature_api.c b/source/blender/makesrna/intern/rna_armature_api.c index cd78bd6e578..4e161e5b22e 100644 --- a/source/blender/makesrna/intern/rna_armature_api.c +++ b/source/blender/makesrna/intern/rna_armature_api.c @@ -36,7 +36,7 @@ #include <stddef.h> #include "BLI_blenlib.h" - +#include "BKE_armature.h" void rna_EditBone_align_roll(EditBone *ebo, float *no) { @@ -48,6 +48,12 @@ void rna_EditBone_align_roll(EditBone *ebo, float *no) } } +float rna_Bone_do_envelope(Bone *bone, float *vec) +{ + float scale = (bone->flag & BONE_MULT_VG_ENV) == BONE_MULT_VG_ENV ? bone->weight : 1.0f; + return distfactor_to_bone(vec, bone->head, bone->tail, bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); +} + #else void RNA_api_armature_edit_bone(StructRNA *srna) @@ -61,4 +67,18 @@ void RNA_api_armature_edit_bone(StructRNA *srna) RNA_def_property_flag(parm, PROP_REQUIRED); } +void RNA_api_bone(StructRNA *srna) +{ + PropertyRNA *parm; + FunctionRNA *func; + + func= RNA_def_function(srna, "evaluate_envelope", "rna_Bone_do_envelope"); + RNA_def_function_ui_description(func, "Calculate bone envelope at given point."); + parm= RNA_def_float_vector_xyz(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "Position in 3d space to evaluate", -FLT_MAX, FLT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return value */ + parm= RNA_def_float(func, "factor", 0, -FLT_MAX, FLT_MAX, "Factor", "Envelope factor", -FLT_MAX, FLT_MAX); + RNA_def_function_return(func, parm); +} + #endif diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c index 3afa135d079..8cd6fcbeff9 100644 --- a/source/blender/makesrna/intern/rna_boid.c +++ b/source/blender/makesrna/intern/rna_boid.c @@ -480,6 +480,12 @@ static void rna_def_boid_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Banking", "Amount of rotation around velocity vector on turns"); RNA_def_property_update(prop, 0, "rna_Boids_reset"); + prop= RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pitch"); + RNA_def_property_range(prop, 0.0, 2.0); + RNA_def_property_ui_text(prop, "Pitch", "Amount of rotation around side vector"); + RNA_def_property_update(prop, 0, "rna_Boids_reset"); + prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 2.0); RNA_def_property_ui_text(prop, "Height", "Boid height relative to particle size"); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 7dffa4aec74..ec089d69d91 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -242,13 +242,13 @@ static void rna_def_imageuser(BlenderRNA *brna) prop= RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "offset"); - RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Offset", "Offsets the number of the frame to use in the animation"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "sfra"); - RNA_def_property_range(prop, 1.0f, MAXFRAMEF); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Start Frame", "Sets the global starting frame of the movie"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 6f72ae0f33b..76ee24a5608 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -225,6 +225,7 @@ char *rna_TextureSlot_path(struct PointerRNA *ptr); void RNA_api_action(StructRNA *srna); void RNA_api_armature_edit_bone(StructRNA *srna); +void RNA_api_bone(StructRNA *srna); void RNA_api_drivers(StructRNA *srna); void RNA_api_image(struct StructRNA *srna); void RNA_api_operator(struct StructRNA *srna); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 5044518ca93..20e74ca5a72 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -593,7 +593,7 @@ static void def_group(StructRNA *srna) { PropertyRNA *prop; - prop = RNA_def_property(srna, "nodetree", PROP_POINTER, PROP_NONE); + prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "NodeTree"); RNA_def_property_flag(prop, PROP_EDITABLE); @@ -1063,7 +1063,7 @@ static void def_cmp_image(StructRNA *srna) prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "sfra"); - RNA_def_property_range(prop, 1, MAXFRAMEF); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Start Frame", ""); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 3777005aaad..d354e152fce 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1748,6 +1748,7 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_editable_array_func(prop, "rna_Object_location_editable"); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); RNA_def_property_ui_text(prop, "Location", "Location of the object"); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); @@ -1785,6 +1786,7 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable"); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); RNA_def_property_float_array_default(prop, default_scale); RNA_def_property_ui_text(prop, "Scale", "Scaling of the object"); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); @@ -1792,6 +1794,7 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the object"); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); diff --git a/source/blender/makesrna/intern/rna_pose_api.c b/source/blender/makesrna/intern/rna_pose_api.c index 922fa285f84..48e8a1e6940 100644 --- a/source/blender/makesrna/intern/rna_pose_api.c +++ b/source/blender/makesrna/intern/rna_pose_api.c @@ -41,8 +41,16 @@ /* #include "DNA_anim_types.h" */ #include "DNA_action_types.h" /* bPose */ +#include "BKE_armature.h" +static float rna_PoseBone_do_envelope(bPoseChannel *chan, float *vec) +{ + Bone *bone = chan->bone; + + float scale = (bone->flag & BONE_MULT_VG_ENV) == BONE_MULT_VG_ENV ? bone->weight : 1.0f; + return distfactor_to_bone(vec, chan->pose_head, chan->pose_tail, bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); +} #else void RNA_api_pose(StructRNA *srna) @@ -53,8 +61,16 @@ void RNA_api_pose(StructRNA *srna) void RNA_api_pose_channel(StructRNA *srna) { -// FunctionRNA *func; -// PropertyRNA *parm; + PropertyRNA *parm; + FunctionRNA *func; + + func= RNA_def_function(srna, "envelope", "rna_PoseBone_do_envelope"); + RNA_def_function_ui_description(func, "Calculate bone envelope at given point."); + parm= RNA_def_float_vector_xyz(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "Position in 3d space to evaluate", -FLT_MAX, FLT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return value */ + parm= RNA_def_float(func, "factor", 0, -FLT_MAX, FLT_MAX, "Factor", "Envelope factor", -FLT_MAX, FLT_MAX); + RNA_def_function_return(func, parm); } diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index d20e5aebcfb..6dddb042533 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -156,6 +156,8 @@ static void rna_Sensor_keyboard_key_set(struct PointerRNA *ptr, int value) if (ISKEYBOARD(value)) ks->key = value; + else + ks->key = 0; } static void rna_Sensor_keyboard_modifier_set(struct PointerRNA *ptr, int value) @@ -165,6 +167,8 @@ static void rna_Sensor_keyboard_modifier_set(struct PointerRNA *ptr, int value) if (ISKEYBOARD(value)) ks->qual = value; + else + ks->qual = 0; } static void rna_Sensor_keyboard_modifier2_set(struct PointerRNA *ptr, int value) @@ -174,6 +178,8 @@ static void rna_Sensor_keyboard_modifier2_set(struct PointerRNA *ptr, int value) if (ISKEYBOARD(value)) ks->qual2 = value; + else + ks->qual2 = 0; } static void rna_Sensor_tap_set(struct PointerRNA *ptr, int value) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 632d8c1be29..7459adc121f 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2655,6 +2655,10 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "keymaps", NULL); RNA_def_property_struct_type(prop, "KeyMap"); RNA_def_property_ui_text(prop, "Edited Keymaps", ""); + + prop= RNA_def_property(srna, "active_keyconfig", PROP_STRING, PROP_DIRPATH); + RNA_def_property_string_sdna(prop, NULL, "keyconfigstr"); + RNA_def_property_ui_text(prop, "Key Config", "The name of the active key configuration"); } static void rna_def_userdef_filepaths(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 900a1fd60cf..62d0c99f6c5 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -697,7 +697,7 @@ static int operator_poll(bContext *C, wmOperatorType *ot) return visible; } -static int operator_exec(bContext *C, wmOperator *op) +static int operator_execute(bContext *C, wmOperator *op) { PointerRNA opr; ParameterList list; @@ -720,6 +720,30 @@ static int operator_exec(bContext *C, wmOperator *op) return result; } +/* same as execute() but no return value */ +static int operator_check(bContext *C, wmOperator *op) +{ + PointerRNA opr; + ParameterList list; + FunctionRNA *func; + void *ret; + int result; + + RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr); + func= RNA_struct_find_function(&opr, "check"); + + RNA_parameter_list_create(&list, &opr, func); + RNA_parameter_set_lookup(&list, "context", &C); + op->type->ext.call(&opr, func, &list); + + RNA_parameter_get_lookup(&list, "result", &ret); + result= *(int*)ret; + + RNA_parameter_list_free(&list); + + return result; +} + static int operator_invoke(bContext *C, wmOperator *op, wmEvent *event) { PointerRNA opr; @@ -796,7 +820,7 @@ static StructRNA *rna_Operator_register(const bContext *C, ReportList *reports, wmOperatorType dummyot = {0}; wmOperator dummyop= {0}; PointerRNA dummyotr; - int have_function[5]; + int have_function[6]; /* setup dummy operator & operator type to store static properties in */ dummyop.type= &dummyot; @@ -846,11 +870,11 @@ static StructRNA *rna_Operator_register(const bContext *C, ReportList *reports, dummyot.ext.free= free; dummyot.pyop_poll= (have_function[0])? operator_poll: NULL; - dummyot.exec= (have_function[1])? operator_exec: NULL; - dummyot.invoke= (have_function[2])? operator_invoke: NULL; - dummyot.modal= (have_function[3])? operator_modal: NULL; - dummyot.ui= (have_function[4])? operator_draw: NULL; - + dummyot.exec= (have_function[1])? operator_execute: NULL; + dummyot.check= (have_function[2])? operator_check: NULL; + dummyot.invoke= (have_function[3])? operator_invoke: NULL; + dummyot.modal= (have_function[4])? operator_modal: NULL; + dummyot.ui= (have_function[5])? operator_draw: NULL; WM_operatortype_append_ptr(operator_wrapper, (void *)&dummyot); /* update while blender is running */ diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index b13d7627a34..36dd6efc256 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -165,6 +165,15 @@ void RNA_api_operator(StructRNA *srna) RNA_def_property_flag(parm, PROP_ENUM_FLAG); RNA_def_function_return(func, parm); + /* check */ + func= RNA_def_function(srna, "check", NULL); + RNA_def_function_ui_description(func, "Check the operator settings."); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_pointer(func, "context", "Context", "", ""); + + parm= RNA_def_boolean(func, "result", 0, "result", ""); // better name? + RNA_def_function_return(func, parm); + /* invoke */ func= RNA_def_function(srna, "invoke", NULL); RNA_def_function_ui_description(func, "Invoke the operator."); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 77d0f4fa90a..997c5f4fce6 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -170,15 +170,7 @@ void BPY_start_python_path(void) /* cmake/MSVC debug build crashes without this, why only in this case is unknown.. */ { - char *envpath = getenv("PYTHONPATH"); - - if(envpath && envpath[0]) { - char *newenvpath = BLI_sprintfN("%s;%s", py_path_bundle, envpath); - BLI_setenv("PYTHONPATH", newenvpath); - MEM_freeN(newenvpath); - } - else - BLI_setenv("PYTHONPATH", py_path_bundle); + BLI_setenv("PYTHONPATH", py_path_bundle); } #endif diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index 27da839960b..6d16896fb16 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -45,9 +45,6 @@ static void operator_properties_init(wmOperatorType *ot) PyErr_Print(); /* failed to register operator props */ PyErr_Clear(); } - - // see bpy_types.py:Operator, May redo this some other way! - PyObject_CallMethod(py_class, "easy_getsets", NULL); } void operator_wrapper(wmOperatorType *ot, void *userdata) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index c20bb3deaee..d2234963927 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -5121,13 +5121,17 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par err= -1; } else { - if(ret_len==1) { + if(ret_len==0 && ret != Py_None) { + PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return None, got a %.200s type instead.", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), Py_TYPE(ret)->tp_name); + err= -1; + } + else if(ret_len==1) { err= pyrna_py_to_prop(&funcptr, pret_single, parms, retdata_single, ret, "calling class function:"); } else if (ret_len > 1) { if(PyTuple_Check(ret)==0) { - PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return a tuple of size %d.", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), ret_len); + PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return a tuple of size %d, got a %.200s type instead.", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), ret_len, Py_TYPE(ret)->tp_name); err= -1; } else if (PyTuple_GET_SIZE(ret) != ret_len) { diff --git a/source/blender/readblenfile/intern/BLO_readblenfile.c b/source/blender/readblenfile/intern/BLO_readblenfile.c index 7c876c96a86..dfcdaf756f7 100644 --- a/source/blender/readblenfile/intern/BLO_readblenfile.c +++ b/source/blender/readblenfile/intern/BLO_readblenfile.c @@ -132,7 +132,8 @@ blo_read_runtime( ReportList *reports) { BlendFileData *bfd= NULL; - int fd, actualsize, datastart; + size_t actualsize; + int fd, datastart; char buf[8]; fd= open(path, O_BINARY|O_RDONLY, 0); diff --git a/source/blender/render/intern/raytrace/reorganize.h b/source/blender/render/intern/raytrace/reorganize.h index 7ef7296945c..1d923c92d6f 100644 --- a/source/blender/render/intern/raytrace/reorganize.h +++ b/source/blender/render/intern/raytrace/reorganize.h @@ -35,6 +35,7 @@ #include "BKE_global.h" #ifdef _WIN32 +#undef INFINITY #define INFINITY FLT_MAX // in mingw math.h: (1.0F/0.0F). This generates compile error, though. #endif diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 9668b2e17c9..690d8ad0f75 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -52,6 +52,8 @@ typedef struct wmJob wmJob; /* general API */ void WM_setprefsize (int stax, int stay, int sizx, int sizy); +void WM_setinitialstate_fullscreen(); +void WM_setinitialstate_normal(); void WM_init (struct bContext *C, int argc, char **argv); void WM_exit (struct bContext *C); @@ -78,7 +80,7 @@ void WM_window_open_temp (struct bContext *C, struct rcti *position, int type); int WM_read_homefile (struct bContext *C, struct wmOperator *op); int WM_write_homefile (struct bContext *C, struct wmOperator *op); void WM_read_file (struct bContext *C, char *name, struct ReportList *reports); -int WM_write_file (struct bContext *C, char *target, int fileflags, struct ReportList *reports, int copy); +int WM_write_file (struct bContext *C, const char *target, int fileflags, struct ReportList *reports, int copy); void WM_read_autosavefile(struct bContext *C); void WM_autosave_init (struct wmWindowManager *wm); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 807125765f7..a732524ca03 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -385,6 +385,12 @@ typedef struct wmOperatorType { * any interface code or input device state. * - see defines below for return values */ int (*exec)(struct bContext *, struct wmOperator *); + + /* this callback executes on a running operator whenever as property + * is changed. It can correct its own properties or report errors for + * invalid settings in exceptional cases. + * Boolean return value, True denotes a change has been made and to redraw */ + int (*check)(struct bContext *, struct wmOperator *); /* for modal temporary operators, initially invoke is called. then * any further events are handled in modal. if the operation is diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 5f386170c54..148932fa941 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -57,8 +57,10 @@ #include "MEM_guardedalloc.h" #include "ED_screen.h" -#include "BPY_extern.h" +#ifndef DISABLE_PYTHON +#include "BPY_extern.h" +#endif /* ****************************************************** */ @@ -229,7 +231,7 @@ void WM_check(bContext *C) } /* case: no open windows at all, for old file reads */ - wm_window_add_ghostwindows(wm); + wm_window_add_ghostwindows(C, wm); /* case: fileread */ if((wm->initialized & WM_INIT_WINDOW) == 0) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 6e8ab87f640..9e7606a9f14 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1224,23 +1224,27 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa case EVT_FILESELECT_EXEC: case EVT_FILESELECT_CANCEL: + case EVT_FILESELECT_EXTERNAL_CANCEL: { /* XXX validate area and region? */ bScreen *screen= CTX_wm_screen(C); - - if(screen != handler->filescreen) - ED_screen_full_prevspace(C, CTX_wm_area(C)); - else - ED_area_prevspace(C, CTX_wm_area(C)); - - /* remlink now, for load file case */ + + /* remlink now, for load file case before removing*/ BLI_remlink(handlers, handler); + if(event->val!=EVT_FILESELECT_EXTERNAL_CANCEL) + if(screen != handler->filescreen) + ED_screen_full_prevspace(C, CTX_wm_area(C)); + else + ED_area_prevspace(C, CTX_wm_area(C)); + wm_handler_op_context(C, handler); /* needed for uiPupMenuReports */ if(event->val==EVT_FILESELECT_EXEC) { +#if 0 // use REDALERT now + /* a bit weak, might become arg for WM_event_fileselect? */ /* XXX also extension code in image-save doesnt work for this yet */ if (RNA_struct_find_property(handler->op->ptr, "check_existing") && @@ -1251,7 +1255,9 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa if(path) MEM_freeN(path); } - else { + else +#endif + { int retval; if(handler->op->type->flag & OPTYPE_UNDO) @@ -1820,6 +1826,12 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) BLI_addhead(&win->modalhandlers, handler); + /* check props once before invoking if check is available + * ensures initial properties are valid */ + if(op->type->check) { + op->type->check(C, op); /* ignore return value */ + } + WM_event_fileselect_event(C, op, full?EVT_FILESELECT_FULL_OPEN:EVT_FILESELECT_OPEN); } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 1264f496103..f0b8577be47 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -96,7 +96,9 @@ #include "GPU_draw.h" +#ifndef DISABLE_PYTHON #include "BPY_extern.h" +#endif #include "WM_api.h" #include "WM_types.h" @@ -403,6 +405,13 @@ int WM_read_homefile(bContext *C, wmOperator *op) ED_editors_init(C); DAG_on_load_update(CTX_data_main(C)); + +#ifndef DISABLE_PYTHON + if(CTX_py_init_get(C)) { + /* sync addons, these may have changed from the defaults */ + BPY_eval_string(C, "__import__('bpy').utils.addon_reset_all()"); + } +#endif WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL); CTX_wm_window_set(C, NULL); /* exits queues */ @@ -576,7 +585,7 @@ int write_crash_blend(void) } } -int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports, int copy) +int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *reports, int copy) { Library *li; int len; @@ -597,25 +606,20 @@ int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports, return -1; } + BLI_strncpy(di, target, FILE_MAX); + BLI_replace_extension(di, FILE_MAX, ".blend"); + /* dont use 'target' anymore */ + /* send the OnSave event */ for (li= G.main->library.first; li; li= li->id.next) { - if (BLI_streq(li->name, target)) { - BKE_report(reports, RPT_ERROR, "Cannot overwrite used library"); + if (strcmp(li->filepath, di) == 0) { + BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%f'", di); return -1; } } - - if (!BLO_has_bfile_extension(target) && (len+6 < FILE_MAX)) { - sprintf(di, "%s.blend", target); - } else { - strcpy(di, target); - } -// if (BLI_exists(di)) { -// XXX if(!saveover(di)) -// XXX return; -// } - + /* operator now handles overwrite checks */ + if (G.fileflags & G_AUTOPACK) { packAll(G.main, reports); } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 95ab84c9192..b84b7eab55f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -928,6 +928,16 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2) uiPupBlockClose(C, block); } +void dialog_check_cb(bContext *C, void *op_ptr, void *dummy2) +{ + wmOperator *op= op_ptr; + if(op->type->check) { + if(op->type->check(C, op)) { + /* refresh */ + } + } +} + /* Dialogs are popups that require user verification (click OK) before exec */ static uiBlock *wm_block_create_dialog(bContext *C, ARegion *ar, void *userData) { @@ -953,6 +963,8 @@ static uiBlock *wm_block_create_dialog(bContext *C, ARegion *ar, void *userData) RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style); uiItemL(layout, op->type->name, 0); + + uiBlockSetFunc(block, dialog_check_cb, op, NULL); if (op->type->ui) { op->layout= layout; @@ -961,6 +973,8 @@ static uiBlock *wm_block_create_dialog(bContext *C, ARegion *ar, void *userData) } else uiDefAutoButsRNA(C, layout, &ptr, columns); + + uiBlockSetFunc(block, NULL, NULL, NULL); /* Create OK button, the callback of which will execute op */ btn= uiDefBut(block, BUT, 0, "OK", 0, 0, 0, 20, NULL, 0, 0, 0, 0, ""); @@ -1799,6 +1813,18 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +/* function used for WM_OT_save_mainfile too */ +static int blend_save_check(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + if(BLI_replace_extension(filepath, sizeof(filepath), ".blend")) { + RNA_string_set(op->ptr, "filepath", filepath); + return TRUE; + } + return FALSE; +} + static void WM_OT_save_as_mainfile(wmOperatorType *ot) { ot->name= "Save As Blender File"; @@ -1807,6 +1833,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot) ot->invoke= wm_save_as_mainfile_invoke; ot->exec= wm_save_as_mainfile_exec; + ot->check= blend_save_check; ot->poll= WM_operator_winactive; WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH); @@ -1857,6 +1884,7 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) ot->invoke= wm_save_mainfile_invoke; ot->exec= wm_save_as_mainfile_exec; + ot->check= blend_save_check; ot->poll= NULL; WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH); @@ -1872,9 +1900,10 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *event) { if(!RNA_property_is_set(op->ptr, "filepath")) { - char *path = BLI_replacestr(G.sce, ".blend", ".dae"); - RNA_string_set(op->ptr, "filepath", path); - MEM_freeN(path); + char *filepath[FILE_MAX]; + BLI_strncpy(filepath, G.sce, sizeof(filepath)); + BLI_replace_extension(filepath, sizeof(filepath), ".dae"); + RNA_string_set(op->ptr, "filepath", filepath); } WM_event_add_fileselect(C, op); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 45234464ef0..4baad110232 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -67,7 +67,7 @@ GHOST_SystemHandle g_system= NULL; /* set by commandline */ -static int prefsizx= 0, prefsizy= 0, prefstax= 0, prefstay= 0; +static int prefsizx= 0, prefsizy= 0, prefstax= 0, prefstay= 0, initialstate= GHOST_kWindowStateNormal; /* ******** win open & close ************ */ @@ -289,19 +289,21 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win) } /* belongs to below */ -static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow *win) +static void wm_window_add_ghostwindow(bContext *C, wmWindowManager *wm, char *title, wmWindow *win) { GHOST_WindowHandle ghostwin; - GHOST_TWindowState inital_state; int scr_w, scr_h, posy; + GHOST_TWindowState initial_state; + + /* when there is no window open uses the initial state */ + if(!CTX_wm_window(C)) + initial_state= initialstate; + else + initial_state= GHOST_kWindowStateNormal; wm_get_screensize(&scr_w, &scr_h); posy= (scr_h - win->posy - win->sizey); - // inital_state = GHOST_kWindowStateFullScreen; - // inital_state = GHOST_kWindowStateMaximized; - inital_state = GHOST_kWindowStateNormal; - #if defined(__APPLE__) && !defined(GHOST_COCOA) { extern int macPrefState; /* creator.c */ @@ -312,13 +314,16 @@ static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow doesn't work well when AA is initialized, even if not used. */ ghostwin= GHOST_CreateWindow(g_system, title, win->posx, posy, win->sizex, win->sizey, - inital_state, + initial_state, GHOST_kDrawingContextTypeOpenGL, 0 /* no stereo */, 0 /* no AA */); if (ghostwin) { + /* set the state*/ + GHOST_SetWindowState(ghostwin, initial_state); + win->ghostwin= ghostwin; GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ @@ -342,7 +347,7 @@ static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow /* for wmWindows without ghostwin, open these and clear */ /* window size is read from window, if 0 it uses prefsize */ /* called in WM_check, also inits stuff after file read */ -void wm_window_add_ghostwindows(wmWindowManager *wm) +void wm_window_add_ghostwindows(bContext* C, wmWindowManager *wm) { wmKeyMap *keymap; wmWindow *win; @@ -372,9 +377,9 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) win->posy= prefstay; win->sizex= prefsizx; win->sizey= prefsizy; - win->windowstate= 0; + win->windowstate= initialstate; } - wm_window_add_ghostwindow(wm, "Blender", win); + wm_window_add_ghostwindow(C, wm, "Blender", win); } /* happens after fileread */ if(win->eventstate==NULL) @@ -1106,6 +1111,17 @@ void WM_setprefsize(int stax, int stay, int sizx, int sizy) prefsizy= sizy; } +/* for borderless and border windows set from command-line */ +void WM_setinitialstate_fullscreen() +{ + initialstate= GHOST_kWindowStateFullScreen; +} + +void WM_setinitialstate_normal() +{ + initialstate= GHOST_kWindowStateNormal; +} + /* This function requires access to the GHOST_SystemHandle (g_system) */ void WM_cursor_warp(wmWindow *win, int x, int y) { diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 6cb3971bd21..e4b56080b03 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -269,10 +269,11 @@ #define EVT_FILESELECT 0x5020 /* event->val */ -#define EVT_FILESELECT_OPEN 1 -#define EVT_FILESELECT_FULL_OPEN 2 -#define EVT_FILESELECT_EXEC 3 -#define EVT_FILESELECT_CANCEL 4 +#define EVT_FILESELECT_OPEN 1 +#define EVT_FILESELECT_FULL_OPEN 2 +#define EVT_FILESELECT_EXEC 3 +#define EVT_FILESELECT_CANCEL 4 +#define EVT_FILESELECT_EXTERNAL_CANCEL 5 /* event->type */ #define EVT_BUT_OPEN 0x5021 diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index d57fd0e75d8..5a425df01e1 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -43,7 +43,7 @@ void wm_window_free (bContext *C, wmWindowManager *wm, wmWindow *win); void wm_window_close (bContext *C, wmWindowManager *wm, wmWindow *win); void wm_window_title (wmWindowManager *wm, wmWindow *win); -void wm_window_add_ghostwindows (wmWindowManager *wm); +void wm_window_add_ghostwindows (bContext *C, wmWindowManager *wm); void wm_window_process_events (const bContext *C); void wm_window_process_events_nosleep(const bContext *C); diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 8fcea674ebb..a61152d37ba 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -113,6 +113,7 @@ IF(UNIX) blenkernel_blc extern_binreloc extern_glew + extern_minilzo ) IF(WITH_QUICKTIME) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 56c3202f04d..8a656f25dc1 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -308,7 +308,6 @@ IF(WITH_INSTALL) POST_BUILD MAIN_DEPENDENCY blender COMMAND copy /Y \"${LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\" # COMMAND copy /Y \"${LIBDIR}\\samplerate\\lib\\libsamplerate-0.dll\" \"${TARGETDIR}\\\" ) ELSE(CMAKE_CL_64) @@ -318,10 +317,24 @@ IF(WITH_INSTALL) COMMAND copy /Y \"${LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\" COMMAND copy /Y \"${LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\" COMMAND copy /Y \"${LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\" # COMMAND copy /Y \"${LIBDIR}\\samplerate\\lib\\libsamplerate-0.dll\" \"${TARGETDIR}\\\" ) ENDIF(CMAKE_CL_64) + + + IF(MSVC) + ADD_CUSTOM_COMMAND(TARGET blender + POST_BUILD + MAIN_DEPENDENCY blender + COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\" + ) + ELSE(MSVC) + ADD_CUSTOM_COMMAND(TARGET blender + POST_BUILD + MAIN_DEPENDENCY blender + COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadGC2.dll\" \"${TARGETDIR}\\\" + ) + ENDIF(MSVC) IF(WITH_PYTHON) IF(NOT CMAKE_BUILD_TYPE) # hack: with multi-configuration generator this is "", so for now copy both python31.dll/zip and python31_d.dll/zip @@ -563,6 +576,10 @@ ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") LIST(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp) ENDIF(WITH_CXX_GUARDEDALLOC) + IF(WITH_IK_ITASC) + LIST(APPEND BLENDER_SORTED_LIBS bf_intern_itasc) + ENDIF(WITH_IK_ITASC) + IF(WITH_QUICKTIME) LIST(APPEND BLENDER_SORTED_LIBS bf_quicktime) ENDIF(WITH_QUICKTIME) diff --git a/source/creator/creator.c b/source/creator/creator.c index 273e7bf2459..922e3a71d76 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -414,16 +414,13 @@ static int prefsize(int argc, char **argv, void *data) static int with_borders(int argc, char **argv, void *data) { - /* with borders XXX OLD CRUFT!*/ - + WM_setinitialstate_normal(); return 0; } static int without_borders(int argc, char **argv, void *data) { - /* borderless, win + linux XXX OLD CRUFT */ - /* XXX, fixme mein, borderless on OSX */ - + WM_setinitialstate_fullscreen(); return 0; } diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 01a9e621304..5a0522a9aa6 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -32,7 +32,7 @@ #include <stdlib.h> #include <stdio.h> -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // don't show stl-warnings #pragma warning (disable:4786) #endif diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h index 5bdf0ccd81d..b7f7be4a279 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h @@ -29,7 +29,7 @@ #ifndef __KX_BLENDERINPUTDEVICE #define __KX_BLENDERINPUTDEVICE -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning(disable : 4786) // shut off 255 char limit debug template warning #endif diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp index e8cb25af868..bc7996a98c0 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp @@ -26,7 +26,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // annoying warnings about truncated STL debug info #pragma warning (disable :4786) #endif diff --git a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp index c3e3935fca5..0326b53dfb1 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp @@ -26,7 +26,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // annoying warnings about truncated STL debug info #pragma warning (disable :4786) #endif diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index 9a7d9c7bcc0..517e0713352 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -30,7 +30,7 @@ #ifndef __KX_BLENDERRENDERTOOLS #define __KX_BLENDERRENDERTOOLS -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // don't show stl-warnings #pragma warning (disable:4786) #endif diff --git a/source/gameengine/BlenderRoutines/KX_BlenderSystem.cpp b/source/gameengine/BlenderRoutines/KX_BlenderSystem.cpp index 813869dd032..a6a9ee2133f 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderSystem.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderSystem.cpp @@ -28,11 +28,14 @@ #include "KX_ISystem.h" -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable :4786) -#include <windows.h> #endif //WIN32 +#ifdef WIN32 +#include <windows.h> +#endif + #include <iostream> #include <stdio.h> #include "KX_BlenderInputDevice.h" diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index d34e86fd556..f9bca9a2cdd 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -28,7 +28,7 @@ * Convert blender data to ketsji */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif @@ -2634,7 +2634,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, sumolist->Release(); // convert world - KX_WorldInfo* worldinfo = new BlenderWorldInfo(blenderscene->world); + KX_WorldInfo* worldinfo = new BlenderWorldInfo(blenderscene, blenderscene->world); converter->RegisterWorldInfo(worldinfo); kxscene->SetWorldInfo(worldinfo); diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h index 5d16e3ba1a8..076bfaeb458 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.h +++ b/source/gameengine/Converter/BL_DeformableGameObject.h @@ -30,7 +30,7 @@ #ifndef BL_DEFORMABLEGAMEOBJECT #define BL_DEFORMABLEGAMEOBJECT -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp index 332c6fee2cf..25dd8678e60 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.cpp +++ b/source/gameengine/Converter/BL_MeshDeformer.cpp @@ -28,7 +28,7 @@ * Simple deformation controller that restores a mesh to its rest position */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // 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 ) diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index 50bad254b42..48878d3f084 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -36,7 +36,7 @@ #include "MT_Point3.h" #include <stdlib.h> -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp index 5ccf8de29b1..f1f30938577 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.cpp +++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp @@ -27,7 +27,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif //WIN32 diff --git a/source/gameengine/Converter/BL_ModifierDeformer.h b/source/gameengine/Converter/BL_ModifierDeformer.h index 6e0ede8e62f..49998f36ccb 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.h +++ b/source/gameengine/Converter/BL_ModifierDeformer.h @@ -30,7 +30,7 @@ #ifndef BL_MODIFIERDEFORMER #define BL_MODIFIERDEFORMER -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 1a90001adca..2fc78646d92 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -27,7 +27,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif //WIN32 diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index 98bd4a1b4ba..b3b0996c27b 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -30,7 +30,7 @@ #ifndef BL_SHAPEDEFORMER #define BL_SHAPEDEFORMER -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index c6e371dc0bf..748df4c2e41 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -27,7 +27,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif //WIN32 diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index df7e8f6dffc..f8483519eb2 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -30,7 +30,7 @@ #ifndef BL_SKINDEFORMER #define BL_SKINDEFORMER -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp index 47653519cfd..f0d6083a8fa 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.cpp +++ b/source/gameengine/Converter/BlenderWorldInfo.cpp @@ -2,7 +2,7 @@ * $Id$ * ***** BEGIN GPL LICENSE BLOCK ***** * - * This program is free software; you can redistribute it and/or + * This program is free software; you can [0]istribute 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. @@ -55,11 +55,13 @@ #include "DNA_world_types.h" #include "DNA_screen_types.h" +#include "BLI_math.h" + #include "BKE_global.h" /* end of blender include block */ -BlenderWorldInfo::BlenderWorldInfo(struct World* blenderworld) +BlenderWorldInfo::BlenderWorldInfo(struct Scene *blenderscene, struct World* blenderworld) { if (blenderworld) { @@ -71,27 +73,24 @@ BlenderWorldInfo::BlenderWorldInfo(struct World* blenderworld) m_hasmist = true; m_miststart = blenderworld->miststa; m_mistdistance = blenderworld->mistdist; - m_mistred = blenderworld->horr; - m_mistgreen = blenderworld->horg; - m_mistblue = blenderworld->horb; + copy_v3_v3(m_mistcolor, &blenderworld->horr); } else { m_hasmist = false; m_miststart = 0.0; m_mistdistance = 0.0; - m_mistred = 0.0; - m_mistgreen = 0.0; - m_mistblue = 0.0; + zero_v3(m_mistcolor); } - m_backgroundred = blenderworld->horr; - m_backgroundgreen = blenderworld->horg; - m_backgroundblue = blenderworld->horb; - - m_ambientred = blenderworld->ambr; - m_ambientgreen = blenderworld->ambg; - m_ambientblue = blenderworld->ambb; + copy_v3_v3(m_backgroundcolor, &blenderworld->horr); + copy_v3_v3(m_ambientcolor, &blenderworld->ambr); + + if(blenderscene->r.color_mgt_flag & R_COLOR_MANAGEMENT) { + linearrgb_to_srgb_v3_v3(m_mistcolor, m_mistcolor); + linearrgb_to_srgb_v3_v3(m_backgroundcolor, m_backgroundcolor); + linearrgb_to_srgb_v3_v3(m_ambientcolor, m_ambientcolor); + } } else { @@ -123,37 +122,37 @@ bool BlenderWorldInfo::hasMist() float BlenderWorldInfo::getBackColorRed() { - return m_backgroundred; + return m_backgroundcolor[0]; } float BlenderWorldInfo::getBackColorGreen() { - return m_backgroundgreen; + return m_backgroundcolor[1]; } float BlenderWorldInfo::getBackColorBlue() { - return m_backgroundblue; + return m_backgroundcolor[2]; } float BlenderWorldInfo::getAmbientColorRed() { - return m_ambientred; + return m_ambientcolor[0]; } float BlenderWorldInfo::getAmbientColorGreen() { - return m_ambientgreen; + return m_ambientcolor[1]; } float BlenderWorldInfo::getAmbientColorBlue() { - return m_ambientblue; + return m_ambientcolor[2]; } float BlenderWorldInfo::getMistStart() @@ -172,21 +171,21 @@ float BlenderWorldInfo::getMistDistance() float BlenderWorldInfo::getMistColorRed() { - return m_mistred; + return m_mistcolor[0]; } float BlenderWorldInfo::getMistColorGreen() { - return m_mistgreen; + return m_mistcolor[1]; } float BlenderWorldInfo::getMistColorBlue() { - return m_mistblue; + return m_mistcolor[2]; } @@ -210,7 +209,7 @@ BlenderWorldInfo::setMistDistance( BlenderWorldInfo::setMistColorRed( float d ) { - m_mistred = d; + m_mistcolor[0] = d; } @@ -218,7 +217,7 @@ BlenderWorldInfo::setMistColorRed( BlenderWorldInfo::setMistColorGreen( float d ) { - m_mistgreen = d; + m_mistcolor[1] = d; } @@ -226,5 +225,5 @@ BlenderWorldInfo::setMistColorGreen( BlenderWorldInfo::setMistColorBlue( float d ) { - m_mistblue = d; + m_mistcolor[2] = d; } diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h index b500c55a7f2..a430e18223e 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.h +++ b/source/gameengine/Converter/BlenderWorldInfo.h @@ -35,23 +35,17 @@ class BlenderWorldInfo : public KX_WorldInfo { bool m_hasworld; - float m_backgroundred; - float m_backgroundgreen; - float m_backgroundblue; + float m_backgroundcolor[3]; bool m_hasmist; float m_miststart; float m_mistdistance; - float m_mistred; - float m_mistgreen; - float m_mistblue; + float m_mistcolor[3]; - float m_ambientred; - float m_ambientgreen; - float m_ambientblue; + float m_ambientcolor[3]; public: - BlenderWorldInfo(struct World* blenderworld); + BlenderWorldInfo(struct Scene *blenderscene, struct World* blenderworld); ~BlenderWorldInfo(); bool hasWorld(); diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 1ce6876dda1..f50fb6838e3 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -26,8 +26,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 - #pragma warning (disable:4786) // suppress stl-MSVC debug info warning +#if defined(WIN32) && !defined(FREE_WINDOWS) +#pragma warning (disable:4786) // suppress stl-MSVC debug info warning #endif #include "KX_Scene.h" diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 9b41470769f..d9d3d7c185d 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -28,7 +28,7 @@ * Convert Blender actuators for use in the GameEngine */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif //WIN32 diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index d65fee93a12..20597d46e82 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -30,7 +30,7 @@ #include <stdio.h> -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif //WIN32 @@ -39,7 +39,7 @@ #include "KX_ConvertSensors.h" /* This little block needed for linking to Blender... */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #include "BLI_winstuff.h" #endif diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index c983c8a5100..774efb3879d 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -26,8 +26,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 - +#if defined(WIN32) && !defined(FREE_WINDOWS) // don't show stl-warnings #pragma warning (disable:4786) #endif diff --git a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp index 9d58a16ddfc..bace00a872d 100644 --- a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp +++ b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp @@ -27,7 +27,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif //WIN32 diff --git a/source/gameengine/Converter/KX_SoftBodyDeformer.h b/source/gameengine/Converter/KX_SoftBodyDeformer.h index ce3f695ef11..76874bdc782 100644 --- a/source/gameengine/Converter/KX_SoftBodyDeformer.h +++ b/source/gameengine/Converter/KX_SoftBodyDeformer.h @@ -30,7 +30,7 @@ #ifndef KX_SOFTBODYDEFORMER #define KX_SOFTBODYDEFORMER -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index 2bb9e39cafc..009d95ee4d2 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -13,7 +13,7 @@ * */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) #endif //WIN32 diff --git a/source/gameengine/Expressions/VectorValue.cpp b/source/gameengine/Expressions/VectorValue.cpp index 59ff601746f..c7b0db4a8f9 100644 --- a/source/gameengine/Expressions/VectorValue.cpp +++ b/source/gameengine/Expressions/VectorValue.cpp @@ -12,7 +12,7 @@ * */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) #endif diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp index 0f3b81a057e..e364225af3d 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp +++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp @@ -29,7 +29,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // 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 ) diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp index 701bcb2fc2f..6cad801e429 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp +++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp @@ -29,7 +29,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // 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 ) diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h index c5f377eeb44..9ddb62df361 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.h +++ b/source/gameengine/GameLogic/SCA_LogicManager.h @@ -30,7 +30,7 @@ #ifndef __KX_LOGICMANAGER #define __KX_LOGICMANAGER -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) #endif diff --git a/source/gameengine/GameLogic/SCA_MouseManager.cpp b/source/gameengine/GameLogic/SCA_MouseManager.cpp index f7f9a566c8d..1241bd07229 100644 --- a/source/gameengine/GameLogic/SCA_MouseManager.cpp +++ b/source/gameengine/GameLogic/SCA_MouseManager.cpp @@ -30,7 +30,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // 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 ) diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp index d794a4f1227..8b99fd669a9 100644 --- a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp +++ b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp @@ -26,8 +26,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 - +#if defined(WIN32) && !defined(FREE_WINDOWS) // 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 ) diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 71507642226..d1b8fb12336 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -370,6 +370,7 @@ bool GPG_Application::startFullScreen( fSystem->beginFullScreen(setting, &m_mainWindow, stereoVisual); m_mainWindow->setCursorVisibility(false); + m_mainWindow->setState(GHOST_kWindowStateFullScreen); success = initEngine(m_mainWindow, stereoMode); if (success) { diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 9cdee2a340c..9c0b5a24aeb 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -161,17 +161,29 @@ static BOOL scr_saver_init(int argc, char **argv) #endif /* WIN32 */ -void usage(const char* program) +void usage(const char* program, bool isBlenderPlayer) { const char * consoleoption; + const char * filename = ""; + const char * pathname = ""; + #ifdef _WIN32 consoleoption = "-c "; #else consoleoption = ""; #endif + + if (isBlenderPlayer) { + filename = "filename.blend"; +#ifdef _WIN32 + pathname = "c:\\"; +#else + pathname = "//home//user//"; +#endif + } printf("usage: %s [-w [w h l t]] [-f [fw fh fb ff]] %s[-g gamengineoptions] " - "[-s stereomode] filename.blend\n", program, consoleoption); + "[-s stereomode] %s\n", program, consoleoption, filename); printf(" -h: Prints this command summary\n\n"); printf(" -w: display in a window\n"); printf(" --Optional parameters--\n"); @@ -227,8 +239,8 @@ void usage(const char* program) printf("\n"); printf(" - : all arguments after this are ignored, allowing python to access them from sys.argv\n"); printf("\n"); - printf("example: %s -w 320 200 10 10 -g noaudio c:\\loadtest.blend\n", program); - printf("example: %s -g show_framerate = 0 c:\\loadtest.blend\n", program); + printf("example: %s -w 320 200 10 10 -g noaudio%s%s\n", program, pathname, filename); + printf("example: %s -g show_framerate = 0 %s%s\n", program, pathname, filename); } static void get_filename(int argc, char **argv, char *filename) @@ -337,8 +349,8 @@ int main(int argc, char** argv) int fullScreenBpp = 32; int fullScreenFrequency = 60; GHOST_TEmbedderWindowID parentWindow = 0; - - + bool isBlenderPlayer = false; + int validArguments=0; #ifdef __linux__ #ifdef __alpha__ @@ -412,7 +424,14 @@ int main(int argc, char** argv) U.audioformat = 0x24; U.audiochannels = 2; - for (i = 1; (i < argc) && !error + /* if running blenderplayer the last argument can't be parsed since it has to be the filename. */ + isBlenderPlayer = !blo_is_a_runtime(argv[0]); + if (isBlenderPlayer) + validArguments = argc - 1; + else + validArguments = argc; + + for (i = 1; (i < validArguments) && !error #ifdef WIN32 && scr_saver_mode == SCREEN_SAVER_MODE_NONE #endif @@ -436,14 +455,14 @@ int main(int argc, char** argv) // Parse game options { i++; - if (i < argc) + if (i <= validArguments) { char* paramname = argv[i]; // Check for single value versus assignment - if (i+1 < argc && (*(argv[i+1]) == '=')) + if (i+1 <= validArguments && (*(argv[i+1]) == '=')) { i++; - if (i + 1 < argc) + if (i + 1 <= validArguments) { i++; // Assignment @@ -479,14 +498,14 @@ int main(int argc, char** argv) i++; fullScreen = true; fullScreenParFound = true; - if ((i + 2) <= argc && argv[i][0] != '-' && argv[i+1][0] != '-') + if ((i + 2) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-') { fullScreenWidth = atoi(argv[i++]); fullScreenHeight = atoi(argv[i++]); - if ((i + 1) <= argc && argv[i][0] != '-') + if ((i + 1) <= validArguments && argv[i][0] != '-') { fullScreenBpp = atoi(argv[i++]); - if ((i + 1) <= argc && argv[i][0] != '-') + if ((i + 1) <= validArguments && argv[i][0] != '-') fullScreenFrequency = atoi(argv[i++]); } } @@ -497,11 +516,11 @@ int main(int argc, char** argv) fullScreen = false; windowParFound = true; - if ((i + 2) <= argc && argv[i][0] != '-' && argv[i+1][0] != '-') + if ((i + 2) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-') { windowWidth = atoi(argv[i++]); windowHeight = atoi(argv[i++]); - if ((i +2) <= argc && argv[i][0] != '-' && argv[i+1][0] != '-') + if ((i + 2) <= validArguments && argv[i][0] != '-' && argv[i+1][0] != '-') { windowLeft = atoi(argv[i++]); windowTop = atoi(argv[i++]); @@ -510,14 +529,19 @@ int main(int argc, char** argv) break; case 'h': - usage(argv[0]); + usage(argv[0], isBlenderPlayer); return 0; break; #ifndef _WIN32 case 'i': i++; - if ( (i + 1) < argc ) - parentWindow = atoi(argv[i++]); + if ( (i + 1) <= validArguments ) + parentWindow = atoi(argv[i++]); + else { + error = true; + printf("error: too few options for parent window argument.\n"); + } + #ifndef NDEBUG printf("XWindows ID = %d\n", parentWindow); #endif //NDEBUG @@ -529,7 +553,7 @@ int main(int argc, char** argv) break; case 's': // stereo i++; - if ((i + 1) < argc) + if ((i + 1) <= validArguments) { stereomode = (RAS_IRasterizer::StereoMode) atoi(argv[i]); if (stereomode < RAS_IRasterizer::RAS_STEREO_NOSTEREO || stereomode >= RAS_IRasterizer::RAS_STEREO_MAXSTEREO) @@ -575,7 +599,7 @@ int main(int argc, char** argv) stereoFlag = STEREO_DOME; stereomode = RAS_IRasterizer::RAS_STEREO_DOME; i++; - if ((i + 1) < argc) + if ((i + 1) <= validArguments) { if(!strcmp(argv[i], "angle")){ i++; @@ -631,7 +655,7 @@ int main(int argc, char** argv) if (error ) { - usage(argv[0]); + usage(argv[0], isBlenderPlayer); return 0; } @@ -714,7 +738,7 @@ int main(int argc, char** argv) //::printf("game data loaded from %s\n", filename); if (!bfd) { - usage(argv[0]); + usage(argv[0], isBlenderPlayer); error = true; exitcode = KX_EXIT_REQUEST_QUIT_GAME; } diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index e793f9d5966..061220ce0c1 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -26,7 +26,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 94258088e9f..44d7827db6a 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -2049,11 +2049,11 @@ void KX_Dome::RenderDomeFrame(KX_Scene* scene, KX_Camera* cam, int i) m_rasterizer->SetViewMatrix(viewmat, cam->NodeGetWorldOrientation(), cam->NodeGetWorldPosition(), 1.0); cam->SetModelviewMatrix(viewmat); - scene->CalculateVisibleMeshes(m_rasterizer,cam); - scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools); - // restore the original orientation cam->NodeSetLocalOrientation(camori); cam->NodeUpdateGS(0.f); + + scene->CalculateVisibleMeshes(m_rasterizer,cam); + scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools); } diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index e44aac2699c..764691c379f 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -34,7 +34,7 @@ typedef unsigned __int64 uint_ptr; typedef unsigned long uint_ptr; #endif -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // 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 ) diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 625ff2609df..524c061b4d5 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -31,7 +31,7 @@ #ifndef __KX_GAMEOBJECT #define __KX_GAMEOBJECT -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // get rid of this stupid "warning 'this' used in initialiser list", generated by VC when including Solid/Sumo #pragma warning (disable : 4355) #endif diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp index 1d4c64483f5..abe63a68e79 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp +++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp @@ -34,7 +34,7 @@ typedef unsigned __int64 uint_ptr; typedef unsigned long uint_ptr; #endif -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // 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 ) diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 1a6ae69f792..4f3b6e5bb96 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -28,7 +28,7 @@ * The engine ties all game modules together. */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif //WIN32 diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index ac20b4f2f56..e282d7ac375 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -26,8 +26,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 - +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 63771ae08dc..19114c86c98 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -28,7 +28,7 @@ * KX_MouseFocusSensor determines mouse in/out/over events. */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // 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 ) diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp index 59d1c197cf3..12f88331d15 100644 --- a/source/gameengine/Ketsji/KX_PyMath.cpp +++ b/source/gameengine/Ketsji/KX_PyMath.cpp @@ -28,7 +28,7 @@ * Initialize Python thingies. */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif //WIN32 diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index dcedade9bd6..291ac83fd42 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -30,7 +30,7 @@ #include "GL/glew.h" -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif //WIN32 @@ -1997,7 +1997,7 @@ void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene* startscene, Main * initVideoTexture(); /* could be done a lot more nicely, but for now a quick way to get bge.* working */ - PyRun_SimpleString("sys = __import__('sys');mod = sys.modules['bge'] = type(sys)('bge');mod.__dict__.update({'logic':__import__('GameLogic'), 'render':__import__('Rasterizer'), 'events':__import__('GameKeys'), 'constraints':__import__('PhysicsConstraints'), 'types':__import__('GameTypes')});"); + PyRun_SimpleString("sys = __import__('sys');mod = sys.modules['bge'] = type(sys)('bge');mod.__dict__.update({'logic':__import__('GameLogic'), 'render':__import__('Rasterizer'), 'events':__import__('GameKeys'), 'constraints':__import__('PhysicsConstraints'), 'types':__import__('GameTypes'), 'texture':__import__('VideoTexture')});"); } static struct PyModuleDef Rasterizer_module_def = { diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index d4936d7054c..863b73adc96 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -28,7 +28,7 @@ * Ketsji scene. Holds references to all scene data. */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable : 4786) #endif //WIN32 diff --git a/source/gameengine/Ketsji/KX_TimeCategoryLogger.h b/source/gameengine/Ketsji/KX_TimeCategoryLogger.h index b020683bfc6..f4eb4d18ab3 100644 --- a/source/gameengine/Ketsji/KX_TimeCategoryLogger.h +++ b/source/gameengine/Ketsji/KX_TimeCategoryLogger.h @@ -30,7 +30,7 @@ #ifndef __KX_TIME_CATEGORY_LOGGER_H #define __KX_TIME_CATEGORY_LOGGER_H -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) // suppress stl-MSVC debug info warning #endif diff --git a/source/gameengine/Ketsji/KX_TimeLogger.h b/source/gameengine/Ketsji/KX_TimeLogger.h index 058b1c2b6c7..9a5c124a462 100644 --- a/source/gameengine/Ketsji/KX_TimeLogger.h +++ b/source/gameengine/Ketsji/KX_TimeLogger.h @@ -30,7 +30,7 @@ #ifndef __KX_TIME_LOGGER_H #define __KX_TIME_LOGGER_H -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) // suppress stl-MSVC debug info warning #endif diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 32fb1e31780..42cdb9659e6 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -26,7 +26,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // don't show these anoying STL warnings #pragma warning (disable:4786) #endif diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h index 17c2cb4695e..f61ac7ea18a 100644 --- a/source/gameengine/Rasterizer/RAS_Deformer.h +++ b/source/gameengine/Rasterizer/RAS_Deformer.h @@ -30,7 +30,7 @@ #ifndef RAS_DEFORMER #define RAS_DEFORMER -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 630a43daddc..d72e910cd2c 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -29,7 +29,7 @@ #ifndef __RAS_IRASTERIZER #define __RAS_IRASTERIZER -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) #endif diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 14acd0259da..ef9bf4e22b7 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -28,8 +28,11 @@ #include "RAS_MaterialBucket.h" -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) +#endif + +#ifdef WIN32 #include <windows.h> #endif // WIN32 diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index 5a834bf26b0..11499b4fbcb 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -29,7 +29,7 @@ #ifndef __RAS_MESHOBJECT #define __RAS_MESHOBJECT -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) // disable the STL warnings ("debug information length > 255") #pragma warning (disable:4786) #endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 7b516cb53a0..387bb2cfd73 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -29,7 +29,7 @@ #ifndef __RAS_OPENGLRASTERIZER #define __RAS_OPENGLRASTERIZER -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) #endif diff --git a/source/gameengine/Rasterizer/RAS_Polygon.cpp b/source/gameengine/Rasterizer/RAS_Polygon.cpp index b038d3bf31a..ab31bb59c36 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.cpp +++ b/source/gameengine/Rasterizer/RAS_Polygon.cpp @@ -26,7 +26,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WIN32 +#if defined(WIN32) && !defined(FREE_WINDOWS) #pragma warning (disable:4786) #endif |