Cleanup: Simplify mesh triangle material counting #105940

Merged
Hans Goudey merged 12 commits from HooglyBoogly/blender:mesh-mat-tri-len-count into main 2023-08-03 05:02:43 +02:00
52 changed files with 2001 additions and 527 deletions
Showing only changes of commit a00b67d64e - 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_;
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

@ -537,6 +537,8 @@ struct GWL_SeatStatePointerScroll {
wl_fixed_t smooth_xy[2] = {0, 0};
/** Discrete scrolling (handled & reset with pointer "frame" callback). */
int32_t discrete_xy[2] = {0, 0};
/** True when the axis is inverted (also known is "natural" scrolling). */
bool inverted_xy[2] = {false, false};
/** The source of scroll event. */
enum wl_pointer_axis_source axis_source = WL_POINTER_AXIS_SOURCE_WHEEL;
};
@ -2227,13 +2229,13 @@ static void data_source_handle_action(void * /*data*/,
CLOG_INFO(LOG, 2, "handle_action (dnd_action=%u)", dnd_action);
}
static const struct wl_data_source_listener data_source_listener = {
data_source_handle_target,
data_source_handle_send,
data_source_handle_cancelled,
data_source_handle_dnd_drop_performed,
data_source_handle_dnd_finished,
data_source_handle_action,
static const wl_data_source_listener data_source_listener = {
/*target*/ data_source_handle_target,
/*send*/ data_source_handle_send,
/*cancelled*/ data_source_handle_cancelled,
/*dnd_drop_performed*/ data_source_handle_dnd_drop_performed,
/*dnd_finished*/ data_source_handle_dnd_finished,
/*action*/ data_source_handle_action,
};
#undef LOG
@ -2274,10 +2276,10 @@ static void data_offer_handle_action(void *data,
data_offer->dnd.action = (enum wl_data_device_manager_dnd_action)dnd_action;
}
static const struct wl_data_offer_listener data_offer_listener = {
data_offer_handle_offer,
data_offer_handle_source_actions,
data_offer_handle_action,
static const wl_data_offer_listener data_offer_listener = {
/*offer*/ data_offer_handle_offer,
/*source_actions*/ data_offer_handle_source_actions,
/*action*/ data_offer_handle_action,
};
#undef LOG
@ -2514,13 +2516,13 @@ static void data_device_handle_selection(void *data,
seat->data_offer_copy_paste = data_offer;
}
static const struct wl_data_device_listener data_device_listener = {
data_device_handle_data_offer,
data_device_handle_enter,
data_device_handle_leave,
data_device_handle_motion,
data_device_handle_drop,
data_device_handle_selection,
static const wl_data_device_listener data_device_listener = {
/*data_offer*/ data_device_handle_data_offer,
/*enter*/ data_device_handle_enter,
/*leave*/ data_device_handle_leave,
/*motion*/ data_device_handle_motion,
/*drop*/ data_device_handle_drop,
/*selection*/ data_device_handle_selection,
};
#undef LOG
@ -2547,8 +2549,8 @@ static void cursor_buffer_handle_release(void *data, struct wl_buffer *wl_buffer
}
}
static const struct wl_buffer_listener cursor_buffer_listener = {
cursor_buffer_handle_release,
static const wl_buffer_listener cursor_buffer_listener = {
/*release*/ cursor_buffer_handle_release,
};
#undef LOG
@ -2623,9 +2625,9 @@ static void cursor_surface_handle_leave(void *data,
update_cursor_scale(seat->cursor, seat->system->wl_shm(), seat_state_pointer, wl_surface);
}
static const struct wl_surface_listener cursor_surface_listener = {
cursor_surface_handle_enter,
cursor_surface_handle_leave,
static const wl_surface_listener cursor_surface_listener = {
/*enter*/ cursor_surface_handle_enter,
/*leave*/ cursor_surface_handle_leave,
};
#undef LOG
@ -2666,6 +2668,8 @@ static void pointer_handle_enter(void *data,
seat->pointer_scroll.smooth_xy[1] = 0;
seat->pointer_scroll.discrete_xy[0] = 0;
seat->pointer_scroll.discrete_xy[1] = 0;
seat->pointer_scroll.inverted_xy[0] = false;
seat->pointer_scroll.inverted_xy[1] = false;
seat->pointer_scroll.axis_source = WL_POINTER_AXIS_SOURCE_WHEEL;
seat->pointer.wl_surface_window = wl_surface;
@ -2851,7 +2855,9 @@ static void pointer_handle_frame(void *data, struct wl_pointer * /*wl_pointer*/)
* has already been applied so there is no need to read this preference. */
-wl_fixed_to_int(seat->pointer_scroll.smooth_xy[0]),
-wl_fixed_to_int(seat->pointer_scroll.smooth_xy[1]),
false));
/* NOTE: GHOST does not support per-axis inversion.
* Assume inversion is used or not. */
seat->pointer_scroll.inverted_xy[0] || seat->pointer_scroll.inverted_xy[1]));
}
seat->pointer_scroll.smooth_xy[0] = 0;
@ -2859,6 +2865,8 @@ static void pointer_handle_frame(void *data, struct wl_pointer * /*wl_pointer*/)
}
seat->pointer_scroll.axis_source = WL_POINTER_AXIS_SOURCE_WHEEL;
seat->pointer_scroll.inverted_xy[0] = false;
seat->pointer_scroll.inverted_xy[1] = false;
}
static void pointer_handle_axis_source(void *data,
struct wl_pointer * /*wl_pointer*/,
@ -2890,17 +2898,46 @@ static void pointer_handle_axis_discrete(void *data,
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
seat->pointer_scroll.discrete_xy[index] = discrete;
}
static void pointer_handle_axis_value120(void * /*data*/,
struct wl_pointer * /*wl_pointer*/,
uint32_t axis,
int32_t value120)
{
/* NOTE: the axis handler seems high resolution enough.
* Nevertheless, we might want to support this. */
CLOG_INFO(LOG, 2, "axis_value120 (axis=%u, value120=%d)", axis, value120);
}
#ifdef WL_POINTER_AXIS_RELATIVE_DIRECTION_ENUM /* Requires WAYLAND 1.22 or newer. */
static void pointer_handle_axis_relative_direction(void *data,
struct wl_pointer * /*wl_pointer*/,
uint32_t axis,
uint32_t direction)
{
CLOG_INFO(LOG, 2, "axis_relative_direction (axis=%u, direction=%u)", axis, direction);
const int index = pointer_axis_as_index(axis);
if (UNLIKELY(index == -1)) {
return;
}
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
seat->pointer_scroll.inverted_xy[index] = (direction ==
WL_POINTER_AXIS_RELATIVE_DIRECTION_INVERTED);
}
#endif /* WL_POINTER_AXIS_RELATIVE_DIRECTION_ENUM */
static const struct wl_pointer_listener pointer_listener = {
pointer_handle_enter,
pointer_handle_leave,
pointer_handle_motion,
pointer_handle_button,
pointer_handle_axis,
pointer_handle_frame,
pointer_handle_axis_source,
pointer_handle_axis_stop,
pointer_handle_axis_discrete,
static const wl_pointer_listener pointer_listener = {
/*enter*/ pointer_handle_enter,
/*leave*/ pointer_handle_leave,
/*motion*/ pointer_handle_motion,
/*button*/ pointer_handle_button,
/*axis*/ pointer_handle_axis,
/*frame*/ pointer_handle_frame,
/*axis_source*/ pointer_handle_axis_source,
/*axis_stop*/ pointer_handle_axis_stop,
/*axis_discrete*/ pointer_handle_axis_discrete,
/*axis_value120*/ pointer_handle_axis_value120,
#ifdef WL_POINTER_AXIS_RELATIVE_DIRECTION_ENUM
/*axis_relative_direction*/ pointer_handle_axis_relative_direction,
#endif
};
#undef LOG
@ -2936,9 +2973,9 @@ static void gesture_hold_handle_end(
CLOG_INFO(LOG, 2, "end (cancelled=%i)", cancelled);
}
static const struct zwp_pointer_gesture_hold_v1_listener gesture_hold_listener = {
gesture_hold_handle_begin,
gesture_hold_handle_end,
static const zwp_pointer_gesture_hold_v1_listener gesture_hold_listener = {
/*begin*/ gesture_hold_handle_begin,
/*end*/ gesture_hold_handle_end,
};
# undef LOG
@ -3078,10 +3115,10 @@ static void gesture_pinch_handle_end(void * /*data*/,
CLOG_INFO(LOG, 2, "end (cancelled=%i)", cancelled);
}
static const struct zwp_pointer_gesture_pinch_v1_listener gesture_pinch_listener = {
gesture_pinch_handle_begin,
gesture_pinch_handle_update,
gesture_pinch_handle_end,
static const zwp_pointer_gesture_pinch_v1_listener gesture_pinch_listener = {
/*begin*/ gesture_pinch_handle_begin,
/*update*/ gesture_pinch_handle_update,
/*end*/ gesture_pinch_handle_end,
};
# undef LOG
@ -3133,10 +3170,10 @@ static void gesture_swipe_handle_end(
CLOG_INFO(LOG, 2, "end (cancelled=%i)", cancelled);
}
static const struct zwp_pointer_gesture_swipe_v1_listener gesture_swipe_listener = {
gesture_swipe_handle_begin,
gesture_swipe_handle_update,
gesture_swipe_handle_end,
static const zwp_pointer_gesture_swipe_v1_listener gesture_swipe_listener = {
/*begin*/ gesture_swipe_handle_begin,
/*update*/ gesture_swipe_handle_update,
/*end*/ gesture_swipe_handle_end,
};
# undef LOG
@ -3214,14 +3251,14 @@ static void touch_seat_handle_orientation(void * /*data*/,
CLOG_INFO(LOG, 2, "orientation");
}
static const struct wl_touch_listener touch_seat_listener = {
touch_seat_handle_down,
touch_seat_handle_up,
touch_seat_handle_motion,
touch_seat_handle_frame,
touch_seat_handle_cancel,
touch_seat_handle_shape,
touch_seat_handle_orientation,
static const wl_touch_listener touch_seat_listener = {
/*down*/ touch_seat_handle_down,
/*up*/ touch_seat_handle_up,
/*motion*/ touch_seat_handle_motion,
/*frame*/ touch_seat_handle_frame,
/*cancel*/ touch_seat_handle_cancel,
/*shape*/ touch_seat_handle_shape,
/*orientation*/ touch_seat_handle_orientation,
};
#undef LOG
@ -3540,26 +3577,26 @@ static void tablet_tool_handle_frame(void *data,
}
}
static const struct zwp_tablet_tool_v2_listener tablet_tool_listner = {
tablet_tool_handle_type,
tablet_tool_handle_hardware_serial,
tablet_tool_handle_hardware_id_wacom,
tablet_tool_handle_capability,
tablet_tool_handle_done,
tablet_tool_handle_removed,
tablet_tool_handle_proximity_in,
tablet_tool_handle_proximity_out,
tablet_tool_handle_down,
tablet_tool_handle_up,
tablet_tool_handle_motion,
tablet_tool_handle_pressure,
tablet_tool_handle_distance,
tablet_tool_handle_tilt,
tablet_tool_handle_rotation,
tablet_tool_handle_slider,
tablet_tool_handle_wheel,
tablet_tool_handle_button,
tablet_tool_handle_frame,
static const zwp_tablet_tool_v2_listener tablet_tool_listner = {
/*type*/ tablet_tool_handle_type,
/*hardware_serial*/ tablet_tool_handle_hardware_serial,
/*hardware_id_wacom*/ tablet_tool_handle_hardware_id_wacom,
/*capability*/ tablet_tool_handle_capability,
/*done*/ tablet_tool_handle_done,
/*removed*/ tablet_tool_handle_removed,
/*proximity_in*/ tablet_tool_handle_proximity_in,
/*proximity_out*/ tablet_tool_handle_proximity_out,
/*down*/ tablet_tool_handle_down,
/*up*/ tablet_tool_handle_up,
/*motion*/ tablet_tool_handle_motion,
/*pressure*/ tablet_tool_handle_pressure,
/*distance*/ tablet_tool_handle_distance,
/*tilt*/ tablet_tool_handle_tilt,
/*rotation*/ tablet_tool_handle_rotation,
/*slider*/ tablet_tool_handle_slider,
/*wheel*/ tablet_tool_handle_wheel,
/*button*/ tablet_tool_handle_button,
/*frame*/ tablet_tool_handle_frame,
};
#undef LOG
@ -3608,10 +3645,10 @@ static void tablet_seat_handle_pad_added(void * /*data*/,
CLOG_INFO(LOG, 2, "pad_added (id=%p)", id);
}
static const struct zwp_tablet_seat_v2_listener tablet_seat_listener = {
tablet_seat_handle_tablet_added,
tablet_seat_handle_tool_added,
tablet_seat_handle_pad_added,
static const zwp_tablet_seat_v2_listener tablet_seat_listener = {
/*tablet_added*/ tablet_seat_handle_tablet_added,
/*tool_added*/ tablet_seat_handle_tool_added,
/*pad_added*/ tablet_seat_handle_pad_added,
};
#undef LOG
@ -4053,7 +4090,7 @@ static void keyboard_handle_modifiers(void *data,
#endif
}
static void keyboard_repeat_handle_info(void *data,
static void keyboard_handle_repeat_info(void *data,
struct wl_keyboard * /*wl_keyboard*/,
const int32_t rate,
const int32_t delay)
@ -4075,13 +4112,13 @@ static void keyboard_repeat_handle_info(void *data,
}
}
static const struct wl_keyboard_listener keyboard_listener = {
keyboard_handle_keymap,
keyboard_handle_enter,
keyboard_handle_leave,
keyboard_handle_key,
keyboard_handle_modifiers,
keyboard_repeat_handle_info,
static const wl_keyboard_listener keyboard_listener = {
/*keymap*/ keyboard_handle_keymap,
/*enter*/ keyboard_handle_enter,
/*leave*/ keyboard_handle_leave,
/*key*/ keyboard_handle_key,
/*modifiers*/ keyboard_handle_modifiers,
/*repeat_info*/ keyboard_handle_repeat_info,
};
#undef LOG
@ -4108,8 +4145,8 @@ static void primary_selection_offer_offer(void *data,
data_offer->types.insert(std::string(type));
}
static const struct zwp_primary_selection_offer_v1_listener primary_selection_offer_listener = {
primary_selection_offer_offer,
static const zwp_primary_selection_offer_v1_listener primary_selection_offer_listener = {
/*offer*/ primary_selection_offer_offer,
};
#undef LOG
@ -4160,9 +4197,9 @@ static void primary_selection_device_handle_selection(
primary->data_offer = data_offer;
}
static const struct zwp_primary_selection_device_v1_listener primary_selection_device_listener = {
primary_selection_device_handle_data_offer,
primary_selection_device_handle_selection,
static const zwp_primary_selection_device_v1_listener primary_selection_device_listener = {
/*data_offer*/ primary_selection_device_handle_data_offer,
/*selection*/ primary_selection_device_handle_selection,
};
#undef LOG
@ -4212,9 +4249,9 @@ static void primary_selection_source_cancelled(void *data,
}
}
static const struct zwp_primary_selection_source_v1_listener primary_selection_source_listener = {
primary_selection_source_send,
primary_selection_source_cancelled,
static const zwp_primary_selection_source_v1_listener primary_selection_source_listener = {
/*send*/ primary_selection_source_send,
/*cancelled*/ primary_selection_source_cancelled,
};
#undef LOG
@ -4417,9 +4454,9 @@ static void seat_handle_name(void *data, struct wl_seat * /*wl_seat*/, const cha
static_cast<GWL_Seat *>(data)->name = std::string(name);
}
static const struct wl_seat_listener seat_listener = {
seat_handle_capabilities,
seat_handle_name,
static const wl_seat_listener seat_listener = {
/*capabilities*/ seat_handle_capabilities,
/*name*/ seat_handle_name,
};
#undef LOG
@ -4505,12 +4542,12 @@ static void xdg_output_handle_description(void * /*data*/,
CLOG_INFO(LOG, 2, "description (description=\"%s\")", description);
}
static const struct zxdg_output_v1_listener xdg_output_listener = {
xdg_output_handle_logical_position,
xdg_output_handle_logical_size,
xdg_output_handle_done,
xdg_output_handle_name,
xdg_output_handle_description,
static const zxdg_output_v1_listener xdg_output_listener = {
/*logical_position*/ xdg_output_handle_logical_position,
/*logical_size*/ xdg_output_handle_logical_size,
/*done*/ xdg_output_handle_done,
/*name*/ xdg_output_handle_name,
/*description*/ xdg_output_handle_description,
};
#undef LOG
@ -4622,11 +4659,11 @@ static void output_handle_scale(void *data, struct wl_output * /*wl_output*/, co
output->system->output_scale_update(output);
}
static const struct wl_output_listener output_listener = {
output_handle_geometry,
output_handle_mode,
output_handle_done,
output_handle_scale,
static const wl_output_listener output_listener = {
/*geometry*/ output_handle_geometry,
/*mode*/ output_handle_mode,
/*done*/ output_handle_done,
/*scale*/ output_handle_scale,
};
#undef LOG
@ -4648,8 +4685,8 @@ static void shell_handle_ping(void * /*data*/,
xdg_wm_base_pong(xdg_wm_base, serial);
}
static const struct xdg_wm_base_listener shell_listener = {
shell_handle_ping,
static const xdg_wm_base_listener shell_listener = {
/*ping*/ shell_handle_ping,
};
#undef LOG
@ -5336,9 +5373,9 @@ static void global_handle_remove(void *data,
}
}
static const struct wl_registry_listener registry_listener = {
global_handle_add,
global_handle_remove,
static const wl_registry_listener registry_listener = {
/*global*/ global_handle_add,
/*global_remove*/ global_handle_remove,
};
#undef LOG

View File

@ -513,8 +513,8 @@ static void xdg_toplevel_handle_close(void *data, xdg_toplevel * /*xdg_toplevel*
}
static const xdg_toplevel_listener xdg_toplevel_listener = {
xdg_toplevel_handle_configure,
xdg_toplevel_handle_close,
/*configure*/ xdg_toplevel_handle_configure,
/*close*/ xdg_toplevel_handle_close,
};
#undef LOG
@ -617,7 +617,8 @@ static void frame_handle_commit(struct libdecor_frame * /*frame*/, void *data)
# endif
}
static struct libdecor_frame_interface libdecor_frame_iface = {
/* NOTE: cannot be `const` because of the LIBDECOR API. */
static libdecor_frame_interface libdecor_frame_iface = {
frame_handle_configure,
frame_handle_close,
frame_handle_commit,
@ -649,7 +650,7 @@ static void xdg_toplevel_decoration_handle_configure(
}
static const zxdg_toplevel_decoration_v1_listener xdg_toplevel_decoration_v1_listener = {
xdg_toplevel_decoration_handle_configure,
/*configure*/ xdg_toplevel_decoration_handle_configure,
};
#undef LOG
@ -693,7 +694,7 @@ static void xdg_surface_handle_configure(void *data,
}
static const xdg_surface_listener xdg_surface_listener = {
xdg_surface_handle_configure,
/*configure*/ xdg_surface_handle_configure,
};
#undef LOG
@ -741,9 +742,9 @@ static void surface_handle_leave(void *data,
}
}
static const struct wl_surface_listener wl_surface_listener = {
surface_handle_enter,
surface_handle_leave,
static const wl_surface_listener wl_surface_listener = {
/*enter*/ surface_handle_enter,
/*leave*/ surface_handle_leave,
};
#undef LOG

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

@ -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

@ -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

@ -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

@ -1123,11 +1123,11 @@ static void bm_edge_table_build(BMesh &bm,
BM_elem_index_set(edge, i); /* set_inline */
table[i] = edge;
hflag |= edge->head.hflag;
need_sharp_edge |= (edge->head.hflag & BM_ELEM_SMOOTH) == 0;
BM_CHECK_ELEMENT(edge);
}
need_select_edge = (hflag & BM_ELEM_SELECT) != 0;
need_hide_edge = (hflag & BM_ELEM_HIDDEN) != 0;
need_sharp_edge = (hflag & BM_ELEM_SMOOTH) != 0;
need_uv_seams = (hflag & BM_ELEM_SEAM) != 0;
}

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

@ -220,8 +220,7 @@ static void accumululate_material_counts_mesh(
}
/* Count how many triangles for each material. */
static void mesh_render_data_mat_tri_len_build(const MeshRenderData &mr,
MutableSpan<int> mat_tri_len)
static Array<int> mesh_render_data_mat_tri_len_build(const MeshRenderData &mr)
{
threading::EnumerableThreadSpecific<Array<int>> all_tri_counts(
[&]() { return Array<int>(mr.mat_len, 0); });
@ -233,20 +232,18 @@ static void mesh_render_data_mat_tri_len_build(const MeshRenderData &mr,
accumululate_material_counts_mesh(mr, all_tri_counts);
}
mat_tri_len.fill(0);
Array<int> mat_tri_len(mr.mat_len, 0);
for (const Array<int> &counts : all_tri_counts) {
for (const int i : mat_tri_len.index_range()) {
mat_tri_len[i] += counts[i];
}
}
return mat_tri_len;
}
static void mesh_render_data_polys_sorted_build(MeshRenderData *mr, MeshBufferCache *cache)
{
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. */
@ -260,6 +257,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

@ -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

@ -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

@ -1069,17 +1069,24 @@ int transformEvent(TransInfo *t, const wmEvent *event)
break;
case TFM_MODAL_SNAP_INV_ON:
t->modifiers |= MOD_SNAP_INVERT;
t->redraw |= TREDRAW_HARD;
if (!(t->modifiers & MOD_SNAP_INVERT)) {
t->modifiers |= MOD_SNAP_INVERT;
transform_snap_flag_from_modifiers_set(t);
t->redraw |= TREDRAW_HARD;
}
handled = true;
break;
case TFM_MODAL_SNAP_INV_OFF:
t->modifiers &= ~MOD_SNAP_INVERT;
t->redraw |= TREDRAW_HARD;
handled = true;
if (t->modifiers & MOD_SNAP_INVERT) {
t->modifiers &= ~MOD_SNAP_INVERT;
transform_snap_flag_from_modifiers_set(t);
t->redraw |= TREDRAW_HARD;
handled = true;
}
break;
case TFM_MODAL_SNAP_TOGGLE:
t->modifiers ^= MOD_SNAP;
transform_snap_flag_from_modifiers_set(t);
t->redraw |= TREDRAW_HARD;
handled = true;
break;
@ -1645,7 +1652,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
if ((prop = RNA_struct_find_property(op->ptr, "snap_elements"))) {
RNA_property_enum_set(op->ptr, prop, t->tsnap.mode);
RNA_boolean_set(op->ptr, "use_snap_project", t->tsnap.project);
RNA_boolean_set(op->ptr, "use_snap_project", (t->tsnap.flag & SCE_SNAP_PROJECT) != 0);
RNA_enum_set(op->ptr, "snap_target", t->tsnap.source_operation);
eSnapTargetOP target = t->tsnap.target_operation;

View File

@ -290,10 +290,6 @@ typedef struct TransSnap {
eSnapSourceOP source_operation;
/* Determines which objects are possible target */
eSnapTargetOP target_operation;
bool align;
bool project;
bool peel;
bool use_backface_culling;
short face_nearest_steps;
eTSnap status;
/* Snapped Element Type (currently for objects only). */

View File

@ -51,8 +51,6 @@
#include "transform_convert.h"
#include "transform_snap.h"
static bool doForceIncrementSnap(const TransInfo *t);
/* use half of flt-max so we can scale up without an exception */
/* -------------------------------------------------------------------- */
@ -120,10 +118,17 @@ bool validSnap(const TransInfo *t)
(SNAP_MULTI_POINTS | SNAP_SOURCE_FOUND);
}
void transform_snap_flag_from_modifiers_set(TransInfo *t)
{
SET_FLAG_FROM_TEST(t->tsnap.flag,
(((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP) ||
((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT)),
SCE_SNAP);
}
bool transform_snap_is_active(const TransInfo *t)
{
return ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP) ||
((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT);
return (t->tsnap.flag & SCE_SNAP) != 0;
}
bool transformModeUseSnap(const TransInfo *t)
@ -151,6 +156,11 @@ static bool doForceIncrementSnap(const TransInfo *t)
return false;
}
if (ELEM(t->spacetype, SPACE_ACTION, SPACE_NLA)) {
/* No incremental snapping. */
return false;
}
return !transformModeUseSnap(t);
}
@ -354,7 +364,7 @@ static bool applyFaceProject(TransInfo *t, TransDataContainer *tc, TransData *td
snap_object_params.snap_target_select = t->tsnap.target_operation;
snap_object_params.edit_mode_type = (t->flag & T_EDIT) != 0 ? SNAP_GEOM_EDIT : SNAP_GEOM_FINAL;
snap_object_params.use_occlusion_test = false;
snap_object_params.use_backface_culling = t->tsnap.use_backface_culling;
snap_object_params.use_backface_culling = (t->tsnap.flag & SCE_SNAP_BACKFACE_CULLING) != 0;
eSnapMode hit = ED_transform_snap_object_project_view3d(t->tsnap.object_context,
t->depsgraph,
@ -379,7 +389,7 @@ static bool applyFaceProject(TransInfo *t, TransDataContainer *tc, TransData *td
add_v3_v3(td->loc, tvec);
if (t->tsnap.align && (t->options & CTX_OBJECT)) {
if ((t->tsnap.flag & SCE_SNAP_ROTATE) && (t->options & CTX_OBJECT)) {
/* handle alignment as well */
const float *original_normal;
float mat[3][3];
@ -456,15 +466,7 @@ bool transform_snap_project_individual_is_active(const TransInfo *t)
return false;
}
if (t->flag & T_NO_PROJECT) {
return false;
}
if (!(t->tsnap.project || (t->tsnap.mode & SCE_SNAP_MODE_FACE_NEAREST))) {
return false;
}
if (doForceIncrementSnap(t)) {
if (!(t->tsnap.flag & SCE_SNAP_PROJECT)) {
return false;
}
@ -508,7 +510,7 @@ static bool transform_snap_mixed_is_active(const TransInfo *t)
return false;
}
if (t->tsnap.mode == SCE_SNAP_MODE_FACE_RAYCAST && t->tsnap.project) {
if ((t->tsnap.mode == SCE_SNAP_MODE_FACE_RAYCAST) && (t->tsnap.flag & SCE_SNAP_PROJECT)) {
return false;
}
@ -516,10 +518,6 @@ static bool transform_snap_mixed_is_active(const TransInfo *t)
return false;
}
if (doForceIncrementSnap(t)) {
return false;
}
return true;
}
@ -555,8 +553,6 @@ void resetSnapping(TransInfo *t)
{
t->tsnap.status = SNAP_RESETTED;
t->tsnap.snapElem = SCE_SNAP_MODE_NONE;
t->tsnap.align = false;
t->tsnap.project = false;
t->tsnap.mode = SCE_SNAP_MODE_NONE;
t->tsnap.target_operation = SCE_SNAP_TARGET_ALL;
t->tsnap.source_operation = SCE_SNAP_SOURCE_CLOSEST;
@ -571,7 +567,7 @@ void resetSnapping(TransInfo *t)
bool usingSnappingNormal(const TransInfo *t)
{
return t->tsnap.align;
return (t->tsnap.flag & SCE_SNAP_ROTATE) != 0;
}
bool validSnappingNormal(const TransInfo *t)
@ -735,16 +731,21 @@ static eSnapTargetOP snap_target_select_from_spacetype(TransInfo *t)
static void initSnappingMode(TransInfo *t)
{
if ((t->spacetype != SPACE_VIEW3D) || !(t->tsnap.mode & SCE_SNAP_MODE_FACE_RAYCAST)) {
if (doForceIncrementSnap(t)) {
t->tsnap.mode = SCE_SNAP_MODE_INCREMENT;
}
if ((t->spacetype != SPACE_VIEW3D) || !(t->tsnap.mode & SCE_SNAP_MODE_FACE_RAYCAST) ||
(t->tsnap.mode & SCE_SNAP_MODE_FACE_NEAREST) || (t->flag & T_NO_PROJECT)) {
/* Force project off when not supported. */
t->tsnap.project = false;
t->tsnap.flag &= ~SCE_SNAP_PROJECT;
}
setSnappingCallback(t);
if (t->spacetype == SPACE_VIEW3D) {
if (t->tsnap.object_context == nullptr) {
t->tsnap.use_backface_culling = snap_use_backface_culling(t);
SET_FLAG_FROM_TEST(t->tsnap.flag, snap_use_backface_culling(t), SCE_SNAP_BACKFACE_CULLING);
t->tsnap.object_context = ED_transform_snap_object_context_create(t->scene, 0);
if (t->data_type == &TransConvertType_Mesh) {
@ -815,14 +816,17 @@ void initSnapping(TransInfo *t, wmOperator *op)
/* snap align only defined in specific cases */
if ((prop = RNA_struct_find_property(op->ptr, "snap_align")) &&
RNA_property_is_set(op->ptr, prop)) {
t->tsnap.align = RNA_property_boolean_get(op->ptr, prop);
SET_FLAG_FROM_TEST(
t->tsnap.flag, RNA_property_boolean_get(op->ptr, prop), SCE_SNAP_ROTATE);
RNA_float_get_array(op->ptr, "snap_normal", t->tsnap.snapNormal);
normalize_v3(t->tsnap.snapNormal);
}
if ((prop = RNA_struct_find_property(op->ptr, "use_snap_project")) &&
RNA_property_is_set(op->ptr, prop)) {
t->tsnap.project = RNA_property_boolean_get(op->ptr, prop);
SET_FLAG_FROM_TEST(
t->tsnap.flag, RNA_property_boolean_get(op->ptr, prop), SCE_SNAP_PROJECT);
}
/* use_snap_self is misnamed and should be use_snap_active */
@ -861,9 +865,6 @@ void initSnapping(TransInfo *t, wmOperator *op)
t->modifiers |= MOD_SNAP;
}
t->tsnap.align = ((t->tsnap.flag & SCE_SNAP_ROTATE) != 0);
t->tsnap.project = ((t->tsnap.flag & SCE_SNAP_PROJECT) != 0);
t->tsnap.peel = ((t->tsnap.flag & SCE_SNAP_PROJECT) != 0);
SET_FLAG_FROM_TEST(t->tsnap.target_operation,
(ts->snap_flag & SCE_SNAP_NOT_TO_ACTIVE),
SCE_SNAP_TARGET_NOT_ACTIVE);
@ -1353,7 +1354,7 @@ eSnapMode snapObjectsTransform(
snap_object_params.snap_target_select = t->tsnap.target_operation;
snap_object_params.edit_mode_type = (t->flag & T_EDIT) != 0 ? SNAP_GEOM_EDIT : SNAP_GEOM_FINAL;
snap_object_params.use_occlusion_test = t->settings->snap_mode != SCE_SNAP_MODE_FACE_RAYCAST;
snap_object_params.use_backface_culling = t->tsnap.use_backface_culling;
snap_object_params.use_backface_culling = (t->tsnap.flag & SCE_SNAP_BACKFACE_CULLING) != 0;
float *target = (t->tsnap.status & SNAP_SOURCE_FOUND) ? t->tsnap.snap_source : t->center_global;
return ED_transform_snap_object_project_view3d(t->tsnap.object_context,
@ -1604,7 +1605,7 @@ static void snap_increment_apply(const TransInfo *t,
const float increment_dist,
float *r_val)
{
BLI_assert((t->tsnap.mode & SCE_SNAP_MODE_INCREMENT) || doForceIncrementSnap(t));
BLI_assert(t->tsnap.mode & SCE_SNAP_MODE_INCREMENT);
BLI_assert(max_index <= 2);
/* Early bailing out if no need to snap */
@ -1638,7 +1639,7 @@ bool transform_snap_increment_ex(const TransInfo *t, bool use_local_space, float
return false;
}
if (!(t->tsnap.mode & SCE_SNAP_MODE_INCREMENT) && !doForceIncrementSnap(t)) {
if (!(t->tsnap.mode & SCE_SNAP_MODE_INCREMENT)) {
return false;
}
@ -1671,8 +1672,7 @@ bool transform_snap_increment(const TransInfo *t, float *r_val)
float transform_snap_increment_get(const TransInfo *t)
{
if (transform_snap_is_active(t) &&
(!transformModeUseSnap(t) ||
(t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) {
(t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID))) {
return (t->modifiers & MOD_PRECISION) ? t->snap[1] : t->snap[0];
}

View File

@ -43,6 +43,7 @@ bool transform_snap_increment_ex(const TransInfo *t, bool use_local_space, float
bool transform_snap_increment(const TransInfo *t, float *val);
float transform_snap_increment_get(const TransInfo *t);
void transform_snap_flag_from_modifiers_set(TransInfo *t);
bool transform_snap_is_active(const TransInfo *t);
bool validSnap(const TransInfo *t);

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`