Fix T43624: Freestyle uses wrong colour on second Line Set with textured lines in Cycles.
This is a regression introduced by rBd8b00a3bf5c1 (Freestyle: memory consumption optimization in stroke rendering). The issue was caused by uninitialized MPoly::mat_nr values. Before the stroke rendering optimization, individual Freestyle strokes were represented by distinct mesh objects, and thus MPoly::mat_nr was left unset (i.e., was always zero). Now that the stroke rendering optimization has been done and mesh objects may represent multiple strokes of different materials, MPoly::mat_nr had to be properly set to the material index that refers to the material of the poly face.
This commit is contained in:
@@ -730,7 +730,6 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
|
|||||||
it != itend; ++it)
|
it != itend; ++it)
|
||||||
{
|
{
|
||||||
mesh->mat[material_index] = (*it)->getMaterial();
|
mesh->mat[material_index] = (*it)->getMaterial();
|
||||||
material_index++;
|
|
||||||
|
|
||||||
vector<Strip*>& strips = (*it)->getStrips();
|
vector<Strip*>& strips = (*it)->getStrips();
|
||||||
for (vector<Strip*>::const_iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
|
for (vector<Strip*>::const_iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
|
||||||
@@ -811,6 +810,7 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
|
|||||||
// poly
|
// poly
|
||||||
polys->loopstart = loop_index;
|
polys->loopstart = loop_index;
|
||||||
polys->totloop = 3;
|
polys->totloop = 3;
|
||||||
|
polys->mat_nr = material_index;
|
||||||
++polys;
|
++polys;
|
||||||
|
|
||||||
// Even and odd loops connect triangles vertices differently
|
// Even and odd loops connect triangles vertices differently
|
||||||
@@ -909,6 +909,7 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
|
|||||||
}
|
}
|
||||||
} // loop over strip vertices
|
} // loop over strip vertices
|
||||||
} // loop over strips
|
} // loop over strips
|
||||||
|
material_index++;
|
||||||
} // loop over strokes
|
} // loop over strokes
|
||||||
|
|
||||||
test_object_materials(freestyle_bmain, (ID *)mesh);
|
test_object_materials(freestyle_bmain, (ID *)mesh);
|
||||||
|
Reference in New Issue
Block a user