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:
authorCampbell Barton <ideasman42@gmail.com>2011-11-11 10:25:45 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-11 10:25:45 +0400
commit92d35b74e79e63ae95732cf3161e84ace1e79e59 (patch)
tree19a8ecf74bfcae5187a4e25520f4e55384e7707b /source/blender/blenlib
parent67386c003d5d4bd5355323acdfbef1aa9fa2b71d (diff)
parentafeb0eeaf0e8caf5e46a5dd6fbea3786e9fb1354 (diff)
svn merge -r41722:41723 ^/trunk/blender
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h1
-rw-r--r--source/blender/blenlib/BLI_threads.h4
-rw-r--r--source/blender/blenlib/intern/math_geom.c15
-rw-r--r--source/blender/blenlib/intern/threads.c14
4 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index bc2d501645d..569b107df2e 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -60,6 +60,7 @@ int is_quad_convex_v3(const float *v1, const float *v2, const float *v3, const f
float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2]);
float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2]);
+void closest_to_line_segment_v2(float closest[2], const float p[2], const float l1[2], const float l2[2]);
float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]);
float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]);
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index 6dd666842d0..d77640ccdb1 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -56,6 +56,10 @@ void BLI_remove_threads(struct ListBase *threadbase);
void BLI_end_threads (struct ListBase *threadbase);
int BLI_thread_is_main(void);
+
+void BLI_begin_threaded_malloc(void);
+void BLI_end_threaded_malloc(void);
+
/* System Information */
int BLI_system_thread_count(void); /* gets the number of threads the system can make use of */
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 21f82353ac2..13f46747259 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -207,6 +207,21 @@ float dist_to_line_segment_v2(const float v1[2], const float v2[2], const float
return sqrtf(rc[0]*rc[0]+ rc[1]*rc[1]);
}
+/* point closest to v1 on line v2-v3 in 2D */
+void closest_to_line_segment_v2(float closest[2], const float p[2], const float l1[2], const float l2[2])
+{
+ float lambda, cp[2];
+
+ lambda= closest_to_line_v2(cp,p, l1, l2);
+
+ if(lambda <= 0.0f)
+ copy_v2_v2(closest, l1);
+ else if(lambda >= 1.0f)
+ copy_v2_v2(closest, l2);
+ else
+ copy_v2_v2(closest, cp);
+}
+
/* point closest to v1 on line v2-v3 in 3D */
void closest_to_line_segment_v3(float closest[3], const float v1[3], const float v2[3], const float v3[3])
{
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 22c71189d90..299a85f8207 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -674,3 +674,17 @@ void BLI_thread_queue_nowait(ThreadQueue *queue)
pthread_mutex_unlock(&queue->mutex);
}
+void BLI_begin_threaded_malloc(void)
+{
+ if(thread_levels == 0) {
+ MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread);
+ }
+ thread_levels++;
+}
+
+void BLI_end_threaded_malloc(void)
+{
+ thread_levels--;
+ if(thread_levels==0)
+ MEM_set_lock_callback(NULL, NULL);
+} \ No newline at end of file