Files
test/source/blender/blenkernel/intern/curve_convert.c
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

68 lines
1.9 KiB
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup bke
*/
#include "DNA_curve_types.h"
#include "DNA_object_types.h"
#include "DNA_vfont_types.h"
#include "BLI_utildefines.h"
#include "BKE_curve.h"
#include "BKE_displist.h"
#include "BKE_lib_id.h"
#include "BKE_modifier.h"
#include "BKE_vfont.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
static Curve *curve_from_font_object(Object *object, Depsgraph *depsgraph)
{
Curve *curve = (Curve *)object->data;
Curve *new_curve = (Curve *)BKE_id_copy_ex(NULL, &curve->id, NULL, LIB_ID_COPY_LOCALIZE);
Object *evaluated_object = DEG_get_evaluated_object(depsgraph, object);
BKE_vfont_to_curve_nubase(evaluated_object, FO_EDIT, &new_curve->nurb);
new_curve->type = OB_CURVE;
new_curve->flag &= ~CU_3D;
BKE_curve_dimension_update(new_curve);
return new_curve;
}
static Curve *curve_from_curve_object(Object *object, Depsgraph *depsgraph, bool apply_modifiers)
{
Object *evaluated_object = DEG_get_evaluated_object(depsgraph, object);
Curve *curve = (Curve *)evaluated_object->data;
Curve *new_curve = (Curve *)BKE_id_copy_ex(NULL, &curve->id, NULL, LIB_ID_COPY_LOCALIZE);
if (apply_modifiers) {
BKE_curve_calc_modifiers_pre(depsgraph,
DEG_get_input_scene(depsgraph),
evaluated_object,
BKE_curve_nurbs_get(curve),
&new_curve->nurb,
DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
}
return new_curve;
}
Curve *BKE_curve_new_from_object(Object *object, Depsgraph *depsgraph, bool apply_modifiers)
{
if (!ELEM(object->type, OB_FONT, OB_CURVE)) {
return NULL;
}
if (object->type == OB_FONT) {
return curve_from_font_object(object, depsgraph);
}
return curve_from_curve_object(object, depsgraph, apply_modifiers);
}