Image: Use OpenImageIO for loading and saving a variety of image formats #105785

Merged
Jesse Yurkovich merged 9 commits from deadpin/blender:oiio-land-formats into main 2023-04-12 05:22:39 +02:00
59 changed files with 2543 additions and 1005 deletions
Showing only changes of commit adbdb14ae5 - Show all commits

View File

@ -577,14 +577,14 @@ void LightManager::device_update_tree(Device *,
int stack_id = 0;
const LightTreeNode *node = light_tree.get_root();
for (int index = 0; index < light_tree.size(); index++) {
light_tree_nodes[index].energy = node->energy;
light_tree_nodes[index].energy = node->measure.energy;
light_tree_nodes[index].bbox.min = node->bbox.min;
light_tree_nodes[index].bbox.max = node->bbox.max;
light_tree_nodes[index].bbox.min = node->measure.bbox.min;
light_tree_nodes[index].bbox.max = node->measure.bbox.max;
light_tree_nodes[index].bcone.axis = node->bcone.axis;
light_tree_nodes[index].bcone.theta_o = node->bcone.theta_o;
light_tree_nodes[index].bcone.theta_e = node->bcone.theta_e;
light_tree_nodes[index].bcone.axis = node->measure.bcone.axis;
light_tree_nodes[index].bcone.theta_o = node->measure.bcone.theta_o;
light_tree_nodes[index].bcone.theta_e = node->measure.bcone.theta_e;
light_tree_nodes[index].bit_trail = node->bit_trail;
light_tree_nodes[index].num_prims = node->num_prims;
@ -597,9 +597,9 @@ void LightManager::device_update_tree(Device *,
int emitter_index = i + node->first_prim_index;
LightTreePrimitive &prim = light_prims[emitter_index];
light_tree_emitters[emitter_index].energy = prim.energy;
light_tree_emitters[emitter_index].theta_o = prim.bcone.theta_o;
light_tree_emitters[emitter_index].theta_e = prim.bcone.theta_e;
light_tree_emitters[emitter_index].energy = prim.measure.energy;
light_tree_emitters[emitter_index].theta_o = prim.measure.bcone.theta_o;
light_tree_emitters[emitter_index].theta_e = prim.measure.bcone.theta_e;
if (prim.is_triangle()) {
light_tree_emitters[emitter_index].mesh_light.object_id = prim.object_id;

View File

@ -9,6 +9,10 @@ CCL_NAMESPACE_BEGIN
float OrientationBounds::calculate_measure() const
{
if (this->is_empty()) {
return 0.0f;
}
float theta_w = fminf(M_PI_F, theta_o + theta_e);
float cos_theta_o = cosf(theta_o);
float sin_theta_o = sinf(theta_o);
@ -20,10 +24,10 @@ float OrientationBounds::calculate_measure() const
OrientationBounds merge(const OrientationBounds &cone_a, const OrientationBounds &cone_b)
{
if (is_zero(cone_a.axis)) {
if (cone_a.is_empty()) {
return cone_b;
}
if (is_zero(cone_b.axis)) {
if (cone_b.is_empty()) {
return cone_a;
}
@ -62,9 +66,6 @@ OrientationBounds merge(const OrientationBounds &cone_a, const OrientationBounds
LightTreePrimitive::LightTreePrimitive(Scene *scene, int prim_id, int object_id)
: prim_id(prim_id), object_id(object_id)
{
bcone = OrientationBounds::empty;
bbox = BoundBox::empty;
if (is_triangle()) {
float3 vertices[3];
Object *object = scene->objects[object_id];
@ -88,7 +89,7 @@ LightTreePrimitive::LightTreePrimitive(Scene *scene, int prim_id, int object_id)
/* TODO: need a better way to handle this when textures are used. */
float area = triangle_area(vertices[0], vertices[1], vertices[2]);
energy = area * average(shader->emission_estimate);
measure.energy = area * average(shader->emission_estimate);
/* NOTE: the original implementation used the bounding box centroid, but primitive centroid
* seems to work fine */
@ -98,24 +99,25 @@ LightTreePrimitive::LightTreePrimitive(Scene *scene, int prim_id, int object_id)
const bool is_back_only = (shader->emission_sampling == EMISSION_SAMPLING_BACK);
if (is_front_only || is_back_only) {
/* One-sided. */
bcone.axis = safe_normalize(cross(vertices[1] - vertices[0], vertices[2] - vertices[0]));
measure.bcone.axis = safe_normalize(
cross(vertices[1] - vertices[0], vertices[2] - vertices[0]));
if (is_back_only) {
bcone.axis = -bcone.axis;
measure.bcone.axis = -measure.bcone.axis;
}
if (transform_negative_scale(object->get_tfm())) {
bcone.axis = -bcone.axis;
measure.bcone.axis = -measure.bcone.axis;
}
bcone.theta_o = 0;
measure.bcone.theta_o = 0;
}
else {
/* Double sided: any vector in the plane. */
bcone.axis = safe_normalize(vertices[0] - vertices[1]);
bcone.theta_o = M_PI_2_F;
measure.bcone.axis = safe_normalize(vertices[0] - vertices[1]);
measure.bcone.theta_o = M_PI_2_F;
}
bcone.theta_e = M_PI_2_F;
measure.bcone.theta_e = M_PI_2_F;
for (int i = 0; i < 3; i++) {
bbox.grow(vertices[i]);
measure.bbox.grow(vertices[i]);
}
}
else {
@ -125,74 +127,75 @@ LightTreePrimitive::LightTreePrimitive(Scene *scene, int prim_id, int object_id)
float3 strength = lamp->get_strength();
centroid = scene->lights[object_id]->get_co();
bcone.axis = normalize(lamp->get_dir());
measure.bcone.axis = normalize(lamp->get_dir());
if (type == LIGHT_AREA) {
bcone.theta_o = 0;
bcone.theta_e = lamp->get_spread() * 0.5f;
measure.bcone.theta_o = 0;
measure.bcone.theta_e = lamp->get_spread() * 0.5f;
/* For an area light, sizeu and sizev determine the 2 dimensions of the area light,
* while axisu and axisv determine the orientation of the 2 dimensions.
* We want to add all 4 corners to our bounding box. */
const float3 half_extentu = 0.5f * lamp->get_sizeu() * lamp->get_axisu() * size;
const float3 half_extentv = 0.5f * lamp->get_sizev() * lamp->get_axisv() * size;
bbox.grow(centroid + half_extentu + half_extentv);
bbox.grow(centroid + half_extentu - half_extentv);
bbox.grow(centroid - half_extentu + half_extentv);
bbox.grow(centroid - half_extentu - half_extentv);
measure.bbox.grow(centroid + half_extentu + half_extentv);
measure.bbox.grow(centroid + half_extentu - half_extentv);
measure.bbox.grow(centroid - half_extentu + half_extentv);
measure.bbox.grow(centroid - half_extentu - half_extentv);
strength *= 0.25f; /* eval_fac scaling in `area.h` */
}
else if (type == LIGHT_POINT) {
bcone.theta_o = M_PI_F;
bcone.theta_e = M_PI_2_F;
measure.bcone.theta_o = M_PI_F;
measure.bcone.theta_e = M_PI_2_F;
/* Point and spot lights can emit light from any point within its radius. */
const float3 radius = make_float3(size);
bbox.grow(centroid - radius);
bbox.grow(centroid + radius);
measure.bbox.grow(centroid - radius);
measure.bbox.grow(centroid + radius);
strength *= 0.25f * M_1_PI_F; /* eval_fac scaling in `spot.h` and `point.h` */
}
else if (type == LIGHT_SPOT) {
bcone.theta_o = 0;
measure.bcone.theta_o = 0;
const float unscaled_theta_e = lamp->get_spot_angle() * 0.5f;
const float len_u = len(lamp->get_axisu());
const float len_v = len(lamp->get_axisv());
const float len_w = len(lamp->get_dir());
bcone.theta_e = fast_atanf(fast_tanf(unscaled_theta_e) * fmaxf(len_u, len_v) / len_w);
measure.bcone.theta_e = fast_atanf(fast_tanf(unscaled_theta_e) * fmaxf(len_u, len_v) /
len_w);
/* Point and spot lights can emit light from any point within its radius. */
const float3 radius = make_float3(size);
bbox.grow(centroid - radius);
bbox.grow(centroid + radius);
measure.bbox.grow(centroid - radius);
measure.bbox.grow(centroid + radius);
strength *= 0.25f * M_1_PI_F; /* eval_fac scaling in `spot.h` and `point.h` */
}
else if (type == LIGHT_BACKGROUND) {
/* Set an arbitrary direction for the background light. */
bcone.axis = make_float3(0.0f, 0.0f, 1.0f);
measure.bcone.axis = make_float3(0.0f, 0.0f, 1.0f);
/* TODO: this may depend on portal lights as well. */
bcone.theta_o = M_PI_F;
bcone.theta_e = 0;
measure.bcone.theta_o = M_PI_F;
measure.bcone.theta_e = 0;
/* integrate over cosine-weighted hemisphere */
strength *= lamp->get_average_radiance() * M_PI_F;
}
else if (type == LIGHT_DISTANT) {
bcone.theta_o = 0;
bcone.theta_e = 0.5f * lamp->get_angle();
measure.bcone.theta_o = 0;
measure.bcone.theta_e = 0.5f * lamp->get_angle();
}
if (lamp->get_shader()) {
strength *= lamp->get_shader()->emission_estimate;
}
/* Use absolute value of energy so lights with negative strength are properly
* supported in the light tree. */
energy = fabsf(average(strength));
/* Use absolute value of energy so lights with negative strength are properly supported in the
* light tree. */
measure.energy = fabsf(average(strength));
}
}
@ -208,22 +211,18 @@ LightTree::LightTree(vector<LightTreePrimitive> &prims,
const int num_prims = prims.size();
const int num_local_lights = num_prims - num_distant_lights;
root = create_node(BoundBox::empty, OrientationBounds::empty, 0.0f, 0);
root_ = create_node(LightTreePrimitivesMeasure::empty, 0);
/* All local lights are grouped to the left child as an inner node. */
recursive_build(left, root.get(), 0, num_local_lights, &prims, 0, 1);
recursive_build(left, root_.get(), 0, num_local_lights, &prims, 0, 1);
task_pool.wait_work();
OrientationBounds bcone = OrientationBounds::empty;
float energy_total = 0.0;
/* All distant lights are grouped to the right child as a leaf node. */
root_->children[right] = create_node(LightTreePrimitivesMeasure::empty, 1);
for (int i = num_local_lights; i < num_prims; i++) {
const LightTreePrimitive &prim = prims.at(i);
bcone = merge(bcone, prim.bcone);
energy_total += prim.energy;
root_->children[right]->add(prims[i]);
}
root->children[right] = create_node(BoundBox::empty, bcone, energy_total, 1);
root->children[right]->make_leaf(num_local_lights, num_distant_lights);
root_->children[right]->make_leaf(num_local_lights, num_distant_lights);
}
void LightTree::recursive_build(const Child child,
@ -234,41 +233,21 @@ void LightTree::recursive_build(const Child child,
const uint bit_trail,
const int depth)
{
BoundBox bbox = BoundBox::empty;
OrientationBounds bcone = OrientationBounds::empty;
BoundBox centroid_bounds = BoundBox::empty;
float energy_total = 0.0f;
const int num_prims = end - start;
for (int i = start; i < end; i++) {
const LightTreePrimitive &prim = (*prims)[i];
bbox.grow(prim.bbox);
bcone = merge(bcone, prim.bcone);
centroid_bounds.grow(prim.centroid);
energy_total += prim.energy;
centroid_bounds.grow((*prims)[i].centroid);
}
parent->children[child] = create_node(bbox, bcone, energy_total, bit_trail);
LightTreeNode *current_node = parent->children[child].get();
parent->children[child] = create_node(LightTreePrimitivesMeasure::empty, bit_trail);
LightTreeNode *node = parent->children[child].get();
const bool try_splitting = num_prims > 1 && len(centroid_bounds.size()) > 0.0f;
int split_dim = -1, split_bucket = 0, num_left_prims = 0;
bool should_split = false;
if (try_splitting) {
/* Find the best place to split the primitives into 2 nodes.
* If the best split cost is no better than making a leaf node, make a leaf instead. */
const float min_cost = min_split_saoh(
centroid_bounds, start, end, bbox, bcone, split_dim, split_bucket, num_left_prims, *prims);
should_split = num_prims > max_lights_in_leaf_ || min_cost < energy_total;
}
if (should_split) {
int middle;
/* Find the best place to split the primitives into 2 nodes.
* If the best split cost is no better than making a leaf node, make a leaf instead. */
int split_dim = -1, middle;
if (should_split(*prims, start, middle, end, node->measure, centroid_bounds, split_dim)) {
if (split_dim != -1) {
/* Partition the primitives between start and end based on the split dimension and bucket
* calculated by `split_saoh` */
middle = start + num_left_prims;
/* Partition the primitives between start and end based on the centroids. */
std::nth_element(prims->begin() + start,
prims->begin() + middle,
prims->begin() + end,
@ -276,141 +255,131 @@ void LightTree::recursive_build(const Child child,
return l.centroid[split_dim] < r.centroid[split_dim];
});
}
else {
/* Degenerate case with many lights in the same place. */
middle = (start + end) / 2;
}
/* Recursively build the left branch. */
if (middle - start > MIN_PRIMS_PER_THREAD) {
task_pool.push([=] {
recursive_build(left, current_node, start, middle, prims, bit_trail, depth + 1);
});
task_pool.push(
[=] { recursive_build(left, node, start, middle, prims, bit_trail, depth + 1); });
}
else {
recursive_build(left, current_node, start, middle, prims, bit_trail, depth + 1);
recursive_build(left, node, start, middle, prims, bit_trail, depth + 1);
}
/* Recursively build the right branch. */
if (end - middle > MIN_PRIMS_PER_THREAD) {
task_pool.push([=] {
recursive_build(
right, current_node, middle, end, prims, bit_trail | (1u << depth), depth + 1);
recursive_build(right, node, middle, end, prims, bit_trail | (1u << depth), depth + 1);
});
}
else {
recursive_build(
right, current_node, middle, end, prims, bit_trail | (1u << depth), depth + 1);
recursive_build(right, node, middle, end, prims, bit_trail | (1u << depth), depth + 1);
}
}
else {
current_node->make_leaf(start, num_prims);
node->make_leaf(start, end - start);
}
}
float LightTree::min_split_saoh(const BoundBox &centroid_bbox,
const int start,
const int end,
const BoundBox &bbox,
const OrientationBounds &bcone,
int &split_dim,
int &split_bucket,
int &num_left_prims,
const vector<LightTreePrimitive> &prims)
bool LightTree::should_split(const vector<LightTreePrimitive> &prims,
const int start,
int &middle,
const int end,
LightTreePrimitivesMeasure &measure,
const BoundBox &centroid_bbox,
int &split_dim)
{
/* Even though this factor is used for every bucket, we use it to compare
* the min_cost and total_energy (when deciding between creating a leaf or interior node. */
const float bbox_area = bbox.area();
const bool has_area = bbox_area != 0.0f;
const float total_area = has_area ? bbox_area : len(bbox.size());
const float total_cost = total_area * bcone.calculate_measure();
if (total_cost == 0.0f) {
return FLT_MAX;
}
const float inv_total_cost = 1.0f / total_cost;
middle = (start + end) / 2;
const int num_prims = end - start;
const float3 extent = centroid_bbox.size();
const float max_extent = max4(extent.x, extent.y, extent.z, 0.0f);
/* Check each dimension to find the minimum splitting cost. */
float total_cost = 0.0f;
float min_cost = FLT_MAX;
for (int dim = 0; dim < 3; dim++) {
/* If the centroid bounding box is 0 along a given dimension, skip it. */
if (centroid_bbox.size()[dim] == 0.0f) {
if (centroid_bbox.size()[dim] == 0.0f && dim != 0) {
continue;
}
const float inv_extent = 1 / (centroid_bbox.size()[dim]);
/* Fill in buckets with primitives. */
std::array<LightTreeBucketInfo, LightTreeBucketInfo::num_buckets> buckets;
std::array<LightTreeBucket, LightTreeBucket::num_buckets> buckets;
for (int i = start; i < end; i++) {
const LightTreePrimitive &prim = prims[i];
/* Place primitive into the appropriate bucket,
* where the centroid box is split into equal partitions. */
int bucket_idx = LightTreeBucketInfo::num_buckets *
/* Place primitive into the appropriate bucket, where the centroid box is split into equal
* partitions. */
int bucket_idx = LightTreeBucket::num_buckets *
(prim.centroid[dim] - centroid_bbox.min[dim]) * inv_extent;
if (bucket_idx == LightTreeBucketInfo::num_buckets) {
bucket_idx = LightTreeBucketInfo::num_buckets - 1;
bucket_idx = clamp(bucket_idx, 0, LightTreeBucket::num_buckets - 1);
buckets[bucket_idx].add(prim);
}
/* Precompute the left bucket measure cumulatively. */
std::array<LightTreeBucket, LightTreeBucket::num_buckets - 1> left_buckets;
left_buckets.front() = buckets.front();
for (int i = 1; i < LightTreeBucket::num_buckets - 1; i++) {
left_buckets[i] = left_buckets[i - 1] + buckets[i];
}
if (dim == 0) {
/* Calculate node measure by summing up the bucket measure. */
measure = left_buckets.back().measure + buckets.back().measure;
/* Do not try to split if there are only one primitive. */
if (num_prims < 2) {
return false;
}
buckets[bucket_idx].count++;
buckets[bucket_idx].energy += prim.energy;
buckets[bucket_idx].bbox.grow(prim.bbox);
buckets[bucket_idx].bcone = merge(buckets[bucket_idx].bcone, prim.bcone);
/* Degenerate case with co-located primitives. */
if (is_zero(centroid_bbox.size())) {
break;
}
total_cost = measure.calculate();
if (total_cost == 0.0f) {
break;
}
}
/* Precompute the right bucket measure cumulatively. */
std::array<LightTreeBucket, LightTreeBucket::num_buckets - 1> right_buckets;
right_buckets.back() = buckets.back();
for (int i = LightTreeBucket::num_buckets - 3; i >= 0; i--) {
right_buckets[i] = right_buckets[i + 1] + buckets[i + 1];
}
/* Calculate the cost of splitting at each point between partitions. */
std::array<float, LightTreeBucketInfo::num_buckets - 1> bucket_costs;
float energy_L, energy_R;
BoundBox bbox_L, bbox_R;
OrientationBounds bcone_L, bcone_R;
for (int split = 0; split < LightTreeBucketInfo::num_buckets - 1; split++) {
energy_L = 0;
energy_R = 0;
bbox_L = BoundBox::empty;
bbox_R = BoundBox::empty;
bcone_L = OrientationBounds::empty;
bcone_R = OrientationBounds::empty;
const float regularization = max_extent * inv_extent;
for (int split = 0; split < LightTreeBucket::num_buckets - 1; split++) {
const float left_cost = left_buckets[split].measure.calculate();
const float right_cost = right_buckets[split].measure.calculate();
const float cost = regularization * (left_cost + right_cost);
for (int left = 0; left <= split; left++) {
if (buckets[left].bbox.valid()) {
energy_L += buckets[left].energy;
bbox_L.grow(buckets[left].bbox);
bcone_L = merge(bcone_L, buckets[left].bcone);
}
}
for (int right = split + 1; right < LightTreeBucketInfo::num_buckets; right++) {
if (buckets[right].bbox.valid()) {
energy_R += buckets[right].energy;
bbox_R.grow(buckets[right].bbox);
bcone_R = merge(bcone_R, buckets[right].bcone);
}
}
/* Calculate the cost of splitting using the heuristic as described in the paper. */
const float area_L = has_area ? bbox_L.area() : len(bbox_L.size());
const float area_R = has_area ? bbox_R.area() : len(bbox_R.size());
const float left = (bbox_L.valid()) ? energy_L * area_L * bcone_L.calculate_measure() : 0.0f;
const float right = (bbox_R.valid()) ? energy_R * area_R * bcone_R.calculate_measure() :
0.0f;
const float regularization = max_extent * inv_extent;
bucket_costs[split] = regularization * (left + right) * inv_total_cost;
if (bucket_costs[split] < min_cost) {
min_cost = bucket_costs[split];
if (cost < total_cost && cost < min_cost) {
min_cost = cost;
split_dim = dim;
split_bucket = split;
num_left_prims = 0;
for (int i = 0; i <= split_bucket; i++) {
num_left_prims += buckets[i].count;
}
middle = start + left_buckets[split].count;
}
}
}
return min_cost;
return min_cost < total_cost || num_prims > max_lights_in_leaf_;
}
__forceinline LightTreePrimitivesMeasure operator+(const LightTreePrimitivesMeasure &a,
const LightTreePrimitivesMeasure &b)
{
LightTreePrimitivesMeasure c(a);
c.add(b);
return c;
}
LightTreeBucket operator+(const LightTreeBucket &a, const LightTreeBucket &b)
{
return LightTreeBucket(a.measure + b.measure, a.count + b.count);
}
CCL_NAMESPACE_END

View File

@ -42,6 +42,11 @@ struct OrientationBounds {
{
}
__forceinline bool is_empty() const
{
return is_zero(axis);
}
float calculate_measure() const;
};
@ -53,6 +58,59 @@ OrientationBounds merge(const OrientationBounds &cone_a, const OrientationBounds
* The light tree construction is based on PBRT's BVH construction.
*/
/* Light Tree uses the bounding box, the orientation bounding cone, and the energy of a cluster to
* compute the Surface Area Orientation Heuristic (SAOH). */
struct LightTreePrimitivesMeasure {
BoundBox bbox = BoundBox::empty;
OrientationBounds bcone = OrientationBounds::empty;
float energy = 0.0f;
enum empty_t { empty = 0 };
__forceinline LightTreePrimitivesMeasure() = default;
__forceinline LightTreePrimitivesMeasure(empty_t)
{
}
__forceinline LightTreePrimitivesMeasure(const BoundBox &bbox,
const OrientationBounds &bcone,
const float &energy)
: bbox(bbox), bcone(bcone), energy(energy)
{
}
__forceinline LightTreePrimitivesMeasure(const LightTreePrimitivesMeasure &other)
: bbox(other.bbox), bcone(other.bcone), energy(other.energy)
{
}
__forceinline bool is_zero() const
{
return energy == 0;
}
__forceinline void add(const LightTreePrimitivesMeasure &measure)
{
if (!measure.is_zero()) {
bbox.grow(measure.bbox);
bcone = merge(bcone, measure.bcone);
energy += measure.energy;
}
}
/* Taken from Eq. 2 in the paper. */
__forceinline float calculate()
{
float area = bbox.area();
float area_measure = area == 0 ? len(bbox.size()) : area;
return energy * area_measure * bcone.calculate_measure();
}
};
LightTreePrimitivesMeasure operator+(const LightTreePrimitivesMeasure &a,
const LightTreePrimitivesMeasure &b);
/* Light Tree Primitive
* Struct that indexes into the scene's triangle and light arrays. */
struct LightTreePrimitive {
@ -60,64 +118,69 @@ struct LightTreePrimitive {
* otherwise `-prim_id-1`(`~prim`) is an index into device lights array. */
int prim_id;
int object_id;
float energy;
float3 centroid;
OrientationBounds bcone;
BoundBox bbox;
LightTreePrimitivesMeasure measure;
LightTreePrimitive(Scene *scene, int prim_id, int object_id);
inline bool is_triangle() const
__forceinline bool is_triangle() const
{
return prim_id >= 0;
};
};
/* Light Tree Bucket Info
/* Light Tree Bucket
* Struct used to determine splitting costs in the light BVH. */
struct LightTreeBucketInfo {
LightTreeBucketInfo()
: energy(0.0f), bbox(BoundBox::empty), bcone(OrientationBounds::empty), count(0)
struct LightTreeBucket {
LightTreePrimitivesMeasure measure;
int count = 0;
static const int num_buckets = 12;
LightTreeBucket() = default;
LightTreeBucket(const LightTreePrimitivesMeasure &measure, const int &count)
: measure(measure), count(count)
{
}
float energy; /* Total energy in the partition */
BoundBox bbox;
OrientationBounds bcone;
int count;
static const int num_buckets = 12;
void add(const LightTreePrimitive &prim)
{
measure.add(prim.measure);
count++;
}
};
LightTreeBucket operator+(const LightTreeBucket &a, const LightTreeBucket &b);
/* Light Tree Node */
struct LightTreeNode {
BoundBox bbox;
OrientationBounds bcone;
float energy;
LightTreePrimitivesMeasure measure;
uint bit_trail;
int num_prims = -1; /* The number of primitives a leaf node stores. A negative
number indicates it is an inner node. */
int first_prim_index; /* Leaf nodes contain an index to first primitive. */
unique_ptr<LightTreeNode> children[2]; /* Inner node. */
unique_ptr<LightTreeNode> children[2]; /* Inner node has two chlidren. */
LightTreeNode() = default;
LightTreeNode(const BoundBox &bbox,
const OrientationBounds &bcone,
const float &energy,
const uint &bit_trial)
: bbox(bbox), bcone(bcone), energy(energy), bit_trail(bit_trial)
LightTreeNode(const LightTreePrimitivesMeasure &measure, const uint &bit_trial)
: measure(measure), bit_trail(bit_trial)
{
}
void make_leaf(const uint &first_prim_index, const int &num_prims)
__forceinline void add(const LightTreePrimitive &prim)
{
measure.add(prim.measure);
}
void make_leaf(const int &first_prim_index, const int &num_prims)
{
this->first_prim_index = first_prim_index;
this->num_prims = num_prims;
}
inline bool is_leaf() const
__forceinline bool is_leaf() const
{
return num_prims >= 0;
}
@ -128,8 +191,8 @@ struct LightTreeNode {
* BVH-like data structure that keeps track of lights
* and considers additional orientation and energy information */
class LightTree {
unique_ptr<LightTreeNode> root;
atomic<int> num_nodes = 0;
unique_ptr<LightTreeNode> root_;
std::atomic<int> num_nodes_ = 0;
uint max_lights_in_leaf_;
public:
@ -145,22 +208,20 @@ class LightTree {
int size() const
{
return num_nodes;
return num_nodes_;
};
LightTreeNode *get_root() const
{
return root.get();
return root_.get();
};
/* NOTE: Always use this function to create a new node so the number of nodes is in sync. */
unique_ptr<LightTreeNode> create_node(const BoundBox &bbox,
const OrientationBounds &bcone,
const float &energy,
unique_ptr<LightTreeNode> create_node(const LightTreePrimitivesMeasure &measure,
const uint &bit_trial)
{
num_nodes++;
return make_unique<LightTreeNode>(bbox, bcone, energy, bit_trial);
num_nodes_++;
return make_unique<LightTreeNode>(measure, bit_trial);
}
private:
@ -176,15 +237,14 @@ class LightTree {
vector<LightTreePrimitive> *prims,
uint bit_trail,
int depth);
float min_split_saoh(const BoundBox &centroid_bbox,
int start,
int end,
const BoundBox &bbox,
const OrientationBounds &bcone,
int &split_dim,
int &split_bucket,
int &num_left_prims,
const vector<LightTreePrimitive> &prims);
bool should_split(const vector<LightTreePrimitive> &prims,
const int start,
int &middle,
const int end,
LightTreePrimitivesMeasure &measure,
const BoundBox &centroid_bbox,
int &split_dim);
};
CCL_NAMESPACE_END

View File

@ -28,6 +28,9 @@ https://github.com/intel/llvm#oneapi-dpc-compiler
** Intel® Open Path Guiding Library; version v0.4.1-beta --
http://www.openpgl.org/
** Mantaflow; version 0.13 -- http://mantaflow.com/
** materialX; version 1.38.6 --
https://github.com/AcademySoftwareFoundation/MaterialX
** meson; version 0.63 -- https://github.com/mesonbuild/meson
** oneAPI Threading Building Block; version 2020_U3 --
https://software.intel.com/en-us/oneapi/onetbb
** OpenCL Wrangler; version 27a6867 -- https://github.com/OpenCLWrangler/clew
@ -37,6 +40,9 @@ https://software.intel.com/en-us/oneapi/onetbb
** RangeTree; version 40ebed8aa209 -- https://github.com/ideasman42/rangetree-c
** SDL Extension Wrangler; version 15edf8e --
https://github.com/SDLWrangler/sdlew
** ShaderC; version 2022.3 -- https://github.com/google/shaderc
** Vulkan Loader; version 1.2.198 --
https://github.com/KhronosGroup/Vulkan-Loader
Apache License
@ -251,6 +257,11 @@ limitations under the License.
* For Mantaflow see also this required NOTICE:
MantaFlow fluid solver framework
Copyright 2011 Tobias Pfaff, Nils Thuerey
* For materialX see also this required NOTICE:
Copyright Contributors to the MaterialX Project
* For meson see also this required NOTICE:
Jussi Pakkanen
https://github.com/mesonbuild/meson/blob/master/CODEOWNERS
* For oneAPI Threading Building Block see also this required NOTICE:
Copyright (c) 2005-2020 Intel Corporation
* For OpenCL Wrangler see also this required NOTICE:
@ -270,6 +281,49 @@ limitations under the License.
Copyright (c) 2016, Campbell Barton.
* For SDL Extension Wrangler see also this required NOTICE:
Copyright 2014 Blender Foundation
* For ShaderC see also this required NOTICE:
Copyright 2015 The Shaderc Authors. All rights reserved.
* For Vulkan Loader see also this required NOTICE:
Copyright (c) 2019 The Khronos Group Inc.
Copyright (c) 2019 Valve Corporation
Copyright (c) 2019 LunarG, Inc.
Copyright (c) 2019 Google Inc.
------
** pybind11; version 2.10.1 -- https://github.com/pybind/pybind11
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>, All rights reserved.
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>, All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Please also refer to the file .github/CONTRIBUTING.md, which clarifies
licensing of
external contributions to this project including patches, pull requests, etc.
------
@ -330,20 +384,21 @@ All rights reserved.
Contributors to the OpenEXR Project.
** ISPC; version 1.17.0 -- https://github.com/ispc/ispc
Copyright Intel Corporation
** NumPy; version 1.22.0 -- https://numpy.org/
** NumPy; version 1.23.5 -- https://numpy.org/
Copyright (c) 2005-2021, NumPy Developers.
** Ogg; version 1.3.5 -- https://www.xiph.org/ogg/
COPYRIGHT (C) 1994-2019 by the Xiph.Org Foundation https://www.xiph.org/
** Open Shading Language; version 1.12.6.2 --
** Open Shading Language; version
1.13-dev-1a7670600c8b08c2443a78d03c8c27e9a1149140 --
https://github.com/imageworks/OpenShadingLanguage
Copyright Contributors to the Open Shading Language project.
** OpenColorIO; version 2.1.1 --
** OpenColorIO; version 2.2.0 --
https://github.com/AcademySoftwareFoundation/OpenColorIO
Copyright Contributors to the OpenColorIO Project.
** OpenEXR; version 3.1.5 --
https://github.com/AcademySoftwareFoundation/openexr
Copyright Contributors to the OpenEXR Project. All rights reserved.
** OpenImageIO; version 2.3.20.0 -- http://www.openimageio.org
** OpenImageIO; version 2.4.6.0 -- http://www.openimageio.org
Copyright (c) 2008-present by Contributors to the OpenImageIO project. All
Rights Reserved.
** Pystring; version 1.1.3 -- https://github.com/imageworks/pystring
@ -1533,6 +1588,9 @@ License.
** Eigen, template library for linear algebra: matrices, vectors, numerical
solvers, and related algorithms; version 3.2.7 --
http://eigen.tuxfamily.org/index.php?title=Main_Page
Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>, Copyright
(C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com
This file is part of Eigen, a lightweight C++ template library for linear
algebra.
** Free Spacenav; version 0.2.3 --
@ -2190,8 +2248,557 @@ of this License. But first, please read <http s ://www.gnu.org/ licenses
------
** Fribidi ; version 1.0.12 -- https://github.com/fribidi/fribidi
Behdad Esfahbod <behdad@gnu.org>
#
# Behdad Esfahbod maintained the entire 0.19 series. He designed, and
# implemented most of what is in FriBidi today.
#
Dov Grobgeld <dov.grobgeld@gmail.com>
#
# Dov Grobgeld originally wrote FriBidi. The 0.1.* releases were all done
# by him. After the a long time of not being involved, Dov received
# back the maintenance of the package in time for the 1.0 release.
# He did the entire algorithmic work to support the changes made
# to the Unicode algorithm in the Unicode 6.3 standard.
#
Roozbeh Pournader <roozbeh@gnu.org>
#
# Roozbeh Pournader hasn't contributed much code to FriBidi personally; but
# has maintained, promoted, and supported the project for a while. He has
# helped with making GNU FriBidi standards compliant, and has sometimes
# lobbied with the Unicode Consortium when needed. Roozbeh was supposed to
# be a co-maintainer of GNU FriBidi, but he's not doing that yet.
#
Khaled Hosny <khaledhosny@eglug.org>
#
# Khaled Hosny has done lots of cleanup and autoconfig work.
# Note: Other people have contributed significant amounts of code, but
# usually the code has faded out because of restructuring and redesigning
# things around GNU FriBidi. As an example, the FriBidiEnv patch by Omer
# Zak, made itself into FriBidi CVS for a couple of years, but was finally
# implemented in a better way by Behdad.
#
# Note: GNU getopt is distributed with and used in GNU FriBidi under bin/, but
# is not part of GNU FriBidi.
#
# Note: Parts of the Unicode Character Database are distributed with and used
# in GNU FriBidi under gen.tab/unidata/, but are not part of GNU FriBidi.
#
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
------
** FFmpeg; version 5.1.2 -- http://ffmpeg.org/
-
Copyright: The FFmpeg contributors
https://github.com/FFmpeg/FFmpeg/blob/master/CREDITS
** Libsndfile; version 1.1.0 -- http://libsndfile.github.io/libsndfile/
Copyright (C) 2011-2016 Erik de Castro Lopo <erikd@mega-nerd.com>
@ -2899,7 +3506,71 @@ SOFTWARE.
------
** OpenVDB; version 9.0.0 -- http://www.openvdb.org/
** Harfbuzz; version 5.1.0 -- https://github.com/harfbuzz/harfbuzz
Copyright © 2010-2022 Google, Inc.
Copyright © 2015-2020 Ebrahim Byagowi
Copyright © 2019,2020 Facebook, Inc.
Copyright © 2012,2015 Mozilla Foundation
Copyright © 2011 Codethink Limited
Copyright © 2008,2010 Nokia Corporation and/or its subsidiary(-ies)
Copyright © 2009 Keith Stribley
Copyright © 2011 Martin Hosken and SIL International
Copyright © 2007 Chris Wilson
Copyright © 2005,2006,2020,2021,2022,2023 Behdad Esfahbod
Copyright © 2004,2007,2008,2009,2010,2013,2021,2022,2023 Red Hat, Inc.
Copyright © 1998-2005 David Turner and Werner Lemberg
Copyright © 2016 Igalia S.L.
Copyright © 2022 Matthias Clasen
Copyright © 2018,2021 Khaled Hosny
Copyright © 2018,2019,2020 Adobe, Inc
Copyright © 2013-2015 Alexei Podtelezhnikov
HarfBuzz is licensed under the so-called "Old MIT" license. Details follow.
For parts of HarfBuzz that are licensed under different licenses see individual
files names COPYING in subdirectories where applicable.
Copyright © 2010-2022 Google, Inc.
Copyright © 2015-2020 Ebrahim Byagowi
Copyright © 2019,2020 Facebook, Inc.
Copyright © 2012,2015 Mozilla Foundation
Copyright © 2011 Codethink Limited
Copyright © 2008,2010 Nokia Corporation and/or its subsidiary(-ies)
Copyright © 2009 Keith Stribley
Copyright © 2011 Martin Hosken and SIL International
Copyright © 2007 Chris Wilson
Copyright © 2005,2006,2020,2021,2022,2023 Behdad Esfahbod
Copyright © 2004,2007,2008,2009,2010,2013,2021,2022,2023 Red Hat, Inc.
Copyright © 1998-2005 David Turner and Werner Lemberg
Copyright © 2016 Igalia S.L.
Copyright © 2022 Matthias Clasen
Copyright © 2018,2021 Khaled Hosny
Copyright © 2018,2019,2020 Adobe, Inc
Copyright © 2013-2015 Alexei Podtelezhnikov
For full copyright notices consult the individual files in the package.
Permission is hereby granted, without written agreement and without
license or royalty fees, to use, copy, modify, and distribute this
software and its documentation for any purpose, provided that the
above copyright notice and the following two paragraphs appear in
all copies of this software.
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
------
** OpenVDB; version 10.0.0 -- http://www.openvdb.org/
Copyright Contributors to the OpenVDB Project
Mozilla Public License Version 2.0
@ -3238,6 +3909,32 @@ the Mozilla Public License, v. 2.0.
------
** minizip-ng; version 3.0.7 -- https://github.com/zlib-ng/minizip-ng
Copyright (C) Nathan Moinvaziri
https://github.com/zlib-ng/minizip-ng
Copyright (C) 1998-2010 Gilles Vollant
https://www.winimage.com/zLibDll/minizip.html
Condition of use and distribution are the same as zlib:
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgement in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
------
** Bullet Continuous Collision Detection and Physics Library; version 3.07 --
http://continuousphysics.com/Bullet/
Bullet Continuous Collision Detection and Physics Library
@ -3330,9 +4027,9 @@ Software.
------
** OpenSubdiv; version 3.4.4 -- http://graphics.pixar.com/opensubdiv
** OpenSubdiv; version 3.5.0 -- http://graphics.pixar.com/opensubdiv
Copyright 2013 Pixar
** Universal Scene Description; version 22.03 -- http://www.openusd.org/
** Universal Scene Description; version 22.11 -- http://www.openusd.org/
Copyright 2016 Pixar
Licensed under the Apache License, Version 2.0 (the "Apache License") with the
@ -3377,8 +4074,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------
** Boost C++ Libraries; version 1.78.0 -- https://www.boost.org/
-
** Boost C++ Libraries; version 1.80.0 -- https://www.boost.org/
The Boost license encourages both commercial and non-commercial use and does
not require attribution for binary use.
Boost Software License - Version 1.0 - August 17th, 2003
@ -3542,7 +4240,7 @@ MIT Expat
------
** Python; version 3.10.8 -- https://www.python.org
** Python; version 3.10.9 -- https://www.python.org
Copyright (c) 2001-2021 Python Software Foundation. All rights reserved.
A. HISTORY OF THE SOFTWARE

View File

@ -928,6 +928,55 @@ def dump_template_messages(msgs, reports, settings):
reports, None, settings)
def dump_asset_messages(msgs, reports, settings):
# Where to search for assets, relative to the local user resources.
assets_dir = os.path.join(bpy.utils.resource_path('LOCAL'), "datafiles", "assets")
# Parse the catalog sidecar file
catalog_file = os.path.join(assets_dir, settings.ASSET_CATALOG_FILE)
with open(catalog_file, encoding="utf8") as f:
data = f.readlines()
catalogs = set()
for line in data:
if (line == "\n" or line.startswith("VERSION") or line.startswith("#")):
continue
_UUID, catalog_path, _simple_catalog_name = line.split(":")
catalogs.update(catalog_path.split("/"))
msgsrc = "Asset catalog from " + settings.ASSET_CATALOG_FILE
for catalog in sorted(catalogs):
process_msg(msgs, settings.DEFAULT_CONTEXT, catalog, msgsrc,
reports, None, settings)
# Parse the asset blend files
asset_files = {}
bfiles = glob.glob(assets_dir + "/**/*.blend", recursive=True)
for bfile in bfiles:
basename = os.path.basename(bfile)
bpy.ops.wm.open_mainfile(filepath=bfile)
# For now, only parse node groups.
# Perhaps some other assets will need to be extracted later?
for asset_type in ("node_groups",):
for asset in getattr(bpy.data, asset_type):
if asset.asset_data is None: # Not an asset
continue
assets = asset_files.setdefault(basename, [])
assets.append((asset.name, asset.asset_data.description))
for asset_file in sorted(asset_files):
for asset in sorted(asset_files[asset_file]):
name, description = asset
msgsrc = "Asset name from file " + asset_file
process_msg(msgs, settings.DEFAULT_CONTEXT, name, msgsrc,
reports, None, settings)
msgsrc = "Asset description from file " + asset_file
process_msg(msgs, settings.DEFAULT_CONTEXT, description, msgsrc,
reports, None, settings)
def dump_addon_bl_info(msgs, reports, module, settings):
for prop in ('name', 'location', 'description', 'warning'):
process_msg(
@ -980,6 +1029,7 @@ def dump_messages(do_messages, do_checks, settings):
dump_preset_messages(msgs, reports, settings)
# Get strings from startup templates.
# This loads each startup blend file in turn.
dump_template_messages(msgs, reports, settings)
# Get strings from addons' bl_info.
@ -1019,6 +1069,10 @@ def dump_messages(do_messages, do_checks, settings):
process_msg(msgs, settings.DEFAULT_CONTEXT, cat[1],
"Language categories labels from bl_i18n_utils/settings.py", reports, None, settings)
# Get strings from asset catalogs and blend files.
# This loads each asset blend file in turn.
dump_asset_messages(msgs, reports, settings)
# pot.check()
pot.unescape() # Strings gathered in py/C source code may contain escaped chars...
print_info(reports, pot)

View File

@ -527,6 +527,9 @@ REL_PRESETS_DIR = os.path.join("scripts", "presets")
# Where to search for templates (relative to SOURCE_DIR).
REL_TEMPLATES_DIR = os.path.join("scripts", "startup", "bl_app_templates_system")
# Name of the built-in asset catalog file.
ASSET_CATALOG_FILE = "blender_assets.cats.txt"
# The template messages file (relative to I18N_DIR).
REL_FILE_NAME_POT = os.path.join(REL_BRANCHES_DIR, DOMAIN + ".pot")

View File

@ -81,6 +81,9 @@ class DATA_PT_display(ArmatureButtonsPanel, Panel):
sub.active = arm.show_axes
sub.prop(arm, "axes_position", text="Position")
sub = col.row(align=True)
sub.prop(arm, "relation_line_position", text="Relations", expand=True)
class DATA_MT_bone_group_context_menu(Menu):
bl_label = "Bone Group Specials"

View File

@ -217,7 +217,11 @@ bool BKE_collection_object_cyclic_check(struct Main *bmain,
struct ListBase BKE_collection_object_cache_get(struct Collection *collection);
ListBase BKE_collection_object_cache_instanced_get(struct Collection *collection);
/** Free the object cache of given `collection` and all of its ancestors (recursively). */
void BKE_collection_object_cache_free(struct Collection *collection);
/** Free the object cache of all collections in given `bmain`, including master collections of
* scenes. */
void BKE_main_collections_object_cache_free(const struct Main *bmain);
struct Base *BKE_collection_or_layer_objects(const struct Scene *scene,
struct ViewLayer *view_layer,

View File

@ -493,11 +493,34 @@ struct ImBuf *BKE_image_get_first_ibuf(struct Image *image);
*/
struct GPUTexture *BKE_image_create_gpu_texture_from_ibuf(struct Image *image, struct ImBuf *ibuf);
/**
* Ensure that the cached GPU texture inside the image matches the pass, layer, and view of the
* given image user, if not, invalidate the cache such that the next call to the GPU texture
* retrieval functions such as BKE_image_get_gpu_texture updates the cache with an image that
* matches the give image user.
*
* This is provided as a separate function and not implemented as part of the GPU texture retrieval
* functions because the current cache system only allows a single pass, layer, and stereo view to
* be cached, so possible frequent invalidations of the cache can have performance implications,
* and making invalidation explicit by calling this function will help make that clear and pave the
* way for a more complete cache system in the future.
*/
void BKE_image_ensure_gpu_texture(struct Image *image, struct ImageUser *iuser);
/**
* Get the #GPUTexture for a given `Image`.
*
* `iuser` and `ibuf` are mutual exclusive parameters. The caller can pass the `ibuf` when already
* available. It is also required when requesting the #GPUTexture for a render result.
*
* The requested GPU texture will be cached for subsequent calls, but only a single layer, pass,
* and view can be cached at a time, so the cache should be invalidated in operators and RNA
* callbacks that change the layer, pass, or view of the image to maintain a correct cache state.
* However, in some cases, multiple layers, passes, or views might be needed at the same time, like
* is the case for the realtime compositor. This is currently not supported, so the caller should
* ensure that the requested layer is indeed the cached one and invalidated the cached otherwise by
* calling BKE_image_ensure_gpu_texture. This is a workaround until image can support a more
* complete caching system.
*/
struct GPUTexture *BKE_image_get_gpu_texture(struct Image *image,
struct ImageUser *iuser,

View File

@ -82,6 +82,8 @@ static CollectionParent *collection_find_parent(Collection *child, Collection *c
static bool collection_find_child_recursive(const Collection *parent,
const Collection *collection);
static void collection_object_cache_free(Collection *collection);
static void collection_gobject_hash_ensure(Collection *collection);
static void collection_gobject_hash_update_object(Collection *collection,
Object *ob_old,
@ -160,7 +162,7 @@ static void collection_free_data(ID *id)
BLI_freelistN(&collection->children);
BLI_freelistN(&collection->runtime.parents);
BKE_collection_object_cache_free(collection);
collection_object_cache_free(collection);
}
static void collection_foreach_id(ID *id, LibraryForeachIDData *data)
@ -887,15 +889,27 @@ static void collection_object_cache_free(Collection *collection)
collection->flag &= ~(COLLECTION_HAS_OBJECT_CACHE | COLLECTION_HAS_OBJECT_CACHE_INSTANCED);
BLI_freelistN(&collection->runtime.object_cache);
BLI_freelistN(&collection->runtime.object_cache_instanced);
}
void BKE_collection_object_cache_free(Collection *collection)
{
collection_object_cache_free(collection);
LISTBASE_FOREACH (CollectionParent *, parent, &collection->runtime.parents) {
collection_object_cache_free(parent->collection);
}
}
void BKE_collection_object_cache_free(Collection *collection)
void BKE_main_collections_object_cache_free(const Main *bmain)
{
collection_object_cache_free(collection);
for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
collection_object_cache_free(scene->master_collection);
}
for (Collection *collection = bmain->collections.first; collection != NULL;
collection = collection->id.next) {
collection_object_cache_free(collection);
}
}
Base *BKE_collection_or_layer_objects(const Scene *scene,

View File

@ -336,6 +336,20 @@ static void image_gpu_texture_try_partial_update(Image *image, ImageUser *iuser)
}
}
void BKE_image_ensure_gpu_texture(Image *image, ImageUser *image_user)
{
if (!image) {
return;
}
/* Note that the image can cache both sterio views, so we only invalidate the cache if the view
* index is more than 2. */
if (image->gpu_pass != image_user->pass || image->gpu_layer != image_user->layer ||
(image->gpu_view != image_user->multi_index && image_user->multi_index >= 2)) {
BKE_image_partial_update_mark_full_update(image);
}
}
static GPUTexture *image_get_gpu_texture(Image *ima,
ImageUser *iuser,
ImBuf *ibuf,
@ -365,6 +379,9 @@ static GPUTexture *image_get_gpu_texture(Image *ima,
ima->gpu_pass = requested_pass;
ima->gpu_layer = requested_layer;
ima->gpu_view = requested_view;
/* The cache should be invalidated here, but it is intentionally isn't due to possible
* performance implications, see the BKE_image_ensure_gpu_texture function for more
* information. */
}
#undef GPU_FLAGS_TO_CHECK

View File

@ -1431,6 +1431,8 @@ void BKE_main_collection_sync_remap(const Main *bmain)
/* On remapping of object or collection pointers free caches. */
/* TODO: try to make this faster */
BKE_main_collections_object_cache_free(bmain);
for (Scene *scene = static_cast<Scene *>(bmain->scenes.first); scene;
scene = static_cast<Scene *>(scene->id.next)) {
LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
@ -1447,14 +1449,12 @@ void BKE_main_collection_sync_remap(const Main *bmain)
view_layer_bases_hash_create(view_layer, true);
}
BKE_collection_object_cache_free(scene->master_collection);
DEG_id_tag_update_ex((Main *)bmain, &scene->master_collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_id_tag_update_ex((Main *)bmain, &scene->id, ID_RECALC_COPY_ON_WRITE);
}
for (Collection *collection = static_cast<Collection *>(bmain->collections.first); collection;
collection = static_cast<Collection *>(collection->id.next)) {
BKE_collection_object_cache_free(collection);
DEG_id_tag_update_ex((Main *)bmain, &collection->id, ID_RECALC_COPY_ON_WRITE);
}

View File

@ -603,8 +603,7 @@ static void copy_or_interp_loop_attributes(Mesh *dest_mesh,
}
for (int source_layer_i = 0; source_layer_i < source_cd->totlayer; ++source_layer_i) {
int ty = source_cd->layers[source_layer_i].type;
if (STREQ(source_cd->layers[source_layer_i].name, ".corner_vert") ||
STREQ(source_cd->layers[source_layer_i].name, ".corner_edge")) {
if (STR_ELEM(source_cd->layers[source_layer_i].name, ".corner_vert", ".corner_edge")) {
continue;
}
const char *name = source_cd->layers[source_layer_i].name;

View File

@ -1041,7 +1041,7 @@ static void ccgDM_copyFinalCornerVertArray(DerivedMesh *dm, int *r_corner_verts)
CopyFinalLoopArrayData data;
data.ccgdm = ccgdm;
data.corner_verts = r_corner_verts;
data.corner_edges = NULL;
data.corner_edges = nullptr;
data.grid_size = ccgSubSurf_getGridSize(ss);
data.grid_offset = dm->getGridOffset(dm);
data.edge_size = ccgSubSurf_getEdgeSize(ss);
@ -1085,7 +1085,7 @@ static void ccgDM_copyFinalCornerEdgeArray(DerivedMesh *dm, int *r_corner_edges)
CopyFinalLoopArrayData data;
data.ccgdm = ccgdm;
data.corner_verts = NULL;
data.corner_verts = nullptr;
data.corner_edges = r_corner_edges;
data.grid_size = ccgSubSurf_getGridSize(ss);
data.grid_offset = dm->getGridOffset(dm);

View File

@ -3639,7 +3639,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
arm->flag &= ~(ARM_FLAG_UNUSED_1 | ARM_FLAG_UNUSED_5 | ARM_FLAG_UNUSED_6 |
arm->flag &= ~(ARM_FLAG_UNUSED_1 | ARM_DRAW_RELATION_FROM_HEAD | ARM_FLAG_UNUSED_6 |
ARM_FLAG_UNUSED_7 | ARM_FLAG_UNUSED_12);
}

View File

@ -12,8 +12,6 @@
namespace blender::compositor {
static int MAX_VIEWER_TRANSLATION_PADDING = 12000;
ViewerOperation::ViewerOperation()
{
this->set_image(nullptr);
@ -137,23 +135,13 @@ void ViewerOperation::init_image()
return;
}
int padding_x = abs(canvas_.xmin) * 2;
int padding_y = abs(canvas_.ymin) * 2;
if (padding_x > MAX_VIEWER_TRANSLATION_PADDING) {
padding_x = MAX_VIEWER_TRANSLATION_PADDING;
}
if (padding_y > MAX_VIEWER_TRANSLATION_PADDING) {
padding_y = MAX_VIEWER_TRANSLATION_PADDING;
}
if (ibuf->x != get_width() || ibuf->y != get_height()) {
display_width_ = get_width() + padding_x;
display_height_ = get_height() + padding_y;
if (ibuf->x != display_width_ || ibuf->y != display_height_) {
imb_freerectImBuf(ibuf);
imb_freerectfloatImBuf(ibuf);
IMB_freezbuffloatImBuf(ibuf);
ibuf->x = display_width_;
ibuf->y = display_height_;
ibuf->x = get_width();
ibuf->y = get_height();
/* zero size can happen if no image buffers exist to define a sensible resolution */
if (ibuf->x > 0 && ibuf->y > 0) {
imb_addrectfloatImBuf(ibuf, 4);
@ -187,11 +175,13 @@ void ViewerOperation::update_image(const rcti *rect)
return;
}
image_->offset_x = canvas_.xmin;
image_->offset_y = canvas_.ymin;
float *buffer = output_buffer_;
IMB_partial_display_buffer_update(ibuf_,
buffer,
nullptr,
display_width_,
get_width(),
0,
0,
view_settings_,
@ -224,32 +214,23 @@ void ViewerOperation::update_memory_buffer_partial(MemoryBuffer * /*output*/,
return;
}
const int offset_x = area.xmin + (canvas_.xmin > 0 ? canvas_.xmin * 2 : 0);
const int offset_y = area.ymin + (canvas_.ymin > 0 ? canvas_.ymin * 2 : 0);
MemoryBuffer output_buffer(
output_buffer_, COM_DATA_TYPE_COLOR_CHANNELS, display_width_, display_height_);
output_buffer_, COM_DATA_TYPE_COLOR_CHANNELS, get_width(), get_height());
const MemoryBuffer *input_image = inputs[0];
output_buffer.copy_from(input_image, area, offset_x, offset_y);
output_buffer.copy_from(input_image, area);
if (use_alpha_input_) {
const MemoryBuffer *input_alpha = inputs[1];
output_buffer.copy_from(
input_alpha, area, 0, COM_DATA_TYPE_VALUE_CHANNELS, offset_x, offset_y, 3);
output_buffer.copy_from(input_alpha, area, 0, COM_DATA_TYPE_VALUE_CHANNELS, 3);
}
if (depth_buffer_) {
MemoryBuffer depth_buffer(
depth_buffer_, COM_DATA_TYPE_VALUE_CHANNELS, display_width_, display_height_);
depth_buffer_, COM_DATA_TYPE_VALUE_CHANNELS, get_width(), get_height());
const MemoryBuffer *input_depth = inputs[2];
depth_buffer.copy_from(input_depth, area, offset_x, offset_y);
depth_buffer.copy_from(input_depth, area);
}
rcti display_area;
BLI_rcti_init(&display_area,
offset_x,
offset_x + BLI_rcti_size_x(&area),
offset_y,
offset_y + BLI_rcti_size_y(&area));
update_image(&display_area);
update_image(&area);
}
void ViewerOperation::clear_display_buffer()

View File

@ -35,9 +35,6 @@ class ViewerOperation : public MultiThreadedOperation {
SocketReader *alpha_input_;
SocketReader *depth_input_;
int display_width_;
int display_height_;
public:
ViewerOperation();
void init_execution() override;

View File

@ -99,8 +99,10 @@ class ImageEngine {
/* Setup the matrix to go from screen UV coordinates to UV texture space coordinates. */
float image_resolution[2] = {image_buffer ? image_buffer->x : 1024.0f,
image_buffer ? image_buffer->y : 1024.0f};
float image_offset[2] = {float(instance_data->image->offset_x),
float(instance_data->image->offset_y)};
space->init_ss_to_texture_matrix(
draw_ctx->region, image_resolution, instance_data->ss_to_texture);
draw_ctx->region, image_offset, image_resolution, instance_data->ss_to_texture);
const Scene *scene = DRW_context_state_get()->scene;
instance_data->sh_params.update(space.get(), scene, instance_data->image, image_buffer);

View File

@ -69,6 +69,7 @@ class AbstractSpaceAccessor {
* (0..1) to texture space UV coordinates.
*/
virtual void init_ss_to_texture_matrix(const ARegion *region,
const float image_offset[2],
const float image_resolution[2],
float r_uv_to_texture[4][4]) const = 0;
};

View File

@ -88,14 +88,19 @@ class SpaceImageAccessor : public AbstractSpaceAccessor {
}
void init_ss_to_texture_matrix(const ARegion *region,
const float /*image_resolution*/[2],
const float image_offset[2],
const float image_resolution[2],
float r_uv_to_texture[4][4]) const override
{
unit_m4(r_uv_to_texture);
float scale_x = 1.0 / BLI_rctf_size_x(&region->v2d.cur);
float scale_y = 1.0 / BLI_rctf_size_y(&region->v2d.cur);
float translate_x = scale_x * -region->v2d.cur.xmin;
float translate_y = scale_y * -region->v2d.cur.ymin;
float display_offset_x = scale_x * image_offset[0] / image_resolution[0];
float display_offset_y = scale_y * image_offset[1] / image_resolution[1];
float translate_x = scale_x * -region->v2d.cur.xmin + display_offset_x;
float translate_y = scale_y * -region->v2d.cur.ymin + display_offset_y;
r_uv_to_texture[0][0] = scale_x;
r_uv_to_texture[1][1] = scale_y;

View File

@ -87,17 +87,22 @@ class SpaceNodeAccessor : public AbstractSpaceAccessor {
* screen.
*/
void init_ss_to_texture_matrix(const ARegion *region,
const float image_offset[2],
const float image_resolution[2],
float r_uv_to_texture[4][4]) const override
{
unit_m4(r_uv_to_texture);
float display_resolution[2];
float image_display_offset[2];
mul_v2_v2fl(display_resolution, image_resolution, snode->zoom);
mul_v2_v2fl(image_display_offset, image_offset, snode->zoom);
const float scale_x = display_resolution[0] / region->winx;
const float scale_y = display_resolution[1] / region->winy;
const float translate_x = ((region->winx - display_resolution[0]) * 0.5f + snode->xof) /
const float translate_x = ((region->winx - display_resolution[0]) * 0.5f + snode->xof +
image_display_offset[0]) /
region->winx;
const float translate_y = ((region->winy - display_resolution[1]) * 0.5f + snode->yof) /
const float translate_y = ((region->winy - display_resolution[1]) * 0.5f + snode->yof +
image_display_offset[1]) /
region->winy;
r_uv_to_texture[0][0] = scale_x;

View File

@ -2023,6 +2023,20 @@ static void pchan_draw_ik_lines(ArmatureDrawContext *ctx,
}
}
static void draw_bone_bone_relationship_line(ArmatureDrawContext *ctx,
const float bone_head[3],
const float parent_head[3],
const float parent_tail[3],
const eArmature_Flag armature_flags)
{
if (armature_flags & ARM_DRAW_RELATION_FROM_HEAD) {
drw_shgroup_bone_relationship_lines(ctx, bone_head, parent_head);
}
else {
drw_shgroup_bone_relationship_lines(ctx, bone_head, parent_tail);
}
}
static void draw_bone_relations(ArmatureDrawContext *ctx,
EditBone *ebone,
bPoseChannel *pchan,
@ -2036,7 +2050,8 @@ static void draw_bone_relations(ArmatureDrawContext *ctx,
* since riggers will want to know about the links between bones
*/
if ((boneflag & BONE_CONNECTED) == 0) {
drw_shgroup_bone_relationship_lines(ctx, ebone->head, ebone->parent->tail);
draw_bone_bone_relationship_line(
ctx, ebone->head, ebone->parent->head, ebone->parent->tail, eArmature_Flag(arm->flag));
}
}
}
@ -2047,7 +2062,11 @@ static void draw_bone_relations(ArmatureDrawContext *ctx,
if ((boneflag & BONE_SELECTED) ||
(pchan->parent->bone && (pchan->parent->bone->flag & BONE_SELECTED))) {
if ((boneflag & BONE_CONNECTED) == 0) {
drw_shgroup_bone_relationship_lines(ctx, pchan->pose_head, pchan->parent->pose_tail);
draw_bone_bone_relationship_line(ctx,
pchan->pose_head,
pchan->parent->pose_head,
pchan->parent->pose_tail,
eArmature_Flag(arm->flag));
}
}
}

View File

@ -227,9 +227,9 @@ static void mesh_render_data_mat_tri_len_build_threaded(MeshRenderData *mr,
}
/* Count how many triangles for each material. */
static void mesh_render_data_mat_tri_len_build(MeshRenderData *mr,
blender::MutableSpan<int> mat_tri_len)
static blender::Array<int> mesh_render_data_mat_tri_len_build(MeshRenderData *mr)
{
blender::Array<int> mat_tri_len(mr->mat_len, 0);
if (mr->extract_type == MR_EXTRACT_BMESH) {
BMesh *bm = mr->bm;
mesh_render_data_mat_tri_len_build_threaded(
@ -239,15 +239,13 @@ static void mesh_render_data_mat_tri_len_build(MeshRenderData *mr,
mesh_render_data_mat_tri_len_build_threaded(
mr, mr->poly_len, mesh_render_data_mat_tri_len_mesh_range_fn, mat_tri_len);
}
return mat_tri_len;
}
static void mesh_render_data_polys_sorted_build(MeshRenderData *mr, MeshBufferCache *cache)
{
using namespace blender;
cache->poly_sorted.tri_first_index.reinitialize(mr->poly_len);
cache->poly_sorted.mat_tri_len.reinitialize(mr->mat_len);
mesh_render_data_mat_tri_len_build(mr, cache->poly_sorted.mat_tri_len);
cache->poly_sorted.mat_tri_len = mesh_render_data_mat_tri_len_build(mr);
const Span<int> mat_tri_len = cache->poly_sorted.mat_tri_len;
/* Apply offset. */
@ -261,6 +259,7 @@ static void mesh_render_data_polys_sorted_build(MeshRenderData *mr, MeshBufferCa
}
cache->poly_sorted.visible_tri_len = visible_tri_len;
cache->poly_sorted.tri_first_index.reinitialize(mr->poly_len);
MutableSpan<int> tri_first_index = cache->poly_sorted.tri_first_index;
/* Sort per material. */

View File

@ -638,15 +638,15 @@ static void cage2d_draw_rect_edge_handles(const rctf *r,
case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X:
case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X: {
const float rad[2] = {0.2f * margin[0], 0.4f * size[1]};
imm_draw_point_aspect_2d(pos, r->xmin, 0.f, rad[0], rad[1], solid);
imm_draw_point_aspect_2d(pos, r->xmax, 0.f, rad[0], rad[1], solid);
imm_draw_point_aspect_2d(pos, r->xmin, 0.0f, rad[0], rad[1], solid);
imm_draw_point_aspect_2d(pos, r->xmax, 0.0f, rad[0], rad[1], solid);
break;
}
case ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y:
case ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y: {
const float rad[2] = {0.4f * size[0], 0.2f * margin[1]};
imm_draw_point_aspect_2d(pos, 0.f, r->ymin, rad[0], rad[1], solid);
imm_draw_point_aspect_2d(pos, 0.f, r->ymax, rad[0], rad[1], solid);
imm_draw_point_aspect_2d(pos, 0.0f, r->ymin, rad[0], rad[1], solid);
imm_draw_point_aspect_2d(pos, 0.0f, r->ymax, rad[0], rad[1], solid);
break;
}
}

View File

@ -148,6 +148,7 @@ typedef enum eKeyframeIterFlags {
* iterator callbacks then. */
KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE = (1 << 3),
} eKeyframeIterFlags;
ENUM_OPERATORS(eKeyframeIterFlags, KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE)
/** \} */

View File

@ -6123,6 +6123,8 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
ScrArea *area = CTX_wm_area(C);
void *owner = nullptr;
int handle_event, icon = 0;
const char *op_name = nullptr;
const char *op_description = nullptr;
uiBlock *block = uiLayoutGetBlock(layout);
UI_block_layout_set_current(block, layout);
@ -6184,6 +6186,10 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER)) {
handle_event = B_STOPRENDER;
icon = ICON_SCENE;
if (U.render_display_type != USER_RENDER_DISPLAY_NONE) {
op_name = "RENDER_OT_view_show";
op_description = "Show the render window";
}
break;
}
if (WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE)) {
@ -6240,12 +6246,26 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
const char *name = active ? WM_jobs_name(wm, owner) : "Canceling...";
/* job name and icon */
/* job icon as a button */
if (op_name) {
uiDefIconButO(block,
UI_BTYPE_BUT,
op_name,
WM_OP_INVOKE_DEFAULT,
icon,
0,
0,
UI_UNIT_X,
UI_UNIT_Y,
TIP_(op_description));
}
/* job name and icon if not previously set */
const int textwidth = UI_fontstyle_string_width(fstyle, name);
uiDefIconTextBut(block,
UI_BTYPE_LABEL,
0,
icon,
op_name ? 0 : icon,
name,
0,
0,

View File

@ -845,7 +845,7 @@ static void define_primitive_add_properties(wmOperatorType *ot)
static int primitive_circle_add_exec(bContext *C, wmOperator *op)
{
const float points[4][2] = {{0.0f, 0.5f}, {0.5f, 1.0f}, {1.0f, 0.5f}, {0.5f, 0.0f}};
int num_points = sizeof(points) / sizeof(float[2]);
int num_points = ARRAY_SIZE(points);
create_primitive_from_points(C, op, points, num_points, HD_AUTO);
@ -880,7 +880,7 @@ void MASK_OT_primitive_circle_add(wmOperatorType *ot)
static int primitive_square_add_exec(bContext *C, wmOperator *op)
{
const float points[4][2] = {{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}};
int num_points = sizeof(points) / sizeof(float[2]);
int num_points = ARRAY_SIZE(points);
create_primitive_from_points(C, op, points, num_points, HD_VECT);

View File

@ -6356,10 +6356,10 @@ void ED_paint_data_warning(ReportList *reports, bool uvs, bool mat, bool tex, bo
BKE_reportf(reports,
RPT_WARNING,
"Missing%s%s%s%s detected!",
!uvs ? " UVs," : "",
!mat ? " Materials," : "",
!tex ? " Textures," : "",
!stencil ? " Stencil," : "");
!uvs ? TIP_(" UVs,") : "",
!mat ? TIP_(" Materials,") : "",
!tex ? TIP_(" Textures,") : "",
!stencil ? TIP_(" Stencil,") : "");
}
bool ED_paint_proj_mesh_data_check(

View File

@ -23,15 +23,15 @@ set(INC_SYS
)
set(SRC
action_buttons.c
action_data.c
action_draw.c
action_edit.c
action_ops.c
action_select.c
space_action.c
action_buttons.cc
action_data.cc
action_draw.cc
action_edit.cc
action_ops.cc
action_select.cc
space_action.cc
action_intern.h
action_intern.hh
)
set(LIB

View File

@ -5,30 +5,30 @@
* \ingroup spaction
*/
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_screen.h"
#include "action_intern.h" /* own include */
#include "action_intern.hh" /* own include */
/* ******************* action editor space & buttons ************** */
/* ******************* general ******************************** */
void action_buttons_register(ARegionType *UNUSED(art))
void action_buttons_register(ARegionType * /*art*/)
{
#if 0
PanelType *pt;
/* TODO: AnimData / Actions List */
pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties");
pt = MEM_cnew<PanelType>("spacetype action panel properties");
strcpy(pt->idname, "ACTION_PT_properties");
strcpy(pt->label, N_("Active F-Curve"));
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
@ -36,7 +36,7 @@ void action_buttons_register(ARegionType *UNUSED(art))
pt->poll = action_anim_panel_poll;
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties");
pt = MEM_cnew<PanelType>("spacetype action panel properties");
strcpy(pt->idname, "ACTION_PT_key_properties");
strcpy(pt->label, N_("Active Keyframe"));
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);

View File

@ -5,10 +5,10 @@
* \ingroup spaction
*/
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "BLI_utildefines.h"
@ -52,7 +52,7 @@
#include "UI_interface.h"
#include "action_intern.h"
#include "action_intern.hh"
/* -------------------------------------------------------------------- */
/** \name Utilities
@ -62,7 +62,7 @@ AnimData *ED_actedit_animdata_from_context(const bContext *C, ID **r_adt_id_owne
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
Object *ob = CTX_data_active_object(C);
AnimData *adt = NULL;
AnimData *adt = nullptr;
/* Get AnimData block to use */
if (saction->mode == SACTCONT_ACTION) {
@ -146,11 +146,11 @@ static void actedit_change_action(bContext *C, bAction *act)
RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, saction, &ptr);
prop = RNA_struct_find_property(&ptr, "action");
/* NOTE: act may be NULL here, so better to just use a cast here */
/* NOTE: act may be nullptr here, so better to just use a cast here */
RNA_id_pointer_create((ID *)act, &idptr);
/* set the new pointer, and force a refresh */
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
RNA_property_update(C, &ptr, prop);
}
@ -181,7 +181,7 @@ static bool action_new_poll(bContext *C)
if (saction->mode == SACTCONT_ACTION) {
/* XXX: This assumes that actions are assigned to the active object in this mode */
if (ob) {
if ((ob->adt == NULL) || (ob->adt->flag & ADT_NLA_EDIT_ON) == 0) {
if ((ob->adt == nullptr) || (ob->adt->flag & ADT_NLA_EDIT_ON) == 0) {
return true;
}
}
@ -189,7 +189,7 @@ static bool action_new_poll(bContext *C)
else if (saction->mode == SACTCONT_SHAPEKEY) {
Key *key = BKE_key_from_object(ob);
if (key) {
if ((key->adt == NULL) || (key->adt->flag & ADT_NLA_EDIT_ON) == 0) {
if ((key->adt == nullptr) || (key->adt->flag & ADT_NLA_EDIT_ON) == 0) {
return true;
}
}
@ -205,14 +205,14 @@ static bool action_new_poll(bContext *C)
return false;
}
static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
static int action_new_exec(bContext *C, wmOperator * /*op*/)
{
PointerRNA ptr, idptr;
PropertyRNA *prop;
bAction *oldact = NULL;
AnimData *adt = NULL;
ID *adt_id_owner = NULL;
bAction *oldact = nullptr;
AnimData *adt = nullptr;
ID *adt_id_owner = nullptr;
/* hook into UI */
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
@ -225,7 +225,7 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
/* stash the old action to prevent it from being lost */
if (ptr.type == &RNA_AnimData) {
adt = ptr.data;
adt = static_cast<AnimData *>(ptr.data);
adt_id_owner = ptr.owner_id;
}
else if (ptr.type == &RNA_SpaceDopeSheetEditor) {
@ -237,11 +237,11 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
oldact = adt->action;
}
{
bAction *action = NULL;
bAction *action = nullptr;
/* Perform stashing operation - But only if there is an action */
if (adt && oldact) {
BLI_assert(adt_id_owner != NULL);
BLI_assert(adt_id_owner != nullptr);
/* stash the action */
if (BKE_nla_action_stash(adt, ID_IS_OVERRIDE_LIBRARY(adt_id_owner))) {
/* The stash operation will remove the user already
@ -252,8 +252,8 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
* or else the user gets decremented twice!
*/
if (ptr.type == &RNA_SpaceDopeSheetEditor) {
SpaceAction *saction = ptr.data;
saction->action = NULL;
SpaceAction *saction = static_cast<SpaceAction *>(ptr.data);
saction->action = nullptr;
}
}
else {
@ -272,13 +272,13 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
* NOTE: we can't use actedit_change_action, as this function is also called from the NLA
*/
RNA_id_pointer_create(&action->id, &idptr);
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
RNA_property_update(C, &ptr, prop);
}
}
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, nullptr);
return OPERATOR_FINISHED;
}
@ -313,7 +313,7 @@ static bool action_pushdown_poll(bContext *C)
{
if (ED_operator_action_active(C)) {
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
/* Check for AnimData, Actions, and that tweak-mode is off. */
if (adt && saction->action) {
@ -333,7 +333,7 @@ static bool action_pushdown_poll(bContext *C)
static int action_pushdown_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
ID *adt_id_owner = NULL;
ID *adt_id_owner = nullptr;
AnimData *adt = ED_actedit_animdata_from_context(C, &adt_id_owner);
/* Do the deed... */
@ -349,7 +349,7 @@ static int action_pushdown_exec(bContext *C, wmOperator *op)
/* action can be safely added */
BKE_nla_action_pushdown(adt, ID_IS_OVERRIDE_LIBRARY(adt_id_owner));
struct Main *bmain = CTX_data_main(C);
Main *bmain = CTX_data_main(C);
DEG_id_tag_update_ex(bmain, adt_id_owner, ID_RECALC_ANIMATION);
/* The action needs updating too, as FCurve modifiers are to be reevaluated. They won't extend
@ -359,11 +359,11 @@ static int action_pushdown_exec(bContext *C, wmOperator *op)
/* Stop displaying this action in this editor
* NOTE: The editor itself doesn't set a user...
*/
saction->action = NULL;
saction->action = nullptr;
}
/* Send notifiers that stuff has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, nullptr);
return OPERATOR_FINISHED;
}
@ -391,7 +391,7 @@ void ACTION_OT_push_down(wmOperatorType *ot)
static int action_stash_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
ID *adt_id_owner = NULL;
ID *adt_id_owner = nullptr;
AnimData *adt = ED_actedit_animdata_from_context(C, &adt_id_owner);
/* Perform stashing operation */
@ -410,7 +410,7 @@ static int action_stash_exec(bContext *C, wmOperator *op)
* the user-count fixes. Hence, we must unset this ref
* first before setting the new action.
*/
saction->action = NULL;
saction->action = nullptr;
}
else {
/* action has already been added - simply warn about this, and clear */
@ -418,11 +418,11 @@ static int action_stash_exec(bContext *C, wmOperator *op)
}
/* clear action refs from editor, and then also the backing data (not necessary) */
actedit_change_action(C, NULL);
actedit_change_action(C, nullptr);
}
/* Send notifiers that stuff has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, nullptr);
return OPERATOR_FINISHED;
}
@ -461,7 +461,7 @@ void ACTION_OT_stash(wmOperatorType *ot)
static bool action_stash_create_poll(bContext *C)
{
if (ED_operator_action_active(C)) {
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
/* Check tweak-mode is off (as you don't want to be tampering with the action in that case) */
/* NOTE: unlike for pushdown,
@ -494,13 +494,13 @@ static bool action_stash_create_poll(bContext *C)
static int action_stash_create_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
ID *adt_id_owner = NULL;
ID *adt_id_owner = nullptr;
AnimData *adt = ED_actedit_animdata_from_context(C, &adt_id_owner);
/* Check for no action... */
if (saction->action == NULL) {
if (saction->action == nullptr) {
/* just create a new action */
bAction *action = action_create_new(C, NULL);
bAction *action = action_create_new(C, nullptr);
actedit_change_action(C, action);
}
else if (adt) {
@ -513,29 +513,29 @@ static int action_stash_create_exec(bContext *C, wmOperator *op)
/* stash the action */
if (BKE_nla_action_stash(adt, ID_IS_OVERRIDE_LIBRARY(adt_id_owner))) {
bAction *new_action = NULL;
bAction *new_action = nullptr;
/* Create new action not based on the old one
* (since the "new" operator already does that). */
new_action = action_create_new(C, NULL);
new_action = action_create_new(C, nullptr);
/* The stash operation will remove the user already,
* so the flushing step later shouldn't double up
* the user-count fixes. Hence, we must unset this ref
* first before setting the new action.
*/
saction->action = NULL;
saction->action = nullptr;
actedit_change_action(C, new_action);
}
else {
/* action has already been added - simply warn about this, and clear */
BKE_report(op->reports, RPT_ERROR, "Action has already been stashed");
actedit_change_action(C, NULL);
actedit_change_action(C, nullptr);
}
}
/* Send notifiers that stuff has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, nullptr);
return OPERATOR_FINISHED;
}
@ -598,19 +598,19 @@ void ED_animedit_unlink_action(
NlaTrack *nlt, *nlt_next;
NlaStrip *strip, *nstrip;
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt_next) {
for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt_next) {
nlt_next = nlt->next;
if (strstr(nlt->name, DATA_("[Action Stash]"))) {
for (strip = nlt->strips.first; strip; strip = nstrip) {
for (strip = static_cast<NlaStrip *>(nlt->strips.first); strip; strip = nstrip) {
nstrip = strip->next;
if (strip->act == act) {
/* Remove this strip, and the track too if it doesn't have anything else */
BKE_nlastrip_remove_and_free(&nlt->strips, strip, true);
if (nlt->strips.first == NULL) {
BLI_assert(nstrip == NULL);
if (nlt->strips.first == nullptr) {
BLI_assert(nstrip == nullptr);
BKE_nlatrack_remove_and_free(&adt->nla_tracks, nlt, true);
}
}
@ -628,15 +628,15 @@ void ED_animedit_unlink_action(
BKE_nla_tweakmode_exit(adt);
Scene *scene = CTX_data_scene(C);
if (scene != NULL) {
if (scene != nullptr) {
scene->flag &= ~SCE_NLA_EDIT_ON;
}
}
else {
/* Unlink normally - Setting it to NULL should be enough to get the old one unlinked */
/* Unlink normally - Setting it to nullptr should be enough to get the old one unlinked */
if (area->spacetype == SPACE_ACTION) {
/* clear action editor -> action */
actedit_change_action(C, NULL);
actedit_change_action(C, nullptr);
}
else {
/* clear AnimData -> action */
@ -648,7 +648,7 @@ void ED_animedit_unlink_action(
prop = RNA_struct_find_property(&ptr, "action");
/* clear... */
RNA_property_pointer_set(&ptr, prop, PointerRNA_NULL, NULL);
RNA_property_pointer_set(&ptr, prop, PointerRNA_NULL, nullptr);
RNA_property_update(C, &ptr, prop);
}
}
@ -660,7 +660,7 @@ static bool action_unlink_poll(bContext *C)
{
if (ED_operator_action_active(C)) {
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
/* Only when there's an active action, in the right modes... */
if (saction->action && adt) {
@ -674,15 +674,15 @@ static bool action_unlink_poll(bContext *C)
static int action_unlink_exec(bContext *C, wmOperator *op)
{
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
bool force_delete = RNA_boolean_get(op->ptr, "force_delete");
if (adt && adt->action) {
ED_animedit_unlink_action(C, NULL, adt, adt->action, op->reports, force_delete);
ED_animedit_unlink_action(C, nullptr, adt, adt->action, op->reports, force_delete);
}
/* Unlink is also abused to exit NLA tweak mode. */
WM_main_add_notifier(NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
WM_main_add_notifier(NC_ANIMATION | ND_NLA_ACTCHANGE, nullptr);
return OPERATOR_FINISHED;
}
@ -733,24 +733,24 @@ static NlaStrip *action_layer_get_nlastrip(ListBase *strips, float ctime)
{
NlaStrip *strip;
for (strip = strips->first; strip; strip = strip->next) {
for (strip = static_cast<NlaStrip *>(strips->first); strip; strip = strip->next) {
/* Can we use this? */
if (IN_RANGE_INCL(ctime, strip->start, strip->end)) {
/* in range - use this one */
return strip;
}
if ((ctime < strip->start) && (strip->prev == NULL)) {
if ((ctime < strip->start) && (strip->prev == nullptr)) {
/* before first - use this one */
return strip;
}
if ((ctime > strip->end) && (strip->next == NULL)) {
if ((ctime > strip->end) && (strip->next == nullptr)) {
/* after last - use this one */
return strip;
}
}
/* nothing suitable found... */
return NULL;
return nullptr;
}
/* Switch NLA Strips/Actions. */
@ -809,7 +809,7 @@ static bool action_layer_next_poll(bContext *C)
{
/* Action Editor's action editing modes only */
if (ED_operator_action_active(C)) {
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
if (adt) {
/* only allow if we're in tweak-mode, and there's something above us... */
if (adt->flag & ADT_NLA_EDIT_ON) {
@ -829,7 +829,7 @@ static bool action_layer_next_poll(bContext *C)
* to "move to an empty layer", even though this means
* that we won't actually have an action.
*/
// return (adt->tmpact != NULL);
// return (adt->tmpact != nullptr);
return true;
}
}
@ -843,7 +843,7 @@ static bool action_layer_next_poll(bContext *C)
static int action_layer_next_exec(bContext *C, wmOperator *op)
{
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
NlaTrack *act_track;
Scene *scene = CTX_data_scene(C);
@ -852,7 +852,7 @@ static int action_layer_next_exec(bContext *C, wmOperator *op)
/* Get active track */
act_track = BKE_nlatrack_find_tweaked(adt);
if (act_track == NULL) {
if (act_track == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Could not find current NLA Track");
return OPERATOR_CANCELLED;
}
@ -924,7 +924,7 @@ static bool action_layer_prev_poll(bContext *C)
{
/* Action Editor's action editing modes only */
if (ED_operator_action_active(C)) {
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
if (adt) {
if (adt->flag & ADT_NLA_EDIT_ON) {
/* Tweak Mode: We need to check if there are any tracks below the active one
@ -947,7 +947,7 @@ static bool action_layer_prev_poll(bContext *C)
}
else {
/* Normal Mode: If there are any tracks, we can try moving to those */
return (adt->nla_tracks.first != NULL);
return (adt->nla_tracks.first != nullptr);
}
}
}
@ -958,7 +958,7 @@ static bool action_layer_prev_poll(bContext *C)
static int action_layer_prev_exec(bContext *C, wmOperator *op)
{
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
NlaTrack *act_track;
NlaTrack *nlt;
@ -966,7 +966,7 @@ static int action_layer_prev_exec(bContext *C, wmOperator *op)
float ctime = BKE_scene_ctime_get(scene);
/* Sanity Check */
if (adt == NULL) {
if (adt == nullptr) {
BKE_report(
op->reports, RPT_ERROR, "Internal Error: Could not find Animation Data/NLA Stack to use");
return OPERATOR_CANCELLED;
@ -982,7 +982,7 @@ static int action_layer_prev_exec(bContext *C, wmOperator *op)
}
else {
/* Active Action - Use the top-most track */
nlt = adt->nla_tracks.last;
nlt = static_cast<NlaTrack *>(adt->nla_tracks.last);
}
/* Find previous action and hook it up */

View File

@ -7,10 +7,10 @@
/* System includes ----------------------------------------------------- */
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "BLI_blenlib.h"
#include "BLI_math.h"
@ -42,7 +42,7 @@
#include "ED_anim_api.h"
#include "ED_keyframes_draw.h"
#include "action_intern.h"
#include "action_intern.hh"
/* -------------------------------------------------------------------- */
/** \name Channel List
@ -50,23 +50,23 @@
void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
View2D *v2d = &region->v2d;
size_t items;
/* build list of channels to draw */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
const int height = ANIM_UI_get_channels_total_height(v2d, items);
const float pad_bottom = BLI_listbase_is_empty(ac->markers) ? 0 : UI_MARKER_MARGIN_Y;
v2d->tot.ymin = -(height + pad_bottom);
/* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */
UI_view2d_sync(NULL, ac->area, v2d, V2D_LOCK_COPY);
UI_view2d_sync(nullptr, ac->area, v2d, V2D_LOCK_COPY);
const float channel_step = ANIM_UI_get_channel_step();
/* Loop through channels, and set up drawing depending on their type. */
@ -74,7 +74,8 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
size_t channel_index = 0;
float ymax = ANIM_UI_get_first_channel_top(v2d);
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step, channel_index++) {
const float ymin = ymax - ANIM_UI_get_channel_height();
/* check if visible */
@ -90,7 +91,8 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
size_t channel_index = 0;
float ymax = ANIM_UI_get_first_channel_top(v2d);
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step, channel_index++) {
const float ymin = ymax - ANIM_UI_get_channel_height();
/* check if visible */
@ -124,8 +126,8 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
static void draw_channel_action_ranges(ListBase *anim_data, View2D *v2d)
{
/* Variables for coalescing the Y region of one action. */
bAction *cur_action = NULL;
AnimData *cur_adt = NULL;
bAction *cur_action = nullptr;
AnimData *cur_adt = nullptr;
float cur_ymax;
/* Walk through channels, grouping contiguous spans referencing the same action. */
@ -133,9 +135,10 @@ static void draw_channel_action_ranges(ListBase *anim_data, View2D *v2d)
const float ystep = ANIM_UI_get_channel_step();
float ymin = ymax - ystep;
for (bAnimListElem *ale = anim_data->first; ale; ale = ale->next, ymax = ymin, ymin -= ystep) {
bAction *action = NULL;
AnimData *adt = NULL;
for (bAnimListElem *ale = static_cast<bAnimListElem *>(anim_data->first); ale;
ale = ale->next, ymax = ymin, ymin -= ystep) {
bAction *action = nullptr;
AnimData *adt = nullptr;
/* check if visible */
if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
@ -170,12 +173,12 @@ static void draw_channel_action_ranges(ListBase *anim_data, View2D *v2d)
void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
View2D *v2d = &region->v2d;
bDopeSheet *ads = &saction->ads;
AnimData *adt = NULL;
AnimData *adt = nullptr;
uchar col1[4], col2[4];
uchar col1a[4], col2a[4];
@ -196,8 +199,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
UI_GetThemeColor4ubv(TH_DOPESHEET_CHANNELSUBOB, col2b);
/* build list of channels to draw */
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS);
size_t items = ANIM_animdata_filter(
ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
const int height = ANIM_UI_get_channels_total_height(v2d, items);
const float pad_bottom = BLI_listbase_is_empty(ac->markers) ? 0 : UI_MARKER_MARGIN_Y;
@ -220,7 +225,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
/* first backdrop strips */
float ymax = ANIM_UI_get_first_channel_top(v2d);
const float channel_step = ANIM_UI_get_channel_step();
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step) {
const float ymin = ymax - ANIM_UI_get_channel_height();
/* check if visible */
@ -255,7 +261,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
break;
}
case ANIMTYPE_GROUP: {
bActionGroup *agrp = ale->data;
bActionGroup *agrp = static_cast<bActionGroup *>(ale->data);
if (show_group_colors && agrp->customCol) {
if (sel) {
immUniformColor3ubvAlpha((uchar *)agrp->cs.select, col1a[3]);
@ -270,7 +276,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
break;
}
case ANIMTYPE_FCURVE: {
FCurve *fcu = ale->data;
FCurve *fcu = static_cast<FCurve *>(ale->data);
if (show_group_colors && fcu->grp && fcu->grp->customCol) {
immUniformColor3ubvAlpha((uchar *)fcu->grp->cs.active, sel ? col1[3] : col2[3]);
}
@ -375,11 +381,12 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
ymax = ANIM_UI_get_first_channel_top(v2d);
struct AnimKeylistDrawList *draw_list = ED_keylist_draw_list_create();
AnimKeylistDrawList *draw_list = ED_keylist_draw_list_create();
const float scale_factor = ANIM_UI_get_keyframe_scale_factor();
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step) {
const float ymin = ymax - ANIM_UI_get_channel_height();
float ycenter = (ymin + ymax) / 2.0f;
@ -393,28 +400,67 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
/* draw 'keyframes' for each specific datatype */
switch (ale->datatype) {
case ALE_ALL:
draw_summary_channel(draw_list, ale->data, ycenter, scale_factor, action_flag);
draw_summary_channel(draw_list,
static_cast<bAnimContext *>(ale->data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_SCE:
draw_scene_channel(draw_list, ads, ale->key_data, ycenter, scale_factor, action_flag);
draw_scene_channel(draw_list,
ads,
static_cast<Scene *>(ale->key_data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_OB:
draw_object_channel(draw_list, ads, ale->key_data, ycenter, scale_factor, action_flag);
draw_object_channel(draw_list,
ads,
static_cast<Object *>(ale->key_data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_ACT:
draw_action_channel(draw_list, adt, ale->key_data, ycenter, scale_factor, action_flag);
draw_action_channel(draw_list,
adt,
static_cast<bAction *>(ale->key_data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_GROUP:
draw_agroup_channel(draw_list, adt, ale->data, ycenter, scale_factor, action_flag);
draw_agroup_channel(draw_list,
adt,
static_cast<bActionGroup *>(ale->data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_FCURVE:
draw_fcurve_channel(draw_list, adt, ale->key_data, ycenter, scale_factor, action_flag);
draw_fcurve_channel(draw_list,
adt,
static_cast<FCurve *>(ale->key_data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_GPFRAME:
draw_gpl_channel(draw_list, ads, ale->data, ycenter, scale_factor, action_flag);
draw_gpl_channel(draw_list,
ads,
static_cast<bGPDlayer *>(ale->data),
ycenter,
scale_factor,
action_flag);
break;
case ALE_MASKLAY:
draw_masklay_channel(draw_list, ads, ale->data, ycenter, scale_factor, action_flag);
draw_masklay_channel(draw_list,
ads,
static_cast<MaskLayer *>(ale->data),
ycenter,
scale_factor,
action_flag);
break;
}
}
@ -630,7 +676,7 @@ static void timeline_cache_draw_single(PTCacheID *pid, float y_offset, float hei
void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
{
if ((saction->cache_display & TIME_CACHE_DISPLAY) == 0 || ob == NULL) {
if ((saction->cache_display & TIME_CACHE_DISPLAY) == 0 || ob == nullptr) {
return;
}
@ -651,7 +697,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
continue;
}
if (pid->cache->cached_frames == NULL) {
if (pid->cache->cached_frames == nullptr) {
continue;
}

View File

@ -5,10 +5,10 @@
* \ingroup spaction
*/
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "BLI_blenlib.h"
#include "BLI_math.h"
@ -52,7 +52,7 @@
#include "UI_interface.h"
#include "action_intern.h"
#include "action_intern.hh"
/* -------------------------------------------------------------------- */
/** \name Pose Markers: Localize Markers
@ -69,7 +69,7 @@ static bool act_markers_make_local_poll(bContext *C)
SpaceAction *sact = CTX_wm_space_action(C);
/* 1) */
if (sact == NULL) {
if (sact == nullptr) {
return 0;
}
@ -77,7 +77,7 @@ static bool act_markers_make_local_poll(bContext *C)
if (ELEM(sact->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) == 0) {
return 0;
}
if (sact->action == NULL) {
if (sact->action == nullptr) {
return 0;
}
@ -87,25 +87,25 @@ static bool act_markers_make_local_poll(bContext *C)
}
/* 4) */
return ED_markers_get_first_selected(ED_context_get_markers(C)) != NULL;
return ED_markers_get_first_selected(ED_context_get_markers(C)) != nullptr;
}
static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op))
static int act_markers_make_local_exec(bContext *C, wmOperator * /*op*/)
{
ListBase *markers = ED_context_get_markers(C);
SpaceAction *sact = CTX_wm_space_action(C);
bAction *act = (sact) ? sact->action : NULL;
bAction *act = (sact) ? sact->action : nullptr;
TimeMarker *marker, *markern = NULL;
TimeMarker *marker, *markern = nullptr;
/* sanity checks */
if (ELEM(NULL, markers, act)) {
if (ELEM(nullptr, markers, act)) {
return OPERATOR_CANCELLED;
}
/* migrate markers */
for (marker = markers->first; marker; marker = markern) {
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = markern) {
markern = marker->next;
/* move if marker is selected */
@ -120,8 +120,8 @@ static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op))
sact->flag |= SACTION_POSEMARKERS_SHOW;
/* notifiers - both sets, as this change affects both */
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, nullptr);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, nullptr);
return OPERATOR_FINISHED;
}
@ -150,9 +150,9 @@ void ACTION_OT_markers_make_local(wmOperatorType *ot)
/* Get the min/max keyframes. */
static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const short onlySel)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
bool found = false;
/* get data to filter, from Action or Dopesheet */
@ -160,7 +160,7 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
* Commented it, was breaking things (eg. the "auto preview range" tool). */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_SEL */ |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* set large values to try to override */
*min = 999999999.0f;
@ -169,14 +169,14 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
/* check if any channels to set range with */
if (anim_data.first) {
/* go through channels, finding max extents */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
if (ale->datatype == ALE_GPFRAME) {
bGPDlayer *gpl = ale->data;
bGPDlayer *gpl = static_cast<bGPDlayer *>(ale->data);
bGPDframe *gpf;
/* Find gp-frame which is less than or equal to current-frame. */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
for (gpf = static_cast<bGPDframe *>(gpl->frames.first); gpf; gpf = gpf->next) {
if (!onlySel || (gpf->flag & GP_FRAME_SELECT)) {
const float framenum = (float)gpf->framenum;
*min = min_ff(*min, framenum);
@ -186,11 +186,12 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
}
}
else if (ale->datatype == ALE_MASKLAY) {
MaskLayer *masklay = ale->data;
MaskLayer *masklay = static_cast<MaskLayer *>(ale->data);
MaskLayerShape *masklay_shape;
/* Find mask layer which is less than or equal to current-frame. */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
for (masklay_shape = static_cast<MaskLayerShape *>(masklay->splines_shapes.first);
masklay_shape;
masklay_shape = masklay_shape->next) {
const float framenum = (float)masklay_shape->frame;
*min = min_ff(*min, framenum);
@ -248,7 +249,7 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
/** \name View: Automatic Preview-Range Operator
* \{ */
static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_previewrange_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
Scene *scene;
@ -258,7 +259,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
}
if (ac.scene == NULL) {
if (ac.scene == nullptr) {
return OPERATOR_CANCELLED;
}
@ -311,21 +312,22 @@ void ACTION_OT_previewrange_set(wmOperatorType *ot)
*/
static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *r_min, float *r_max)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
/* NOTE: not bool, since we want prioritize individual channels over expanders. */
short found = 0;
/* get all items - we need to do it this way */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* loop through all channels, finding the first one that's selected */
float ymax = ANIM_UI_get_first_channel_top(&ac->region->v2d);
const float channel_step = ANIM_UI_get_channel_step();
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale;
ale = ale->next, ymax -= channel_step) {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
/* must be selected... */
@ -407,7 +409,7 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
float ymid = (ymax - ymin) / 2.0f + ymin;
float x_center;
UI_view2d_center_get(v2d, &x_center, NULL);
UI_view2d_center_get(v2d, &x_center, nullptr);
UI_view2d_center_set(v2d, x_center, ymid);
}
}
@ -423,13 +425,13 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
/* ......... */
static int actkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_viewall_exec(bContext *C, wmOperator * /*op*/)
{
/* whole range */
return actkeys_viewall(C, false);
}
static int actkeys_viewsel_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_viewsel_exec(bContext *C, wmOperator * /*op*/)
{
/* only selected */
return actkeys_viewall(C, true);
@ -506,8 +508,9 @@ void ACTION_OT_view_frame(wmOperatorType *ot)
static short copy_action_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
int filter, ok = 0;
ListBase anim_data = {nullptr, nullptr};
eAnimFilter_Flags filter;
short ok = 0;
/* clear buffer first */
ANIM_fcurves_copybuf_free();
@ -515,7 +518,7 @@ static short copy_action_keys(bAnimContext *ac)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FCURVESONLY |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* copy keyframes */
ok = copy_animedit_keys(ac, &anim_data);
@ -531,8 +534,8 @@ static eKeyPasteError paste_action_keys(bAnimContext *ac,
const eKeyMergeMode merge_mode,
bool flip)
{
ListBase anim_data = {NULL, NULL};
int filter;
ListBase anim_data = {nullptr, nullptr};
eAnimFilter_Flags filter;
/* filter data
* - First time we try to filter more strictly, allowing only selected channels
@ -543,8 +546,9 @@ static eKeyPasteError paste_action_keys(bAnimContext *ac,
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS);
if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) {
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
if (ANIM_animdata_filter(
ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, eAnimCont_Types(ac->datatype)) == 0) {
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
}
/* Value offset is always None because the user cannot see the effect of it. */
@ -614,8 +618,8 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset");
const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge");
const eKeyPasteOffset offset_mode = eKeyPasteOffset(RNA_enum_get(op->ptr, "offset"));
const eKeyMergeMode merge_mode = eKeyMergeMode(RNA_enum_get(op->ptr, "merge"));
const bool flipped = RNA_boolean_get(op->ptr, "flipped");
bool gpframes_inbuf = false;
@ -668,17 +672,15 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
/* Grease Pencil needs extra update to refresh the added keyframes. */
if (ac.datatype == ANIMCONT_GPENCIL || gpframes_inbuf) {
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, nullptr);
}
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
static char *actkeys_paste_description(bContext *UNUSED(C),
wmOperatorType *UNUSED(op),
PointerRNA *ptr)
static char *actkeys_paste_description(bContext * /*C*/, wmOperatorType * /*op*/, PointerRNA *ptr)
{
/* Custom description if the 'flipped' option is used. */
if (RNA_boolean_get(ptr, "flipped")) {
@ -686,7 +688,7 @@ static char *actkeys_paste_description(bContext *UNUSED(C),
}
/* Use the default description in the other cases. */
return NULL;
return nullptr;
}
void ACTION_OT_paste(wmOperatorType *ot)
@ -738,7 +740,7 @@ static const EnumPropertyItem prop_actkeys_insertkey_types[] = {
{2, "SEL", 0, "Only Selected Channels", ""},
/* XXX not in all cases. */
{3, "GROUP", 0, "In Active Group", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static void insert_gpencil_key(bAnimContext *ac,
@ -770,10 +772,10 @@ static void insert_fcurve_key(bAnimContext *ac,
ToolSettings *ts = scene->toolsettings;
/* Read value from property the F-Curve represents, or from the curve only?
* - ale->id != NULL:
* - ale->id != nullptr:
* Typically, this means that we have enough info to try resolving the path.
*
* - ale->owner != NULL:
* - ale->owner != nullptr:
* If this is set, then the path may not be resolvable from the ID alone,
* so it's easier for now to just read the F-Curve directly.
* (TODO: add the full-blown PointerRNA relative parsing case here...)
@ -782,12 +784,12 @@ static void insert_fcurve_key(bAnimContext *ac,
insert_keyframe(ac->bmain,
reports,
ale->id,
NULL,
((fcu->grp) ? (fcu->grp->name) : (NULL)),
nullptr,
((fcu->grp) ? (fcu->grp->name) : (nullptr)),
fcu->rna_path,
fcu->array_index,
&anim_eval_context,
ts->keyframe_type,
eBezTriple_KeyframeType(ts->keyframe_type),
nla_cache,
flag);
}
@ -801,7 +803,8 @@ static void insert_fcurve_key(bAnimContext *ac,
}
const float curval = evaluate_fcurve(fcu, cfra);
insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0);
insert_vert_fcurve(
fcu, cfra, curval, eBezTriple_KeyframeType(ts->keyframe_type), eInsertKeyFlags(0));
}
ale->update |= ANIM_UPDATE_DEFAULT;
@ -810,17 +813,17 @@ static void insert_fcurve_key(bAnimContext *ac,
/* this function is responsible for inserting new keyframes */
static void insert_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase nla_cache = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
ListBase nla_cache = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
Scene *scene = ac->scene;
ToolSettings *ts = scene->toolsettings;
eInsertKeyFlags flag;
eGP_GetFrame_Mode add_frame_mode;
bGPdata *gpd_old = NULL;
bGPdata *gpd_old = nullptr;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
@ -832,7 +835,7 @@ static void insert_action_keys(bAnimContext *ac, short mode)
filter |= ANIMFILTER_ACTGROUPED;
}
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Init keyframing flag. */
flag = ANIM_get_keyframing_flags(scene, true);
@ -848,7 +851,7 @@ static void insert_action_keys(bAnimContext *ac, short mode)
/* insert keyframes */
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
ac->depsgraph, (float)scene->r.cfra);
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
switch (ale->type) {
case ANIMTYPE_GPLAYER:
insert_gpencil_key(ac, ale, add_frame_mode, &gpd_old);
@ -894,9 +897,9 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op)
/* set notifier that keyframes have changed */
if (ac.datatype == ANIMCONT_GPENCIL) {
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, nullptr);
}
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, nullptr);
return OPERATOR_FINISHED;
}
@ -928,18 +931,18 @@ void ACTION_OT_keyframe_insert(wmOperatorType *ot)
static bool duplicate_action_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
bool changed = false;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* loop through filtered data and delete selected keys */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
changed |= duplicate_fcurve_keys((FCurve *)ale->key_data);
}
@ -965,7 +968,7 @@ static bool duplicate_action_keys(bAnimContext *ac)
/* ------------------- */
static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_duplicate_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@ -980,7 +983,7 @@ static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
}
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, nullptr);
return OPERATOR_FINISHED;
}
@ -1008,18 +1011,18 @@ void ACTION_OT_duplicate(wmOperatorType *ot)
static bool delete_action_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
bool changed_final = false;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* loop through filtered data and delete selected keys */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
bool changed = false;
if (ale->type == ANIMTYPE_GPLAYER) {
@ -1038,7 +1041,7 @@ static bool delete_action_keys(bAnimContext *ac)
/* Only delete curve too if it won't be doing anything anymore */
if (BKE_fcurve_is_empty(fcu)) {
ANIM_fcurve_delete_from_animdata(ac, adt, fcu);
ale->key_data = NULL;
ale->key_data = nullptr;
}
}
@ -1056,7 +1059,7 @@ static bool delete_action_keys(bAnimContext *ac)
/* ------------------- */
static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_delete_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
@ -1071,7 +1074,7 @@ static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
}
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, nullptr);
return OPERATOR_FINISHED;
}
@ -1101,17 +1104,17 @@ void ACTION_OT_delete(wmOperatorType *ot)
static void clean_action_keys(bAnimContext *ac, float thresh, bool clean_chan)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_SEL | ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* loop through filtered data and clean curves */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
clean_fcurve(ac, ale, thresh, clean_chan);
ale->update |= ANIM_UPDATE_DEFAULT;
@ -1147,7 +1150,7 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op)
clean_action_keys(&ac, thresh, clean_chan);
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@ -1182,17 +1185,17 @@ void ACTION_OT_clean(wmOperatorType *ot)
/* Evaluates the curves between each selected keyframe on each frame, and keys the value. */
static void sample_action_keys(bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Loop through filtered data and add keys between selected keyframes on every frame. */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
sample_fcurve((FCurve *)ale->key_data);
ale->update |= ANIM_UPDATE_DEPS;
@ -1222,7 +1225,7 @@ static int actkeys_sample_exec(bContext *C, wmOperator *op)
sample_action_keys(&ac);
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@ -1275,23 +1278,23 @@ static const EnumPropertyItem prop_actkeys_expo_types[] = {
0,
"Clear Cyclic (F-Modifier)",
"Remove Cycles F-Modifier if not needed anymore"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* this function is responsible for setting extrapolation mode for keyframes */
static void setexpo_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_SEL | ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* loop through setting mode per F-Curve */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
if (mode >= 0) {
@ -1311,9 +1314,9 @@ static void setexpo_action_keys(bAnimContext *ac, short mode)
}
else if (mode == CLEAR_CYCLIC_EXPO) {
/* remove all the modifiers fitting this description */
FModifier *fcm, *fcn = NULL;
FModifier *fcm, *fcn = nullptr;
for (fcm = fcu->modifiers.first; fcm; fcm = fcn) {
for (fcm = static_cast<FModifier *>(fcu->modifiers.first); fcm; fcm = fcn) {
fcn = fcm->next;
if (fcm->type == FMODIFIER_TYPE_CYCLES) {
@ -1354,7 +1357,7 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op)
setexpo_action_keys(&ac, mode);
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@ -1410,7 +1413,7 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op)
ANIM_editkeyframes_ipo(mode));
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@ -1464,7 +1467,7 @@ static int actkeys_easing_exec(bContext *C, wmOperator *op)
ANIM_editkeyframes_easing(mode));
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@ -1499,9 +1502,9 @@ void ACTION_OT_easing_type(wmOperatorType *ot)
/* this function is responsible for setting handle-type of selected keyframes */
static void sethandles_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode);
KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
@ -1509,19 +1512,19 @@ static void sethandles_action_keys(bAnimContext *ac, short mode)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Loop through setting flags for handles
* NOTE: we do not supply KeyframeEditData to the looper yet.
* Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
/* any selected keyframes for editing? */
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) {
if (ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, sel_cb, nullptr)) {
/* change type of selected handles */
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, edit_cb, BKE_fcurve_handles_recalc);
ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, edit_cb, BKE_fcurve_handles_recalc);
ale->update |= ANIM_UPDATE_DEFAULT;
}
@ -1555,7 +1558,7 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op)
sethandles_action_keys(&ac, mode);
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@ -1588,29 +1591,30 @@ void ACTION_OT_handle_type(wmOperatorType *ot)
/* this function is responsible for setting keyframe type for keyframes */
static void setkeytype_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditFunc set_cb = ANIM_editkeyframes_keytype(mode);
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* Loop through setting BezTriple interpolation
* NOTE: we do not supply KeyframeEditData to the looper yet.
* Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
switch (ale->type) {
case ANIMTYPE_GPLAYER:
ED_gpencil_layer_frames_keytype_set(ale->data, mode);
ED_gpencil_layer_frames_keytype_set(static_cast<bGPDlayer *>(ale->data), mode);
ale->update |= ANIM_UPDATE_DEPS;
break;
case ANIMTYPE_FCURVE:
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, NULL);
ANIM_fcurve_keyframes_loop(
nullptr, static_cast<FCurve *>(ale->key_data), nullptr, set_cb, nullptr);
ale->update |= ANIM_UPDATE_DEPS | ANIM_UPDATE_HANDLES;
break;
@ -1647,7 +1651,7 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op)
setkeytype_action_keys(&ac, mode);
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr);
return OPERATOR_FINISHED;
}
@ -1688,13 +1692,13 @@ static bool actkeys_framejump_poll(bContext *C)
}
/* snap current-frame indicator to 'average time' of selected keyframe */
static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
static int actkeys_framejump_exec(bContext *C, wmOperator * /*op*/)
{
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
KeyframeEditData ked = {{NULL}};
eAnimFilter_Flags filter;
KeyframeEditData ked = {{nullptr}};
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
@ -1704,15 +1708,15 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
/* init edit data */
/* loop over action data, averaging values */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
switch (ale->datatype) {
case ALE_GPFRAME: {
bGPDlayer *gpl = ale->data;
bGPDlayer *gpl = static_cast<bGPDlayer *>(ale->data);
bGPDframe *gpf;
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
for (gpf = static_cast<bGPDframe *>(gpl->frames.first); gpf; gpf = gpf->next) {
/* only if selected */
if (!(gpf->flag & GP_FRAME_SELECT)) {
continue;
@ -1728,13 +1732,14 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
case ALE_FCURVE: {
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
FCurve *fcurve = static_cast<FCurve *>(ale->key_data);
if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, bezt_calc_average, nullptr);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 1, 1);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, bezt_calc_average, nullptr);
}
break;
}
@ -1803,17 +1808,17 @@ static const EnumPropertyItem prop_actkeys_snap_types[] = {
0,
"Selection to Nearest Marker",
"Snap selected keyframes to the nearest marker"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* this function is responsible for snapping keyframes to frame-times */
static void snap_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
KeyframeEditFunc edit_cb;
/* filter data */
@ -1824,38 +1829,40 @@ static void snap_action_keys(bAnimContext *ac, short mode)
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
}
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* get beztriple editing callbacks */
edit_cb = ANIM_editkeyframes_snap(mode);
ked.scene = ac->scene;
if (mode == ACTKEYS_SNAP_NEAREST_MARKER) {
ked.list.first = (ac->markers) ? ac->markers->first : NULL;
ked.list.last = (ac->markers) ? ac->markers->last : NULL;
ked.list.first = (ac->markers) ? ac->markers->first : nullptr;
ked.list.last = (ac->markers) ? ac->markers->last : nullptr;
}
/* snap keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_layer_snap_frames(ale->data, ac->scene, mode);
ED_gpencil_layer_snap_frames(static_cast<bGPDlayer *>(ale->data), ac->scene, mode);
}
else if (ale->type == ANIMTYPE_MASKLAYER) {
ED_masklayer_snap_frames(ale->data, ac->scene, mode);
ED_masklayer_snap_frames(static_cast<MaskLayer *>(ale->data), ac->scene, mode);
}
else if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
FCurve *fcurve = static_cast<FCurve *>(ale->key_data);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, edit_cb, BKE_fcurve_handles_recalc);
BKE_fcurve_merge_duplicate_keys(
ale->key_data, SELECT, false); /* only use handles in graph editor */
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
fcurve, SELECT, false); /* only use handles in graph editor */
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 1, 0);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
FCurve *fcurve = static_cast<FCurve *>(ale->key_data);
ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, edit_cb, BKE_fcurve_handles_recalc);
BKE_fcurve_merge_duplicate_keys(
ale->key_data, SELECT, false); /* only use handles in graph editor */
fcurve, SELECT, false); /* only use handles in graph editor */
}
ale->update |= ANIM_UPDATE_DEFAULT;
@ -1884,7 +1891,7 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op)
snap_action_keys(&ac, mode);
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}
@ -1931,17 +1938,17 @@ static const EnumPropertyItem prop_actkeys_mirror_types[] = {
0,
"By Times Over First Selected Marker",
"Flip times of selected keyframes using the first selected marker as the reference point"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* this function is responsible for mirroring keyframes */
static void mirror_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
ListBase anim_data = {nullptr, nullptr};
bAnimListElem *ale;
int filter;
eAnimFilter_Flags filter;
KeyframeEditData ked = {{NULL}};
KeyframeEditData ked = {{nullptr}};
KeyframeEditFunc edit_cb;
/* get beztriple editing callbacks */
@ -1965,25 +1972,27 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
/* mirror keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gpencil_layer_mirror_frames(ale->data, ac->scene, mode);
ED_gpencil_layer_mirror_frames(static_cast<bGPDlayer *>(ale->data), ac->scene, mode);
}
else if (ale->type == ANIMTYPE_MASKLAYER) {
/* TODO */
}
else if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
FCurve *fcurve = static_cast<FCurve *>(ale->key_data);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, edit_cb, BKE_fcurve_handles_recalc);
ANIM_nla_mapping_apply_fcurve(adt, fcurve, 1, 0);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, BKE_fcurve_handles_recalc);
ANIM_fcurve_keyframes_loop(
&ked, static_cast<FCurve *>(ale->key_data), nullptr, edit_cb, BKE_fcurve_handles_recalc);
}
ale->update |= ANIM_UPDATE_DEFAULT;
@ -2012,7 +2021,7 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op)
mirror_action_keys(&ac, mode);
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr);
return OPERATOR_FINISHED;
}

View File

@ -1,135 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2008 Blender Foundation. All rights reserved. */
/** \file
* \ingroup spaction
*/
#pragma once
struct ARegion;
struct ARegionType;
struct Object;
struct Scene;
struct SpaceAction;
struct bAnimContext;
struct bContext;
struct wmOperatorType;
/* internal exports only */
/* **************************************** */
/* space_action.c / action_buttons.c */
void action_buttons_register(struct ARegionType *art);
/* ***************************************** */
/* action_draw.c */
/**
* Left hand part.
*/
void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *region);
/**
* Draw keyframes in each channel.
*/
void draw_channel_strips(struct bAnimContext *ac,
struct SpaceAction *saction,
struct ARegion *region);
void timeline_draw_cache(struct SpaceAction *saction, struct Object *ob, struct Scene *scene);
/* ***************************************** */
/* action_select.c */
void ACTION_OT_select_all(struct wmOperatorType *ot);
void ACTION_OT_select_box(struct wmOperatorType *ot);
void ACTION_OT_select_lasso(struct wmOperatorType *ot);
void ACTION_OT_select_circle(struct wmOperatorType *ot);
void ACTION_OT_select_column(struct wmOperatorType *ot);
void ACTION_OT_select_linked(struct wmOperatorType *ot);
void ACTION_OT_select_more(struct wmOperatorType *ot);
void ACTION_OT_select_less(struct wmOperatorType *ot);
void ACTION_OT_select_leftright(struct wmOperatorType *ot);
void ACTION_OT_clickselect(struct wmOperatorType *ot);
/* defines for left-right select tool */
enum eActKeys_LeftRightSelect_Mode {
ACTKEYS_LRSEL_TEST = 0,
ACTKEYS_LRSEL_LEFT,
ACTKEYS_LRSEL_RIGHT,
};
/* defines for column-select mode */
enum eActKeys_ColumnSelect_Mode {
ACTKEYS_COLUMNSEL_KEYS = 0,
ACTKEYS_COLUMNSEL_CFRA,
ACTKEYS_COLUMNSEL_MARKERS_COLUMN,
ACTKEYS_COLUMNSEL_MARKERS_BETWEEN,
};
/* ***************************************** */
/* action_edit.c */
void ACTION_OT_previewrange_set(struct wmOperatorType *ot);
void ACTION_OT_view_all(struct wmOperatorType *ot);
void ACTION_OT_view_selected(struct wmOperatorType *ot);
void ACTION_OT_view_frame(struct wmOperatorType *ot);
void ACTION_OT_copy(struct wmOperatorType *ot);
void ACTION_OT_paste(struct wmOperatorType *ot);
void ACTION_OT_keyframe_insert(struct wmOperatorType *ot);
void ACTION_OT_duplicate(struct wmOperatorType *ot);
void ACTION_OT_delete(struct wmOperatorType *ot);
void ACTION_OT_clean(struct wmOperatorType *ot);
void ACTION_OT_sample(struct wmOperatorType *ot);
void ACTION_OT_keyframe_type(struct wmOperatorType *ot);
void ACTION_OT_handle_type(struct wmOperatorType *ot);
void ACTION_OT_interpolation_type(struct wmOperatorType *ot);
void ACTION_OT_extrapolation_type(struct wmOperatorType *ot);
void ACTION_OT_easing_type(struct wmOperatorType *ot);
void ACTION_OT_frame_jump(struct wmOperatorType *ot);
void ACTION_OT_snap(struct wmOperatorType *ot);
void ACTION_OT_mirror(struct wmOperatorType *ot);
void ACTION_OT_new(struct wmOperatorType *ot);
void ACTION_OT_unlink(struct wmOperatorType *ot);
void ACTION_OT_push_down(struct wmOperatorType *ot);
void ACTION_OT_stash(struct wmOperatorType *ot);
void ACTION_OT_stash_and_create(struct wmOperatorType *ot);
void ACTION_OT_layer_next(struct wmOperatorType *ot);
void ACTION_OT_layer_prev(struct wmOperatorType *ot);
void ACTION_OT_markers_make_local(struct wmOperatorType *ot);
/* defines for snap keyframes
* NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h)
*/
enum eActKeys_Snap_Mode {
ACTKEYS_SNAP_CFRA = 1,
ACTKEYS_SNAP_NEAREST_FRAME,
ACTKEYS_SNAP_NEAREST_SECOND,
ACTKEYS_SNAP_NEAREST_MARKER,
};
/* defines for mirror keyframes
* NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.h)
*/
enum eActKeys_Mirror_Mode {
ACTKEYS_MIRROR_CFRA = 1,
ACTKEYS_MIRROR_YAXIS,
ACTKEYS_MIRROR_XAXIS,
ACTKEYS_MIRROR_MARKER,
};
/* ***************************************** */
/* action_ops.c */
void action_operatortypes(void);
void action_keymap(struct wmKeyConfig *keyconf);

View File

@ -0,0 +1,133 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2008 Blender Foundation. All rights reserved. */
/** \file
* \ingroup spaction
*/
#pragma once
struct ARegion;
struct ARegionType;
struct Object;
struct Scene;
struct SpaceAction;
struct bAnimContext;
struct bContext;
struct wmOperatorType;
/* internal exports only */
/* **************************************** */
/* space_action.c / action_buttons.c */
void action_buttons_register(ARegionType *art);
/* ***************************************** */
/* action_draw.c */
/**
* Left hand part.
*/
void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region);
/**
* Draw keyframes in each channel.
*/
void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region);
void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene);
/* ***************************************** */
/* action_select.c */
void ACTION_OT_select_all(wmOperatorType *ot);
void ACTION_OT_select_box(wmOperatorType *ot);
void ACTION_OT_select_lasso(wmOperatorType *ot);
void ACTION_OT_select_circle(wmOperatorType *ot);
void ACTION_OT_select_column(wmOperatorType *ot);
void ACTION_OT_select_linked(wmOperatorType *ot);
void ACTION_OT_select_more(wmOperatorType *ot);
void ACTION_OT_select_less(wmOperatorType *ot);
void ACTION_OT_select_leftright(wmOperatorType *ot);
void ACTION_OT_clickselect(wmOperatorType *ot);
/* defines for left-right select tool */
enum eActKeys_LeftRightSelect_Mode {
ACTKEYS_LRSEL_TEST = 0,
ACTKEYS_LRSEL_LEFT,
ACTKEYS_LRSEL_RIGHT,
};
/* defines for column-select mode */
enum eActKeys_ColumnSelect_Mode {
ACTKEYS_COLUMNSEL_KEYS = 0,
ACTKEYS_COLUMNSEL_CFRA,
ACTKEYS_COLUMNSEL_MARKERS_COLUMN,
ACTKEYS_COLUMNSEL_MARKERS_BETWEEN,
};
/* ***************************************** */
/* action_edit.c */
void ACTION_OT_previewrange_set(wmOperatorType *ot);
void ACTION_OT_view_all(wmOperatorType *ot);
void ACTION_OT_view_selected(wmOperatorType *ot);
void ACTION_OT_view_frame(wmOperatorType *ot);
void ACTION_OT_copy(wmOperatorType *ot);
void ACTION_OT_paste(wmOperatorType *ot);
void ACTION_OT_keyframe_insert(wmOperatorType *ot);
void ACTION_OT_duplicate(wmOperatorType *ot);
void ACTION_OT_delete(wmOperatorType *ot);
void ACTION_OT_clean(wmOperatorType *ot);
void ACTION_OT_sample(wmOperatorType *ot);
void ACTION_OT_keyframe_type(wmOperatorType *ot);
void ACTION_OT_handle_type(wmOperatorType *ot);
void ACTION_OT_interpolation_type(wmOperatorType *ot);
void ACTION_OT_extrapolation_type(wmOperatorType *ot);
void ACTION_OT_easing_type(wmOperatorType *ot);
void ACTION_OT_frame_jump(wmOperatorType *ot);
void ACTION_OT_snap(wmOperatorType *ot);
void ACTION_OT_mirror(wmOperatorType *ot);
void ACTION_OT_new(wmOperatorType *ot);
void ACTION_OT_unlink(wmOperatorType *ot);
void ACTION_OT_push_down(wmOperatorType *ot);
void ACTION_OT_stash(wmOperatorType *ot);
void ACTION_OT_stash_and_create(wmOperatorType *ot);
void ACTION_OT_layer_next(wmOperatorType *ot);
void ACTION_OT_layer_prev(wmOperatorType *ot);
void ACTION_OT_markers_make_local(wmOperatorType *ot);
/* defines for snap keyframes
* NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h)
*/
enum eActKeys_Snap_Mode {
ACTKEYS_SNAP_CFRA = 1,
ACTKEYS_SNAP_NEAREST_FRAME,
ACTKEYS_SNAP_NEAREST_SECOND,
ACTKEYS_SNAP_NEAREST_MARKER,
};
/* defines for mirror keyframes
* NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.h)
*/
enum eActKeys_Mirror_Mode {
ACTKEYS_MIRROR_CFRA = 1,
ACTKEYS_MIRROR_YAXIS,
ACTKEYS_MIRROR_XAXIS,
ACTKEYS_MIRROR_MARKER,
};
/* ***************************************** */
/* action_ops.c */
void action_operatortypes(void);
void action_keymap(wmKeyConfig *keyconf);

View File

@ -5,15 +5,15 @@
* \ingroup spaction
*/
#include <math.h>
#include <stdlib.h>
#include <cmath>
#include <cstdlib>
#include "DNA_space_types.h"
#include "ED_anim_api.h"
#include "ED_transform.h"
#include "action_intern.h"
#include "action_intern.hh"
#include "RNA_access.h"

View File

@ -5,8 +5,8 @@
* \ingroup spaction
*/
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <cstring>
#include "DNA_action_types.h"
#include "DNA_anim_types.h"
@ -44,7 +44,7 @@
#include "BLO_read_write.h"
#include "action_intern.h" /* own include */
#include "action_intern.hh" /* own include */
/* -------------------------------------------------------------------- */
/** \name Default Callbacks for Action Space
@ -55,7 +55,7 @@ static SpaceLink *action_create(const ScrArea *area, const Scene *scene)
SpaceAction *saction;
ARegion *region;
saction = MEM_callocN(sizeof(SpaceAction), "initaction");
saction = MEM_cnew<SpaceAction>("initaction");
saction->spacetype = SPACE_ACTION;
saction->autosnap = SACTSNAP_FRAME;
@ -72,14 +72,14 @@ static SpaceLink *action_create(const ScrArea *area, const Scene *scene)
saction->cache_display |= TIME_CACHE_RIGIDBODY;
/* header */
region = MEM_callocN(sizeof(ARegion), "header for action");
region = MEM_cnew<ARegion>("header for action");
BLI_addtail(&saction->regionbase, region);
region->regiontype = RGN_TYPE_HEADER;
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
/* channel list region */
region = MEM_callocN(sizeof(ARegion), "channel region for action");
region = MEM_cnew<ARegion>("channel region for action");
BLI_addtail(&saction->regionbase, region);
region->regiontype = RGN_TYPE_CHANNELS;
region->alignment = RGN_ALIGN_LEFT;
@ -89,14 +89,14 @@ static SpaceLink *action_create(const ScrArea *area, const Scene *scene)
region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
/* ui buttons */
region = MEM_callocN(sizeof(ARegion), "buttons region for action");
region = MEM_cnew<ARegion>("buttons region for action");
BLI_addtail(&saction->regionbase, region);
region->regiontype = RGN_TYPE_UI;
region->alignment = RGN_ALIGN_RIGHT;
/* main region */
region = MEM_callocN(sizeof(ARegion), "main region for action");
region = MEM_cnew<ARegion>("main region for action");
BLI_addtail(&saction->regionbase, region);
region->regiontype = RGN_TYPE_WINDOW;
@ -127,21 +127,21 @@ static SpaceLink *action_create(const ScrArea *area, const Scene *scene)
}
/* not spacelink itself */
static void action_free(SpaceLink *UNUSED(sl))
static void action_free(SpaceLink * /*sl*/)
{
// SpaceAction *saction = (SpaceAction *) sl;
}
/* spacetype; init callback */
static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *area)
static void action_init(wmWindowManager * /*wm*/, ScrArea *area)
{
SpaceAction *saction = area->spacedata.first;
SpaceAction *saction = static_cast<SpaceAction *>(area->spacedata.first);
saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
}
static SpaceLink *action_duplicate(SpaceLink *sl)
{
SpaceAction *sactionn = MEM_dupallocN(sl);
SpaceAction *sactionn = static_cast<SpaceAction *>(MEM_dupallocN(sl));
memset(&sactionn->runtime, 0x0, sizeof(sactionn->runtime));
@ -192,7 +192,7 @@ static void action_main_region_draw(const bContext *C, ARegion *region)
/* Draw the manually set intended playback frame range highlight in the Action editor. */
if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) && saction->action) {
AnimData *adt = ED_actedit_animdata_from_context(C, NULL);
AnimData *adt = ED_actedit_animdata_from_context(C, nullptr);
ANIM_draw_action_framerange(adt, saction->action, v2d, -FLT_MAX, FLT_MAX);
}
@ -246,7 +246,7 @@ static void action_main_region_draw_overlay(const bContext *C, ARegion *region)
ED_time_scrub_draw_current_frame(region, scene, saction->flag & SACTION_DRAWTIME);
/* scrollers */
UI_view2d_scrollers_draw(v2d, NULL);
UI_view2d_scrollers_draw(v2d, nullptr);
}
/* add handlers, stuff you only do once or on area/region changes */
@ -293,7 +293,7 @@ static void action_channel_region_draw(const bContext *C, ARegion *region)
}
/* add handlers, stuff you only do once or on area/region changes */
static void action_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
static void action_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
{
ED_region_header_init(region);
}
@ -360,7 +360,7 @@ static void action_channel_region_listener(const wmRegionListenerParams *params)
static void saction_channel_region_message_subscribe(const wmRegionMessageSubscribeParams *params)
{
struct wmMsgBus *mbus = params->message_bus;
wmMsgBus *mbus = params->message_bus;
bScreen *screen = params->screen;
ScrArea *area = params->area;
ARegion *region = params->region;
@ -368,11 +368,10 @@ static void saction_channel_region_message_subscribe(const wmRegionMessageSubscr
PointerRNA ptr;
RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, area->spacedata.first, &ptr);
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
.user_data = region,
.notify = ED_region_do_msg_notify_tag_redraw,
};
wmMsgSubscribeValue msg_sub_value_region_tag_redraw{};
msg_sub_value_region_tag_redraw.owner = region;
msg_sub_value_region_tag_redraw.user_data = region;
msg_sub_value_region_tag_redraw.notify = ED_region_do_msg_notify_tag_redraw;
/* All dopesheet filter settings, etc. affect the drawing of this editor,
* also same applies for all animation-related datatypes that may appear here,
@ -477,7 +476,7 @@ static void action_main_region_listener(const wmRegionListenerParams *params)
static void saction_main_region_message_subscribe(const wmRegionMessageSubscribeParams *params)
{
struct wmMsgBus *mbus = params->message_bus;
wmMsgBus *mbus = params->message_bus;
Scene *scene = params->scene;
bScreen *screen = params->screen;
ScrArea *area = params->area;
@ -486,11 +485,10 @@ static void saction_main_region_message_subscribe(const wmRegionMessageSubscribe
PointerRNA ptr;
RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, area->spacedata.first, &ptr);
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
.user_data = region,
.notify = ED_region_do_msg_notify_tag_redraw,
};
wmMsgSubscribeValue msg_sub_value_region_tag_redraw{};
msg_sub_value_region_tag_redraw.owner = region;
msg_sub_value_region_tag_redraw.user_data = region;
msg_sub_value_region_tag_redraw.notify = ED_region_do_msg_notify_tag_redraw;
/* Timeline depends on scene properties. */
{
@ -578,7 +576,7 @@ static void action_listener(const wmSpaceTypeListenerParams *params)
case ND_FRAME_RANGE:
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
Scene *scene = wmn->reference;
Scene *scene = static_cast<Scene *>(wmn->reference);
region->v2d.tot.xmin = (float)(scene->r.sfra - 4);
region->v2d.tot.xmax = (float)(scene->r.efra + 4);
break;
@ -801,7 +799,7 @@ static void action_refresh(const bContext *C, ScrArea *area)
* or else they don't update #28962.
*/
ED_area_tag_redraw(area);
for (region = area->regionbase.first; region; region = region->next) {
for (region = static_cast<ARegion *>(area->regionbase.first); region; region = region->next) {
ED_region_tag_redraw(region);
}
}
@ -810,9 +808,7 @@ static void action_refresh(const bContext *C, ScrArea *area)
/* XXX re-sizing y-extents of tot should go here? */
}
static void action_id_remap(ScrArea *UNUSED(area),
SpaceLink *slink,
const struct IDRemapper *mappings)
static void action_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings)
{
SpaceAction *sact = (SpaceAction *)slink;
@ -828,13 +824,13 @@ static void action_id_remap(ScrArea *UNUSED(area),
*/
static int action_space_subtype_get(ScrArea *area)
{
SpaceAction *sact = area->spacedata.first;
SpaceAction *sact = static_cast<SpaceAction *>(area->spacedata.first);
return sact->mode == SACTCONT_TIMELINE ? SACTCONT_TIMELINE : SACTCONT_DOPESHEET;
}
static void action_space_subtype_set(ScrArea *area, int value)
{
SpaceAction *sact = area->spacedata.first;
SpaceAction *sact = static_cast<SpaceAction *>(area->spacedata.first);
if (value == SACTCONT_TIMELINE) {
if (sact->mode != SACTCONT_TIMELINE) {
sact->mode_prev = sact->mode;
@ -846,14 +842,14 @@ static void action_space_subtype_set(ScrArea *area, int value)
}
}
static void action_space_subtype_item_extend(bContext *UNUSED(C),
static void action_space_subtype_item_extend(bContext * /*C*/,
EnumPropertyItem **item,
int *totitem)
{
RNA_enum_items_add(item, totitem, rna_enum_space_action_mode_items);
}
static void action_blend_read_data(BlendDataReader *UNUSED(reader), SpaceLink *sl)
static void action_blend_read_data(BlendDataReader * /*reader*/, SpaceLink *sl)
{
SpaceAction *saction = (SpaceAction *)sl;
memset(&saction->runtime, 0x0, sizeof(saction->runtime));
@ -877,7 +873,7 @@ static void action_blend_write(BlendWriter *writer, SpaceLink *sl)
BLO_write_struct(writer, SpaceAction, sl);
}
static void action_main_region_view2d_changed(const bContext *UNUSED(C), ARegion *region)
static void action_main_region_view2d_changed(const bContext * /*C*/, ARegion *region)
{
/* V2D_KEEPTOT_STRICT cannot be used to clamp scrolling
* because it also clamps the x-axis to 0. */
@ -886,7 +882,7 @@ static void action_main_region_view2d_changed(const bContext *UNUSED(C), ARegion
void ED_spacetype_action(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype action");
SpaceType *st = MEM_cnew<SpaceType>("spacetype action");
ARegionType *art;
st->spaceid = SPACE_ACTION;
@ -909,7 +905,7 @@ void ED_spacetype_action(void)
st->blend_write = action_blend_write;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
art = MEM_cnew<ARegionType>("spacetype action region");
art->regionid = RGN_TYPE_WINDOW;
art->init = action_main_region_init;
art->draw = action_main_region_draw;
@ -922,7 +918,7 @@ void ED_spacetype_action(void)
BLI_addhead(&st->regiontypes, art);
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
art = MEM_cnew<ARegionType>("spacetype action region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
@ -934,7 +930,7 @@ void ED_spacetype_action(void)
BLI_addhead(&st->regiontypes, art);
/* regions: channels */
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
art = MEM_cnew<ARegionType>("spacetype action region");
art->regionid = RGN_TYPE_CHANNELS;
art->prefsizex = 200;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
@ -947,7 +943,7 @@ void ED_spacetype_action(void)
BLI_addhead(&st->regiontypes, art);
/* regions: UI buttons */
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
art = MEM_cnew<ARegionType>("spacetype action region");
art->regionid = RGN_TYPE_UI;
art->prefsizex = UI_SIDEBAR_PANEL_WIDTH;
art->keymapflag = ED_KEYMAP_UI;

View File

@ -181,7 +181,7 @@ static void node_add_catalog_assets_draw(const bContext *C, Menu *menu)
for (const LibraryAsset &item : asset_items) {
uiLayout *col = uiLayoutColumn(layout, false);
PointerRNA asset_ptr{NULL, &RNA_AssetRepresentation, &item.asset};
PointerRNA asset_ptr{nullptr, &RNA_AssetRepresentation, &item.asset};
uiLayoutSetContextPointer(col, "asset", &asset_ptr);
PointerRNA library_ptr{&screen.id,
@ -190,7 +190,7 @@ static void node_add_catalog_assets_draw(const bContext *C, Menu *menu)
uiLayoutSetContextPointer(col, "asset_library_ref", &library_ptr);
uiItemO(
col, AS_asset_representation_name_get(&item.asset), ICON_NONE, "NODE_OT_add_group_asset");
col, IFACE_(AS_asset_representation_name_get(&item.asset)), ICON_NONE, "NODE_OT_add_group_asset");
}
catalog_item->foreach_child([&](asset_system::AssetCatalogTreeItem &child_item) {
@ -200,7 +200,7 @@ static void node_add_catalog_assets_draw(const bContext *C, Menu *menu)
&screen.id, &RNA_AssetCatalogPath, const_cast<asset_system::AssetCatalogPath *>(&path)};
uiLayout *col = uiLayoutColumn(layout, false);
uiLayoutSetContextPointer(col, "asset_catalog_path", &path_ptr);
uiItemM(col, "NODE_MT_node_add_catalog_assets", path.name().c_str(), ICON_NONE);
uiItemM(col, "NODE_MT_node_add_catalog_assets", IFACE_(path.name().c_str()), ICON_NONE);
});
}
@ -270,7 +270,7 @@ static void add_root_catalogs_draw(const bContext *C, Menu *menu)
&screen.id, &RNA_AssetCatalogPath, const_cast<asset_system::AssetCatalogPath *>(&path)};
uiLayout *col = uiLayoutColumn(layout, false);
uiLayoutSetContextPointer(col, "asset_catalog_path", &path_ptr);
uiItemM(col, "NODE_MT_node_add_catalog_assets", path.name().c_str(), ICON_NONE);
uiItemM(col, "NODE_MT_node_add_catalog_assets", IFACE_(path.name().c_str()), ICON_NONE);
});
}

View File

@ -1547,8 +1547,10 @@ void draw_nodespace_back_pix(const bContext &C,
if (ibuf) {
/* somehow the offset has to be calculated inverse */
wmOrtho2_region_pixelspace(&region);
const float x = (region.winx - snode.zoom * ibuf->x) / 2 + snode.xof;
const float y = (region.winy - snode.zoom * ibuf->y) / 2 + snode.yof;
const float offset_x = snode.xof + ima->offset_x * snode.zoom;
const float offset_y = snode.yof + ima->offset_y * snode.zoom;
const float x = (region.winx - snode.zoom * ibuf->x) / 2 + offset_x;
const float y = (region.winy - snode.zoom * ibuf->y) / 2 + offset_y;
/** \note draw selected info on backdrop */
if (snode.edittree) {

View File

@ -468,7 +468,7 @@ static char *node_add_group_asset_get_description(struct bContext *C,
if (!asset_data.description) {
return nullptr;
}
return BLI_strdup(asset_data.description);
return BLI_strdup(DATA_(asset_data.description));
}
void NODE_OT_add_group_asset(wmOperatorType *ot)

View File

@ -402,9 +402,14 @@ static void node_area_listener(const wmSpaceTypeListenerParams *params)
case ND_FRAME:
node_area_tag_tree_recalc(snode, area);
break;
case ND_COMPO_RESULT:
case ND_COMPO_RESULT: {
ED_area_tag_redraw(area);
/* Backdrop image offset is calculated during compositing so gizmos need to be updated
* afterwards. */
const ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
WM_gizmomap_tag_refresh(region->gizmo_map);
break;
}
case ND_TRANSFORM_DONE:
node_area_tag_recalc_auto_compositing(snode, area);
break;

View File

@ -1040,19 +1040,6 @@ void UV_OT_minimize_stretch(wmOperatorType *ot)
/** \} */
/** Compute `r = mat * (a + b)` with high precision. */
static void mul_v2_m2_add_v2v2(float r[2],
const float mat[2][2],
const float a[2],
const float b[2])
{
const double x = double(a[0]) + double(b[0]);
const double y = double(a[1]) + double(b[1]);
r[0] = float(mat[0][0] * x + mat[1][0] * y);
r[1] = float(mat[0][1] * x + mat[1][1] * y);
}
static void island_uv_transform(FaceIsland *island,
const float matrix[2][2], /* Scale and rotation. */
const float pre_translate[2] /* (pre) Translation. */
@ -1077,7 +1064,7 @@ static void island_uv_transform(FaceIsland *island,
BMIter iter;
BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset);
mul_v2_m2_add_v2v2(luv, matrix, luv, pre_translate);
blender::geometry::mul_v2_m2_add_v2v2(luv, matrix, luv, pre_translate);
}
}
}
@ -1410,6 +1397,9 @@ static void uvedit_pack_islands_multi(const Scene *scene,
selection_center[1] = (selection_min_co[1] + selection_max_co[1]) / 2.0f;
}
MemArena *arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
Heap *heap = BLI_heap_new();
float scale[2] = {1.0f, 1.0f};
blender::Vector<blender::geometry::PackIsland *> pack_island_vector;
for (int i = 0; i < island_vector.size(); i++) {
@ -1418,7 +1408,29 @@ static void uvedit_pack_islands_multi(const Scene *scene,
pack_island->bounds_rect = face_island->bounds_rect;
pack_island->caller_index = i;
pack_island_vector.append(pack_island);
for (int i = 0; i < face_island->faces_len; i++) {
BMFace *f = face_island->faces[i];
/* Storage. */
blender::Array<blender::float2> uvs(f->len);
/* Obtain UVs of polygon. */
BMLoop *l;
BMIter iter;
int j;
BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, j) {
copy_v2_v2(uvs[j], BM_ELEM_CD_GET_FLOAT_P(l, face_island->offsets.uv));
}
pack_island->add_polygon(uvs, arena, heap);
BLI_memarena_clear(arena);
}
pack_island->finalize_geometry(*params, arena, heap);
}
BLI_heap_free(heap, nullptr);
BLI_memarena_free(arena);
pack_islands(pack_island_vector, *params, scale);
float base_offset[2] = {0.0f, 0.0f};
@ -1543,6 +1555,8 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
pack_island_params.margin_method = eUVPackIsland_MarginMethod(
RNA_enum_get(op->ptr, "margin_method"));
pack_island_params.margin = RNA_float_get(op->ptr, "margin");
pack_island_params.shape_method = eUVPackIsland_ShapeMethod(
RNA_enum_get(op->ptr, "shape_method"));
UVMapUDIM_Params closest_udim_buf;
UVMapUDIM_Params *closest_udim = nullptr;
@ -1579,6 +1593,14 @@ static const EnumPropertyItem pack_margin_method_items[] = {
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem pack_shape_method_items[] = {
{ED_UVPACK_SHAPE_CONCAVE, "CONCAVE", 0, "Exact shape (Concave)", "Uses exact geometry"},
{ED_UVPACK_SHAPE_CONVEX, "CONVEX", 0, "Boundary shape (Convex)", "Uses convex hull"},
RNA_ENUM_ITEM_SEPR,
{ED_UVPACK_SHAPE_AABB, "AABB", 0, "Bounding box", "Uses bounding boxes"},
{0, nullptr, 0, nullptr, nullptr},
};
void UV_OT_pack_islands(wmOperatorType *ot)
{
static const EnumPropertyItem pack_target[] = {
@ -1613,6 +1635,12 @@ void UV_OT_pack_islands(wmOperatorType *ot)
"");
RNA_def_float_factor(
ot->srna, "margin", 0.001f, 0.0f, 1.0f, "Margin", "Space between islands", 0.0f, 1.0f);
RNA_def_enum(ot->srna,
"shape_method",
pack_shape_method_items,
ED_UVPACK_SHAPE_CONCAVE,
"Shape Method",
"");
}
/** \} */

View File

@ -1,7 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_heap.h"
#include "BLI_math_matrix.hh"
#include "BLI_memarena.h"
#include "BLI_span.hh"
#include "BLI_vector.hh"
#include "DNA_space_types.h"
#include "DNA_vec_types.h"
@ -20,6 +23,12 @@ enum eUVPackIsland_MarginMethod {
ED_UVPACK_MARGIN_FRACTION, /* Specify a precise fraction of final UV output. */
};
enum eUVPackIsland_ShapeMethod {
ED_UVPACK_SHAPE_AABB = 0, /* Use Axis-Aligned Bounding-Boxes. */
ED_UVPACK_SHAPE_CONVEX, /* Use convex hull. */
ED_UVPACK_SHAPE_CONCAVE, /* Use concave hull. */
};
namespace blender::geometry {
/** See also #UnwrapOptions. */
@ -51,6 +60,8 @@ class UVPackIsland_Params {
eUVPackIsland_MarginMethod margin_method;
/** Additional translation for bottom left corner. */
float udim_base_offset[2];
/** Which shape to use when packing. */
eUVPackIsland_ShapeMethod shape_method;
};
class PackIsland {
@ -58,10 +69,21 @@ class PackIsland {
rctf bounds_rect;
float2 pre_translate; /* Output. */
int caller_index; /* Unchanged by #pack_islands, used by caller. */
void add_triangle(const float2 uv0, const float2 uv1, const float2 uv2);
void add_polygon(const blender::Span<float2> uvs, MemArena *arena, Heap *heap);
void finalize_geometry(const UVPackIsland_Params &params, MemArena *arena, Heap *heap);
private:
blender::Vector<float2> triangleVertices;
friend class Occupancy;
};
void pack_islands(const Span<PackIsland *> &islands,
const UVPackIsland_Params &params,
float r_scale[2]);
/** Compute `r = mat * (a + b)` with high precision. */
void mul_v2_m2_add_v2v2(float r[2], const float mat[2][2], const float a[2], const float b[2]);
} // namespace blender::geometry

View File

@ -11,6 +11,8 @@
#include "BLI_convexhull_2d.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_polyfill_2d.h"
#include "BLI_polyfill_2d_beautify.h"
#include "BLI_rect.h"
#include "BLI_vector.hh"
@ -22,6 +24,142 @@
namespace blender::geometry {
/** Compute `r = mat * (a + b)` with high precision.
*
* Often, linear transforms are written as :
* `A.x + b`
*
* When transforming UVs, the familiar expression can
* damage UVs due to round-off error, expecially when
* using UDIM and if there are large numbers of islands.
*
* Instead, we provide a helper which evaluates :
* `A. (x + b)`
*
* To further reduce damage, all internal calculations are
* performed using double precision. */
void mul_v2_m2_add_v2v2(float r[2], const float mat[2][2], const float a[2], const float b[2])
{
const double x = double(a[0]) + double(b[0]);
const double y = double(a[1]) + double(b[1]);
r[0] = float(mat[0][0] * x + mat[1][0] * y);
r[1] = float(mat[0][1] * x + mat[1][1] * y);
}
/* Compute signed distance squared to a line passing through `uva` and `uvb`.
*/
static float dist_signed_squared_to_edge(float2 probe, float2 uva, float2 uvb)
{
const float2 edge = uvb - uva;
const float2 side = probe - uva;
const float edge_length_squared = blender::math::length_squared(edge);
/* Tolerance here is to avoid division by zero later. */
if (edge_length_squared < 1e-40f) {
return blender::math::length_squared(side);
}
const float numerator = edge.x * side.y - edge.y * side.x; /* c.f. cross product. */
const float numerator_ssq = numerator >= 0.0f ? numerator * numerator : -numerator * numerator;
return numerator_ssq / edge_length_squared;
}
void PackIsland::add_triangle(const float2 uv0, const float2 uv1, const float2 uv2)
{
/* Be careful with winding. */
if (dist_signed_squared_to_edge(uv0, uv1, uv2) < 0.0f) {
triangleVertices.append(uv0);
triangleVertices.append(uv1);
triangleVertices.append(uv2);
}
else {
triangleVertices.append(uv0);
triangleVertices.append(uv2);
triangleVertices.append(uv1);
}
}
void PackIsland::add_polygon(const blender::Span<float2> uvs, MemArena *arena, Heap *heap)
{
int vert_count = int(uvs.size());
BLI_assert(vert_count >= 3);
int nfilltri = vert_count - 2;
if (nfilltri == 1) {
/* Trivial case, just one triangle. */
add_triangle(uvs[0], uvs[1], uvs[2]);
return;
}
/* Storage. */
uint(*tris)[3] = static_cast<uint(*)[3]>(
BLI_memarena_alloc(arena, sizeof(*tris) * size_t(nfilltri)));
float(*source)[2] = static_cast<float(*)[2]>(
BLI_memarena_alloc(arena, sizeof(*source) * size_t(vert_count)));
/* Copy input. */
for (int i = 0; i < vert_count; i++) {
copy_v2_v2(source[i], uvs[i]);
}
/* Triangulate. */
BLI_polyfill_calc_arena(source, vert_count, 0, tris, arena);
/* Beautify improves performance of packer. (Optional)
* Long thin triangles, especially at 45 degree angles,
* can trigger worst-case performance in #trace_triangle.
* Using `Beautify` brings more inputs into average-case.
*/
BLI_polyfill_beautify(source, vert_count, tris, arena, heap);
/* Add as triangles. */
for (int j = 0; j < nfilltri; j++) {
uint *tri = tris[j];
add_triangle(source[tri[0]], source[tri[1]], source[tri[2]]);
}
BLI_heap_clear(heap, nullptr);
}
void PackIsland::finalize_geometry(const UVPackIsland_Params &params, MemArena *arena, Heap *heap)
{
BLI_assert(triangleVertices.size() >= 3);
const eUVPackIsland_ShapeMethod shape_method = params.shape_method;
if (shape_method == ED_UVPACK_SHAPE_CONVEX) {
/* Compute convex hull of existing triangles. */
if (triangleVertices.size() <= 3) {
return; /* Trivial case, nothing to do. */
}
int vert_count = int(triangleVertices.size());
/* Allocate storage. */
int *index_map = static_cast<int *>(
BLI_memarena_alloc(arena, sizeof(*index_map) * vert_count));
float(*source)[2] = static_cast<float(*)[2]>(
BLI_memarena_alloc(arena, sizeof(*source) * size_t(vert_count)));
/* Prepare input for convex hull. */
for (int i = 0; i < vert_count; i++) {
copy_v2_v2(source[i], triangleVertices[i]);
}
/* Compute convex hull. */
int convex_len = BLI_convexhull_2d(source, vert_count, index_map);
/* Write back. */
triangleVertices.clear();
blender::Array<float2> convexVertices(convex_len);
for (int i = 0; i < convex_len; i++) {
convexVertices[i] = source[index_map[i]];
}
add_polygon(convexVertices, arena, heap);
BLI_heap_clear(heap, nullptr);
}
}
UVPackIsland_Params::UVPackIsland_Params()
{
/* TEMPORARY, set every thing to "zero" for backwards compatibility. */
@ -36,6 +174,7 @@ UVPackIsland_Params::UVPackIsland_Params()
margin_method = ED_UVPACK_MARGIN_SCALED;
udim_base_offset[0] = 0.0f;
udim_base_offset[1] = 0.0f;
shape_method = ED_UVPACK_SHAPE_AABB;
}
/* Compact representation for AABB packers. */
@ -110,10 +249,317 @@ static void pack_islands_alpaca_turbo(const Span<UVAABBIsland *> islands,
*r_max_v = next_v1;
}
/**
* Helper class for the `xatlas` strategy.
* Accelerates geometry queries by approximating exact queries with a bitmap.
* Includes some book keeping variables to simplify the algorithm.
*/
class Occupancy {
public:
Occupancy(const float initial_scale);
void increase_scale(); /* Resize the scale of the bitmap and clear it. */
/* Write or Query a triangle on the bitmap. */
float trace_triangle(const float2 &uv0,
const float2 &uv1,
const float2 &uv2,
const float margin,
const bool write) const;
/* Write or Query an island on the bitmap. */
float trace_island(PackIsland *island,
const float scale,
const float margin,
const float2 &uv,
const bool write) const;
int bitmap_radix; /* Width and Height of `bitmap`. */
float bitmap_scale_reciprocal; /* == 1.0f / `bitmap_scale`. */
private:
mutable blender::Array<float> bitmap;
mutable float2 witness; /* Witness to a previously known occupied pixel. */
mutable float witness_distance; /* Signed distance to nearest placed island. */
mutable uint triangle_hint; /* Hint to a previously suspected overlapping triangle. */
const float terminal = 1048576.0f; /* A "very" large number, much bigger than 4 * bitmap_radix */
};
Occupancy::Occupancy(const float initial_scale)
: bitmap_radix(800), bitmap(bitmap_radix * bitmap_radix, false)
{
increase_scale();
bitmap_scale_reciprocal = bitmap_radix / initial_scale;
}
void Occupancy::increase_scale()
{
bitmap_scale_reciprocal *= 0.5f;
for (int i = 0; i < bitmap_radix * bitmap_radix; i++) {
bitmap[i] = terminal;
}
witness.x = -1;
witness.y = -1;
witness_distance = 0.0f;
triangle_hint = 0;
}
static float signed_distance_fat_triangle(const float2 probe,
const float2 uv0,
const float2 uv1,
const float2 uv2)
{
/* Be careful with ordering, uv0 <- uv1 <- uv2 <- uv0 <- uv1 etc. */
const float dist01_ssq = dist_signed_squared_to_edge(probe, uv0, uv1);
const float dist12_ssq = dist_signed_squared_to_edge(probe, uv1, uv2);
const float dist20_ssq = dist_signed_squared_to_edge(probe, uv2, uv0);
float result_ssq = max_fff(dist01_ssq, dist12_ssq, dist20_ssq);
if (result_ssq < 0.0f) {
return -sqrtf(-result_ssq);
}
BLI_assert(result_ssq >= 0.0f);
result_ssq = std::min(result_ssq, blender::math::length_squared(probe - uv0));
result_ssq = std::min(result_ssq, blender::math::length_squared(probe - uv1));
result_ssq = std::min(result_ssq, blender::math::length_squared(probe - uv2));
BLI_assert(result_ssq >= 0.0f);
return sqrtf(result_ssq);
}
float Occupancy::trace_triangle(const float2 &uv0,
const float2 &uv1,
const float2 &uv2,
const float margin,
const bool write) const
{
const float x0 = min_fff(uv0.x, uv1.x, uv2.x);
const float y0 = min_fff(uv0.y, uv1.y, uv2.y);
const float x1 = max_fff(uv0.x, uv1.x, uv2.x);
const float y1 = max_fff(uv0.y, uv1.y, uv2.y);
float spread = write ? margin * 2 : 0.0f;
int ix0 = std::max(int(floorf((x0 - spread) * bitmap_scale_reciprocal)), 0);
int iy0 = std::max(int(floorf((y0 - spread) * bitmap_scale_reciprocal)), 0);
int ix1 = std::min(int(floorf((x1 + spread) * bitmap_scale_reciprocal + 2)), bitmap_radix);
int iy1 = std::min(int(floorf((y1 + spread) * bitmap_scale_reciprocal + 2)), bitmap_radix);
const float2 uv0s = uv0 * bitmap_scale_reciprocal;
const float2 uv1s = uv1 * bitmap_scale_reciprocal;
const float2 uv2s = uv2 * bitmap_scale_reciprocal;
/* TODO: Better epsilon handling here could reduce search size. */
float epsilon = 0.7071f; /* == sqrt(0.5f), rounded up by 0.00002f. */
epsilon = std::max(epsilon, 2 * margin * bitmap_scale_reciprocal);
if (!write) {
if (ix0 <= witness.x && witness.x < ix1) {
if (iy0 <= witness.y && witness.y < iy1) {
const float distance = signed_distance_fat_triangle(witness, uv0s, uv1s, uv2s);
const float extent = epsilon - distance - witness_distance;
if (extent > 0.0f) {
return extent; /* Witness observes occupied. */
}
}
}
}
/* Iterate in opposite direction to outer search to improve witness effectiveness. */
for (int y = iy1 - 1; y >= iy0; y--) {
for (int x = ix1 - 1; x >= ix0; x--) {
float *hotspot = &bitmap[y * bitmap_radix + x];
if (!write && *hotspot > epsilon) {
continue;
}
const float2 probe(x, y);
const float distance = signed_distance_fat_triangle(probe, uv0s, uv1s, uv2s);
if (write) {
*hotspot = min_ff(distance, *hotspot);
continue;
}
const float extent = epsilon - distance - *hotspot;
if (extent > 0.0f) {
witness = probe;
witness_distance = *hotspot;
return extent; /* Occupied. */
}
}
}
return -1.0f; /* Available. */
}
float Occupancy::trace_island(PackIsland *island,
const float scale,
const float margin,
const float2 &uv,
const bool write) const
{
if (!write) {
if (uv.x <= 0.0f || uv.y <= 0.0f) {
return std::max(-uv.x, -uv.y); /* Occupied. */
}
}
const float2 origin(island->bounds_rect.xmin, island->bounds_rect.ymin);
const float2 delta = uv - origin * scale;
uint vert_count = uint(island->triangleVertices.size());
for (uint i = 0; i < vert_count; i += 3) {
uint j = (i + triangle_hint) % vert_count;
float extent = trace_triangle(delta + island->triangleVertices[j] * scale,
delta + island->triangleVertices[j + 1] * scale,
delta + island->triangleVertices[j + 2] * scale,
margin,
write);
if (!write && extent >= 0.0f) {
triangle_hint = j;
return extent; /* Occupied. */
}
}
return -1.0f; /* Available. */
}
static float2 find_best_fit_for_island(
PackIsland *island, int scan_line, Occupancy &occupancy, const float scale, const float margin)
{
const float scan_line_bscaled = scan_line / occupancy.bitmap_scale_reciprocal;
const float size_x_scaled = BLI_rctf_size_x(&island->bounds_rect) * scale;
const float size_y_scaled = BLI_rctf_size_y(&island->bounds_rect) * scale;
int t = 0;
while (t <= scan_line) {
const float t_bscaled = t / occupancy.bitmap_scale_reciprocal;
/* Scan using an "Alpaca"-style search, both horizontally and vertically at the same time. */
const float2 horiz(scan_line_bscaled - size_x_scaled, t_bscaled - size_y_scaled);
const float extentH = occupancy.trace_island(island, scale, margin, horiz, false);
if (extentH < 0.0f) {
return horiz;
}
const float2 vert(t_bscaled - size_x_scaled, scan_line_bscaled - size_y_scaled);
const float extentV = occupancy.trace_island(island, scale, margin, vert, false);
if (extentV < 0.0f) {
return vert;
}
const float min_extent = std::min(extentH, extentV);
t = t + std::max(1, int(min_extent));
}
return float2(-1, -1);
}
static float guess_initial_scale(const Span<PackIsland *> islands,
const float scale,
const float margin)
{
float sum = 1e-40f;
for (int64_t i : islands.index_range()) {
PackIsland *island = islands[i];
sum += BLI_rctf_size_x(&island->bounds_rect) * scale + 2 * margin;
sum += BLI_rctf_size_y(&island->bounds_rect) * scale + 2 * margin;
}
return sqrtf(sum) / 3.0f;
}
/**
* Pack irregular islands using the "xatlas" strategy, with no rotation.
*
* Loosely based on the 'xatlas' code by Jonathan Young
* from https://github.com/jpcy/xatlas
*
* A brute force packer (BFPacker) with accelerators:
* - Uses a Bitmap Occupancy class.
* - Uses a "Witness Pixel" and a "Triangle Hint".
* - Write with `margin * 2`, read with `margin == 0`.
* - Lazy resetting of BF search.
*
* Performance would normally be `O(n^4)`, however the occupancy
* bitmap_radix is fixed, which gives a reduced time complexity of `O(n^3)`.
*/
static void pack_island_xatlas(const Span<UVAABBIsland *> island_indices,
const Span<PackIsland *> islands,
BoxPack *box_array,
const float scale,
const float margin,
float *r_max_u,
float *r_max_v)
{
Occupancy occupancy(guess_initial_scale(islands, scale, margin));
float max_u = 0.0f;
float max_v = 0.0f;
int scan_line = 0;
int i = 0;
/* The following `while` loop is setting up a three-way race:
* for (scan_line=0; scan_line<bitmap_radix; scan_line++)
* for (i : island_indices.index_range())
* while (bitmap_scale_reciprocal > 0) { bitmap_scale_reciprocal *= 0.5f; }
*/
while (i < island_indices.size()) {
PackIsland *island = islands[island_indices[i]->index];
const float2 best = find_best_fit_for_island(island, scan_line, occupancy, scale, margin);
if (best.x <= -1.0f) {
/* Unable to find a fit on this scan_line. */
if (i < 10) {
scan_line++;
}
else {
/* Increasing by 2 here has the effect of changing the sampling pattern.
* The parameter '2' is not "free" in the sense that changing it requires
* a change to `bitmap_radix` and then retuning `alpaca_cutoff`.
* Possible values here *could* be 1, 2 or 3, however the only *reasonable*
* choice is 2.
*/
scan_line += 2;
}
if (scan_line < occupancy.bitmap_radix) {
continue; /* Try again on next scan_line. */
}
/* Enlarge search parameters. */
scan_line = 0;
occupancy.increase_scale();
/* Redraw already placed islands. (Greedy.) */
for (int j = 0; j < i; j++) {
BoxPack *box = box_array + j;
occupancy.trace_island(
islands[island_indices[j]->index], scale, margin, float2(box->x, box->y), true);
}
continue;
}
/* Place island. */
BoxPack *box = box_array + i;
box->x = best.x;
box->y = best.y;
max_u = std::max(box->x + BLI_rctf_size_x(&island->bounds_rect) * scale + 2 * margin, max_u);
max_v = std::max(box->y + BLI_rctf_size_y(&island->bounds_rect) * scale + 2 * margin, max_v);
occupancy.trace_island(island, scale, margin, float2(box->x, box->y), true);
i++; /* Next island. */
if (i < 128 || (i & 31) == 16) {
scan_line = 0; /* Restart completely. */
}
else {
scan_line = std::max(0, scan_line - 25); /* `-25` must by odd. */
}
}
*r_max_u = max_u;
*r_max_v = max_v;
}
static float pack_islands_scale_margin(const Span<PackIsland *> islands,
BoxPack *box_array,
const float scale,
const float margin)
const float margin,
const UVPackIsland_Params &params)
{
/* #BLI_box_pack_2d produces layouts with high packing efficiency, but has `O(n^3)`
* time complexity, causing poor performance if there are lots of islands. See: #102843.
@ -148,10 +594,18 @@ static float pack_islands_scale_margin(const Span<PackIsland *> islands,
return b->uv_diagonal.x * b->uv_diagonal.y < a->uv_diagonal.x * a->uv_diagonal.y;
});
/* Partition island_vector, largest will go to box_pack, the rest alpaca_turbo.
/* Partition `islands`, largest will go to a slow packer, the rest alpaca_turbo.
* See discussion above for details. */
const int64_t alpaca_cutoff = int64_t(1024); /* TODO: Tune constant. */
int64_t max_box_pack = std::min(alpaca_cutoff, islands.size());
int64_t alpaca_cutoff = int64_t(
1024); /* Regular situation, pack 1024 islands with slow packer. */
int64_t alpaca_cutoff_fast = int64_t(
80); /* Reduced problem size, only 80 islands with slow packer. */
if (params.margin_method == ED_UVPACK_MARGIN_FRACTION) {
if (margin > 0.0f) {
alpaca_cutoff = alpaca_cutoff_fast;
}
}
const int64_t max_box_pack = std::min(alpaca_cutoff, islands.size());
/* Prepare for box_pack_2d. */
for (const int64_t i : islands.index_range()) {
@ -165,7 +619,21 @@ static float pack_islands_scale_margin(const Span<PackIsland *> islands,
/* Call box_pack_2d (slow for large N.) */
float max_u = 0.0f;
float max_v = 0.0f;
BLI_box_pack_2d(box_array, int(max_box_pack), &max_u, &max_v);
switch (params.shape_method) {
case ED_UVPACK_SHAPE_CONVEX:
case ED_UVPACK_SHAPE_CONCAVE:
pack_island_xatlas(aabbs.as_span().take_front(max_box_pack),
islands,
box_array,
scale,
margin,
&max_u,
&max_v);
break;
default:
BLI_box_pack_2d(box_array, int(max_box_pack), &max_u, &max_v);
break;
}
/* At this stage, `max_u` and `max_v` contain the box_pack UVs. */
@ -192,7 +660,8 @@ static float pack_islands_scale_margin(const Span<PackIsland *> islands,
static float pack_islands_margin_fraction(const Span<PackIsland *> &island_vector,
BoxPack *box_array,
const float margin_fraction)
const float margin_fraction,
const UVPackIsland_Params &params)
{
/*
* Root finding using a combined search / modified-secant method.
@ -260,7 +729,7 @@ static float pack_islands_margin_fraction(const Span<PackIsland *> &island_vecto
/* Evaluate our `f`. */
scale_last = scale;
float max_uv = pack_islands_scale_margin(
island_vector, box_array, scale_last, margin_fraction);
island_vector, box_array, scale_last, margin_fraction, params);
float value = sqrtf(max_uv) - 1.0f;
if (value <= 0.0f) {
@ -284,7 +753,7 @@ static float pack_islands_margin_fraction(const Span<PackIsland *> &island_vecto
if (scale_last != scale_low) {
scale_last = scale_low;
float max_uv = pack_islands_scale_margin(
island_vector, box_array, scale_last, margin_fraction);
island_vector, box_array, scale_last, margin_fraction, params);
UNUSED_VARS(max_uv);
/* TODO (?): `if (max_uv < 1.0f) { scale_last /= max_uv; }` */
}
@ -326,7 +795,7 @@ static BoxPack *pack_islands_box_array(const Span<PackIsland *> &island_vector,
if (params.margin == 0.0f) {
/* Special case for zero margin. Margin_method is ignored as all formulas give same result. */
const float max_uv = pack_islands_scale_margin(island_vector, box_array, 1.0f, 0.0f);
const float max_uv = pack_islands_scale_margin(island_vector, box_array, 1.0f, 0.0f, params);
r_scale[0] = 1.0f / max_uv;
r_scale[1] = r_scale[0];
return box_array;
@ -334,7 +803,8 @@ static BoxPack *pack_islands_box_array(const Span<PackIsland *> &island_vector,
if (params.margin_method == ED_UVPACK_MARGIN_FRACTION) {
/* Uses a line search on scale. ~10x slower than other method. */
const float scale = pack_islands_margin_fraction(island_vector, box_array, params.margin);
const float scale = pack_islands_margin_fraction(
island_vector, box_array, params.margin, params);
r_scale[0] = scale;
r_scale[1] = scale;
/* pack_islands_margin_fraction will pad FaceIslands, return early. */
@ -355,7 +825,7 @@ static BoxPack *pack_islands_box_array(const Span<PackIsland *> &island_vector,
BLI_assert_unreachable();
}
const float max_uv = pack_islands_scale_margin(island_vector, box_array, 1.0f, margin);
const float max_uv = pack_islands_scale_margin(island_vector, box_array, 1.0f, margin, params);
r_scale[0] = 1.0f / max_uv;
r_scale[1] = r_scale[0];

View File

@ -4191,17 +4191,16 @@ void uv_parametrizer_pack(ParamHandle *handle, float margin, bool do_rotate, boo
PackIsland *pack_island = pack_island_vector[i];
PChart *chart = handle->charts[pack_island->caller_index];
/* TODO: Replace with #mul_v2_m2_add_v2v2 here soon. */
float m[2];
float m[2][2];
float b[2];
m[0] = scale[0];
m[1] = scale[1];
m[0][0] = scale[0];
m[0][1] = 0.0f;
m[1][0] = 0.0f;
m[1][1] = scale[1];
b[0] = pack_island->pre_translate.x;
b[1] = pack_island->pre_translate.y;
for (PVert *v = chart->verts; v; v = v->nextlink) {
/* Unusual accumulate-and-multiply here (will) reduce round-off error. */
v->uv[0] = m[0] * (v->uv[0] + b[0]);
v->uv[1] = m[1] * (v->uv[1] + b[1]);
blender::geometry::mul_v2_m2_add_v2v2(v->uv, m, v->uv, b);
}
pack_island_vector[i] = nullptr;

View File

@ -953,7 +953,7 @@ void GPU_material_compile(GPUMaterial *mat)
* configurations to ensure compile time remains fast, as these first
* entries will be the most commonly used PSOs. As not all PSOs are necessarily
* required immediately, this limit should remain low (1-3 at most). */
if (mat->default_mat != NULL && mat->default_mat != mat) {
if (!ELEM(mat->default_mat, NULL, mat)) {
if (mat->default_mat->pass != NULL) {
GPUShader *parent_sh = GPU_pass_shader_get(mat->default_mat->pass);
if (parent_sh) {

View File

@ -52,8 +52,7 @@ static IKPlugin ikplugin_tab[] = {
static IKPlugin *get_plugin(bPose *pose)
{
if (!pose || pose->iksolver < 0 ||
pose->iksolver >= ((sizeof(ikplugin_tab) / sizeof(IKPlugin)) - 1)) {
if (!pose || pose->iksolver < 0 || pose->iksolver >= ((ARRAY_SIZE(ikplugin_tab)) - 1)) {
return NULL;
}

View File

@ -523,7 +523,7 @@ const FormatDescriptor s_d3dFormats[] = {
{D3DFMT_L16, 16, 16, 0, 0, 0}, /* DXGI_FORMAT_R16_UNORM */
};
const uint s_d3dFormatCount = sizeof(s_d3dFormats) / sizeof(s_d3dFormats[0]);
const uint s_d3dFormatCount = ARRAY_SIZE(s_d3dFormats);
} /* namespace */

View File

@ -62,28 +62,28 @@ static void skip_space(Span<char> &str)
static PlyDataTypes type_from_string(Span<char> word)
{
StringRef input(word.data(), word.size());
if (input == "uchar" || input == "uint8") {
if (ELEM(input, "uchar", "uint8")) {
return PlyDataTypes::UCHAR;
}
if (input == "char" || input == "int8") {
if (ELEM(input, "char", "int8")) {
return PlyDataTypes::CHAR;
}
if (input == "ushort" || input == "uint16") {
if (ELEM(input, "ushort", "uint16")) {
return PlyDataTypes::USHORT;
}
if (input == "short" || input == "int16") {
if (ELEM(input, "short", "int16")) {
return PlyDataTypes::SHORT;
}
if (input == "uint" || input == "uint32") {
if (ELEM(input, "uint", "uint32")) {
return PlyDataTypes::UINT;
}
if (input == "int" || input == "int32") {
if (ELEM(input, "int", "int32")) {
return PlyDataTypes::INT;
}
if (input == "float" || input == "float32") {
if (ELEM(input, "float", "float32")) {
return PlyDataTypes::FLOAT;
}
if (input == "double" || input == "float64") {
if (ELEM(input, "double", "float64")) {
return PlyDataTypes::DOUBLE;
}
return PlyDataTypes::NONE;

View File

@ -53,7 +53,7 @@ class ply_import_test : public testing::Test {
BLI_hash_mm2a_init(&hash, 0);
uint32_t offset = 0;
for (uint32_t face_size : data->face_sizes) {
BLI_hash_mm2a_add(&hash, (const unsigned char *)&data->face_vertices[offset], face_size * 4);
BLI_hash_mm2a_add(&hash, (const uchar *)&data->face_vertices[offset], face_size * 4);
offset += face_size;
}
uint16_t face_hash = BLI_hash_mm2a_end(&hash);
@ -62,9 +62,8 @@ class ply_import_test : public testing::Test {
}
if (!data->edges.is_empty()) {
uint16_t edge_hash = BLI_hash_mm2((const unsigned char *)data->edges.data(),
data->edges.size() * sizeof(data->edges[0]),
0);
uint16_t edge_hash = BLI_hash_mm2(
(const uchar *)data->edges.data(), data->edges.size() * sizeof(data->edges[0]), 0);
ASSERT_EQ(edge_hash, exp.edgehash);
}

View File

@ -154,9 +154,12 @@ typedef enum eArmature_Flag {
ARM_DRAWAXES = (1 << 2),
ARM_DRAWNAMES = (1 << 3),
ARM_POSEMODE = (1 << 4),
ARM_FLAG_UNUSED_5 = (1 << 5), /* cleared */
ARM_FLAG_UNUSED_6 = (1 << 6), /* cleared */
ARM_FLAG_UNUSED_7 = (1 << 7),
/** Position of the parent-child relation lines on the bone (cleared = drawn
* from the tail, set = drawn from the head). Only controls the parent side of
* the line; the child side is always drawn to the head of the bone. */
ARM_DRAW_RELATION_FROM_HEAD = (1 << 5), /* Cleared in versioning of pre-2.80 files. */
ARM_FLAG_UNUSED_6 = (1 << 6), /* cleared */
ARM_FLAG_UNUSED_7 = (1 << 7), /* cleared */
ARM_MIRROR_EDIT = (1 << 8),
ARM_FLAG_UNUSED_9 = (1 << 9),
/** Made option negative, for backwards compatibility. */

View File

@ -196,6 +196,9 @@ typedef struct Image {
char eye;
char views_format;
/** Offset caused by translation. Used in compositor backdrop for viewer nodes in image space. */
int offset_x, offset_y;
/* ImageTile list for UDIMs. */
int active_tile_index;
ListBase tiles;

View File

@ -653,6 +653,30 @@ static void rna_Armature_transform(bArmature *arm, float mat[16])
ED_armature_transform(arm, (const float(*)[4])mat, true);
}
static int rna_Armature_relation_line_position_get(PointerRNA *ptr)
{
bArmature *arm = (bArmature *)ptr->data;
/* Translate the bitflag to an EnumPropertyItem prop_relation_lines_items item ID. */
return (arm->flag & ARM_DRAW_RELATION_FROM_HEAD) ? 1 : 0;
}
static void rna_Armature_relation_line_position_set(PointerRNA *ptr, const int value)
{
bArmature *arm = (bArmature *)ptr->data;
/* Translate the EnumPropertyItem prop_relation_lines_items item ID to a bitflag */
switch (value) {
case 0:
arm->flag &= ~ARM_DRAW_RELATION_FROM_HEAD;
break;
case 1:
arm->flag |= ARM_DRAW_RELATION_FROM_HEAD;
break;
default:
return;
}
}
#else
void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone, bool is_editbone)
@ -1460,6 +1484,11 @@ static void rna_def_armature(BlenderRNA *brna)
"Show Armature in binding pose state (no posing possible)"},
{0, NULL, 0, NULL, NULL},
};
static const EnumPropertyItem prop_relation_lines_items[] = {
{0, "TAIL", 0, "Tail", "Draw the relationship line from the parent tail to the child head"},
{1, "HEAD", 0, "Head", "Draw the relationship line from the parent head to the child head"},
{0, NULL, 0, NULL, NULL},
};
srna = RNA_def_struct(brna, "Armature", "ID");
RNA_def_struct_ui_text(
@ -1554,6 +1583,20 @@ static void rna_def_armature(BlenderRNA *brna)
"closer to the tip; decreasing moves it closer to the root");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
RNA_define_verify_sdna(false); /* This property does not live in DNA. */
prop = RNA_def_property(srna, "relation_line_position", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_relation_lines_items);
RNA_def_property_ui_text(prop,
"Relation Line Position",
"The start position of the relation lines from parent to child bones");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
RNA_def_property_enum_funcs(prop,
"rna_Armature_relation_line_position_get",
"rna_Armature_relation_line_position_set",
/*item function*/ NULL);
RNA_define_verify_sdna(true); /* Restore default. */
prop = RNA_def_property(srna, "show_names", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWNAMES);
RNA_def_property_ui_text(prop, "Display Names", "Display bone names");

View File

@ -256,7 +256,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
const int vert_i = orig_corner_verts[corner_i];
const int prev_vert_i = orig_corner_verts[corner_i_prev];
/* add edge user */
eidx = (int)(orig_corner_edges[corner_i_prev]);
eidx = int(orig_corner_edges[corner_i_prev]);
if (edge_users[eidx] == INVALID_UNUSED) {
edge = &orig_edges[eidx];
BLI_assert(ELEM(prev_vert_i, edge->v1, edge->v2) && ELEM(vert_i, edge->v1, edge->v2));

View File

@ -516,6 +516,7 @@ class ImageOperation : public NodeOperation {
}
ImageUser image_user = compute_image_user_for_output(identifier);
BKE_image_ensure_gpu_texture(get_image(), &image_user);
GPUTexture *image_texture = BKE_image_get_gpu_texture(get_image(), &image_user, nullptr);
const int2 size = int2(GPU_texture_width(image_texture), GPU_texture_height(image_texture));

View File

@ -1177,9 +1177,9 @@ static PyObject *C_BVHTree_FromObject(PyObject * /*cls*/, PyObject *args, PyObje
for (i = 0; i < tris_len; i++, lt++) {
float co[3][3];
tris[i][0] = (uint)corner_verts[lt->tri[0]];
tris[i][1] = (uint)corner_verts[lt->tri[1]];
tris[i][2] = (uint)corner_verts[lt->tri[2]];
tris[i][0] = uint(corner_verts[lt->tri[0]]);
tris[i][1] = uint(corner_verts[lt->tri[1]]);
tris[i][2] = uint(corner_verts[lt->tri[2]]);
copy_v3_v3(co[0], coords[tris[i][0]]);
copy_v3_v3(co[1], coords[tris[i][1]]);

View File

@ -481,7 +481,7 @@ static void do_multires_bake(MultiresBakeRender *bkr,
const float(*positions)[3] = (float(*)[3])dm->getVertArray(dm);
const MPoly *polys = dm->getPolyArray(dm);
float(*mloopuv)[2] = static_cast<float(*)[2]>(dm->getLoopDataArray(dm, CD_PROP_FLOAT2));
float *pvtangent = NULL;
float *pvtangent = nullptr;
ListBase threads;
int i, tot_thread = bkr->threads > 0 ? bkr->threads : BLI_system_thread_count();

View File

@ -1081,12 +1081,16 @@ class edit_generators:
float(foo(a + b))
"""
@staticmethod
def edit_list_from_file(_source: str, data: str, _shared_edit_data: Any) -> List[Edit]:
def edit_list_from_file(source: str, data: str, _shared_edit_data: Any) -> List[Edit]:
edits: List[Edit] = []
# The user might include C & C++, if they forget, it is better not to operate on C.
if source.lower().endswith((".h", ".c")):
return edits
any_number_re = "(" + "|".join(BUILT_IN_NUMERIC_TYPES) + ")"
edits = []
# Handle both:
# - Simple case: `(float)(a + b)` -> `float(a + b)`.
# - Complex Case: `(float)foo(a + b) + c` -> `float(foo(a + b)) + c`