[Bf-blender-cvs] [65166e145b4] master: Cleanup: Remove scene frame macros (`CFRA` et al.)

Julian Eisel noreply at git.blender.org
Thu Jun 30 18:44:33 CEST 2022


Commit: 65166e145b4d6292abc289b71894c53b25c186ba
Author: Julian Eisel
Date:   Thu Jun 30 18:36:42 2022 +0200
Branches: master
https://developer.blender.org/rB65166e145b4d6292abc289b71894c53b25c186ba

Cleanup: Remove scene frame macros (`CFRA` et al.)

Removes the following macros for scene/render frame values:
- `CFRA`
- `SUBFRA`
- `SFRA`
- `EFRA`

These macros don't add much, other than saving a few characters when typing.
It's not immediately clear what they refer to, they just hide what they
actually access. Just be explicit and clear about that.
Plus these macros gave read and write access to the variables, so eyesores like
this would be done (eyesore because it looks like assigning to a constant):
```
CFRA = some_frame_nbr;
```

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D15311

===================================================================

M	source/blender/blenkernel/intern/gpencil_curve.c
M	source/blender/blenkernel/intern/gpencil_geom.cc
M	source/blender/blenkernel/intern/image.cc
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenkernel/intern/sound.c
M	source/blender/draw/engines/eevee/eevee_engine.c
M	source/blender/draw/engines/overlay/overlay_extra.c
M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/animation/anim_draw.c
M	source/blender/editors/animation/anim_markers.c
M	source/blender/editors/animation/anim_motion_paths.c
M	source/blender/editors/animation/anim_ops.c
M	source/blender/editors/animation/keyframes_edit.c
M	source/blender/editors/animation/keyframes_general.c
M	source/blender/editors/animation/keyframing.c
M	source/blender/editors/armature/pose_lib.c
M	source/blender/editors/armature/pose_lib_2.c
M	source/blender/editors/armature/pose_slide.c
M	source/blender/editors/armature/pose_transform.c
M	source/blender/editors/gpencil/annotate_draw.c
M	source/blender/editors/gpencil/annotate_paint.c
M	source/blender/editors/gpencil/editaction_gpencil.c
M	source/blender/editors/gpencil/gpencil_add_blank.c
M	source/blender/editors/gpencil/gpencil_add_monkey.c
M	source/blender/editors/gpencil/gpencil_add_stroke.c
M	source/blender/editors/gpencil/gpencil_bake_animation.cc
M	source/blender/editors/gpencil/gpencil_convert.c
M	source/blender/editors/gpencil/gpencil_data.c
M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/gpencil/gpencil_fill.c
M	source/blender/editors/gpencil/gpencil_interpolate.c
M	source/blender/editors/gpencil/gpencil_merge.c
M	source/blender/editors/gpencil/gpencil_mesh.cc
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_primitive.c
M	source/blender/editors/gpencil/gpencil_sculpt_paint.c
M	source/blender/editors/gpencil/gpencil_select.c
M	source/blender/editors/io/io_alembic.c
M	source/blender/editors/io/io_gpencil_export.c
M	source/blender/editors/io/io_gpencil_import.c
M	source/blender/editors/io/io_obj.c
M	source/blender/editors/mask/mask_add.c
M	source/blender/editors/mask/mask_draw.c
M	source/blender/editors/mask/mask_editaction.c
M	source/blender/editors/mask/mask_ops.c
M	source/blender/editors/mask/mask_shapekey.c
M	source/blender/editors/object/object_add.cc
M	source/blender/editors/physics/particle_edit.c
M	source/blender/editors/physics/physics_fluid.c
M	source/blender/editors/render/render_opengl.cc
M	source/blender/editors/render/render_preview.cc
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/space_action/action_edit.c
M	source/blender/editors/space_action/action_select.c
M	source/blender/editors/space_action/space_action.c
M	source/blender/editors/space_clip/clip_draw.c
M	source/blender/editors/space_clip/clip_editor.c
M	source/blender/editors/space_clip/clip_graph_ops.c
M	source/blender/editors/space_clip/clip_ops.c
M	source/blender/editors/space_clip/clip_utils.c
M	source/blender/editors/space_clip/tracking_ops.c
M	source/blender/editors/space_clip/tracking_ops_track.c
M	source/blender/editors/space_graph/graph_edit.c
M	source/blender/editors/space_graph/graph_ops.c
M	source/blender/editors/space_graph/graph_select.c
M	source/blender/editors/space_image/image_buttons.c
M	source/blender/editors/space_image/image_draw.c
M	source/blender/editors/space_image/image_ops.c
M	source/blender/editors/space_nla/nla_edit.c
M	source/blender/editors/space_nla/nla_select.c
M	source/blender/editors/space_nla/space_nla.c
M	source/blender/editors/space_node/drawnode.cc
M	source/blender/editors/space_sequencer/sequencer_add.c
M	source/blender/editors/space_sequencer/sequencer_edit.c
M	source/blender/editors/space_sequencer/sequencer_select.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/space_view3d/view3d_gizmo_ruler.c
M	source/blender/editors/space_view3d/view3d_utils.c
M	source/blender/editors/transform/transform_convert_action.c
M	source/blender/editors/transform/transform_convert_armature.c
M	source/blender/editors/transform/transform_convert_gpencil.c
M	source/blender/editors/transform/transform_convert_graph.c
M	source/blender/editors/transform/transform_convert_mask.c
M	source/blender/editors/transform/transform_convert_nla.c
M	source/blender/editors/transform/transform_convert_object.c
M	source/blender/editors/transform/transform_convert_sequencer.c
M	source/blender/editors/transform/transform_convert_sequencer_image.c
M	source/blender/editors/transform/transform_mode_timescale.c
M	source/blender/editors/transform/transform_snap_object.cc
M	source/blender/editors/transform/transform_snap_sequencer.c
M	source/blender/editors/util/ed_util_imbuf.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencilshrinkwrap.c
M	source/blender/io/gpencil/intern/gpencil_io_capi.cc
M	source/blender/io/wavefront_obj/exporter/obj_exporter.cc
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/sequencer/intern/strip_relations.c
M	source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c

