diff options
author | Miika Hamalainen <blender@miikah.org> | 2011-11-10 14:24:34 +0400 |
---|---|---|
committer | Miika Hamalainen <blender@miikah.org> | 2011-11-10 14:24:34 +0400 |
commit | afeb0eeaf0e8caf5e46a5dd6fbea3786e9fb1354 (patch) | |
tree | 36ab74ff3fa36d27c0f35527d3b55e68e3d27fe5 /source/blender/blenlib | |
parent | 1e035381d10068eb17345a88d42cebc0d579adf3 (diff) | |
parent | 1b4a54ad73c058baa59ffdc9e5f18b0b79030fb0 (diff) |
Dynamic Paint merge:
Commit Dynamic Paint from "soc-2011-carrot" branch into trunk.
End-user documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Modifiers/Simulation/Dynamic_Paint
GSoC wiki page:
http://wiki.blender.org/index.php/User:MiikaH/GSoC-2011-DynamicPaint
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_geom.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_threads.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 15 | ||||
-rw-r--r-- | source/blender/blenlib/intern/threads.c | 14 |
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 713466f13f8..8a42414ea9f 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -58,6 +58,7 @@ float area_poly_v3(int nr, float verts[][3], const float normal[3]); 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 1c9c9188e44..a513b9f9e85 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 b79ae9f0042..99ead8e9d6a 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 8247b861a7a..38b3fe669b6 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -669,3 +669,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 |