From e73273e24b0d814fccadbdea359d992f0643b7c4 Mon Sep 17 00:00:00 2001 From: Pratik Borhade Date: Thu, 6 Jul 2023 10:55:33 +0200 Subject: [PATCH] Animation: Set hardmin/max for frame start and end of action Currently start and end property of action don't have hardmin/hardmax. This results in an error when exporting action having extreme range values in FBX and gltf formats (#107965). Pull Request: https://projects.blender.org/blender/blender/pulls/107985 --- source/blender/blenkernel/BKE_blender_version.h | 2 +- source/blender/blenkernel/intern/action.c | 4 ++-- source/blender/blenloader/intern/versioning_400.cc | 6 ++++++ source/blender/makesrna/intern/rna_action.cc | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index c171a7e82b9..96edba09c31 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -27,7 +27,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 7 +#define BLENDER_FILE_SUBVERSION 8 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 63d830420d7..ca558d328bf 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1470,8 +1470,8 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_ max += 1.0f; } - *start = min; - *end = max; + *start = max_ff(min, MINAFRAMEF); + *end = min_ff(max, MAXFRAMEF); } else { *start = 0.0f; diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 75f9f9e29c0..7a9b0ffdb09 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -258,6 +258,12 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) } } + if (!MAIN_VERSION_ATLEAST(bmain, 400, 8)) { + LISTBASE_FOREACH (bAction *, act, &bmain->actions) { + act->frame_start = max_ff(act->frame_start, MINAFRAMEF); + act->frame_end = min_ff(act->frame_end, MAXFRAMEF); + } + } /** * Versioning code until next subversion bump goes here. * diff --git a/source/blender/makesrna/intern/rna_action.cc b/source/blender/makesrna/intern/rna_action.cc index 8bd8bea4cea..e7c751714aa 100644 --- a/source/blender/makesrna/intern/rna_action.cc +++ b/source/blender/makesrna/intern/rna_action.cc @@ -921,7 +921,7 @@ static void rna_def_action(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_float_sdna(prop, nullptr, "frame_start"); RNA_def_property_float_funcs(prop, nullptr, "rna_Action_start_frame_set", nullptr); - RNA_def_property_ui_range(prop, MINFRAME, MAXFRAME, 100, 2); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text( prop, "Start Frame", "The start frame of the manually set intended playback range"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr); @@ -930,7 +930,7 @@ static void rna_def_action(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_float_sdna(prop, nullptr, "frame_end"); RNA_def_property_float_funcs(prop, nullptr, "rna_Action_end_frame_set", nullptr); - RNA_def_property_ui_range(prop, MINFRAME, MAXFRAME, 100, 2); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text( prop, "End Frame", "The end frame of the manually set intended playback range"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr);