Merged changes in the trunk up to revision 31987.

This commit is contained in:
Tamito Kajiyama 2010-09-18 00:50:13 +00:00
commit 28d618e41b
216 changed files with 2008 additions and 2703 deletions

View File

@ -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 ")
# 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_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 ")
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)

View File

@ -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

View File

@ -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
}

View File

@ -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 $*

View File

@ -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])

View File

@ -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)

View File

@ -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}")

View File

@ -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,

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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()

View File

@ -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

View File

@ -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)

View File

@ -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()

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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__ = ()
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)
@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 __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

View File

@ -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')

View File

@ -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:

View File

@ -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):

View File

@ -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)

View File

@ -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')

View File

@ -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.name:
return {'FINISHED'}
if not self.remove_active:
if not self.name:
return {'FINISHED'}
filename = self._as_filename(self.name) + ".py"
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
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)
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")
preset_active = preset_menu_class.bl_label
for rna_path in self.preset_values:
value = eval(rna_path)
file_preset.write("%s = %s\n" % (rna_path, repr(value)))
# fairly sloppy but convenient.
filepath = bpy.utils.preset_find(preset_active, self.preset_subdir)
file_preset.close()
if not filepath:
filepath = bpy.utils.preset_find(preset_active, self.preset_subdir, display_name=True)
if not filepath:
return {'CANCELLED'}
if hasattr(self, "remove"):
self.remove(context, filepath)
else:
try:
os.remove(filepath)
except:
import traceback
traceback.print_exc()
# XXX, stupid!
preset_menu_class.bl_label = "Presets"
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

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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

View File

@ -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()

View File

@ -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

View File

@ -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)

View File

@ -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()

View File

@ -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")

View File

@ -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")

View File

@ -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
mod = bpy.utils.addon_enable(self.module)
# note, this still gets added to _bpy_types.TypeMap
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:
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...")
# check if add-on is written for current blender version, or raise a warning
info = addon_info_get(mod)
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()
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'}
# 2) try register collected modules
try:
_bpy_types._register_module(module_name)
except:
handle_error()
del sys.modules[module_name]
return {'CANCELLED'}
# 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 {'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'}

View File

@ -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'}

View File

@ -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")

View File

@ -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 */

View File

@ -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

View File

@ -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);

View File

@ -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 ****************** */

View File

@ -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
}

View File

@ -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)

View File

@ -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;

View File

@ -29,6 +29,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <math.h>

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include "MEM_guardedalloc.h"

View File

@ -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 */

View File

@ -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;
}

View File

@ -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);

View File

@ -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 */

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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}")

View File

@ -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);

View File

@ -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) {

View File

@ -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"

View File

@ -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);
}

View File

@ -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);

View File

@ -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 );
}

View File

@ -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);

View File

@ -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

View File

@ -28,6 +28,7 @@
* .blend file reading entry point
*/
#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <stdlib.h>

View File

@ -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! */

View File

@ -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,

View File

@ -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 */

View File

@ -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;

View File

@ -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 */

View File

@ -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))

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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));
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(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;
}
}
}
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);

View File

@ -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);

View File

@ -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 */

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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 */

View File

@ -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);

View File

@ -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);

View File

@ -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) {

View File

@ -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. */

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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;
}
}

View File

@ -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) {

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

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