Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2011-11-08 10:30:02 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2011-11-08 10:30:02 +0400
commit80e398e7b2cfbdf0192b11734cb02b378b423d65 (patch)
tree69bda0498a17f6a3ad5acb47465e1eef8a5e1faa /source/blender/blenlib
parent72cfdfec3083cbb756ff07c860293be9ca25f8b4 (diff)
parentf086201518b85f6dd2ae60ae37dc14f1d1406c01 (diff)
Merged changes in the trunk up to revision 41638.
Conflicts resolved: doc/python_api/sphinx_doc_gen.py source/blender/blenkernel/BKE_main.h source/blender/blenkernel/intern/library.c source/blender/blenloader/intern/readfile.c source/blender/blenloader/intern/writefile.c source/blender/editors/include/UI_resources.h source/blender/editors/interface/resources.c source/blender/makesdna/DNA_ID.h source/blender/makesdna/intern/makesdna.c source/blender/makesrna/intern/rna_internal.h source/blender/makesrna/intern/rna_main.c source/blender/makesrna/intern/rna_main_api.c source/blender/makesrna/intern/rna_scene.c
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_bpath.h10
-rw-r--r--source/blender/blenlib/BLI_callbacks.h2
-rw-r--r--source/blender/blenlib/BLI_kdopbvh.h12
-rw-r--r--source/blender/blenlib/BLI_math_rotation.h4
-rw-r--r--source/blender/blenlib/BLI_math_vector.h9
-rw-r--r--source/blender/blenlib/BLI_path_util.h1
-rw-r--r--source/blender/blenlib/BLI_threads.h2
-rw-r--r--source/blender/blenlib/CMakeLists.txt4
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c34
-rw-r--r--source/blender/blenlib/intern/bpath.c7
-rw-r--r--source/blender/blenlib/intern/graph.c4
-rw-r--r--source/blender/blenlib/intern/math_rotation.c8
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c44
-rw-r--r--source/blender/blenlib/intern/path_util.c106
-rw-r--r--source/blender/blenlib/intern/pbvh.c2
-rw-r--r--source/blender/blenlib/intern/threads.c10
-rw-r--r--source/blender/blenlib/intern/uvproject.c2
17 files changed, 188 insertions, 73 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_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h
index 4daa27a5c72..8ead7bf5f17 100644
--- a/source/blender/blenlib/BLI_kdopbvh.h
+++ b/source/blender/blenlib/BLI_kdopbvh.h
@@ -85,11 +85,11 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis);
void BLI_bvhtree_free(BVHTree *tree);
/* construct: first insert points, then call balance */
-int BLI_bvhtree_insert(BVHTree *tree, int index, float *co, int numpoints);
+int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints);
void BLI_bvhtree_balance(BVHTree *tree);
/* update: first update points/nodes, then call update_tree to refit the bounding volumes */
-int BLI_bvhtree_update_node(BVHTree *tree, int index, float *co, float *co_moving, int numpoints);
+int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const float *co_moving, int numpoints);
void BLI_bvhtree_update_tree(BVHTree *tree);
/* collision/overlap: check two trees if they overlap, alloc's *overlap with length of the int return value */
@@ -98,14 +98,14 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
float BLI_bvhtree_getepsilon(BVHTree *tree);
/* find nearest node to the given coordinates (if nearest is given it will only search nodes where square distance is smaller than nearest->dist) */
-int BLI_bvhtree_find_nearest(BVHTree *tree, const float *co, BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata);
+int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata);
-int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata);
+int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float *dir, float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata);
-float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, float *pos);
+float BLI_bvhtree_bb_raycast(float *bv, const float light_start[3], const float light_end[3], float pos[3]);
/* range query */
-int BLI_bvhtree_range_query(BVHTree *tree, const float *co, float radius, BVHTree_RangeQuery callback, void *userdata);
+int BLI_bvhtree_range_query(BVHTree *tree, const float co[3], float radius, BVHTree_RangeQuery callback, void *userdata);
#ifdef __cplusplus
}
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_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index e259071a27a..2b9d6d2d6d6 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -54,11 +54,18 @@ MINLINE void swap_v2_v2(float a[2], float b[2]);
MINLINE void swap_v3_v3(float a[3], float b[3]);
MINLINE void swap_v4_v4(float a[4], float b[4]);
+/* char */
+MINLINE void copy_v2_v2_char(char r[2], const char a[2]);
+MINLINE void copy_v3_v3_char(char r[3], const char a[3]);
+MINLINE void copy_v4_v4_char(char r[4], const char a[4]);
/* short */
MINLINE void copy_v2_v2_short(short r[2], const short a[2]);
MINLINE void copy_v3_v3_short(short r[3], const short a[3]);
MINLINE void copy_v4_v4_short(short r[4], const short a[4]);
-
+/* int */
+MINLINE void copy_v2_v2_int(int r[2], const int a[2]);
+MINLINE void copy_v3_v3_int(int r[3], const int a[3]);
+MINLINE void copy_v4_v4_int(int r[4], const int a[4]);
/********************************* Arithmetic ********************************/
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index dd4bc868ab0..68bb1a7280d 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -102,6 +102,7 @@ int BLI_testextensie(const char *str, const char *ext);
int BLI_testextensie_array(const char *str, const char **ext_array);
int BLI_testextensie_glob(const char *str, const char *ext_fnmatch);
int BLI_replace_extension(char *path, size_t maxlen, const char *ext);
+int BLI_ensure_extension(char *path, size_t maxlen, const char *ext);
void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len);
int BLI_uniquename_cb(int (*unique_check)(void *, const char *), void *arg, const char defname[], char delim, char *name, short name_len);
void BLI_newname(char * name, int add);
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index 00d8131d813..1c9c9188e44 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -70,6 +70,8 @@ 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
+#define LOCK_MOVIECLIP 7
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 405b7fad1ee..a424c2ac169 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -149,4 +149,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/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index d1734151b4a..f01777bdce1 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -387,7 +387,7 @@ static void build_skip_links(BVHTree *tree, BVHNode *node, BVHNode *left, BVHNod
/*
* BVHTree bounding volumes functions
*/
-static void create_kdop_hull(BVHTree *tree, BVHNode *node, float *co, int numpoints, int moving)
+static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int numpoints, int moving)
{
float newminmax;
float *bv = node->bv;
@@ -973,7 +973,7 @@ void BLI_bvhtree_balance(BVHTree *tree)
//bvhtree_info(tree);
}
-int BLI_bvhtree_insert(BVHTree *tree, int index, float *co, int numpoints)
+int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints)
{
int i;
BVHNode *node = NULL;
@@ -1005,7 +1005,7 @@ int BLI_bvhtree_insert(BVHTree *tree, int index, float *co, int numpoints)
// call before BLI_bvhtree_update_tree()
-int BLI_bvhtree_update_node(BVHTree *tree, int index, float *co, float *co_moving, int numpoints)
+int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const float *co_moving, int numpoints)
{
int i;
BVHNode *node= NULL;
@@ -1194,7 +1194,7 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
}
//Determines the nearest point of the given node BV. Returns the squared distance to that point.
-static float calc_nearest_point(const float *proj, BVHNode *node, float *nearest)
+static float calc_nearest_point(const float proj[3], BVHNode *node, float *nearest)
{
int i;
const float *bv = node->bv;
@@ -1212,7 +1212,7 @@ static float calc_nearest_point(const float *proj, BVHNode *node, float *nearest
/*
//nearest on a general hull
- VECCOPY(nearest, data->co);
+ copy_v3_v3(nearest, data->co);
for(i = data->tree->start_axis; i != data->tree->stop_axis; i++, bv+=2)
{
float proj = dot_v3v3( nearest, KDOP_AXES[i]);
@@ -1221,11 +1221,11 @@ static float calc_nearest_point(const float *proj, BVHNode *node, float *nearest
if(dl > 0)
{
- VECADDFAC(nearest, nearest, KDOP_AXES[i], dl);
+ madd_v3_v3fl(nearest, KDOP_AXES[i], dl);
}
else if(du < 0)
{
- VECADDFAC(nearest, nearest, KDOP_AXES[i], du);
+ madd_v3_v3fl(nearest, KDOP_AXES[i], du);
}
}
*/
@@ -1377,7 +1377,7 @@ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node)
#endif
-int BLI_bvhtree_find_nearest(BVHTree *tree, const float *co, BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
+int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
{
int i;
@@ -1510,7 +1510,7 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node)
{
data->hit.index = node->index;
data->hit.dist = dist;
- VECADDFAC(data->hit.co, data->ray.origin, data->ray.direction, dist);
+ madd_v3_v3v3fl(data->hit.co, data->ray.origin, data->ray.direction, dist);
}
}
else
@@ -1553,7 +1553,7 @@ static void iterative_raycast(BVHRayCastData *data, BVHNode *node)
{
data->hit.index = node->index;
data->hit.dist = dist;
- VECADDFAC(data->hit.co, data->ray.origin, data->ray.direction, dist);
+ madd_v3_v3v3fl(data->hit.co, data->ray.origin, data->ray.direction, dist);
}
node = node->skip[1];
@@ -1566,7 +1566,7 @@ static void iterative_raycast(BVHRayCastData *data, BVHNode *node)
}
#endif
-int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
+int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
{
int i;
BVHRayCastData data;
@@ -1577,8 +1577,8 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float
data.callback = callback;
data.userdata = userdata;
- VECCOPY(data.ray.origin, co);
- VECCOPY(data.ray.direction, dir);
+ copy_v3_v3(data.ray.origin, co);
+ copy_v3_v3(data.ray.direction, dir);
data.ray.radius = radius;
normalize_v3(data.ray.direction);
@@ -1620,7 +1620,7 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float
return data.hit.index;
}
-float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, float *pos)
+float BLI_bvhtree_bb_raycast(float *bv, const float light_start[3], const float light_end[3], float pos[3])
{
BVHRayCastData data;
float dist = 0.0;
@@ -1639,13 +1639,13 @@ float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, fl
data.ray.origin[2] = light_start[2];
normalize_v3(data.ray.direction);
- VECCOPY(data.ray_dot_axis, data.ray.direction);
+ copy_v3_v3(data.ray_dot_axis, data.ray.direction);
dist = ray_nearest_hit(&data, bv);
if(dist > 0.0f)
{
- VECADDFAC(pos, light_start, data.ray.direction, dist);
+ madd_v3_v3v3fl(pos, light_start, data.ray.direction, dist);
}
return dist;
@@ -1706,7 +1706,7 @@ static void dfs_range_query(RangeQueryData *data, BVHNode *node)
}
}
-int BLI_bvhtree_range_query(BVHTree *tree, const float *co, float radius, BVHTree_RangeQuery callback, void *userdata)
+int BLI_bvhtree_range_query(BVHTree *tree, const float co[3], float radius, BVHTree_RangeQuery callback, void *userdata)
{
BVHNode * root = tree->nodes[tree->totleaf];
diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c
index 1d7dfbde934..2afa17cb4e1 100644
--- a/source/blender/blenlib/intern/bpath.c
+++ b/source/blender/blenlib/intern/bpath.c
@@ -363,7 +363,7 @@ static int rewrite_path_alloc(char **path, BPathVisitor visit_cb, const char *ab
void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int flag, void *bpath_user_data)
{
Image *ima;
- const char *absbase= (flag & BPATH_TRAVERSE_ABS) ? (id->lib ? id->lib->filepath : bmain->name) : NULL;
+ const char *absbase= (flag & BPATH_TRAVERSE_ABS) ? ID_BLEND_PATH(bmain, id) : NULL;
if ((flag & BPATH_TRAVERSE_SKIP_LIBRARY) && id->lib) {
return;
@@ -501,6 +501,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/graph.c b/source/blender/blenlib/intern/graph.c
index 6dd278ed777..d0d3d0e137e 100644
--- a/source/blender/blenlib/intern/graph.c
+++ b/source/blender/blenlib/intern/graph.c
@@ -823,14 +823,14 @@ static void testAxialSymmetry(BGraph *graph, BNode* root_node, BNode* node1, BNo
}
/* mirror node2 along axis */
- VECCOPY(p, node2->p);
+ copy_v3_v3(p, node2->p);
BLI_mirrorAlongAxis(p, root_node->p, nor);
/* check if it's within limit before continuing */
if (len_v3v3(node1->p, p) <= limit)
{
/* mark node as symmetric physically */
- VECCOPY(root_node->symmetry_axis, nor);
+ copy_v3_v3(root_node->symmetry_axis, nor);
root_node->symmetry_flag |= SYM_PHYSICAL;
root_node->symmetry_flag |= SYM_AXIAL;
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/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index c460b69679b..1c7d131c750 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -78,6 +78,28 @@ MINLINE void copy_v4_v4(float r[4], const float a[4])
}
/* short */
+MINLINE void copy_v2_v2_char(char r[2], const char a[2])
+{
+ r[0]= a[0];
+ r[1]= a[1];
+}
+
+MINLINE void copy_v3_v3_char(char r[3], const char a[3])
+{
+ r[0]= a[0];
+ r[1]= a[1];
+ r[2]= a[2];
+}
+
+MINLINE void copy_v4_v4_char(char r[4], const char a[4])
+{
+ r[0]= a[0];
+ r[1]= a[1];
+ r[2]= a[2];
+ r[3]= a[3];
+}
+
+/* short */
MINLINE void copy_v2_v2_short(short r[2], const short a[2])
{
r[0]= a[0];
@@ -99,6 +121,28 @@ MINLINE void copy_v4_v4_short(short r[4], const short a[4])
r[3]= a[3];
}
+/* int */
+MINLINE void copy_v2_v2_int(int r[2], const int a[2])
+{
+ r[0]= a[0];
+ r[1]= a[1];
+}
+
+MINLINE void copy_v3_v3_int(int r[3], const int a[3])
+{
+ r[0]= a[0];
+ r[1]= a[1];
+ r[2]= a[2];
+}
+
+MINLINE void copy_v4_v4_int(int r[4], const int a[4])
+{
+ r[0]= a[0];
+ r[1]= a[1];
+ r[2]= a[2];
+ r[3]= a[3];
+}
+
MINLINE void swap_v2_v2(float a[2], float b[2])
{
SWAP(float, a[0], b[0]);
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index e03a7baca0c..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 */
@@ -1397,22 +1404,51 @@ int BLI_testextensie_glob(const char *str, const char *ext_fnmatch)
int BLI_replace_extension(char *path, size_t maxlen, const char *ext)
{
+ size_t path_len= strlen(path);
+ size_t ext_len= strlen(ext);
size_t a;
- for(a=strlen(path); a>0; a--) {
- if(path[a-1] == '.' || path[a-1] == '/' || path[a-1] == '\\') {
- a--;
+ for(a= path_len - 1; a >= 0; a--) {
+ if (ELEM3(path[a], '.', '/', '\\')) {
break;
}
}
-
- if(path[a] != '.')
- a= strlen(path);
- if(a + strlen(ext) >= maxlen)
+ if(a + ext_len >= maxlen)
+ return 0;
+
+ memcpy(path+a, ext, ext_len + 1);
+ return 1;
+}
+
+/* strip's trailing '.'s and adds the extension only when needed */
+int BLI_ensure_extension(char *path, size_t maxlen, const char *ext)
+{
+ size_t path_len= strlen(path);
+ size_t ext_len= strlen(ext);
+ size_t a;
+
+ /* first check the extension is alread there */
+ if ( (ext_len <= path_len) &&
+ (strcmp(path + (path_len - ext_len), ext) == 0))
+ {
+ return 1;
+ }
+
+ for(a= path_len - 1; a >= 0; a--) {
+ if (path[a] == '.') {
+ path[a]= '\0';
+ }
+ else {
+ break;
+ }
+ }
+ a++;
+
+ if(a + ext_len >= maxlen)
return 0;
- strcpy(path+a, ext);
+ memcpy(path+a, ext, ext_len + 1);
return 1;
}
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 c049ab85546..8247b861a7a 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -113,6 +113,8 @@ 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_mutex_t _movieclip_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_t mainid;
static int thread_levels= 0; /* threads can be invoked inside threads */
@@ -347,6 +349,10 @@ 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);
+ else if (type==LOCK_MOVIECLIP)
+ pthread_mutex_lock(&_movieclip_lock);
}
void BLI_unlock_thread(int type)
@@ -363,6 +369,10 @@ 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);
+ else if(type==LOCK_MOVIECLIP)
+ pthread_mutex_unlock(&_movieclip_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 */