Geometry Nodes: Rewrite mesh delete geometry node #108435
|
@ -17,7 +17,13 @@
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
|
||||||
#include <windows.h>
|
#ifndef NOMINMAX
|
||||||
|
# define NOMINMAX
|
||||||
|
# include <windows.h>
|
||||||
|
# undef NOMINMAX
|
||||||
|
#else
|
||||||
|
# include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef rad
|
#undef rad
|
||||||
#undef rad1
|
#undef rad1
|
||||||
|
|
|
@ -57,6 +57,7 @@ set(SRC
|
||||||
tree/tree_element_driver.cc
|
tree/tree_element_driver.cc
|
||||||
tree/tree_element_gpencil_layer.cc
|
tree/tree_element_gpencil_layer.cc
|
||||||
tree/tree_element_id.cc
|
tree/tree_element_id.cc
|
||||||
|
tree/tree_element_id_curve.cc
|
||||||
tree/tree_element_id_library.cc
|
tree/tree_element_id_library.cc
|
||||||
tree/tree_element_id_mesh.cc
|
tree/tree_element_id_mesh.cc
|
||||||
tree/tree_element_id_scene.cc
|
tree/tree_element_id_scene.cc
|
||||||
|
@ -78,6 +79,7 @@ set(SRC
|
||||||
tree/tree_element_driver.hh
|
tree/tree_element_driver.hh
|
||||||
tree/tree_element_gpencil_layer.hh
|
tree/tree_element_gpencil_layer.hh
|
||||||
tree/tree_element_id.hh
|
tree/tree_element_id.hh
|
||||||
|
tree/tree_element_id_curve.hh
|
||||||
tree/tree_element_id_library.hh
|
tree/tree_element_id_library.hh
|
||||||
tree/tree_element_id_mesh.hh
|
tree/tree_element_id_mesh.hh
|
||||||
tree/tree_element_id_scene.hh
|
tree/tree_element_id_scene.hh
|
||||||
|
|
|
@ -552,24 +552,13 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
|
||||||
case ID_LI:
|
case ID_LI:
|
||||||
case ID_SCE:
|
case ID_SCE:
|
||||||
case ID_ME:
|
case ID_ME:
|
||||||
|
case ID_CU_LEGACY:
|
||||||
BLI_assert_msg(0, "ID type expected to be expanded through new tree-element design");
|
BLI_assert_msg(0, "ID type expected to be expanded through new tree-element design");
|
||||||
break;
|
break;
|
||||||
case ID_OB: {
|
case ID_OB: {
|
||||||
outliner_add_object_contents(space_outliner, te, tselem, (Object *)id);
|
outliner_add_object_contents(space_outliner, te, tselem, (Object *)id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ID_CU_LEGACY: {
|
|
||||||
Curve *cu = (Curve *)id;
|
|
||||||
|
|
||||||
if (outliner_animdata_test(cu->adt)) {
|
|
||||||
outliner_add_element(space_outliner, &te->subtree, cu, te, TSE_ANIM_DATA, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int a = 0; a < cu->totcol; a++) {
|
|
||||||
outliner_add_element(space_outliner, &te->subtree, cu->mat[a], te, TSE_SOME_ID, a);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ID_MB: {
|
case ID_MB: {
|
||||||
MetaBall *mb = (MetaBall *)id;
|
MetaBall *mb = (MetaBall *)id;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "../outliner_intern.hh"
|
#include "../outliner_intern.hh"
|
||||||
#include "common.hh"
|
#include "common.hh"
|
||||||
|
#include "tree_element_id_curve.hh"
|
||||||
#include "tree_element_id_library.hh"
|
#include "tree_element_id_library.hh"
|
||||||
#include "tree_element_id_mesh.hh"
|
#include "tree_element_id_mesh.hh"
|
||||||
#include "tree_element_id_scene.hh"
|
#include "tree_element_id_scene.hh"
|
||||||
|
@ -42,8 +43,9 @@ std::unique_ptr<TreeElementID> TreeElementID::createFromID(TreeElement &legacy_t
|
||||||
return std::make_unique<TreeElementIDScene>(legacy_te, (Scene &)id);
|
return std::make_unique<TreeElementIDScene>(legacy_te, (Scene &)id);
|
||||||
case ID_ME:
|
case ID_ME:
|
||||||
return std::make_unique<TreeElementIDMesh>(legacy_te, (Mesh &)id);
|
return std::make_unique<TreeElementIDMesh>(legacy_te, (Mesh &)id);
|
||||||
case ID_OB:
|
|
||||||
case ID_CU_LEGACY:
|
case ID_CU_LEGACY:
|
||||||
|
return std::make_unique<TreeElementIDCurve>(legacy_te, (Curve &)id);
|
||||||
|
case ID_OB:
|
||||||
case ID_MB:
|
case ID_MB:
|
||||||
case ID_MA:
|
case ID_MA:
|
||||||
case ID_TE:
|
case ID_TE:
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \ingroup spoutliner
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "DNA_curve_types.h"
|
||||||
|
#include "DNA_listBase.h"
|
||||||
|
#include "DNA_outliner_types.h"
|
||||||
|
|
||||||
|
#include "../outliner_intern.hh"
|
||||||
|
|
||||||
|
#include "tree_element_id_curve.hh"
|
||||||
|
|
||||||
|
namespace blender::ed::outliner {
|
||||||
|
|
||||||
|
TreeElementIDCurve::TreeElementIDCurve(TreeElement &legacy_te, Curve &curve)
|
||||||
|
: TreeElementID(legacy_te, curve.id), curve_(curve)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TreeElementIDCurve::isExpandValid() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TreeElementIDCurve::expand(SpaceOutliner &space_outliner) const
|
||||||
|
{
|
||||||
|
expand_animation_data(space_outliner, curve_.adt);
|
||||||
|
|
||||||
|
expandMaterials(space_outliner);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TreeElementIDCurve::expandMaterials(SpaceOutliner &space_outliner) const
|
||||||
|
{
|
||||||
|
for (int a = 0; a < curve_.totcol; a++) {
|
||||||
|
outliner_add_element(
|
||||||
|
&space_outliner, &legacy_te_.subtree, curve_.mat[a], &legacy_te_, TSE_SOME_ID, a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace blender::ed::outliner
|
|
@ -0,0 +1,28 @@
|
||||||
|
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \ingroup spoutliner
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "tree_element_id.hh"
|
||||||
|
|
||||||
|
namespace blender::ed::outliner {
|
||||||
|
|
||||||
|
class TreeElementIDCurve final : public TreeElementID {
|
||||||
|
Curve &curve_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TreeElementIDCurve(TreeElement &legacy_te, Curve &curve);
|
||||||
|
|
||||||
|
void expand(SpaceOutliner &) const override;
|
||||||
|
bool isExpandValid() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void expandMaterials(SpaceOutliner &) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace blender::ed::outliner
|
|
@ -375,7 +375,7 @@ class UVAABBIsland {
|
||||||
*/
|
*/
|
||||||
static void pack_islands_alpaca_turbo(const int64_t exclude_index,
|
static void pack_islands_alpaca_turbo(const int64_t exclude_index,
|
||||||
const rctf &exclude,
|
const rctf &exclude,
|
||||||
const Span<UVAABBIsland *> islands,
|
const Span<std::unique_ptr<UVAABBIsland>> islands,
|
||||||
const float target_aspect_y,
|
const float target_aspect_y,
|
||||||
MutableSpan<uv_phi> r_phis,
|
MutableSpan<uv_phi> r_phis,
|
||||||
rctf *r_extent)
|
rctf *r_extent)
|
||||||
|
@ -390,9 +390,9 @@ static void pack_islands_alpaca_turbo(const int64_t exclude_index,
|
||||||
|
|
||||||
/* Visit every island in order, except the excluded islands at the start. */
|
/* Visit every island in order, except the excluded islands at the start. */
|
||||||
for (int64_t index = exclude_index; index < islands.size(); index++) {
|
for (int64_t index = exclude_index; index < islands.size(); index++) {
|
||||||
UVAABBIsland *island = islands[index];
|
UVAABBIsland &island = *islands[index];
|
||||||
const float dsm_u = island->uv_diagonal.x;
|
const float dsm_u = island.uv_diagonal.x;
|
||||||
const float dsm_v = island->uv_diagonal.y;
|
const float dsm_v = island.uv_diagonal.y;
|
||||||
|
|
||||||
bool restart = false;
|
bool restart = false;
|
||||||
if (zigzag) {
|
if (zigzag) {
|
||||||
|
@ -409,7 +409,7 @@ static void pack_islands_alpaca_turbo(const int64_t exclude_index,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Place the island. */
|
/* Place the island. */
|
||||||
uv_phi &phi = r_phis[island->index];
|
uv_phi &phi = r_phis[island.index];
|
||||||
phi.rotation = 0.0f;
|
phi.rotation = 0.0f;
|
||||||
phi.translation.x = u0 + dsm_u * 0.5f;
|
phi.translation.x = u0 + dsm_u * 0.5f;
|
||||||
phi.translation.y = v0 + dsm_v * 0.5f;
|
phi.translation.y = v0 + dsm_v * 0.5f;
|
||||||
|
@ -486,7 +486,7 @@ static void update_hole_rotate(float2 &hole,
|
||||||
*/
|
*/
|
||||||
static void pack_islands_alpaca_rotate(const int64_t exclude_index,
|
static void pack_islands_alpaca_rotate(const int64_t exclude_index,
|
||||||
const rctf &exclude,
|
const rctf &exclude,
|
||||||
const Span<UVAABBIsland *> islands,
|
const Span<std::unique_ptr<UVAABBIsland>> islands,
|
||||||
const float target_aspect_y,
|
const float target_aspect_y,
|
||||||
MutableSpan<uv_phi> r_phis,
|
MutableSpan<uv_phi> r_phis,
|
||||||
rctf *r_extent)
|
rctf *r_extent)
|
||||||
|
@ -506,30 +506,30 @@ static void pack_islands_alpaca_rotate(const int64_t exclude_index,
|
||||||
|
|
||||||
/* Visit every island in order, except the excluded islands at the start. */
|
/* Visit every island in order, except the excluded islands at the start. */
|
||||||
for (int64_t index = exclude_index; index < islands.size(); index++) {
|
for (int64_t index = exclude_index; index < islands.size(); index++) {
|
||||||
UVAABBIsland *island = islands[index];
|
UVAABBIsland &island = *islands[index];
|
||||||
uv_phi &phi = r_phis[island->index];
|
uv_phi &phi = r_phis[island.index];
|
||||||
const float uvdiag_x = island->uv_diagonal.x * island->aspect_y;
|
const float uvdiag_x = island.uv_diagonal.x * island.aspect_y;
|
||||||
float min_dsm = std::min(uvdiag_x, island->uv_diagonal.y);
|
float min_dsm = std::min(uvdiag_x, island.uv_diagonal.y);
|
||||||
float max_dsm = std::max(uvdiag_x, island->uv_diagonal.y);
|
float max_dsm = std::max(uvdiag_x, island.uv_diagonal.y);
|
||||||
|
|
||||||
if (min_dsm < hole_diagonal.x && max_dsm < hole_diagonal.y) {
|
if (min_dsm < hole_diagonal.x && max_dsm < hole_diagonal.y) {
|
||||||
/* Place island in the hole. */
|
/* Place island in the hole. */
|
||||||
if (hole_rotate == (min_dsm == island->uv_diagonal.x)) {
|
if (hole_rotate == (min_dsm == island.uv_diagonal.x)) {
|
||||||
phi.rotation = DEG2RADF(90.0f);
|
phi.rotation = DEG2RADF(90.0f);
|
||||||
phi.translation.x = hole[0] + island->uv_diagonal.y * 0.5f / island->aspect_y;
|
phi.translation.x = hole[0] + island.uv_diagonal.y * 0.5f / island.aspect_y;
|
||||||
phi.translation.y = hole[1] + island->uv_diagonal.x * 0.5f * island->aspect_y;
|
phi.translation.y = hole[1] + island.uv_diagonal.x * 0.5f * island.aspect_y;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
phi.rotation = 0.0f;
|
phi.rotation = 0.0f;
|
||||||
phi.translation.x = hole[0] + island->uv_diagonal.x * 0.5f;
|
phi.translation.x = hole[0] + island.uv_diagonal.x * 0.5f;
|
||||||
phi.translation.y = hole[1] + island->uv_diagonal.y * 0.5f;
|
phi.translation.y = hole[1] + island.uv_diagonal.y * 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update space left in the hole. */
|
/* Update space left in the hole. */
|
||||||
float p[6];
|
float p[6];
|
||||||
p[0] = hole[0];
|
p[0] = hole[0];
|
||||||
p[1] = hole[1];
|
p[1] = hole[1];
|
||||||
p[2] = hole[0] + (hole_rotate ? max_dsm : min_dsm) / island->aspect_y;
|
p[2] = hole[0] + (hole_rotate ? max_dsm : min_dsm) / island.aspect_y;
|
||||||
p[3] = hole[1] + (hole_rotate ? min_dsm : max_dsm);
|
p[3] = hole[1] + (hole_rotate ? min_dsm : max_dsm);
|
||||||
p[4] = hole[0] + (hole_rotate ? hole_diagonal.y : hole_diagonal.x);
|
p[4] = hole[0] + (hole_rotate ? hole_diagonal.y : hole_diagonal.x);
|
||||||
p[5] = hole[1] + (hole_rotate ? hole_diagonal.x : hole_diagonal.y);
|
p[5] = hole[1] + (hole_rotate ? hole_diagonal.x : hole_diagonal.y);
|
||||||
|
@ -546,7 +546,7 @@ static void pack_islands_alpaca_rotate(const int64_t exclude_index,
|
||||||
restart = (next_v1 < v0 + min_dsm);
|
restart = (next_v1 < v0 + min_dsm);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
restart = (next_u1 < u0 + min_dsm / island->aspect_y);
|
restart = (next_u1 < u0 + min_dsm / island.aspect_y);
|
||||||
}
|
}
|
||||||
if (restart) {
|
if (restart) {
|
||||||
update_hole_rotate(hole, hole_diagonal, hole_rotate, u0, v0, next_u1, next_v1);
|
update_hole_rotate(hole, hole_diagonal, hole_rotate, u0, v0, next_u1, next_v1);
|
||||||
|
@ -559,25 +559,25 @@ static void pack_islands_alpaca_rotate(const int64_t exclude_index,
|
||||||
/* Place the island. */
|
/* Place the island. */
|
||||||
if (zigzag == (min_dsm == uvdiag_x)) {
|
if (zigzag == (min_dsm == uvdiag_x)) {
|
||||||
phi.rotation = DEG2RADF(90.0f);
|
phi.rotation = DEG2RADF(90.0f);
|
||||||
phi.translation.x = u0 + island->uv_diagonal.y * 0.5f / island->aspect_y;
|
phi.translation.x = u0 + island.uv_diagonal.y * 0.5f / island.aspect_y;
|
||||||
phi.translation.y = v0 + island->uv_diagonal.x * 0.5f * island->aspect_y;
|
phi.translation.y = v0 + island.uv_diagonal.x * 0.5f * island.aspect_y;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
phi.rotation = 0.0f;
|
phi.rotation = 0.0f;
|
||||||
phi.translation.x = u0 + island->uv_diagonal.x * 0.5f;
|
phi.translation.x = u0 + island.uv_diagonal.x * 0.5f;
|
||||||
phi.translation.y = v0 + island->uv_diagonal.y * 0.5f;
|
phi.translation.y = v0 + island.uv_diagonal.y * 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move according to the "Alpaca rules", with rotation. */
|
/* Move according to the "Alpaca rules", with rotation. */
|
||||||
if (zigzag) {
|
if (zigzag) {
|
||||||
/* Move upwards. */
|
/* Move upwards. */
|
||||||
v0 += min_dsm;
|
v0 += min_dsm;
|
||||||
next_u1 = max_ff(next_u1, u0 + max_dsm / island->aspect_y);
|
next_u1 = max_ff(next_u1, u0 + max_dsm / island.aspect_y);
|
||||||
next_v1 = max_ff(next_v1, v0);
|
next_v1 = max_ff(next_v1, v0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Move sideways. */
|
/* Move sideways. */
|
||||||
u0 += min_dsm / island->aspect_y;
|
u0 += min_dsm / island.aspect_y;
|
||||||
next_v1 = max_ff(next_v1, v0 + max_dsm);
|
next_v1 = max_ff(next_v1, v0 + max_dsm);
|
||||||
next_u1 = max_ff(next_u1, u0);
|
next_u1 = max_ff(next_u1, u0);
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,7 @@ static void pack_islands_alpaca_rotate(const int64_t exclude_index,
|
||||||
*/
|
*/
|
||||||
static void pack_islands_fast(const int64_t exclude_index,
|
static void pack_islands_fast(const int64_t exclude_index,
|
||||||
const rctf &exclude,
|
const rctf &exclude,
|
||||||
const Span<UVAABBIsland *> aabbs,
|
const Span<std::unique_ptr<UVAABBIsland>> aabbs,
|
||||||
const bool rotate,
|
const bool rotate,
|
||||||
const float target_aspect_y,
|
const float target_aspect_y,
|
||||||
MutableSpan<uv_phi> r_phis,
|
MutableSpan<uv_phi> r_phis,
|
||||||
|
@ -607,7 +607,7 @@ static void pack_islands_fast(const int64_t exclude_index,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Frits Göbel, 1979. */
|
/** Frits Göbel, 1979. */
|
||||||
static void pack_gobel(const Span<UVAABBIsland *> aabbs,
|
static void pack_gobel(const Span<std::unique_ptr<UVAABBIsland>> aabbs,
|
||||||
const float scale,
|
const float scale,
|
||||||
const int m,
|
const int m,
|
||||||
MutableSpan<uv_phi> r_phis)
|
MutableSpan<uv_phi> r_phis)
|
||||||
|
@ -643,7 +643,7 @@ static void pack_gobel(const Span<UVAABBIsland *> aabbs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Attempt to find an "Optimal" packing of the islands, e.g. assuming squares or circles. */
|
/* Attempt to find an "Optimal" packing of the islands, e.g. assuming squares or circles. */
|
||||||
static void pack_islands_optimal_pack(const Span<UVAABBIsland *> aabbs,
|
static void pack_islands_optimal_pack(const Span<std::unique_ptr<UVAABBIsland>> aabbs,
|
||||||
const UVPackIsland_Params ¶ms,
|
const UVPackIsland_Params ¶ms,
|
||||||
MutableSpan<uv_phi> r_phis,
|
MutableSpan<uv_phi> r_phis,
|
||||||
rctf *r_extent)
|
rctf *r_extent)
|
||||||
|
@ -694,7 +694,7 @@ static void pack_islands_optimal_pack(const Span<UVAABBIsland *> aabbs,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wrapper around #BLI_box_pack_2d. */
|
/* Wrapper around #BLI_box_pack_2d. */
|
||||||
static void pack_island_box_pack_2d(const Span<UVAABBIsland *> aabbs,
|
static void pack_island_box_pack_2d(const Span<std::unique_ptr<UVAABBIsland>> aabbs,
|
||||||
const UVPackIsland_Params ¶ms,
|
const UVPackIsland_Params ¶ms,
|
||||||
MutableSpan<uv_phi> r_phis,
|
MutableSpan<uv_phi> r_phis,
|
||||||
rctf *r_extent)
|
rctf *r_extent)
|
||||||
|
@ -1093,7 +1093,7 @@ class UVMinimumEnclosingSquareFinder {
|
||||||
* If that square is smaller than `r_extent`, then update `r_phis` accordingly.
|
* If that square is smaller than `r_extent`, then update `r_phis` accordingly.
|
||||||
* \return True if `r_phis` and `r_extent` are modified.
|
* \return True if `r_phis` and `r_extent` are modified.
|
||||||
*/
|
*/
|
||||||
static bool rotate_inside_square(const Span<UVAABBIsland *> island_indices,
|
static bool rotate_inside_square(const Span<std::unique_ptr<UVAABBIsland>> island_indices,
|
||||||
const Span<PackIsland *> islands,
|
const Span<PackIsland *> islands,
|
||||||
const UVPackIsland_Params ¶ms,
|
const UVPackIsland_Params ¶ms,
|
||||||
const float scale,
|
const float scale,
|
||||||
|
@ -1194,7 +1194,7 @@ static bool rotate_inside_square(const Span<UVAABBIsland *> island_indices,
|
||||||
* Performance would normally be `O(n^4)`, however the occupancy
|
* Performance would normally be `O(n^4)`, however the occupancy
|
||||||
* bitmap_radix is fixed, which gives a reduced time complexity of `O(n^3)`.
|
* bitmap_radix is fixed, which gives a reduced time complexity of `O(n^3)`.
|
||||||
*/
|
*/
|
||||||
static int64_t pack_island_xatlas(const Span<UVAABBIsland *> island_indices,
|
static int64_t pack_island_xatlas(const Span<std::unique_ptr<UVAABBIsland>> island_indices,
|
||||||
const Span<PackIsland *> islands,
|
const Span<PackIsland *> islands,
|
||||||
const float scale,
|
const float scale,
|
||||||
const float margin,
|
const float margin,
|
||||||
|
@ -1402,27 +1402,28 @@ static float pack_islands_scale_margin(const Span<PackIsland *> islands,
|
||||||
const bool all_can_rotate = can_rotate(islands, params);
|
const bool all_can_rotate = can_rotate(islands, params);
|
||||||
|
|
||||||
/* First, copy information from our input into the AABB structure. */
|
/* First, copy information from our input into the AABB structure. */
|
||||||
Array<UVAABBIsland *> aabbs(islands.size());
|
Array<std::unique_ptr<UVAABBIsland>> aabbs(islands.size());
|
||||||
for (const int64_t i : islands.index_range()) {
|
for (const int64_t i : islands.index_range()) {
|
||||||
PackIsland *pack_island = islands[i];
|
PackIsland *pack_island = islands[i];
|
||||||
float island_scale = scale;
|
float island_scale = scale;
|
||||||
if (!pack_island->can_scale_(params)) {
|
if (!pack_island->can_scale_(params)) {
|
||||||
island_scale = 1.0f;
|
island_scale = 1.0f;
|
||||||
}
|
}
|
||||||
UVAABBIsland *aabb = new UVAABBIsland();
|
std::unique_ptr<UVAABBIsland> aabb = std::make_unique<UVAABBIsland>();
|
||||||
aabb->index = i;
|
aabb->index = i;
|
||||||
aabb->uv_diagonal.x = pack_island->half_diagonal_.x * 2 * island_scale + 2 * margin;
|
aabb->uv_diagonal.x = pack_island->half_diagonal_.x * 2 * island_scale + 2 * margin;
|
||||||
aabb->uv_diagonal.y = pack_island->half_diagonal_.y * 2 * island_scale + 2 * margin;
|
aabb->uv_diagonal.y = pack_island->half_diagonal_.y * 2 * island_scale + 2 * margin;
|
||||||
aabb->aspect_y = pack_island->aspect_y;
|
aabb->aspect_y = pack_island->aspect_y;
|
||||||
aabbs[i] = aabb;
|
aabbs[i] = std::move(aabb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sort from "biggest" to "smallest". */
|
/* Sort from "biggest" to "smallest". */
|
||||||
|
|
||||||
if (all_can_rotate) {
|
if (all_can_rotate) {
|
||||||
std::stable_sort(aabbs.begin(),
|
std::stable_sort(
|
||||||
|
aabbs.begin(),
|
||||||
aabbs.end(),
|
aabbs.end(),
|
||||||
[¶ms, &islands](const UVAABBIsland *a, const UVAABBIsland *b) {
|
[&](const std::unique_ptr<UVAABBIsland> &a, const std::unique_ptr<UVAABBIsland> &b) {
|
||||||
const bool can_translate_a = islands[a->index]->can_translate_(params);
|
const bool can_translate_a = islands[a->index]->can_translate_(params);
|
||||||
const bool can_translate_b = islands[b->index]->can_translate_(params);
|
const bool can_translate_b = islands[b->index]->can_translate_(params);
|
||||||
if (can_translate_a != can_translate_b) {
|
if (can_translate_a != can_translate_b) {
|
||||||
|
@ -1451,10 +1452,10 @@ static float pack_islands_scale_margin(const Span<PackIsland *> islands,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
std::stable_sort(
|
||||||
std::stable_sort(aabbs.begin(),
|
aabbs.begin(),
|
||||||
aabbs.end(),
|
aabbs.end(),
|
||||||
[¶ms, &islands](const UVAABBIsland *a, const UVAABBIsland *b) {
|
[&](const std::unique_ptr<UVAABBIsland> &a, const std::unique_ptr<UVAABBIsland> &b) {
|
||||||
const bool can_translate_a = islands[a->index]->can_translate_(params);
|
const bool can_translate_a = islands[a->index]->can_translate_(params);
|
||||||
const bool can_translate_b = islands[b->index]->can_translate_(params);
|
const bool can_translate_b = islands[b->index]->can_translate_(params);
|
||||||
if (can_translate_a != can_translate_b) {
|
if (can_translate_a != can_translate_b) {
|
||||||
|
@ -1462,8 +1463,7 @@ static float pack_islands_scale_margin(const Span<PackIsland *> islands,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Choose the AABB with larger rectangular area. */
|
/* Choose the AABB with larger rectangular area. */
|
||||||
return b->uv_diagonal.x * b->uv_diagonal.y <
|
return b->uv_diagonal.x * b->uv_diagonal.y < a->uv_diagonal.x * a->uv_diagonal.y;
|
||||||
a->uv_diagonal.x * a->uv_diagonal.y;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1499,7 +1499,7 @@ static float pack_islands_scale_margin(const Span<PackIsland *> islands,
|
||||||
|
|
||||||
alpaca_cutoff = std::max(alpaca_cutoff, locked_island_count); /* ...TODO... */
|
alpaca_cutoff = std::max(alpaca_cutoff, locked_island_count); /* ...TODO... */
|
||||||
|
|
||||||
Span<UVAABBIsland *> slow_aabbs = aabbs.as_span().take_front(
|
Span<std::unique_ptr<UVAABBIsland>> slow_aabbs = aabbs.as_span().take_front(
|
||||||
std::min(alpaca_cutoff, islands.size()));
|
std::min(alpaca_cutoff, islands.size()));
|
||||||
rctf extent = {0.0f, 1e30f, 0.0f, 1e30f};
|
rctf extent = {0.0f, 1e30f, 0.0f, 1e30f};
|
||||||
|
|
||||||
|
@ -1546,13 +1546,6 @@ static float pack_islands_scale_margin(const Span<PackIsland *> islands,
|
||||||
r_phis,
|
r_phis,
|
||||||
&final_extent);
|
&final_extent);
|
||||||
|
|
||||||
/* Housekeeping. */
|
|
||||||
for (const int64_t i : aabbs.index_range()) {
|
|
||||||
UVAABBIsland *aabb = aabbs[i];
|
|
||||||
aabbs[i] = nullptr;
|
|
||||||
delete aabb;
|
|
||||||
}
|
|
||||||
|
|
||||||
return get_aspect_scaled_extent(final_extent, params);
|
return get_aspect_scaled_extent(final_extent, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue