[Bf-blender-cvs] [c34f3c777f9] master: Fix T53559: Auto texture space for text and font is wrong in Cycles

Sergey Sharybin noreply at git.blender.org
Tue Dec 19 10:02:53 CET 2017


Commit: c34f3c777f9a783033a098734c25716d1def3f09
Author: Sergey Sharybin
Date:   Tue Dec 19 10:01:00 2017 +0100
Branches: master
https://developer.blender.org/rBc34f3c777f9a783033a098734c25716d1def3f09

Fix T53559: Auto texture space for text and font is wrong in Cycles

The issue actually goes a bit deeper, converting curve to mesh will
change texture space just because font and bezier curves are using CV
to calculate texture space.

So now when those objects are converted to mesh, we disable auto
texture space and copy evaluated space over.

===================================================================

M	source/blender/blenkernel/intern/mesh.c

===================================================================

diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 0d01fe77453..a3fa754c725 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -1396,6 +1396,17 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const bool use
 	me->totcol = cu->totcol;
 	me->mat = cu->mat;
 
+	/* Copy evaluated texture space from curve to mesh.
+	 *
+	 * Note that we disable auto texture space feature since that will cause
+	 * texture space to evaluate differently for curve and mesh, since curve
+	 * uses CV to calculate bounding box, and mesh uses what is coming from
+	 * tessellated curve.
+	 */
+	me->texflag = cu->texflag & ~CU_AUTOSPACE;
+	copy_v3_v3(me->loc, cu->loc);
+	copy_v3_v3(me->size, cu->size);
+	copy_v3_v3(me->rot, cu->rot);
 	BKE_mesh_texspace_calc(me);
 
 	cu->mat = NULL;
@@ -2420,6 +2431,11 @@ Mesh *BKE_mesh_new_from_object(
 			/* copies the data */
 			copycu = tmpobj->data = BKE_curve_copy(bmain, (Curve *) ob->data);
 
+			/* make sure texture space is calculated for a copy of curve,
+			 * it will be used for the final result.
+			 */
+			BKE_curve_texspace_calc(copycu);
+
 			/* temporarily set edit so we get updates from edit mode, but
 			 * also because for text datablocks copying it while in edit
 			 * mode gives invalid data structures */
@@ -2450,8 +2466,6 @@ Mesh *BKE_mesh_new_from_object(
 				return NULL;
 			}
 
-			BKE_mesh_texspace_copy_from_object(tmpmesh, ob);
-
 			BKE_libblock_free_us(bmain, tmpobj);
 
 			/* XXX The curve to mesh conversion is convoluted... But essentially, BKE_mesh_from_nurbs_displist()



More information about the Bf-blender-cvs mailing list