===================================================================

diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c
index 20b8342f090..d68b322e4c5 100644
--- a/source/blender/blenkernel/intern/gpencil_curve.c
+++ b/source/blender/blenkernel/intern/gpencil_curve.c
@@ -501,7 +501,7 @@ void BKE_gpencil_convert_curve(Main *bmain,
   }
 
   /* Check if there is an active frame and add if needed. */
-  bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_ADD_COPY);
+  bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, scene->r.cfra, GP_GETFRAME_ADD_COPY);
 
   /* Read all splines of the curve and create a stroke for each. */
   LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc
index 0445a1540c7..d0075a7d161 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.cc
+++ b/source/blender/blenkernel/intern/gpencil_geom.cc
@@ -2706,7 +2706,7 @@ bool BKE_gpencil_convert_mesh(Main *bmain,
       gpl_fill = BKE_gpencil_layer_addnew(gpd, element_name, true, false);
     }
     bGPDframe *gpf_fill = BKE_gpencil_layer_frame_get(
-        gpl_fill, CFRA + frame_offset, GP_GETFRAME_ADD_NEW);
+        gpl_fill, scene->r.cfra + frame_offset, GP_GETFRAME_ADD_NEW);
     int i;
     for (i = 0; i < mpoly_len; i++) {
       const MPoly *mp = &mpoly[i];
@@ -2781,7 +2781,7 @@ bool BKE_gpencil_convert_mesh(Main *bmain,
     gpl_stroke = BKE_gpencil_layer_addnew(gpd, element_name, true, false);
   }
   bGPDframe *gpf_stroke = BKE_gpencil_layer_frame_get(
-      gpl_stroke, CFRA + frame_offset, GP_GETFRAME_ADD_NEW);
+      gpl_stroke, scene->r.cfra + frame_offset, GP_GETFRAME_ADD_NEW);
 
   gpencil_generate_edgeloops(ob_eval,
                              gpd,
diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc
index afde8893b93..0c4dc3c87f3 100644
--- a/source/blender/blenkernel/intern/image.cc
+++ b/source/blender/blenkernel/intern/image.cc
@@ -1582,7 +1582,7 @@ static void stampdata(
   }
 
   if (use_dynamic && scene->r.stamp & R_STAMP_MARKER) {
-    const char *name = BKE_scene_find_last_marker_name(scene, CFRA);
+    const char *name = BKE_scene_find_last_marker_name(scene, scene->r.cfra);
 
     if (name) {
       STRNCPY(text, name);
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 21217a7f9bf..5d8025dce8a 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -2920,7 +2920,7 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
     BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
   }
   else if (after) {
-    BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, CFRA);
+    BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, scene->r.cfra);
   }
 
   return (reset || clear || after);
