UV: restore internal solver state variable
Removed in [0] however I think it helps track the state,
so restore the state and assertions.
[0]: 8ace65e3c6
This commit is contained in:
@@ -883,6 +883,7 @@ static void minimize_stretch_exit(bContext *C, wmOperator *op, bool cancel)
|
||||
blender::geometry::uv_parametrizer_flush(ms->handle);
|
||||
}
|
||||
|
||||
blender::geometry::uv_parametrizer_stretch_end(ms->handle);
|
||||
delete (ms->handle);
|
||||
|
||||
for (uint ob_index = 0; ob_index < ms->objects_len; ob_index++) {
|
||||
|
||||
@@ -23,11 +23,19 @@ struct PHash;
|
||||
using ParamKey = uintptr_t; /* Key (hash) for identifying verts and faces. */
|
||||
#define PARAM_KEY_MAX UINTPTR_MAX
|
||||
|
||||
enum PHandleState {
|
||||
PHANDLE_STATE_ALLOCATED,
|
||||
PHANDLE_STATE_CONSTRUCTED,
|
||||
PHANDLE_STATE_LSCM,
|
||||
PHANDLE_STATE_STRETCH,
|
||||
};
|
||||
|
||||
class ParamHandle {
|
||||
public:
|
||||
ParamHandle();
|
||||
~ParamHandle();
|
||||
|
||||
PHandleState state;
|
||||
MemArena *arena;
|
||||
MemArena *polyfill_arena;
|
||||
Heap *polyfill_heap;
|
||||
@@ -114,6 +122,7 @@ void uv_parametrizer_lscm_end(ParamHandle *handle);
|
||||
void uv_parametrizer_stretch_begin(ParamHandle *handle);
|
||||
void uv_parametrizer_stretch_blend(ParamHandle *handle, float blend);
|
||||
void uv_parametrizer_stretch_iter(ParamHandle *handle);
|
||||
void uv_parametrizer_stretch_end(ParamHandle *handle);
|
||||
|
||||
/** \} */
|
||||
|
||||
|
||||
@@ -3618,6 +3618,7 @@ static void p_chart_rotate_fit_aabb(PChart *chart)
|
||||
|
||||
ParamHandle::ParamHandle()
|
||||
{
|
||||
state = PHANDLE_STATE_ALLOCATED;
|
||||
arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "param construct arena");
|
||||
polyfill_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "param polyfill arena");
|
||||
polyfill_heap = BLI_heap_new_ex(BLI_POLYFILL_ALLOC_NGON_RESERVE);
|
||||
@@ -3818,6 +3819,7 @@ void uv_parametrizer_face_add(ParamHandle *phandle,
|
||||
const bool *select)
|
||||
{
|
||||
BLI_assert(nverts >= 3);
|
||||
BLI_assert(phandle->state == PHANDLE_STATE_ALLOCATED);
|
||||
|
||||
if (nverts > 3) {
|
||||
/* Protect against (manifold) geometry which has a non-manifold triangulation.
|
||||
@@ -3897,6 +3899,8 @@ void uv_parametrizer_face_add(ParamHandle *phandle,
|
||||
|
||||
void uv_parametrizer_edge_set_seam(ParamHandle *phandle, ParamKey *vkeys)
|
||||
{
|
||||
BLI_assert(phandle->state == PHANDLE_STATE_ALLOCATED);
|
||||
|
||||
PEdge *e = p_edge_lookup(phandle, vkeys);
|
||||
if (e) {
|
||||
e->flag |= PEDGE_SEAM;
|
||||
@@ -3910,6 +3914,8 @@ void uv_parametrizer_construct_end(ParamHandle *phandle,
|
||||
{
|
||||
int i, j;
|
||||
|
||||
BLI_assert(phandle->state == PHANDLE_STATE_ALLOCATED);
|
||||
|
||||
phandle->ncharts = p_connect_pairs(phandle, topology_from_uvs);
|
||||
phandle->charts = p_split_charts(phandle, phandle->construction_chart, phandle->ncharts);
|
||||
|
||||
@@ -3946,10 +3952,15 @@ void uv_parametrizer_construct_end(ParamHandle *phandle,
|
||||
}
|
||||
|
||||
phandle->ncharts = j;
|
||||
|
||||
phandle->state = PHANDLE_STATE_CONSTRUCTED;
|
||||
}
|
||||
|
||||
void uv_parametrizer_lscm_begin(ParamHandle *phandle, bool live, bool abf)
|
||||
{
|
||||
BLI_assert(phandle->state == PHANDLE_STATE_CONSTRUCTED);
|
||||
phandle->state = PHANDLE_STATE_LSCM;
|
||||
|
||||
for (int i = 0; i < phandle->ncharts; i++) {
|
||||
for (PFace *f = phandle->charts[i]->faces; f; f = f->nextlink) {
|
||||
p_face_backup_uvs(f);
|
||||
@@ -3960,6 +3971,8 @@ void uv_parametrizer_lscm_begin(ParamHandle *phandle, bool live, bool abf)
|
||||
|
||||
void uv_parametrizer_lscm_solve(ParamHandle *phandle, int *count_changed, int *count_failed)
|
||||
{
|
||||
BLI_assert(phandle->state == PHANDLE_STATE_LSCM);
|
||||
|
||||
for (int i = 0; i < phandle->ncharts; i++) {
|
||||
PChart *chart = phandle->charts[i];
|
||||
|
||||
@@ -3996,16 +4009,23 @@ void uv_parametrizer_lscm_solve(ParamHandle *phandle, int *count_changed, int *c
|
||||
|
||||
void uv_parametrizer_lscm_end(ParamHandle *phandle)
|
||||
{
|
||||
BLI_assert(phandle->state == PHANDLE_STATE_LSCM);
|
||||
|
||||
for (int i = 0; i < phandle->ncharts; i++) {
|
||||
p_chart_lscm_end(phandle->charts[i]);
|
||||
#if 0
|
||||
p_chart_complexify(phandle->charts[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
phandle->state = PHANDLE_STATE_CONSTRUCTED;
|
||||
}
|
||||
|
||||
void uv_parametrizer_stretch_begin(ParamHandle *phandle)
|
||||
{
|
||||
BLI_assert(phandle->state == PHANDLE_STATE_CONSTRUCTED);
|
||||
phandle->state = PHANDLE_STATE_STRETCH;
|
||||
|
||||
phandle->rng = BLI_rng_new(31415926);
|
||||
phandle->blend = 0.0f;
|
||||
|
||||
@@ -4027,16 +4047,24 @@ void uv_parametrizer_stretch_begin(ParamHandle *phandle)
|
||||
|
||||
void uv_parametrizer_stretch_blend(ParamHandle *phandle, float blend)
|
||||
{
|
||||
BLI_assert(phandle->state == PHANDLE_STATE_STRETCH);
|
||||
phandle->blend = blend;
|
||||
}
|
||||
|
||||
void uv_parametrizer_stretch_iter(ParamHandle *phandle)
|
||||
{
|
||||
BLI_assert(phandle->state == PHANDLE_STATE_STRETCH);
|
||||
for (int i = 0; i < phandle->ncharts; i++) {
|
||||
p_chart_stretch_minimize(phandle->charts[i], phandle->rng);
|
||||
}
|
||||
}
|
||||
|
||||
void uv_parametrizer_stretch_end(ParamHandle *phandle)
|
||||
{
|
||||
BLI_assert(phandle->state == PHANDLE_STATE_STRETCH);
|
||||
phandle->state = PHANDLE_STATE_CONSTRUCTED;
|
||||
}
|
||||
|
||||
void uv_parametrizer_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_pinned)
|
||||
{
|
||||
if (handle->ncharts == 0) {
|
||||
|
||||
Reference in New Issue
Block a user