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>2013-06-20 17:27:48 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-06-20 17:27:48 +0400
commitf35264706a403a666e7f3077c4b807bd1aaa3765 (patch)
tree0da658570dec1e9a97c6c109076b666e448ce44c /source/blender/blenkernel/intern/cdderivedmesh.c
parent70212510438fdb1494892b8f75b59cd018b47d5b (diff)
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.
Diffstat (limited to 'source/blender/blenkernel/intern/cdderivedmesh.c')
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 64d6ca6666e..73c722a4849 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -1823,16 +1823,19 @@ DerivedMesh *CDDM_from_curve(Object *ob)
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 @@ DerivedMesh *CDDM_from_curve_displist(Object *ob, ListBase *dispbase)
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);