batch remove .'s used with RNA_def_struct_ui_text
[blender.git] / source / blender / editors / physics / physics_fluid.c
index 7893b314e3e0dfbd72525e0383098183e7139f71..144682536a7c2a3e4219db2e822e0f3f1335ecc6 100644 (file)
 /* enable/disable overall compilation */
 #ifndef DISABLE_ELBEEM
 
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+/* ************** libgomp (Apple gcc 4.2.1) TLS bug workaround *************** */
+#include <pthread.h>
+extern pthread_key_t gomp_tls_key;
+static void *thread_tls_data;
+#endif
+
+
 /* XXX */
 /* from header info.c */
 static int start_progress_bar(void) {return 0;};
-static void end_progress_bar(void) {};
+static void end_progress_bar(wmWindow *win) {WM_cursor_restore(win);};
 static void waitcursor(int val) {};
-static int progress_bar(float done, char *busy_info) {return 0;}
+static int progress_bar(wmWindow *win, float done, char *busy_info) { WM_timecursor(win,done*100); return 0;}
 static int pupmenu() {return 0;}
 /* XXX */
 
@@ -320,6 +328,11 @@ static void *fluidsimSimulateThread(void *unused) { // *ptr) {
        //char* fnameCfgPath = (char*)(ptr);
        int ret=0;
        
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+       // Workaround for Apple gcc 4.2.1 omp vs background thread bug
+       pthread_setspecific (gomp_tls_key, thread_tls_data);
+#endif
+
        ret = elbeemSimulate();
        BLI_lock_thread(LOCK_CUSTOM1);
        if(globalBakeState==0) {
@@ -1036,13 +1049,18 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *ob)
                // set to neutral, -1 means user abort, -2 means init error
                globalBakeState = 0;
                globalBakeFrame = 0;
+               
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+               // Workaround for Apple gcc 4.2.1 omp vs background thread bug
+               thread_tls_data = pthread_getspecific(gomp_tls_key);
+#endif
                BLI_init_threads(&threads, fluidsimSimulateThread, 1);
                BLI_insert_thread(&threads, targetFile);
                
                {
                        int done = 0;
                        float noFramesf = (float)noFrames;
-                       float percentdone = 0.0;
+                       float percentdone = 0.0, oldpercentdone = -1.0;
                        int lastRedraw = -1;
                        
                        g_break= 0;
@@ -1057,11 +1075,15 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *ob)
                                
                                // lukep we add progress bar as an interim mesure
                                percentdone = globalBakeFrame / noFramesf;
-                               sprintf(busy_mess, "baking fluids %d / %d       |||", globalBakeFrame, (int) noFramesf);
-                               progress_bar(percentdone, busy_mess );
+                               if (percentdone != oldpercentdone) {
+                                       sprintf(busy_mess, "baking fluids %d / %d       |||", globalBakeFrame, (int) noFramesf);
+                                       percentdone = percentdone < 0.0 ? 0.0:percentdone;
+                                       progress_bar(CTX_wm_window(C), percentdone, busy_mess );
+                                       oldpercentdone = percentdone;
+                               }
                                
-                               // longer delay to prevent frequent redrawing
-                               PIL_sleep_ms(2000);
+                               //XXX no more need for longer delay to prevent frequent redrawing
+                               PIL_sleep_ms(200);
                                
                                BLI_lock_thread(LOCK_CUSTOM1);
                                if(globalBakeState != 0) done = 1; // 1=ok, <0=error/abort
@@ -1103,7 +1125,7 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *ob)
 #endif
                                } // redraw
                        }
-                       end_progress_bar();
+                       end_progress_bar(CTX_wm_window(C));
                }
                BLI_end_threads(&threads);
        } // El'Beem API init, thread creation 
@@ -1195,7 +1217,7 @@ void FLUID_OT_bake(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Fluid Simulation Bake";
-       ot->description= "Bake fluid simulation.";
+       ot->description= "Bake fluid simulation";
        ot->idname= "FLUID_OT_bake";
        
        /* api callbacks */