Blender  V3.3
curve_convert.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "DNA_curve_types.h"
8 #include "DNA_object_types.h"
9 #include "DNA_vfont_types.h"
10 
11 #include "BLI_utildefines.h"
12 
13 #include "BKE_curve.h"
14 #include "BKE_displist.h"
15 #include "BKE_lib_id.h"
16 #include "BKE_modifier.h"
17 #include "BKE_vfont.h"
18 
19 #include "DEG_depsgraph.h"
20 #include "DEG_depsgraph_query.h"
21 
23 {
24  Curve *curve = (Curve *)object->data;
26 
27  Object *evaluated_object = DEG_get_evaluated_object(depsgraph, object);
28  BKE_vfont_to_curve_nubase(evaluated_object, FO_EDIT, &new_curve->nurb);
29 
30  new_curve->type = OB_CURVES_LEGACY;
31 
32  new_curve->flag &= ~CU_3D;
33  BKE_curve_dimension_update(new_curve);
34 
35  return new_curve;
36 }
37 
38 static Curve *curve_from_curve_object(Object *object, Depsgraph *depsgraph, bool apply_modifiers)
39 {
40  Object *evaluated_object = DEG_get_evaluated_object(depsgraph, object);
41  Curve *curve = (Curve *)evaluated_object->data;
43 
44  if (apply_modifiers) {
47  evaluated_object,
49  &new_curve->nurb,
51  }
52 
53  return new_curve;
54 }
55 
56 Curve *BKE_curve_new_from_object(Object *object, Depsgraph *depsgraph, bool apply_modifiers)
57 {
58  if (!ELEM(object->type, OB_FONT, OB_CURVES_LEGACY)) {
59  return NULL;
60  }
61 
62  if (object->type == OB_FONT) {
63  return curve_from_font_object(object, depsgraph);
64  }
65 
66  return curve_from_curve_object(object, depsgraph, apply_modifiers);
67 }
void BKE_curve_dimension_update(struct Curve *cu)
Definition: curve.cc:465
ListBase * BKE_curve_nurbs_get(struct Curve *cu)
Definition: curve.cc:4976
display list (or rather multi purpose list) stuff.
void BKE_curve_calc_modifiers_pre(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, struct ListBase *source_nurb, struct ListBase *target_nurb, bool for_render)
@ LIB_ID_COPY_LOCALIZE
Definition: BKE_lib_id.h:187
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, int flag)
bool BKE_vfont_to_curve_nubase(struct Object *ob, int mode, struct ListBase *r_nubase)
Definition: vfont.c:1737
#define ELEM(...)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
@ DAG_EVAL_RENDER
Definition: DEG_depsgraph.h:46
struct Scene * DEG_get_input_scene(const Depsgraph *graph)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
@ CU_3D
Object is a sort of wrapper for general info.
@ OB_FONT
@ OB_CURVES_LEGACY
#define FO_EDIT
Curve * BKE_curve_new_from_object(Object *object, Depsgraph *depsgraph, bool apply_modifiers)
Definition: curve_convert.c:56
static Curve * curve_from_font_object(Object *object, Depsgraph *depsgraph)
Definition: curve_convert.c:22
static Curve * curve_from_curve_object(Object *object, Depsgraph *depsgraph, bool apply_modifiers)
Definition: curve_convert.c:38
Curve curve
const Depsgraph * depsgraph
void * data