Maniphest T39839

Applying the subsurf modifier deletes the freestyle edge marks.
Closed, Resolved

Assigned To
Tamito Kajiyama (kjym3)
Authored By
Fazekas Laszlo (totoro)
Apr 22 2014, 11:16 AM
Tags
  • BF Blender
Subscribers
Bastien Montagne (mont29)
Fazekas Laszlo (totoro)
Tamito Kajiyama (kjym3)

Description

System Information
Ubuntu 14.04 x86-64 NVidia

Blender Version
Broken: 2.70a
Worked: -

Short description of error
Applying the subsurf modifier deletes the freestyle edge marks of the mesh.

Exact steps for others to reproduce the error
In edit mode, mark one edge of the default cube as freestyle edge. Add a subdivision surface modifier to the stack. If you render it with freestyle enabled, you can see the mesh still has the marked (and subdivided) edge. It is also possible to see/set/clear this property in the edit mode. So the subsurf algorithm works fine on the freestyle marked edges. But after you apply the modifier, the freestyle marks are lost.

Revisions and Commits

rB Blender
rBAC Blender Add-ons Contrib

Event Timeline

Fazekas Laszlo (totoro) created this task.Apr 22 2014, 11:16 AM
Fazekas Laszlo (totoro) raised the priority of this task from to 90.
Fazekas Laszlo (totoro) updated the task description.
Fazekas Laszlo (totoro) added a project: BF Blender.
Fazekas Laszlo (totoro) edited a custom field.
Fazekas Laszlo (totoro) added a subscriber: Fazekas Laszlo (totoro).
Fazekas Laszlo (totoro) added a comment.Apr 23 2014, 10:06 AM

So I digged into the source and found a makeshift solution to this problem. The problem is that during the creation of the new DerivedMesh, the CustomData layers are created as empty, but not copied from the original dm. A makeshift solution for just the freestyle edge mark is below (using the fact that the original splitted edges are at the end of the new table). I hope this helps, but I think this needs a more general solution.

source/blender/blenkernel/intern/subsurf_ccg.c
L3752+
...
ccgdm->dm.numVertData = vertNum;
ccgdm->dm.numEdgeData = edgeNum;
ccgdm->dm.numTessFaceData = faceNum;
ccgdm->dm.numLoopData = loopindex2;
ccgdm->dm.numPolyData = faceNum;

/* add new code from here */

#ifdef WITH_FREESTYLE

       	{
		FreestyleEdge *dstFed= DM_get_edge_data_layer(&ccgdm->dm,CD_FREESTYLE_EDGE);
		FreestyleEdge *srcFed= DM_get_edge_data_layer(dm,CD_FREESTYLE_EDGE);

		if (dstFed && srcFed) {
			int	max= edgeNum - totedge * (edgeSize - 1);
			int	i;

			for(index= 0; index < totedge; index++) {
				   i= max;
				   max += (edgeSize - 1);

				   for(; i < max; i++)
				   	dstFed[i]= srcFed[index];
			}
		}

}
#endif

/* new code end */

/* All tessellated CD layers were updated! */
ccgdm->dm.dirty &= ~DM_DIRTY_TESS_CDLAYERS;

Bastien Montagne (mont29) assigned this task to Tamito Kajiyama (kjym3).Apr 23 2014, 4:25 PM
Bastien Montagne (mont29) lowered the priority of this task from 90 to Normal.
Bastien Montagne (mont29) added a subscriber: Bastien Montagne (mont29).

Tamito, this one is for you I think. :)

Campbell Barton (campbellbarton) edited this Maniphest Task.Apr 23 2014, 9:21 PM
Campbell Barton (campbellbarton) changed the task status from Unknown Status to Resolved.Apr 23 2014, 9:21 PM

Closed by commit rB3182c54da6fd.

Campbell Barton (campbellbarton) edited this Maniphest Task.May 12 2014, 4:49 PM