From 2b0cc73ef6088a0e9856bc181c6492198c44ca96 Mon Sep 17 00:00:00 2001 From: Pratik Borhade Date: Fri, 30 May 2025 06:32:08 +0200 Subject: [PATCH] Modifiers: Change softbody fuzzy default value Set fuzzy=1 when softbody modifier is added. As of now, value is 0, this raises concern of division by zero so bump it to 1. Updated `softbody_test.blend` to fix the failing test. Resolves #137849 Pull Request: https://projects.blender.org/blender/blender/pulls/137878 --- source/blender/blenkernel/BKE_blender_version.h | 2 +- source/blender/blenkernel/intern/softbody.cc | 1 + source/blender/blenloader/intern/versioning_450.cc | 8 ++++++++ tests/files/physics/softbody_test.blend | 4 ++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 2176a8db160..f27d557c473 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -27,7 +27,7 @@ /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 82 +#define BLENDER_FILE_SUBVERSION 83 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and cancel loading the file, showing a warning to diff --git a/source/blender/blenkernel/intern/softbody.cc b/source/blender/blenkernel/intern/softbody.cc index c5af4090da7..2dee8200373 100644 --- a/source/blender/blenkernel/intern/softbody.cc +++ b/source/blender/blenkernel/intern/softbody.cc @@ -3140,6 +3140,7 @@ SoftBody *sbNew() sb->maxloops = 300; sb->choke = 3; + sb->fuzzyness = 1; sb_new_scratch(sb); /* TODO: backward file compatibility should set `sb->shearstiff = 1.0f` while reading old files. */ diff --git a/source/blender/blenloader/intern/versioning_450.cc b/source/blender/blenloader/intern/versioning_450.cc index a2e72766f6f..6851001ce8c 100644 --- a/source/blender/blenloader/intern/versioning_450.cc +++ b/source/blender/blenloader/intern/versioning_450.cc @@ -15,6 +15,7 @@ #include "DNA_defaults.h" #include "DNA_light_types.h" #include "DNA_mesh_types.h" +#include "DNA_object_force_types.h" #include "DNA_sequence_types.h" #include "BLI_listbase.h" @@ -6094,6 +6095,13 @@ void blo_do_versions_450(FileData * /*fd*/, Library * /*lib*/, Main *bmain) } } + if (!MAIN_VERSION_FILE_ATLEAST(bmain, 405, 83)) { + LISTBASE_FOREACH (Object *, ob, &bmain->objects) { + if (ob->soft) { + ob->soft->fuzzyness = std::max(1, ob->soft->fuzzyness); + } + } + } /* Always run this versioning (keep at the bottom of the function). Meshes are written with the * legacy format which always needs to be converted to the new format on file load. To be moved * to a subversion check in 5.0. */ diff --git a/tests/files/physics/softbody_test.blend b/tests/files/physics/softbody_test.blend index 18d37fb5f1d..4ddfff80be4 100644 --- a/tests/files/physics/softbody_test.blend +++ b/tests/files/physics/softbody_test.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2bd2c2a520cb0be78c1cf27aa5d584617f2d22c0a446bdb264a16872a7085b42 -size 580770 +oid sha256:4769c79f02b4d07cdcefdf834211e5b0208f3be26ce619c2863de32bb306e0bc +size 1300230