@@ -3162,8 +3162,8 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
   PTCacheID *pid = &baker->pid;
   PointCache *cache = NULL;
   float frameleno = scene->r.framelen;
-  int cfrao = CFRA;
-  int startframe = MAXFRAME, endframe = baker->anim_init ? scene->r.sfra : CFRA;
+  int cfrao = scene->r.cfra;
+  int startframe = MAXFRAME, endframe = baker->anim_init ? scene->r.sfra : scene->r.cfra;
   int bake = baker->bake;
   int render = baker->render;
 
@@ -3270,7 +3270,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
     }
   }
 
-  CFRA = startframe;
+  scene->r.cfra = startframe;
   scene->r.framelen = 1.0;
 
   /* bake */
@@ -3282,21 +3282,21 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
 
   stime = ptime = PIL_check_seconds_timer();
 
-  for (int fr = CFRA; fr <= endframe; fr += baker->quick_step, CFRA = fr) {
+  for (int fr = scene->r.cfra; fr <= endframe; fr += baker->quick_step, scene->r.cfra = fr) {
     BKE_scene_graph_update_for_newframe(depsgraph);
 
     if (baker->update_progress) {
-      float progress = ((float)(CFRA - startframe) / (float)(endframe - startframe));
+      float progress = ((float)(scene->r.cfra - startframe) / (float)(endframe - startframe));
       baker->update_progress(baker->bake_job, progress, &cancel);
     }
 
     if (G.background) {
-      printf("bake: frame %d :: %d\n", CFRA, endframe);
+      printf("bake: frame %d :: %d\n", scene->r.cfra, endframe);
     }
     else {
       ctime = PIL_check_seconds_timer();
 
-      fetd = (ctime - ptime) * (endframe - CFRA) / baker->quick_step;
+      fetd = (ctime - ptime) * (endframe - scene->r.cfra) / baker->quick_step;
 
       if (use_timer || fetd > 60.0) {
         use_timer = true;
@@ -3307,7 +3307,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
 
         printf("Baked for %s, current frame: %i/%i (%.3fs), ETC: %s\r",
                run,
-               CFRA - startframe + 1,
+               scene->r.cfra - startframe + 1,
                endframe - startframe + 1,
                ctime - ptime,
                etd);
@@ -3321,7 +3321,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
       break;
     }
 
-    CFRA += 1;
+    scene->r.cfra += 1;
   }
 
   if (use_timer) {
@@ -3330,7 +3330,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
     printf("\nBake %s %s (%i frames simulated).\n",
            (cancel ? "canceled after" : "finished in"),
            run,
-           CFRA - startframe);
+           scene->r.cfra - startframe);
   }
 
   /* clear baking flag */
@@ -3379,7 +3379,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
   }
 
   scene->r.framelen = frameleno;
-  CFRA = cfrao;
+  scene->r.cfra = cfrao;
 
   if (bake) { /* already on cfra unless baking */
     BKE_scene_graph_update_for_newframe(depsgraph);
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 343a829cf76..f459b5a82ac 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -804,7 +804,7 @@ void BKE_sound_set_scene_volume(Scene *scene, float volume)
   }
   AUD_Sequence_setAnimationData(scene->sound_scene,
                                 AUD_AP_VOLUME,
-                                CFRA,
+                                scene->r.cfra,
                                 &volume,
                                 (scene->audio.flag & AUDIO_VOLUME_ANIMATED) != 0);
 }
@@ -855,7 +855,7 @@ static double get_cur_time(Scene *scene)
   /* We divide by the current framelen to take into account time remapping.
    * Otherwise we will get the wrong starting time which will break A/V sync.
    * See T74111 for further details. */
