Cycles: progress printing in background mode, print finished at the end and
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 30 Oct 2011 10:12:34 +0000 (10:12 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 30 Oct 2011 10:12:34 +0000 (10:12 +0000)
avoid duplicate prints.

intern/cycles/blender/blender_session.cpp
intern/cycles/blender/blender_session.h
intern/cycles/render/session.cpp

index c6f016b7971e9c0984360ad3a98ae5dbd844f4f5..4fa878156012f4eb580e2508b99c433904b5312a 100644 (file)
@@ -76,6 +76,10 @@ void BlenderSession::create_session()
        SceneParams scene_params = BlenderSync::get_scene_params(b_scene);
        SessionParams session_params = BlenderSync::get_session_params(b_scene, background);
 
+       /* reset status/progress */
+       last_status= "";
+       last_progress= -1.0f;
+
        /* create scene */
        scene = new Scene(scene_params);
 
@@ -264,8 +268,14 @@ void BlenderSession::update_status_progress()
        if(substatus.size() > 0)
                status += " | " + substatus;
 
-       RE_engine_update_stats((RenderEngine*)b_engine.ptr.data, "", status.c_str());
-       RE_engine_update_progress((RenderEngine*)b_engine.ptr.data, progress);
+       if(status != last_status) {
+               RE_engine_update_stats((RenderEngine*)b_engine.ptr.data, "", status.c_str());
+               last_status = status;
+       }
+       if(progress != last_progress) {
+               RE_engine_update_progress((RenderEngine*)b_engine.ptr.data, progress);
+               last_progress = progress;
+       }
 }
 
 void BlenderSession::tag_update()
index 8608ddd2658f9af0b3ca6dacd59d963b890de38b..e30b60c3d637bedf5d95dc39c90b7ad4343bfbb3 100644 (file)
@@ -70,6 +70,9 @@ public:
        BL::SpaceView3D b_v3d;
        BL::RegionView3D b_rv3d;
 
+       string last_status;
+       float last_progress;
+
        int width, height;
 };
 
index 50f7017bacfd93f6cf03e191c1409f4fcd3b1082..2deb83674cca58ff4be9cf07ceae9555e7ca5b53 100644 (file)
@@ -170,8 +170,10 @@ void Session::run_gpu()
 
                if(params.background) {
                        /* if no work left and in background mode, we can stop immediately */
-                       if(no_tiles)
+                       if(no_tiles) {
+                               progress.set_status("Finished");
                                break;
+                       }
                }
                else {
                        /* if in interactive mode, and we are either paused or done for now,
@@ -305,8 +307,10 @@ void Session::run_cpu()
 
                if(params.background) {
                        /* if no work left and in background mode, we can stop immediately */
-                       if(no_tiles)
+                       if(no_tiles) {
+                               progress.set_status("Finished");
                                break;
+                       }
                }
                else {
                        /* if in interactive mode, and we are either paused or done for now,