Merge branch 'blender2.7'
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 19 Mar 2019 17:54:17 +0000 (18:54 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 19 Mar 2019 17:54:17 +0000 (18:54 +0100)
1  2 
intern/cycles/blender/addon/operators.py
intern/cycles/blender/blender_python.cpp
intern/cycles/blender/blender_session.cpp
intern/cycles/blender/blender_util.h

@@@ -393,25 -379,12 +393,16 @@@ static void add_cryptomatte_layer(BL::R
        render_add_metadata(b_rr, prefix+"manifest", manifest);
  }
  
- /* TODO(sergey): Ideally this will be an utility function in util string.h, but
-  * currently is relying on Blender side function, so can not do that. */
- static string make_human_readable_time(double time)
- {
-       char time_str[128];
-       BLI_timecode_string_from_time_simple(time_str, sizeof(time_str), time);
-       return time_str;
- }
 -void BlenderSession::stamp_view_layer_metadata_do(const string& prefix)
 +void BlenderSession::stamp_view_layer_metadata(Scene *scene, const string& view_layer_name)
  {
        BL::RenderResult b_rr = b_engine.get_result();
 +      string prefix = "cycles." + view_layer_name + ".";
 +
        /* Configured number of samples for the view layer. */
 -      b_rr.stamp_data_add_field((prefix + "samples").c_str(),
 -                                to_string(session->params.samples).c_str());
 +      b_rr.stamp_data_add_field(
 +              (prefix + "samples").c_str(),
 +              to_string(session->params.samples).c_str());
 +
        /* Store ranged samples information. */
        if(session->tile_manager.range_num_samples != -1) {
                b_rr.stamp_data_add_field(
                        (prefix + "range_num_samples").c_str(),
                        to_string(session->tile_manager.range_num_samples).c_str());
        }
 -}
  
 -void BlenderSession::stamp_view_layer_metadata(const string& view_layer_name)
 -{
 -      stamp_view_layer_metadata_do("cycles." + view_layer_name + ".");
 +      /* Write cryptomatte metadata. */
 +      if(scene->film->cryptomatte_passes & CRYPT_OBJECT) {
 +              add_cryptomatte_layer(b_rr, view_layer_name + ".CryptoObject",
 +                                    scene->object_manager->get_cryptomatte_objects(scene));
 +      }
 +      if(scene->film->cryptomatte_passes & CRYPT_MATERIAL) {
 +              add_cryptomatte_layer(b_rr, view_layer_name + ".CryptoMaterial",
 +                                    scene->shader_manager->get_cryptomatte_materials(scene));
 +      }
 +      if(scene->film->cryptomatte_passes & CRYPT_ASSET) {
 +              add_cryptomatte_layer(b_rr, view_layer_name + ".CryptoAsset",
 +                                    scene->object_manager->get_cryptomatte_assets(scene));
 +      }
 +
 +      /* Store synchronization and bare-render times. */
 +      double total_time, render_time;
 +      session->progress.get_time(total_time, render_time);
 +      b_rr.stamp_data_add_field((prefix + "total_time").c_str(),
-                                 make_human_readable_time(total_time).c_str());
++                                time_human_readable_from_seconds(total_time).c_str());
 +      b_rr.stamp_data_add_field((prefix + "render_time").c_str(),
-                                 make_human_readable_time(render_time).c_str());
++                                time_human_readable_from_seconds(render_time).c_str());
 +      b_rr.stamp_data_add_field((prefix + "synchronization_time").c_str(),
-                                 make_human_readable_time(total_time - render_time).c_str());
++                                time_human_readable_from_seconds(total_time - render_time).c_str());
  }
  
 -void BlenderSession::render()
 +void BlenderSession::render(BL::Depsgraph& b_depsgraph_)
  {
 +      b_depsgraph = b_depsgraph_;
 +
        /* set callback to write out render results */
        session->write_render_tile_cb = function_bind(&BlenderSession::write_render_tile, this, _1);
        session->update_render_tile_cb = function_bind(&BlenderSession::update_render_tile, this, _1, _2);
@@@ -1011,10 -957,9 +1002,9 @@@ void BlenderSession::update_bake_progre
  void BlenderSession::update_status_progress()
  {
        string timestatus, status, substatus, kernel_status;
 -      string scene = "";
 +      string scene_status = "";
        float progress;
        double total_time, remaining_time = 0, render_time;
-       char time_str[128];
        float mem_used = (float)session->stats.mem_used / 1024.0f / 1024.0f;
        float mem_peak = (float)session->stats.mem_peak / 1024.0f / 1024.0f;
  
                remaining_time = (1.0 - (double)progress) * (render_time / (double)progress);
  
        if(background) {
 -              scene += " | " + b_scene.name();
 +              scene_status += " | " + scene->name;
                if(b_rlay_name != "")
 -                      scene += ", "  + b_rlay_name;
 +                      scene_status += ", "  + b_rlay_name;
  
                if(b_rview_name != "")
 -                      scene += ", " + b_rview_name;
 -      }
 -      else {
 -              timestatus = "Time:" + time_human_readable_from_seconds(total_time) + " | ";
 -      }
 +                      scene_status += ", " + b_rview_name;
  
 -      if(remaining_time > 0) {
 -              timestatus += "Remaining:" + time_human_readable_from_seconds(remaining_time) + " | ";
 -      }
 +              if(remaining_time > 0) {
-                       BLI_timecode_string_from_time_simple(time_str, sizeof(time_str), remaining_time);
-                       timestatus += "Remaining:" + string(time_str) + " | ";
++                      timestatus += "Remaining:" + time_human_readable_from_seconds(remaining_time) + " | ";
 +              }
  
 -      timestatus += string_printf("Mem:%.2fM, Peak:%.2fM", (double)mem_used, (double)mem_peak);
 +              timestatus += string_printf("Mem:%.2fM, Peak:%.2fM", (double)mem_used, (double)mem_peak);
  
 -      if(status.size() > 0)
 -              status = " | " + status;
 -      if(substatus.size() > 0)
 -              status += " | " + substatus;
 -      if(kernel_status.size() > 0)
 -              status += " | " + kernel_status;
 +              if(status.size() > 0)
 +                      status = " | " + status;
 +              if(substatus.size() > 0)
 +                      status += " | " + substatus;
 +              if(kernel_status.size() > 0)
 +                      status += " | " + kernel_status;
 +      }
  
        double current_time = time_dt();
        /* When rendering in a window, redraw the status at least once per second to keep the elapsed and remaining time up-to-date.
@@@ -32,8 -32,7 +32,7 @@@
   * todo: clean this up ... */
  
  extern "C" {
- size_t BLI_timecode_string_from_time_simple(char *str, size_t maxlen, double time_seconds);
 -void BKE_image_user_frame_calc(void *iuser, int cfra, int fieldnr);
 +void BKE_image_user_frame_calc(void *iuser, int cfra);
  void BKE_image_user_file_path(void *iuser, void *ima, char *path);
  unsigned char *BKE_image_get_pixels_for_frame(void *image, int frame);
  float *BKE_image_get_float_pixels_for_frame(void *image, int frame);