-  return FRA2TIME((CFRA + SUBFRA) / (double)scene->r.framelen);
+  return FRA2TIME((scene->r.cfra + scene->r.subframe) / (double)scene->r.framelen);
 }
 
 void BKE_sound_play_scene(Scene *scene)
@@ -911,7 +911,7 @@ void BKE_sound_seek_scene(Main *bmain, Scene *scene)
   int animation_playing;
 
   const double one_frame = 1.0 / FPS;
-  const double cur_time = FRA2TIME(CFRA);
+  const double cur_time = FRA2TIME(scene->r.cfra);
 
   AUD_Device_lock(sound_device);
 
@@ -1131,13 +1131,13 @@ static void sound_update_base(Scene *scene, Object *object, void *new_set)
 
         mat4_to_quat(quat, object->obmat);
         AUD_SequenceEntry_setAnimationData(
-            strip->speaker_handle, AUD_AP_LOCATION, CFRA, object->obmat[3], 1);
+            strip->speaker_handle, AUD_AP_LOCATION, scene->r.cfra, object->obmat[3], 1);
         AUD_SequenceEntry_setAnimationData(
-            strip->speaker_handle, AUD_AP_ORIENTATION, CFRA, quat, 1);
+            strip->speaker_handle, AUD_AP_ORIENTATION, scene->r.cfra, quat, 1);
         AUD_SequenceEntry_setAnimationData(
-            strip->speaker_handle, AUD_AP_VOLUME, CFRA, &speaker->volume, 1);
+            strip->speaker_handle, AUD_AP_VOLUME, scene->r.cfra, &speaker->volume, 1);
         AUD_SequenceEntry_setAnimationData(
-            strip->speaker_handle, AUD_AP_PITCH, CFRA, &speaker->pitch, 1);
+            strip->speaker_handle, AUD_AP_PITCH, scene->r.cfra, &speaker->pitch, 1);
         AUD_SequenceEntry_setSound(strip->speaker_handle, speaker->sound->playback_handle);
         AUD_SequenceEntry_setMuted(strip->speaker_handle, mute);
       }
@@ -1172,8 +1172,8 @@ void BKE_sound_update_scene(Depsgraph *depsgraph, Scene *scene)
   if (scene->camera) {
     mat4_to_quat(quat, scene->camera->obmat);
     AUD_Sequence_setAnimationData(
-        scene->sound_scene, AUD_AP_LOCATION, CFRA, scene->camera->obmat[3], 1);
-    AUD_Sequence_setAnimationData(scene->sound_scene, AUD_AP_ORIENTATION, CFRA, quat, 1);
+        scene->sound_scene, AUD_AP_LOCATION, scene->r.cfra, scene->camera->obmat[3], 1);
+    AUD_Sequence_setAnimationData(scene->sound_scene, AUD_AP_ORIENTATION, scene->r.cfra, quat, 1);
   }
 
   AUD_destroySet(scene->speaker_handles);
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index 0cdeeaf314f..ffe0863fb9f 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -451,8 +451,8 @@ static void eevee_render_to_image(void *vedata,
   }
   EEVEE_PrivateData *g_data = ved->stl->g_data;
 
-  int initial_frame = CFRA;
-  float initial_subframe = SUBFRA;
+  int initial_frame = scene->r.cfra;
+  float initial_subframe = scene->r.subframe;
   float shuttertime = (do_motion_blur) ? scene->eevee.motion_blur_shutter : 0.0f;
   int time_steps_tot = (do_motion_blur) ? max_ii(1, scene->eevee.motion_blur_steps) : 1;
   g_data->render_timesteps = time_steps_tot;
@@ -588,7 +588,7 @@ static void eevee_render_to_image(void *vedata,
   /* Restore original viewport size. */
   DRW_render_viewport_size_set((int[2]){g_data->size_orig[0], g_data->size_orig[1]});
 
-  if (CFRA != initial_frame || SUBFRA != initial_subframe) {
+  if (scene->r.cfra != initial_frame || scene->r.subframe != initial_subframe) {
     /* Restore original frame number. This is because the render pipeline expects it. */
     RE_engine_frame_set(engine, initial_frame, initial_subframe);
   }
diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c
index f875254a685..9d478310104 100644
--- a/source/blender/draw/engines/overlay/overlay_extra.c
+++

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list