Previously, it was only possible to bake to disk with geometry nodes. This patch adds support for storing the baked data directly in the .blend file. By default, new bakes are stored in the .blend file now. Whether a new bake should be packed or stored on disk can be configured in two places: in the properties of the bake node and in the bake panel of the modifier. These settings don't affect existing bakes, only the next bake. To unpack or pack an individual bake, there is a new operator button next to the bake button. The icon and the label below indicate where the bake is currently stored. The label now also contains the size of the bake. To unpack or pack all bakes, the `File > External Data > Pack Resources / Unpack Resources` operators can be used. The unpack operator also has a new title that mentions the number if individual files separate from the number of bakes. This works better than just listing a number of files because a bake can consist of many files. Pull Request: https://projects.blender.org/blender/blender/pulls/124230
92 lines
1.9 KiB
C++
92 lines
1.9 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include <cmath>
|
|
|
|
#include "BLI_assert.h"
|
|
#include "BLI_hash.hh"
|
|
#include "BLI_math_base.h"
|
|
#include "BLI_struct_equality_utils.hh"
|
|
|
|
namespace blender {
|
|
|
|
/**
|
|
* Contains an integer frame number and a subframe float in the range [0, 1).
|
|
*/
|
|
struct SubFrame {
|
|
private:
|
|
int frame_;
|
|
float subframe_;
|
|
|
|
public:
|
|
SubFrame(const int frame = 0, float subframe = 0.0f) : frame_(frame), subframe_(subframe)
|
|
{
|
|
BLI_assert(subframe >= 0.0f);
|
|
BLI_assert(subframe < 1.0f);
|
|
}
|
|
|
|
SubFrame(const float frame) : SubFrame(int(floorf(frame)), fractf(frame)) {}
|
|
|
|
int frame() const
|
|
{
|
|
return frame_;
|
|
}
|
|
|
|
float subframe() const
|
|
{
|
|
return subframe_;
|
|
}
|
|
|
|
explicit operator float() const
|
|
{
|
|
return float(frame_) + float(subframe_);
|
|
}
|
|
|
|
explicit operator double() const
|
|
{
|
|
return double(frame_) + double(subframe_);
|
|
}
|
|
|
|
static SubFrame min()
|
|
{
|
|
return {INT32_MIN, 0.0f};
|
|
}
|
|
|
|
static SubFrame max()
|
|
{
|
|
return {INT32_MAX, std::nexttowardf(1.0f, 0.0)};
|
|
}
|
|
|
|
uint64_t hash() const
|
|
{
|
|
return get_default_hash(frame_, subframe_);
|
|
}
|
|
|
|
BLI_STRUCT_EQUALITY_OPERATORS_2(SubFrame, frame_, subframe_)
|
|
|
|
friend bool operator<(const SubFrame &a, const SubFrame &b)
|
|
{
|
|
return a.frame_ < b.frame_ || (a.frame_ == b.frame_ && a.subframe_ < b.subframe_);
|
|
}
|
|
|
|
friend bool operator<=(const SubFrame &a, const SubFrame &b)
|
|
{
|
|
return a.frame_ <= b.frame_ || (a.frame_ == b.frame_ && a.subframe_ <= b.subframe_);
|
|
}
|
|
|
|
friend bool operator>(const SubFrame &a, const SubFrame &b)
|
|
{
|
|
return a.frame_ > b.frame_ || (a.frame_ == b.frame_ && a.subframe_ > b.subframe_);
|
|
}
|
|
|
|
friend bool operator>=(const SubFrame &a, const SubFrame &b)
|
|
{
|
|
return a.frame_ >= b.frame_ || (a.frame_ == b.frame_ && a.subframe_ >= b.subframe_);
|
|
}
|
|
};
|
|
|
|
} // namespace blender
|