diff options
author | Miika Hamalainen <blender@miikah.org> | 2011-11-05 12:04:49 +0400 |
---|---|---|
committer | Miika Hamalainen <blender@miikah.org> | 2011-11-05 12:04:49 +0400 |
commit | 2ed6f077b3952123d56916980d18a379ecb3e5ac (patch) | |
tree | 1aa273e5566c95214739fb224d4c6cf115417882 /source/blender/blenlib | |
parent | b9c83456b27da57a14bcf8d274b460e670d49990 (diff) | |
parent | 62f22185546e80b661424b45c88006f8b592d8b1 (diff) |
Merge with trunk r41545
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_bpath.h | 10 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_callbacks.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_math_rotation.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_threads.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/CMakeLists.txt | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/bpath.c | 5 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_rotation.c | 8 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 61 | ||||
-rw-r--r-- | source/blender/blenlib/intern/pbvh.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/threads.c | 5 | ||||
-rw-r--r-- | source/blender/blenlib/intern/uvproject.c | 2 |
11 files changed, 66 insertions, 38 deletions
diff --git a/source/blender/blenlib/BLI_bpath.h b/source/blender/blenlib/BLI_bpath.h index 89ba4b2675e..e850db5a171 100644 --- a/source/blender/blenlib/BLI_bpath.h +++ b/source/blender/blenlib/BLI_bpath.h @@ -48,9 +48,13 @@ void bpath_traverse_id_list(struct Main *bmain, struct ListBase *lb, BPathVisito void bpath_traverse_main(struct Main *bmain, BPathVisitor visit_cb, const int flag, void *userdata); int bpath_relocate_visitor(void *oldbasepath, char *path_dst, const char *path_src); -#define BPATH_TRAVERSE_ABS (1<<0) /* convert paths to absolute */ -#define BPATH_TRAVERSE_SKIP_LIBRARY (1<<2) /* skip library paths */ -#define BPATH_TRAVERSE_SKIP_PACKED (1<<3) /* skip packed data */ +#define BPATH_TRAVERSE_ABS (1<<0) /* convert paths to absolute */ +#define BPATH_TRAVERSE_SKIP_LIBRARY (1<<2) /* skip library paths */ +#define BPATH_TRAVERSE_SKIP_PACKED (1<<3) /* skip packed data */ +#define BPATH_TRAVERSE_SKIP_MULTIFILE (1<<4) /* skip paths where a single dir is used with an array of files, eg. + * sequence strip images and pointcache. in this case only use the first + * file, this is needed for directory manipulation functions which might + * otherwise modify the same directory multiple times */ /* high level funcs */ diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h index 5322ce04a2e..7e4fad54cda 100644 --- a/source/blender/blenlib/BLI_callbacks.h +++ b/source/blender/blenlib/BLI_callbacks.h @@ -47,6 +47,8 @@ typedef enum { BLI_CB_EVT_LOAD_POST, BLI_CB_EVT_SAVE_PRE, BLI_CB_EVT_SAVE_POST, + BLI_CB_EVT_SCENE_UPDATE_PRE, + BLI_CB_EVT_SCENE_UPDATE_POST, BLI_CB_EVT_TOT } eCbEvent; diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index aef1c4bb46c..fca7c3469a1 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -179,8 +179,8 @@ void dquat_to_mat4(float R[4][4], DualQuat *dq); void quat_apply_track(float quat[4], short axis, short upflag); void vec_apply_track(float vec[3], short axis); -float lens_to_angle(float lens); -float angle_to_lens(float angle); +float focallength_to_fov(float focal_length, float sensor); +float fov_to_focallength(float fov, float sensor); float angle_wrap_rad(float angle); float angle_wrap_deg(float angle); diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index 97252247e4b..10a0787adf2 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -74,6 +74,7 @@ int BLI_system_thread_count(void); /* gets the number of threads the system can #define LOCK_CUSTOM1 3 #define LOCK_RCACHE 4 #define LOCK_OPENGL 5 +#define LOCK_NODES 6 void BLI_lock_thread(int type); void BLI_unlock_thread(int type); diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 4711acbb600..5d54ffbeb36 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -148,4 +148,8 @@ if(WITH_OPENMP) add_definitions(-DPARALLEL=1) endif() +if(WITH_XDG_USER_DIRS) + add_definitions(-DWITH_XDG_USER_DIRS) +endif() + blender_add_lib(bf_blenlib "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index b7fe7ef5efd..259b25e67dd 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -499,6 +499,11 @@ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int fla int len= MEM_allocN_len(se) / sizeof(*se); int i; + if (flag & BPATH_TRAVERSE_SKIP_MULTIFILE) { + /* only operate on one path */ + len= MIN2(1, len); + } + for(i= 0; i < len; i++, se++) { rewrite_path_fixed_dirfile(seq->strip->dir, se->name, visit_cb, absbase, bpath_user_data); } diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 0ca8b72c1e3..7fecbae8229 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1688,14 +1688,14 @@ void vec_apply_track(float vec[3], short axis) } /* lens/angle conversion (radians) */ -float lens_to_angle(float lens) +float focallength_to_fov(float focal_length, float sensor) { - return 2.0f * atanf(16.0f/lens); + return 2.0f * atanf((sensor/2.0f) / focal_length); } -float angle_to_lens(float angle) +float fov_to_focallength(float hfov, float sensor) { - return 16.0f / tanf(angle * 0.5f); + return (sensor/2.0f) / tanf(hfov * 0.5f); } /* 'mod_inline(-3,4)= 1', 'fmod(-3,4)= -3' */ diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index bbb62db58f2..7aa84523e9d 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -52,7 +52,7 @@ #include "GHOST_Path-api.h" #if defined WIN32 && !defined _LIBC -# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ +# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ #else # ifndef _GNU_SOURCE # define _GNU_SOURCE @@ -61,35 +61,34 @@ #endif #ifdef WIN32 -#include <io.h> - -#ifdef _WIN32_IE -#undef _WIN32_IE -#endif -#define _WIN32_IE 0x0501 -#include <windows.h> -#include <shlobj.h> - -#include "BLI_winstuff.h" - +# include <io.h> +# ifdef _WIN32_IE +# undef _WIN32_IE +# endif +# define _WIN32_IE 0x0501 +# include <windows.h> +# include <shlobj.h> +# include "BLI_winstuff.h" #else /* non windows */ - -#ifdef WITH_BINRELOC -#include "binreloc.h" -#endif - +# ifdef WITH_BINRELOC +# include "binreloc.h" +# endif #endif /* WIN32 */ /* standard paths */ #ifdef WIN32 -#define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s" -#define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s" +# define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s" +# define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s" #elif defined(__APPLE__) -#define BLENDER_USER_FORMAT "%s/Blender/%s" -#define BLENDER_SYSTEM_FORMAT "%s/Blender/%s" -#else -#define BLENDER_USER_FORMAT "%s/.blender/%s" -#define BLENDER_SYSTEM_FORMAT "%s/blender/%s" +# define BLENDER_USER_FORMAT "%s/Blender/%s" +# define BLENDER_SYSTEM_FORMAT "%s/Blender/%s" +#else /* UNIX */ +# ifndef WITH_XDG_USER_DIRS /* oldschool unix ~/.blender/ */ +# define BLENDER_USER_FORMAT "%s/.blender/%s" +# else /* new XDG ~/blender/.config/ */ +# define BLENDER_USER_FORMAT "%s/blender/%s" +# endif // WITH_XDG_USER_DIRS +# define BLENDER_SYSTEM_FORMAT "%s/blender/%s" #endif /* local */ @@ -797,10 +796,18 @@ void BLI_getlastdir(const char* dir, char *last, const size_t maxlen) as default location to save documents */ const char *BLI_getDefaultDocumentFolder(void) { - #if !defined(WIN32) +#ifndef WIN32 + +#ifdef WITH_XDG_USER_DIRS + const char *xdg_documents_dir= getenv("XDG_DOCUMENTS_DIR"); + if (xdg_documents_dir) { + return xdg_documents_dir; + } +#endif + return getenv("HOME"); - #else /* Windows */ +#else /* Windows */ const char * ret; static char documentfolder[MAXPATHLEN]; HRESULT hResult; @@ -825,7 +832,7 @@ const char *BLI_getDefaultDocumentFolder(void) } return NULL; - #endif +#endif /* WIN32 */ } /* NEW stuff, to be cleaned up when fully migrated */ diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 9471f096682..5a8e378e8c4 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -80,7 +80,7 @@ typedef struct { struct PBVHNode { /* Opaque handle for drawing code */ - void *draw_buffers; + GPU_Buffers *draw_buffers; /* Voxel bounds */ BB vb; diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index a125bf87534..d472f43accd 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -113,6 +113,7 @@ static pthread_mutex_t _viewer_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _custom1_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _rcache_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t _opengl_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t _nodes_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_t mainid; static int thread_levels= 0; /* threads can be invoked inside threads */ @@ -347,6 +348,8 @@ void BLI_lock_thread(int type) pthread_mutex_lock(&_rcache_lock); else if (type==LOCK_OPENGL) pthread_mutex_lock(&_opengl_lock); + else if (type==LOCK_NODES) + pthread_mutex_lock(&_nodes_lock); } void BLI_unlock_thread(int type) @@ -363,6 +366,8 @@ void BLI_unlock_thread(int type) pthread_mutex_unlock(&_rcache_lock); else if(type==LOCK_OPENGL) pthread_mutex_unlock(&_opengl_lock); + else if(type==LOCK_NODES) + pthread_mutex_unlock(&_nodes_lock); } /* Mutex Locks */ diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c index 30625e7b34e..8b00d8e48a6 100644 --- a/source/blender/blenlib/intern/uvproject.c +++ b/source/blender/blenlib/intern/uvproject.c @@ -141,7 +141,7 @@ UvCameraInfo *project_camera_info(Object *ob, float (*rotmat)[4], float winx, fl uci.do_pano = (camera->flag & CAM_PANORAMA); uci.do_persp = (camera->type==CAM_PERSP); - uci.camangle= lens_to_angle(camera->lens) / 2.0f; + uci.camangle= focallength_to_fov(camera->lens, camera->sensor_x) / 2.0f; uci.camsize= uci.do_persp ? tanf(uci.camangle) : camera->ortho_scale; /* account for scaled cameras */ |