Files
test2/source/blender/blenkernel/BKE_curve_legacy_convert.hh
Mattias Fredriksson d0cf7dd8b5 Fix: Improve OBJ NURBS IO, support exporting custom knots
Corrects behavior with NURBS knot values in .obj exporter. Knot values
denoting the curve parameter range and values at the boundary region
in the span ends had hardcoded knot values. It also implemented its own
knot calculation, which is not ideal...

Importer is updated to not try to second guess the knot values.
Not entirely sure what it was trying to do but it used wrong indices
and missed writing the end of the knot vector. Combined the changes
should make it possible to import and export a simple NURBS curve with
custom knots and leaving it intact.

This replaces some of the erronous behavior using functions from [new]
Curves implementation. Mixing new and legacy curve implementation is not
ideal but exporter is exporting POLY curves as NURBS while legacy method
does not support computing the knot vector. To avoid introducing
additional branch cases nor update legacy functions, using the new
functions seems to be the correct choice. These functions should be
functionally equivalent but is not identical (e.g. legacy curve returns
knots in [0, 1] range). It should also make it easier to transition to
exporting new Curves.

Pull Request: https://projects.blender.org/blender/blender/pulls/138732
2025-05-12 16:51:21 +02:00

34 lines
764 B
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup bke
*/
#include "DNA_curves_types.h"
struct Curve;
struct ListBase;
namespace blender::bke {
/**
* Convert the old curve type to the new data type. Caller owns the returned pointer.
*/
Curves *curve_legacy_to_curves(const Curve &curve_legacy);
/**
* Convert the old curve type to the new data type using a specific list of #Nurb for the actual
* geometry data. Caller owns the returned pointer.
*/
Curves *curve_legacy_to_curves(const Curve &curve_legacy, const ListBase &nurbs_list);
/**
* Determine Curves knot mode from legacy flag.
*/
KnotsMode knots_mode_from_legacy(short flag);
} // namespace blender::bke