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:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-12-19 17:08:29 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-12-19 17:55:56 +0300
commit7e8525663c71aa350c00b17b6150e40134c3e467 (patch)
treef6b7beeecffb558586e0b5d4bcc8dba4a4528085 /source/blender/blenkernel/intern/curve.c
parentab1af38c74a5f20115e14fdd54d7580df380a924 (diff)
Font objects: Support proper auto-space
Annoyingly, need to convert vfont to nurbs, do minmax and toss nurbs away. This is likely to be fine, since this function is not intended to be used a lot, and this is the only way to get more meaningful result. However, it's not very clear what to do with font on curve. This fixes rendering of font object with auto texture space in Cycles introduced in c34f3c7. It is probably possible to introduce new mode to vfont_to_curve which will do boundbox without extra allocations, but that's more like an optimization. Reviewers: campbellbarton, mano-wii Reviewed By: campbellbarton Subscribers: zeauro Differential Revision: https://developer.blender.org/D2971
Diffstat (limited to 'source/blender/blenkernel/intern/curve.c')
-rw-r--r--source/blender/blenkernel/intern/curve.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 5f72abbadf3..f3894fb034f 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -4933,12 +4933,27 @@ void BKE_curve_nurb_vert_active_validate(Curve *cu)
bool BKE_curve_minmax(Curve *cu, bool use_radius, float min[3], float max[3])
{
ListBase *nurb_lb = BKE_curve_nurbs_get(cu);
- Nurb *nu;
-
- for (nu = nurb_lb->first; nu; nu = nu->next)
+ ListBase temp_nurb_lb = {NULL, NULL};
+ const bool is_font = (BLI_listbase_is_empty(nurb_lb)) && (cu->len != 0);
+ /* For font curves we generate temp list of splines.
+ *
+ * This is likely to be fine, this function is not supposed to be called
+ * often, and it's the only way to get meaningful bounds for fonts.
+ */
+ if (is_font) {
+ nurb_lb = &temp_nurb_lb;
+ BKE_vfont_to_curve_ex(G.main, NULL, cu, FO_EDIT, nurb_lb,
+ NULL, NULL, NULL, NULL);
+ use_radius = false;
+ }
+ /* Do bounding box based on splines. */
+ for (Nurb *nu = nurb_lb->first; nu; nu = nu->next) {
BKE_nurb_minmax(nu, use_radius, min, max);
-
- return (BLI_listbase_is_empty(nurb_lb) == false);
+ }
+ const bool result = (BLI_listbase_is_empty(nurb_lb) == false);
+ /* Cleanup if needed. */
+ BKE_nurbList_free(&temp_nurb_lb);
+ return result;
}
bool BKE_curve_center_median(Curve *cu, float cent[3])