[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57609] trunk/blender/source/blender/ blenkernel/intern: Construct orco UV layer for curve when applying constructive modifier

Sergey Sharybin sergey.vfx at gmail.com
Thu Jun 20 15:27:49 CEST 2013


Revision: 57609
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57609
Author:   nazgul
Date:     2013-06-20 13:27:48 +0000 (Thu, 20 Jun 2013)
Log Message:
-----------
Construct orco UV layer for curve when applying constructive modifier
Also construct orco uv layer when converting curve to a mesh.

This makes it possible to preserve automatically generated coordinates
("use uv for mapping" option) when using constructive modifiers or
converting curve to the mesh.

With cycles nothing special is needed to preserve texture mapping
after such operations, in blender internal you'll need to change
texture mapping from Generated to UV.

This feature is useful on it's own and also would help in potential
switch 3d viewport to always use DM to draw objects, which would
help making drawing more thread-safe.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
    trunk/blender/source/blender/blenkernel/intern/mesh.c

Modified: trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c	2013-06-20 13:24:07 UTC (rev 57608)
+++ trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c	2013-06-20 13:27:48 UTC (rev 57609)
@@ -1823,16 +1823,19 @@
 
 DerivedMesh *CDDM_from_curve_displist(Object *ob, ListBase *dispbase)
 {
+	Curve *cu = (Curve *) ob->data;
 	DerivedMesh *dm;
 	CDDerivedMesh *cddm;
 	MVert *allvert;
 	MEdge *alledge;
 	MLoop *allloop;
 	MPoly *allpoly;
+	MLoopUV *alluv = NULL;
 	int totvert, totedge, totloop, totpoly;
+	bool use_orco_uv = (cu->flag & CU_UV_ORCO) != 0;
 
 	if (BKE_mesh_nurbs_displist_to_mdata(ob, dispbase, &allvert, &totvert, &alledge,
-	                                     &totedge, &allloop, &allpoly, NULL,
+	                                     &totedge, &allloop, &allpoly, (use_orco_uv) ? &alluv : NULL,
 	                                     &totloop, &totpoly) != 0)
 	{
 		/* Error initializing mdata. This often happens when curve is empty */
@@ -1850,6 +1853,12 @@
 	memcpy(cddm->mloop, allloop, totloop * sizeof(MLoop));
 	memcpy(cddm->mpoly, allpoly, totpoly * sizeof(MPoly));
 
+	if (alluv) {
+		const char *uvname = "Orco";
+		CustomData_add_layer_named(&cddm->dm.polyData, CD_MTEXPOLY, CD_DEFAULT, NULL, totpoly, uvname);
+		CustomData_add_layer_named(&cddm->dm.loopData, CD_MLOOPUV, CD_ASSIGN, alluv, totloop, uvname);
+	}
+
 	MEM_freeN(allvert);
 	MEM_freeN(alledge);
 	MEM_freeN(allloop);

Modified: trunk/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mesh.c	2013-06-20 13:24:07 UTC (rev 57608)
+++ trunk/blender/source/blender/blenkernel/intern/mesh.c	2013-06-20 13:27:48 UTC (rev 57609)
@@ -1636,7 +1636,10 @@
 
 void BKE_mesh_from_nurbs(Object *ob)
 {
-	BKE_mesh_from_nurbs_displist(ob, &ob->disp, false);
+	Curve *cu = (Curve *) ob->data;
+	bool use_orco_uv = (cu->flag & CU_UV_ORCO) != 0;
+
+	BKE_mesh_from_nurbs_displist(ob, &ob->disp, use_orco_uv);
 }
 
 typedef struct EdgeLink {




More information about the Bf-blender-cvs mailing list