Geometry Nodes: new Bake node #115466
|
@ -63,12 +63,12 @@ std::optional<std::string> get_modifier_bake_path(const Main &bmain,
|
|||
if (bmain_path.is_empty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
if (StringRef(nmd.simulation_bake_directory).is_empty()) {
|
||||
if (StringRef(nmd.bake_directory).is_empty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
const char *base_path = ID_BLEND_PATH(&bmain, &object.id);
|
||||
char absolute_bake_dir[FILE_MAX];
|
||||
STRNCPY(absolute_bake_dir, nmd.simulation_bake_directory);
|
||||
STRNCPY(absolute_bake_dir, nmd.bake_directory);
|
||||
BLI_path_abs(absolute_bake_dir, base_path);
|
||||
return absolute_bake_dir;
|
||||
}
|
||||
|
|
|
@ -538,14 +538,14 @@ static void bake_simulation_validate_paths(bContext *C,
|
|||
}
|
||||
|
||||
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
|
||||
if (StringRef(nmd->simulation_bake_directory).is_empty()) {
|
||||
if (StringRef(nmd->bake_directory).is_empty()) {
|
||||
BKE_reportf(op->reports,
|
||||
RPT_INFO,
|
||||
"Bake directory of object %s, modifier %s is empty, setting default path",
|
||||
object->id.name + 2,
|
||||
md->name);
|
||||
|
||||
nmd->simulation_bake_directory = BLI_strdup(
|
||||
nmd->bake_directory = BLI_strdup(
|
||||
bake::get_default_modifier_bake_directory(*bmain, *object, *nmd).c_str());
|
||||
}
|
||||
}
|
||||
|
@ -573,12 +573,12 @@ static PathUsersMap bake_simulation_get_path_users(bContext *C, const Span<Objec
|
|||
continue;
|
||||
}
|
||||
const NodesModifierData *nmd = reinterpret_cast<const NodesModifierData *>(md);
|
||||
if (StringRef(nmd->simulation_bake_directory).is_empty()) {
|
||||
if (StringRef(nmd->bake_directory).is_empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
char absolute_bake_dir[FILE_MAX];
|
||||
STRNCPY(absolute_bake_dir, nmd->simulation_bake_directory);
|
||||
STRNCPY(absolute_bake_dir, nmd->bake_directory);
|
||||
BLI_path_abs(absolute_bake_dir, base_path);
|
||||
path_users.add_or_modify(
|
||||
absolute_bake_dir, [](int *value) { *value = 1; }, [](int *value) { ++(*value); });
|
||||
|
@ -726,7 +726,7 @@ static int delete_baked_simulation_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int bake_single_simulation_exec(bContext *C, wmOperator *op)
|
||||
static int bake_single_node_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
@ -747,9 +747,9 @@ static int bake_single_simulation_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
NodesModifierData &nmd = *reinterpret_cast<NodesModifierData *>(md);
|
||||
|
||||
if (StringRef(nmd.simulation_bake_directory).is_empty()) {
|
||||
if (StringRef(nmd.bake_directory).is_empty()) {
|
||||
const std::string directory = bake::get_default_modifier_bake_directory(*bmain, *object, nmd);
|
||||
nmd.simulation_bake_directory = BLI_strdup(directory.c_str());
|
||||
nmd.bake_directory = BLI_strdup(directory.c_str());
|
||||
}
|
||||
|
||||
const int bake_id = RNA_int_get(op->ptr, "bake_id");
|
||||
|
@ -787,9 +787,7 @@ static int bake_single_simulation_exec(bContext *C, wmOperator *op)
|
|||
return start_bake_job(C, std::move(objects_to_bake), op);
|
||||
}
|
||||
|
||||
static int bake_single_simulation_modal(bContext *C,
|
||||
wmOperator * /*op*/,
|
||||
const wmEvent * /*event*/)
|
||||
static int bake_single_node_modal(bContext *C, wmOperator * /*op*/, const wmEvent * /*event*/)
|
||||
{
|
||||
if (!WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_BAKE_SIMULATION_NODES)) {
|
||||
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
|
||||
|
@ -882,8 +880,8 @@ void OBJECT_OT_simulation_nodes_cache_bake_single(wmOperatorType *ot)
|
|||
ot->description = "Bake a single simulation zone";
|
||||
ot->idname = "OBJECT_OT_simulation_nodes_cache_bake_single";
|
||||
|
||||
ot->exec = bake_single_simulation_exec;
|
||||
ot->modal = bake_single_simulation_modal;
|
||||
ot->exec = bake_single_node_exec;
|
||||
ot->modal = bake_single_node_modal;
|
||||
|
||||
WM_operator_properties_id_lookup(ot, false);
|
||||
|
||||
|
|
|
@ -2355,7 +2355,7 @@ typedef struct NodesModifierData {
|
|||
/**
|
||||
* Directory where baked simulation states are stored. This may be relative to the .blend file.
|
||||
*/
|
||||
char *simulation_bake_directory;
|
||||
char *bake_directory;
|
||||
/** NodesModifierFlag. */
|
||||
int8_t flag;
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ DNA_STRUCT_RENAME_ELEM(MovieTrackingTrack, pat_min, pat_min_legacy)
|
|||
DNA_STRUCT_RENAME_ELEM(MovieTrackingTrack, search_max, search_max_legacy)
|
||||
DNA_STRUCT_RENAME_ELEM(MovieTrackingTrack, search_min, search_min_legacy)
|
||||
DNA_STRUCT_RENAME_ELEM(NodeCryptomatte, num_inputs, inputs_num)
|
||||
DNA_STRUCT_RENAME_ELEM(NodesModifierData, simulation_bake_directory, bake_directory)
|
||||
DNA_STRUCT_RENAME_ELEM(Object, col, color)
|
||||
DNA_STRUCT_RENAME_ELEM(Object, dup_group, instance_collection)
|
||||
DNA_STRUCT_RENAME_ELEM(Object, dupfacesca, instance_faces_scale)
|
||||
|
|
|
@ -7125,7 +7125,7 @@ static void rna_def_modifier_nodes(BlenderRNA *brna)
|
|||
RNA_def_property_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_update(prop, 0, "rna_NodesModifier_node_group_update");
|
||||
|
||||
prop = RNA_def_property(srna, "simulation_bake_directory", PROP_STRING, PROP_DIRPATH);
|
||||
prop = RNA_def_property(srna, "bake_directory", PROP_STRING, PROP_DIRPATH);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Simulation Bake Directory", "Location on disk where the bake data is stored");
|
||||
RNA_def_property_update(prop, 0, nullptr);
|
||||
|
|
|
@ -1803,7 +1803,7 @@ static void internal_dependencies_panel_draw(const bContext * /*C*/, Panel *pane
|
|||
uiLayout *col = uiLayoutColumn(layout, false);
|
||||
uiLayoutSetPropSep(col, true);
|
||||
uiLayoutSetPropDecorate(col, false);
|
||||
uiItemR(col, ptr, "simulation_bake_directory", UI_ITEM_NONE, IFACE_("Bake"), ICON_NONE);
|
||||
uiItemR(col, ptr, "bake_directory", UI_ITEM_NONE, IFACE_("Bake"), ICON_NONE);
|
||||
|
||||
geo_log::GeoTreeLog *tree_log = get_root_tree_log(*nmd);
|
||||
if (tree_log == nullptr) {
|
||||
|
@ -1893,7 +1893,7 @@ static void blend_write(BlendWriter *writer, const ID * /*id_owner*/, const Modi
|
|||
|
||||
BLO_write_struct(writer, NodesModifierData, nmd);
|
||||
|
||||
BLO_write_string(writer, nmd->simulation_bake_directory);
|
||||
BLO_write_string(writer, nmd->bake_directory);
|
||||
|
||||
if (nmd->settings.properties != nullptr) {
|
||||
Map<IDProperty *, IDPropertyUIDataBool *> boolean_props;
|
||||
|
@ -1938,7 +1938,7 @@ static void blend_write(BlendWriter *writer, const ID * /*id_owner*/, const Modi
|
|||
static void blend_read(BlendDataReader *reader, ModifierData *md)
|
||||
{
|
||||
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
|
||||
BLO_read_data_address(reader, &nmd->simulation_bake_directory);
|
||||
BLO_read_data_address(reader, &nmd->bake_directory);
|
||||
if (nmd->node_group == nullptr) {
|
||||
nmd->settings.properties = nullptr;
|
||||
}
|
||||
|
@ -1979,15 +1979,13 @@ static void copy_data(const ModifierData *md, ModifierData *target, const int fl
|
|||
/* Share the simulation cache between the original and evaluated modifier. */
|
||||
tnmd->runtime->cache = nmd->runtime->cache;
|
||||
/* Keep bake path in the evaluated modifier. */
|
||||
tnmd->simulation_bake_directory = nmd->simulation_bake_directory ?
|
||||
BLI_strdup(nmd->simulation_bake_directory) :
|
||||
nullptr;
|
||||
tnmd->bake_directory = nmd->bake_directory ? BLI_strdup(nmd->bake_directory) : nullptr;
|
||||
}
|
||||
else {
|
||||
tnmd->runtime->cache = std::make_shared<bake::ModifierCache>();
|
||||
update_existing_bake_caches(*tnmd);
|
||||
/* Clear the bake path when duplicating. */
|
||||
tnmd->simulation_bake_directory = nullptr;
|
||||
tnmd->bake_directory = nullptr;
|
||||
}
|
||||
|
||||
if (nmd->settings.properties != nullptr) {
|
||||
|
@ -2008,7 +2006,7 @@ static void free_data(ModifierData *md)
|
|||
}
|
||||
MEM_SAFE_FREE(nmd->bakes);
|
||||
|
||||
MEM_SAFE_FREE(nmd->simulation_bake_directory);
|
||||
MEM_SAFE_FREE(nmd->bake_directory);
|
||||
MEM_delete(nmd->runtime);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue