Listing the "Blender Foundation" as copyright holder implied the Blender Foundation holds copyright to files which may include work from many developers. While keeping copyright on headers makes sense for isolated libraries, Blender's own code may be refactored or moved between files in a way that makes the per file copyright holders less meaningful. Copyright references to the "Blender Foundation" have been replaced with "Blender Authors", with the exception of `./extern/` since these this contains libraries which are more isolated, any changed to license headers there can be handled on a case-by-case basis. Some directories in `./intern/` have also been excluded: - `./intern/cycles/` it's own `AUTHORS` file is planned. - `./intern/opensubdiv/`. An "AUTHORS" file has been added, using the chromium projects authors file as a template. Design task: #110784 Ref !110783.
96 lines
2.0 KiB
C++
96 lines
2.0 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include "BLI_assert.h"
|
|
#include "BLI_math_base.h"
|
|
|
|
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)};
|
|
}
|
|
|
|
friend bool operator==(const SubFrame &a, const SubFrame &b)
|
|
{
|
|
return a.frame_ == b.frame_ && a.subframe_ == b.subframe_;
|
|
}
|
|
|
|
friend bool operator!=(const SubFrame &a, const SubFrame &b)
|
|
{
|
|
return !(a == b);
|
|
}
|
|
|
|
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_);
|
|
}
|
|
|
|
friend std::ostream &operator<<(std::ostream &stream, const SubFrame &a)
|
|
{
|
|
return stream << float(a);
|
|
}
|
|
};
|
|
|
|
} // namespace blender
|