Clear the cache bake directory when duplicating a modifier

Duplicating will otherwise keep the same bake directory, which causes
a path conflict and requires manual fixing by users. Clearing the path
on copy makes it so the default path is generated on baking.

This does not change the path when doing internal copies, like
- Depsgraph "evaluated" object vs "original"
- Appending or linking objects
- Making a linked object local

Pull Request: https://projects.blender.org/blender/blender/pulls/109014
This commit is contained in:
Lukas Tönne
2023-06-15 17:40:38 +02:00
parent 0ab58864f3
commit 8fa56a4d19

View File

@@ -2069,13 +2069,16 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
/* Share the simulation cache between the original and evaluated modifier. */
tnmd->simulation_cache = MEM_new<blender::bke::sim::ModifierSimulationCachePtr>(
__func__, *nmd->simulation_cache);
/* Keep bake path in the evaluated modifier. */
tnmd->simulation_bake_directory = nmd->simulation_bake_directory ?
BLI_strdup(nmd->simulation_bake_directory) :
nullptr;
}
else {
tnmd->simulation_cache = new_simulation_cache();
/* Clear the bake path when duplicating. */
tnmd->simulation_bake_directory = nullptr;
}
tnmd->simulation_bake_directory = nmd->simulation_bake_directory ?
BLI_strdup(nmd->simulation_bake_directory) :
nullptr;
if (nmd->settings.properties != nullptr) {
tnmd->settings.properties = IDP_CopyProperty_ex(nmd->settings.properties, flag);