From a130c82f0a8df7a949d0888cb1fa798740012a48 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 19 Dec 2017 09:50:55 +0100 Subject: [PATCH 1/2] Cycles tests: Enable texture space tests --- tests/python/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index 7e42f36c6e4..781e12a6955 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -547,6 +547,7 @@ if(WITH_CYCLES) add_cycles_render_test(shader) add_cycles_render_test(shader_tangent) add_cycles_render_test(shadow_catcher) + add_cycles_render_test(texture_space) add_cycles_render_test(volume) else() MESSAGE(STATUS "Disabling Cycles tests because tests folder does not exist") From c34f3c777f9a783033a098734c25716d1def3f09 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 19 Dec 2017 10:01:00 +0100 Subject: [PATCH 2/2] 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. --- source/blender/blenkernel/intern/mesh.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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()