Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Emara <mail@OmarEmara.dev>2021-02-20 19:05:13 +0300
committerOmar Emara <mail@OmarEmara.dev>2021-02-20 19:05:13 +0300
commitf2c0bbed1ce5270eee1332a02da02c1819bb230c (patch)
tree3bc309ba191cc1a4c81d3daa6e1b57fa987ef6a1 /source/blender/blenkernel/intern/displist.c
parent5dced2a0636a7f3db73be09139cf8abd952612e7 (diff)
Python: Add to_curve method to the object API
This patch adds a to_curve method to the Object ID. This method is analogous to the to_mesh method. The method can operate on curve and text objects. For text objects, the text is converted into a 3D Curve ID and that curve is returned. For curve objects, if apply_modifiers is true, the spline deform modifiers will be applied and a Curve ID with the result will be returned, otherwise a copy of the curve will be returned. The goal of this addition is to allow the developer to access the splines of text objects and to get the result of modifier applications which was otherwise not possible. Reviewed By: Brecht Differential Revision: https://developer.blender.org/D10354
Diffstat (limited to 'source/blender/blenkernel/intern/displist.c')
-rw-r--r--source/blender/blenkernel/intern/displist.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 1fcc1b1bcef..c860e57520d 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -770,8 +770,12 @@ static ModifierData *curve_get_tessellate_point(Scene *scene,
}
/* Return true if any modifier was applied. */
-static bool curve_calc_modifiers_pre(
- Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *nurb, const bool for_render)
+bool BKE_curve_calc_modifiers_pre(Depsgraph *depsgraph,
+ Scene *scene,
+ Object *ob,
+ ListBase *source_nurb,
+ ListBase *target_nurb,
+ const bool for_render)
{
VirtualModifierData virtualModifierData;
ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData);
@@ -810,13 +814,13 @@ static bool curve_calc_modifiers_pre(
keyVerts = BKE_key_evaluate_object(ob, &numElems);
if (keyVerts) {
- BLI_assert(BKE_keyblock_curve_element_count(nurb) == numElems);
+ BLI_assert(BKE_keyblock_curve_element_count(source_nurb) == numElems);
/* split coords from key data, the latter also includes
* tilts, which is passed through in the modifier stack.
* this is also the reason curves do not use a virtual
* shape key modifier yet. */
- deformedVerts = BKE_curve_nurbs_key_vert_coords_alloc(nurb, keyVerts, &numVerts);
+ deformedVerts = BKE_curve_nurbs_key_vert_coords_alloc(source_nurb, keyVerts, &numVerts);
}
}
@@ -832,7 +836,7 @@ static bool curve_calc_modifiers_pre(
}
if (!deformedVerts) {
- deformedVerts = BKE_curve_nurbs_vert_coords_alloc(nurb, &numVerts);
+ deformedVerts = BKE_curve_nurbs_vert_coords_alloc(source_nurb, &numVerts);
}
mti->deformVerts(md, &mectx, NULL, deformedVerts, numVerts);
@@ -845,11 +849,11 @@ static bool curve_calc_modifiers_pre(
}
if (deformedVerts) {
- BKE_curve_nurbs_vert_coords_apply(nurb, deformedVerts, false);
+ BKE_curve_nurbs_vert_coords_apply(target_nurb, deformedVerts, false);
MEM_freeN(deformedVerts);
}
if (keyVerts) { /* these are not passed through modifier stack */
- BKE_curve_nurbs_key_vert_tilts_apply(nurb, keyVerts);
+ BKE_curve_nurbs_key_vert_tilts_apply(target_nurb, keyVerts);
}
if (keyVerts) {
@@ -1151,7 +1155,8 @@ void BKE_displist_make_surf(Depsgraph *depsgraph,
}
if (!for_orco) {
- force_mesh_conversion = curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, for_render);
+ force_mesh_conversion = BKE_curve_calc_modifiers_pre(
+ depsgraph, scene, ob, &nubase, &nubase, for_render);
}
LISTBASE_FOREACH (Nurb *, nu, &nubase) {
@@ -1501,7 +1506,8 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
}
if (!for_orco) {
- force_mesh_conversion = curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, for_render);
+ force_mesh_conversion = BKE_curve_calc_modifiers_pre(
+ depsgraph, scene, ob, &nubase, &nubase, for_render);
}
BKE_curve_bevelList_make(ob, &nubase, for_render);