d1c2b45836
Blob stands for "binary large object" and is a known term. I used to use the term `bdata`
to mean "binary data", mainly because I didn't think of a better name. Blob is a much
better name as it captures the intend of those files much better.
This change breaks existing bakes, because I rename the folder from `bdata` to `blobs`.
I think that is ok, because I also just broke bakes two days ago in a larger refactor
(e92c59bc9b).
Pull Request: https://projects.blender.org/blender/blender/pulls/111822
85 lines
2.5 KiB
C++
85 lines
2.5 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include "BKE_bake_items_paths.hh"
|
|
#include "BKE_bake_items_serialize.hh"
|
|
#include "BKE_geometry_set.hh"
|
|
|
|
#include "BLI_map.hh"
|
|
#include "BLI_sub_frame.hh"
|
|
|
|
struct bNodeTree;
|
|
struct ModifierData;
|
|
struct NodesModifierData;
|
|
struct Main;
|
|
|
|
namespace blender::bke::sim {
|
|
|
|
enum class CacheState {
|
|
/** The cache is up-to-date with the inputs. */
|
|
Valid,
|
|
/**
|
|
* Nodes or input values have changed since the cache was created, i.e. the output would be
|
|
* different if the simulation was run again.
|
|
*/
|
|
Invalid,
|
|
/** The cache has been baked and will not be invalidated by changing inputs. */
|
|
Baked,
|
|
};
|
|
|
|
struct SimulationZoneFrameCache {
|
|
SubFrame frame;
|
|
BakeState state;
|
|
/** Used when the baked data is loaded lazily. */
|
|
std::optional<std::string> meta_path;
|
|
};
|
|
|
|
struct SimulationZonePrevState {
|
|
BakeState state;
|
|
SubFrame frame;
|
|
};
|
|
|
|
struct SimulationZoneCache {
|
|
Vector<std::unique_ptr<SimulationZoneFrameCache>> frame_caches;
|
|
std::optional<SimulationZonePrevState> prev_state;
|
|
|
|
std::optional<std::string> blobs_dir;
|
|
std::unique_ptr<BlobSharing> blob_sharing;
|
|
bool failed_finding_bake = false;
|
|
CacheState cache_state = CacheState::Valid;
|
|
|
|
void reset();
|
|
};
|
|
|
|
class ModifierSimulationCache {
|
|
public:
|
|
mutable std::mutex mutex;
|
|
Map<int, std::unique_ptr<SimulationZoneCache>> cache_by_zone_id;
|
|
};
|
|
|
|
/**
|
|
* Reset all simulation caches in the scene, for use when some fundamental change made them
|
|
* impossible to reuse.
|
|
*/
|
|
void scene_simulation_states_reset(Scene &scene);
|
|
|
|
std::optional<bake_paths::BakePath> get_simulation_zone_bake_path(const Main &bmain,
|
|
const Object &object,
|
|
const NodesModifierData &nmd,
|
|
int zone_id);
|
|
std::optional<std::string> get_modifier_simulation_bake_path(const Main &bmain,
|
|
const Object &object,
|
|
const NodesModifierData &nmd);
|
|
|
|
/**
|
|
* Get the directory that contains all baked simulation data for the given modifier.
|
|
*/
|
|
std::string get_default_modifier_bake_directory(const Main &bmain,
|
|
const Object &object,
|
|
const ModifierData &md);
|
|
|
|
} // namespace blender::bke::sim
|