diff options
Diffstat (limited to 'source/blender/freestyle')
28 files changed, 353 insertions, 498 deletions
diff --git a/source/blender/freestyle/CMakeLists.txt b/source/blender/freestyle/CMakeLists.txt index f6b7efe978c..e08686a8f33 100644 --- a/source/blender/freestyle/CMakeLists.txt +++ b/source/blender/freestyle/CMakeLists.txt @@ -392,12 +392,12 @@ set(SRC intern/scene_graph/NodeGroup.h intern/scene_graph/NodeLight.cpp intern/scene_graph/NodeLight.h - intern/scene_graph/NodeSceneRenderLayer.cpp - intern/scene_graph/NodeSceneRenderLayer.h intern/scene_graph/NodeShape.cpp intern/scene_graph/NodeShape.h intern/scene_graph/NodeTransform.cpp intern/scene_graph/NodeTransform.h + intern/scene_graph/NodeViewLayer.cpp + intern/scene_graph/NodeViewLayer.h intern/scene_graph/OrientedLineRep.cpp intern/scene_graph/OrientedLineRep.h intern/scene_graph/Rep.cpp @@ -557,6 +557,7 @@ set(INC ../blenkernel ../blenlib ../blentranslation + ../depsgraph ../imbuf ../makesdna ../makesrna diff --git a/source/blender/freestyle/FRS_freestyle.h b/source/blender/freestyle/FRS_freestyle.h index f01400e60fd..bb7e5489a93 100644 --- a/source/blender/freestyle/FRS_freestyle.h +++ b/source/blender/freestyle/FRS_freestyle.h @@ -29,6 +29,7 @@ struct FreestyleConfig; struct FreestyleLineStyle; struct Material; struct Render; +struct RenderLayer; struct FreestyleGlobals { struct Scene *scene; @@ -45,14 +46,13 @@ extern struct FreestyleGlobals g_freestyle; /* Rendering */ void FRS_initialize(void); void FRS_set_context(struct bContext *C); -void FRS_read_file(struct bContext *C); -int FRS_is_freestyle_enabled(struct SceneRenderLayer *srl); +int FRS_is_freestyle_enabled(struct ViewLayer *view_layer); void FRS_init_stroke_renderer(struct Render *re); void FRS_begin_stroke_rendering(struct Render *re); -struct Render *FRS_do_stroke_rendering(struct Render *re, struct SceneRenderLayer *srl, int render); +struct Render *FRS_do_stroke_rendering(struct Render *re, struct ViewLayer *view_layer, int render); void FRS_end_stroke_rendering(struct Render *re); void FRS_free_view_map_cache(void); -void FRS_composite_result(struct Render *re, struct SceneRenderLayer *srl, struct Render *freestyle_render); +void FRS_composite_result(struct Render *re, struct ViewLayer *view_layer, struct Render *freestyle_render); void FRS_exit(void); /* FreestyleConfig.linesets */ diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp index e5b51c5bf83..34db3c248cd 100644 --- a/source/blender/freestyle/intern/application/Controller.cpp +++ b/source/blender/freestyle/intern/application/Controller.cpp @@ -36,7 +36,7 @@ extern "C" { #include "../scene_graph/NodeDrawingStyle.h" #include "../scene_graph/NodeShape.h" #include "../scene_graph/NodeTransform.h" -#include "../scene_graph/NodeSceneRenderLayer.h" +#include "../scene_graph/NodeViewLayer.h" #include "../scene_graph/ScenePrettyPrinter.h" #include "../scene_graph/VertexRep.h" @@ -228,9 +228,9 @@ bool Controller::hitViewMapCache() return false; } -int Controller::LoadMesh(Render *re, SceneRenderLayer *srl) +int Controller::LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) { - BlenderFileLoader loader(re, srl); + BlenderFileLoader loader(re, view_layer, depsgraph); loader.setRenderMonitor(_pRenderMonitor); @@ -297,7 +297,7 @@ int Controller::LoadMesh(Render *re, SceneRenderLayer *srl) } cam->setProjectionMatrix(proj); _RootNode->AddChild(cam); - _RootNode->AddChild(new NodeSceneRenderLayer(*re->scene, *srl)); + _RootNode->AddChild(new NodeViewLayer(*re->scene, *view_layer)); sceneHashFunc.reset(); //blenderScene->accept(sceneHashFunc); diff --git a/source/blender/freestyle/intern/application/Controller.h b/source/blender/freestyle/intern/application/Controller.h index b33b8f5d253..1cd1ff5672c 100644 --- a/source/blender/freestyle/intern/application/Controller.h +++ b/source/blender/freestyle/intern/application/Controller.h @@ -64,7 +64,7 @@ public: //soc void init_options(); - int LoadMesh(Render *re, SceneRenderLayer *srl); + int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph); int Load3DSFile(const char *iFileName); void CloseFile(); void ComputeViewMap(); diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp index ccc63eda02f..ecd068a1351 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp @@ -28,16 +28,16 @@ namespace Freestyle { -BlenderFileLoader::BlenderFileLoader(Render *re, SceneRenderLayer *srl) +BlenderFileLoader::BlenderFileLoader(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) { _re = re; - _srl = srl; + _depsgraph = depsgraph; _Scene = NULL; _numFacesRead = 0; #if 0 _minEdgeSize = DBL_MAX; #endif - _smooth = (srl->freestyleConfig.flags & FREESTYLE_FACE_SMOOTHNESS_FLAG) != 0; + _smooth = (view_layer->freestyle_config.flags & FREESTYLE_FACE_SMOOTHNESS_FLAG) != 0; _pRenderMonitor = NULL; } @@ -48,8 +48,6 @@ BlenderFileLoader::~BlenderFileLoader() NodeGroup *BlenderFileLoader::Load() { - ObjectInstanceRen *obi; - if (G.debug & G_DEBUG_FREESTYLE) { cout << "\n=== Importing triangular meshes into Blender ===" << endl; } @@ -86,34 +84,37 @@ NodeGroup *BlenderFileLoader::Load() #endif int id = 0; - unsigned cnt = 1; - unsigned cntStep = (unsigned)ceil(0.01f * _re->totinstance); - for (obi = (ObjectInstanceRen *)_re->instancetable.first; obi; obi = obi->next) { - if (_pRenderMonitor) { - if (_pRenderMonitor->testBreak()) - break; - if (cnt % cntStep == 0) { - stringstream ss; - ss << "Freestyle: Mesh loading " << (100 * cnt / _re->totinstance) << "%"; - _pRenderMonitor->setInfo(ss.str()); - _pRenderMonitor->progress((float)cnt / _re->totinstance); - } - cnt++; + + DEG_OBJECT_ITER_BEGIN( + _depsgraph, ob, + DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | + DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | + DEG_ITER_OBJECT_FLAG_VISIBLE | + DEG_ITER_OBJECT_FLAG_DUPLI) + { + if (_pRenderMonitor && _pRenderMonitor->testBreak()) { + break; } - if (!(obi->lay & _srl->lay)) + if (ob->base_flag & (BASE_HOLDOUT | BASE_INDIRECT_ONLY)) { continue; - char *name = obi->ob->id.name; - //printf("%c%c:%s\n", name[0], name[1], name+2); - //print_m4("obi->mat", obi->mat); - - if (obi->obr->totvlak > 0) { - insertShapeNode(obi, ++id); } - else if (G.debug & G_DEBUG_FREESTYLE) { - cout << "Warning: " << (name + 2) << " is not a vlak-based object (ignored)" << endl; + + bool apply_modifiers = false; + bool calc_undeformed = false; + Mesh *mesh = BKE_mesh_new_from_object(_depsgraph, + _re->main, + _re->scene, + ob, + apply_modifiers, + calc_undeformed); + + if (mesh) { + insertShapeNode(ob, mesh, ++id); + BKE_id_free_ex(_re->main, &mesh->id, LIB_ID_FREE_NO_UI_USER, true); } } + DEG_OBJECT_ITER_END; // Return the built scene. return _Scene; @@ -361,95 +362,92 @@ int BlenderFileLoader::testDegenerateTriangle(float v1[3], float v2[3], float v3 return 0; } -// Checks if edge rotation (if necessary) can prevent the given quad from -// being decomposed into a degenerate triangle -bool BlenderFileLoader::testEdgeRotation(float v1[3], float v2[3], float v3[3], float v4[3]) +static bool testEdgeMark(Mesh *me, FreestyleEdge *fed, const MLoopTri *lt, int i) { - if (testDegenerateTriangle(v1, v2, v3) == 2 || testDegenerateTriangle(v1, v3, v4) == 2) { - if (testDegenerateTriangle(v1, v2, v4) == 2 || testDegenerateTriangle(v2, v3, v4) == 2) { -#if 0 - if (G.debug & G_DEBUG_FREESTYLE) { - printf("BlenderFileLoader::testEdgeRotation: edge rotation is unsuccessful.\n"); - } -#endif - return false; - } - return true; + MLoop *mloop = &me->mloop[lt->tri[i]]; + MLoop *mloop_next = &me->mloop[lt->tri[(i+1)%3]]; + MEdge *medge = &me->medge[mloop->e]; + + if (!ELEM(mloop_next->v, medge->v1, medge->v2)) { + /* Not an edge in the original mesh before triangulation. */ + return false; } - return false; + + return (fed[mloop->e].flag & FREESTYLE_EDGE_MARK) != 0; } -void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id) +void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id) { - ObjectRen *obr = obi->obr; - char *name = obi->ob->id.name + 2; + char *name = ob->id.name + 2; + + // Compute loop triangles + int tottri = poly_to_tri_count(me->totpoly, me->totloop); + MLoopTri *mlooptri = (MLoopTri*)MEM_malloc_arrayN(tottri, sizeof(*mlooptri), __func__); + BKE_mesh_recalc_looptri( + me->mloop, me->mpoly, + me->mvert, + me->totloop, me->totpoly, + mlooptri); + + // Compute loop normals + BKE_mesh_calc_normals_split(me); + float (*lnors)[3] = NULL; + + if (CustomData_has_layer(&me->ldata, CD_NORMAL)) { + lnors = (float(*)[3])CustomData_get_layer(&me->ldata, CD_NORMAL); + } - // We parse vlak nodes and count the number of faces after the clipping by - // the near and far view planes is applied (Note: mesh vertices are in the - // camera coordinate system). - VlakRen *vlr = NULL; + // Get other mesh data + MVert *mvert = me->mvert; + MLoop *mloop = me->mloop; + MPoly *mpoly = me->mpoly; + FreestyleEdge *fed = (FreestyleEdge*)CustomData_get_layer(&me->edata, CD_FREESTYLE_EDGE); + FreestyleFace *ffa = (FreestyleFace*)CustomData_get_layer(&me->pdata, CD_FREESTYLE_FACE); + + // Compute view matrix + Object *ob_camera_eval = DEG_get_evaluated_object(_depsgraph, RE_GetCamera(_re)); + float viewinv[4][4], viewmat[4][4]; + RE_GetCameraModelMatrix(_re, ob_camera_eval, viewinv); + invert_m4_m4(viewmat, viewinv); + + // Compute matrix including camera transform + float obmat[4][4], nmat[4][4]; + mul_m4_m4m4(obmat, viewmat, ob->obmat); + invert_m4_m4(nmat, obmat); + transpose_m4(nmat); + + // We count the number of triangles after the clipping by the near and far view + // planes is applied (Note: mesh vertices are in the camera coordinate system). unsigned numFaces = 0; - float v1[3], v2[3], v3[3], v4[3]; - float n1[3], n2[3], n3[3], n4[3], facenormal[3]; - int clip_1[3], clip_2[3]; - int wire_material = 0; - for (int a = 0; a < obr->totvlak; a++) { - if ((a & 255) == 0) - vlr = obr->vlaknodes[a>>8].vlak; - else - vlr++; - if (vlr->mat->mode & MA_ONLYCAST) - continue; - if (vlr->mat->material_type == MA_TYPE_WIRE) { - wire_material = 1; - continue; - } - copy_v3_v3(v1, vlr->v1->co); - copy_v3_v3(v2, vlr->v2->co); - copy_v3_v3(v3, vlr->v3->co); - if (vlr->v4) - copy_v3_v3(v4, vlr->v4->co); - if (obi->flag & R_TRANSFORMED) { - mul_m4_v3(obi->mat, v1); - mul_m4_v3(obi->mat, v2); - mul_m4_v3(obi->mat, v3); - if (vlr->v4) - mul_m4_v3(obi->mat, v4); - } + float v1[3], v2[3], v3[3]; + float n1[3], n2[3], n3[3], facenormal[3]; + int clip[3]; + for (int a = 0; a < tottri; a++) { + const MLoopTri *lt = &mlooptri[a]; + + copy_v3_v3(v1, mvert[mloop[lt->tri[0]].v].co); + copy_v3_v3(v2, mvert[mloop[lt->tri[1]].v].co); + copy_v3_v3(v3, mvert[mloop[lt->tri[2]].v].co); + + mul_m4_v3(obmat, v1); + mul_m4_v3(obmat, v2); + mul_m4_v3(obmat, v3); + v1[2] += _z_offset; v2[2] += _z_offset; v3[2] += _z_offset; - if (vlr->v4) - v4[2] += _z_offset; -#if 0 - print_v3("v1", v1); - print_v3("v2", v2); - print_v3("v3", v3); - if (vlr->v4) - print_v3("v4", v4); -#endif - if (!vlr->v4 || !testEdgeRotation(v1, v2, v3, v4)) { - numFaces += countClippedFaces(v1, v2, v3, clip_1); - if (vlr->v4) - numFaces += countClippedFaces(v1, v3, v4, clip_2); - } - else { - numFaces += countClippedFaces(v1, v2, v4, clip_1); - numFaces += countClippedFaces(v2, v3, v4, clip_2); - } - } - if (wire_material) { - if (G.debug & G_DEBUG_FREESTYLE) { - cout << "Warning: Object " << name << " has wire materials (ignored)" << endl; - } + + numFaces += countClippedFaces(v1, v2, v3, clip); } #if 0 if (G.debug & G_DEBUG_FREESTYLE) { cout << "numFaces " << numFaces << endl; } #endif - if (numFaces == 0) + if (numFaces == 0) { + MEM_freeN(mlooptri); return; + } // We allocate memory for the meshes to be imported NodeGroup *currentMesh = new NodeGroup; @@ -492,107 +490,62 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id) // We parse the vlak nodes again and import meshes while applying the clipping // by the near and far view planes. - int p; - for (p = 0; p < obr->totvlak; ++p) { // we parse the faces of the mesh - if ((p & 255) == 0) - vlr = obr->vlaknodes[p>>8].vlak; - else - vlr++; - if ((vlr->mat->mode & MA_ONLYCAST) || vlr->mat->material_type == MA_TYPE_WIRE) - continue; - copy_v3_v3(v1, vlr->v1->co); - copy_v3_v3(v2, vlr->v2->co); - copy_v3_v3(v3, vlr->v3->co); - if (vlr->v4) - copy_v3_v3(v4, vlr->v4->co); - if (obi->flag & R_TRANSFORMED) { - mul_m4_v3(obi->mat, v1); - mul_m4_v3(obi->mat, v2); - mul_m4_v3(obi->mat, v3); - if (vlr->v4) - mul_m4_v3(obi->mat, v4); - } + for (int a = 0; a < tottri; a++) { + const MLoopTri *lt = &mlooptri[a]; + const MPoly *mp = &mpoly[lt->poly]; + Material *mat = give_current_material(ob, mp->mat_nr + 1); + + copy_v3_v3(v1, mvert[mloop[lt->tri[0]].v].co); + copy_v3_v3(v2, mvert[mloop[lt->tri[1]].v].co); + copy_v3_v3(v3, mvert[mloop[lt->tri[2]].v].co); + + mul_m4_v3(obmat, v1); + mul_m4_v3(obmat, v2); + mul_m4_v3(obmat, v3); + v1[2] += _z_offset; v2[2] += _z_offset; v3[2] += _z_offset; - if (vlr->v4) - v4[2] += _z_offset; - if (_smooth && (vlr->flag & R_SMOOTH)) { - copy_v3_v3(n1, vlr->v1->n); - copy_v3_v3(n2, vlr->v2->n); - copy_v3_v3(n3, vlr->v3->n); - if (vlr->v4) - copy_v3_v3(n4, vlr->v4->n); - if (obi->flag & R_TRANSFORMED) { - mul_m3_v3(obi->nmat, n1); - mul_m3_v3(obi->nmat, n2); - mul_m3_v3(obi->nmat, n3); - normalize_v3(n1); - normalize_v3(n2); - normalize_v3(n3); - if (vlr->v4) { - mul_m3_v3(obi->nmat, n4); - normalize_v3(n4); - } - } + + if (_smooth && (mp->flag & ME_SMOOTH) && lnors) { + copy_v3_v3(n1, lnors[lt->tri[0]]); + copy_v3_v3(n2, lnors[lt->tri[1]]); + copy_v3_v3(n3, lnors[lt->tri[2]]); + + mul_mat3_m4_v3(nmat, n1); + mul_mat3_m4_v3(nmat, n2); + mul_mat3_m4_v3(nmat, n3); + + normalize_v3(n1); + normalize_v3(n2); + normalize_v3(n3); } else { - RE_vlakren_get_normal(_re, obi, vlr, facenormal); -#ifndef NDEBUG - /* test if normals are inverted in rendering [T39669] */ - float tnor[3]; - if (vlr->v4) - normal_quad_v3(tnor, v4, v3, v2, v1); - else - normal_tri_v3(tnor, v3, v2, v1); - BLI_assert(dot_v3v3(tnor, facenormal) > 0.0f); -#endif + normal_tri_v3(facenormal, v3, v2, v1); + copy_v3_v3(n1, facenormal); copy_v3_v3(n2, facenormal); copy_v3_v3(n3, facenormal); - if (vlr->v4) - copy_v3_v3(n4, facenormal); } - unsigned int numTris_1, numTris_2; - bool edge_rotation; - if (!vlr->v4 || !testEdgeRotation(v1, v2, v3, v4)) { - numTris_1 = countClippedFaces(v1, v2, v3, clip_1); - numTris_2 = (!vlr->v4) ? 0 : countClippedFaces(v1, v3, v4, clip_2); - edge_rotation = false; - } - else { - numTris_1 = countClippedFaces(v1, v2, v4, clip_1); - numTris_2 = countClippedFaces(v2, v3, v4, clip_2); - edge_rotation = true; - if (G.debug & G_DEBUG_FREESTYLE) { - printf("BlenderFileLoader::insertShapeNode: edge rotation is performed.\n"); - } - } - if (numTris_1 == 0 && numTris_2 == 0) + unsigned int numTris = countClippedFaces(v1, v2, v3, clip); + if (numTris == 0) continue; - bool fm, em1, em2, em3, em4; - fm = (vlr->freestyle_face_mark) != 0; - em1 = (vlr->freestyle_edge_mark & R_EDGE_V1V2) != 0; - em2 = (vlr->freestyle_edge_mark & R_EDGE_V2V3) != 0; - if (!vlr->v4) { - em3 = (vlr->freestyle_edge_mark & R_EDGE_V3V1) != 0; - em4 = false; - } - else { - em3 = (vlr->freestyle_edge_mark & R_EDGE_V3V4) != 0; - em4 = (vlr->freestyle_edge_mark & R_EDGE_V4V1) != 0; + + bool fm = (ffa) ? (ffa[lt->poly].flag & FREESTYLE_FACE_MARK) != 0 : false; + bool em1 = false, em2 = false, em3 = false; + + if (fed) { + em1 = testEdgeMark(me, fed, lt, 0); + em2 = testEdgeMark(me, fed, lt, 1); + em3 = testEdgeMark(me, fed, lt, 2); } - Material *mat = vlr->mat; if (mat) { tmpMat.setLine(mat->line_col[0], mat->line_col[1], mat->line_col[2], mat->line_col[3]); - tmpMat.setDiffuse(mat->r, mat->g, mat->b, mat->alpha); - tmpMat.setSpecular(mat->specr, mat->specg, mat->specb, mat->spectra); - float s = 1.0 * (mat->har + 1) / 4 ; // in Blender: [1;511] => in OpenGL: [0;128] - if (s > 128.f) - s = 128.f; - tmpMat.setShininess(s); + tmpMat.setDiffuse(mat->r, mat->g, mat->b, 1.0f); + tmpMat.setSpecular(mat->specr, mat->specg, mat->specb, 1.0f); + tmpMat.setShininess(128.f); tmpMat.setPriority(mat->line_priority); } @@ -627,43 +580,19 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id) float triCoords[5][3], triNormals[5][3]; bool edgeMarks[5]; // edgeMarks[i] is for the edge between i-th and (i+1)-th vertices - if (numTris_1 > 0) { - if (!edge_rotation) { - clipTriangle(numTris_1, triCoords, v1, v2, v3, triNormals, n1, n2, n3, - edgeMarks, em1, em2, (!vlr->v4) ? em3 : false, clip_1); - } - else { - clipTriangle(numTris_1, triCoords, v1, v2, v4, triNormals, n1, n2, n4, - edgeMarks, em1, false, em4, clip_1); - } - for (i = 0; i < numTris_1; i++) { - addTriangle(&ls, triCoords[0], triCoords[i + 1], triCoords[i + 2], - triNormals[0], triNormals[i + 1], triNormals[i + 2], - fm, (i == 0) ? edgeMarks[0] : false, edgeMarks[i + 1], - (i == numTris_1 - 1) ? edgeMarks[i + 2] : false); - _numFacesRead++; - } - } - - if (numTris_2 > 0) { - if (!edge_rotation) { - clipTriangle(numTris_2, triCoords, v1, v3, v4, triNormals, n1, n3, n4, - edgeMarks, false, em3, em4, clip_2); - } - else { - clipTriangle(numTris_2, triCoords, v2, v3, v4, triNormals, n2, n3, n4, - edgeMarks, em2, em3, false, clip_2); - } - for (i = 0; i < numTris_2; i++) { - addTriangle(&ls, triCoords[0], triCoords[i + 1], triCoords[i + 2], - triNormals[0], triNormals[i + 1], triNormals[i + 2], - fm, (i == 0) ? edgeMarks[0] : false, edgeMarks[i + 1], - (i == numTris_2 - 1) ? edgeMarks[i + 2] : false); - _numFacesRead++; - } + clipTriangle(numTris, triCoords, v1, v2, v3, triNormals, n1, n2, n3, + edgeMarks, em1, em2, em3, clip); + for (i = 0; i < numTris; i++) { + addTriangle(&ls, triCoords[0], triCoords[i + 1], triCoords[i + 2], + triNormals[0], triNormals[i + 1], triNormals[i + 2], + fm, (i == 0) ? edgeMarks[0] : false, edgeMarks[i + 1], + (i == numTris - 1) ? edgeMarks[i + 2] : false); + _numFacesRead++; } } + MEM_freeN(mlooptri); + // We might have several times the same vertex. We want a clean // shape with no real-vertex. Here, we are making a cleaning pass. float *cleanVertices = NULL; @@ -802,8 +731,8 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id) cleanNIndices, niSize, MIndices, viSize, 0, 0, 0); // sets the id of the rep rep->setId(Id(id, 0)); - rep->setName(obi->ob->id.name + 2); - rep->setLibraryPath(obi->ob->id.lib ? obi->ob->id.lib->name : NULL); + rep->setName(ob->id.name + 2); + rep->setLibraryPath(ob->id.lib ? ob->id.lib->name : ""); const BBox<Vec3r> bbox = BBox<Vec3r>(Vec3r(ls.minBBox[0], ls.minBBox[1], ls.minBBox[2]), Vec3r(ls.maxBBox[0], ls.maxBBox[1], ls.maxBBox[2])); diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h index 96b0d9ea4f8..3500234cbc9 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h @@ -36,19 +36,30 @@ #include "../system/RenderMonitor.h" extern "C" { +#include "MEM_guardedalloc.h" + #include "DNA_material_types.h" +#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "renderdatabase.h" #include "render_types.h" +#include "BKE_customdata.h" +#include "BKE_library.h" +#include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_scene.h" +#include "BLI_iterator.h" +#include "BLI_listbase.h" #include "BLI_math.h" } +#include "DEG_depsgraph_query.h" + #ifdef WITH_CXX_GUARDEDALLOC #include "MEM_guardedalloc.h" #endif @@ -74,7 +85,7 @@ class BlenderFileLoader { public: /*! Builds a MaxFileLoader */ - BlenderFileLoader(Render *re, SceneRenderLayer *srl); + BlenderFileLoader(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph); virtual ~BlenderFileLoader(); /*! Loads the 3D scene and returns a pointer to the scene root node */ @@ -92,9 +103,8 @@ public: inline void setRenderMonitor(RenderMonitor *iRenderMonitor) {_pRenderMonitor = iRenderMonitor;} protected: - void insertShapeNode(ObjectInstanceRen *obi, int id); + void insertShapeNode(Object *ob, Mesh *mesh, int id); int testDegenerateTriangle(float v1[3], float v2[3], float v3[3]); - bool testEdgeRotation(float v1[3], float v2[3], float v3[3], float v4[3]); int countClippedFaces(float v1[3], float v2[3], float v3[3], int clip[3]); void clipLine(float v1[3], float v2[3], float c[3], float z); void clipTriangle(int numTris, float triCoords[][3], float v1[3], float v2[3], float v3[3], @@ -110,7 +120,7 @@ protected: unsigned n; }; Render *_re; - SceneRenderLayer *_srl; + Depsgraph *_depsgraph; NodeGroup *_Scene; unsigned _numFacesRead; #if 0 diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index d4bd6982587..6f02bbc15a5 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -30,6 +30,7 @@ extern "C" { #include "RNA_types.h" #include "DNA_camera_types.h" +#include "DNA_collection_types.h" #include "DNA_listBase.h" #include "DNA_linestyle_types.h" #include "DNA_material_types.h" @@ -39,9 +40,11 @@ extern "C" { #include "DNA_screen_types.h" #include "DNA_scene_types.h" +#include "BKE_collection.h" #include "BKE_customdata.h" -#include "BKE_depsgraph.h" +#include "BKE_idprop.h" #include "BKE_global.h" +#include "BKE_layer.h" #include "BKE_library.h" /* free_libblock */ #include "BKE_material.h" #include "BKE_mesh.h" @@ -55,6 +58,9 @@ extern "C" { #include "BLI_math_vector.h" #include "BLI_utildefines.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "RE_pipeline.h" #include "render_types.h" @@ -81,7 +87,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str freestyle_scene = BKE_scene_add(freestyle_bmain, name); freestyle_scene->r.cfra = old_scene->r.cfra; freestyle_scene->r.mode = old_scene->r.mode & - ~(R_EDGE_FRS | R_SHADOW | R_SSS | R_PANORAMA | R_ENVMAP | R_MBLUR | R_BORDER); + ~(R_EDGE_FRS | R_BORDER); freestyle_scene->r.xsch = re->rectx; // old_scene->r.xsch freestyle_scene->r.ysch = re->recty; // old_scene->r.ysch freestyle_scene->r.xasp = 1.0f; // old_scene->r.xasp; @@ -89,8 +95,6 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str freestyle_scene->r.tilex = old_scene->r.tilex; freestyle_scene->r.tiley = old_scene->r.tiley; freestyle_scene->r.size = 100; // old_scene->r.size - //freestyle_scene->r.maximsize = old_scene->r.maximsize; /* DEPRECATED */ - freestyle_scene->r.ocres = old_scene->r.ocres; freestyle_scene->r.color_mgt_flag = 0; // old_scene->r.color_mgt_flag; freestyle_scene->r.scemode = (old_scene->r.scemode & ~(R_SINGLE_LAYER | R_NO_FRAME_UPDATE | R_MULTIVIEW)) & (re->r.scemode | ~R_FULL_SAMPLE); @@ -105,27 +109,41 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str freestyle_scene->r.safety.ymin = old_scene->r.safety.ymin; freestyle_scene->r.safety.xmax = old_scene->r.safety.xmax; freestyle_scene->r.safety.ymax = old_scene->r.safety.ymax; - freestyle_scene->r.osa = old_scene->r.osa; - freestyle_scene->r.filtertype = old_scene->r.filtertype; - freestyle_scene->r.gauss = old_scene->r.gauss; freestyle_scene->r.dither_intensity = old_scene->r.dither_intensity; - BLI_strncpy(freestyle_scene->r.engine, old_scene->r.engine, sizeof(freestyle_scene->r.engine)); + STRNCPY(freestyle_scene->r.engine, old_scene->r.engine); + if (G.debug & G_DEBUG_FREESTYLE) { + cout << "Stroke rendering engine : " << freestyle_scene->r.engine << endl; + } freestyle_scene->r.im_format.planes = R_IMF_PLANES_RGBA; freestyle_scene->r.im_format.imtype = R_IMF_IMTYPE_PNG; + // Copy ID properties, including Cycles render properties + if (old_scene->id.properties) { + freestyle_scene->id.properties = IDP_CopyProperty_ex(old_scene->id.properties, 0); + } + + /* Render with transparent background. */ + freestyle_scene->r.alphamode = R_ALPHAPREMUL; + + if (STREQ(freestyle_scene->r.engine, RE_engine_id_CYCLES)) { + PointerRNA freestyle_scene_ptr; + RNA_id_pointer_create(&freestyle_scene->id, &freestyle_scene_ptr); + PointerRNA freestyle_cycles_ptr = RNA_pointer_get(&freestyle_scene_ptr, "cycles"); + RNA_boolean_set(&freestyle_cycles_ptr, "film_transparent", 1); + } + if (G.debug & G_DEBUG_FREESTYLE) { printf("%s: %d thread(s)\n", __func__, BKE_render_num_threads(&freestyle_scene->r)); } - // Render layer - SceneRenderLayer *srl = (SceneRenderLayer *)freestyle_scene->r.layers.first; - srl->layflag = SCE_LAY_SOLID | SCE_LAY_ZTRA; - BKE_scene_set_background(freestyle_bmain, freestyle_scene); + // Scene layer. + ViewLayer *view_layer = (ViewLayer *)freestyle_scene->view_layers.first; + view_layer->layflag = SCE_LAY_SOLID | SCE_LAY_ZTRA; + // Camera - Object *object_camera = BKE_object_add(freestyle_bmain, freestyle_scene, OB_CAMERA, NULL); - DAG_relations_tag_update(freestyle_bmain); + Object *object_camera = BKE_object_add(freestyle_bmain, freestyle_scene, view_layer, OB_CAMERA, NULL); Camera *camera = (Camera *)object_camera->data; camera->type = CAM_ORTHO; @@ -145,14 +163,14 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str // Reset serial mesh ID (used for BlenderStrokeRenderer::NewMesh()) _mesh_id = 0xffffffff; - // Check if the rendering engine uses new shading nodes - _use_shading_nodes = BKE_scene_use_new_shading_nodes(freestyle_scene); - // Create a bNodeTree-to-Material hash table - if (_use_shading_nodes) - _nodetree_hash = BLI_ghash_ptr_new("BlenderStrokeRenderer::_nodetree_hash"); - else - _nodetree_hash = NULL; + _nodetree_hash = BLI_ghash_ptr_new("BlenderStrokeRenderer::_nodetree_hash"); + + // Depsgraph + freestyle_depsgraph = DEG_graph_new(freestyle_scene, view_layer, DAG_EVAL_RENDER); + DEG_graph_id_tag_update(freestyle_bmain, freestyle_depsgraph, &freestyle_scene->id, 0); + DEG_graph_id_tag_update(freestyle_bmain, freestyle_depsgraph, &object_camera->id, 0); + DEG_graph_tag_relations_update(freestyle_depsgraph); } BlenderStrokeRenderer::~BlenderStrokeRenderer() @@ -163,9 +181,11 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer() // compositor has finished. // release objects and data blocks - for (Base *b = (Base *)freestyle_scene->base.first; b; b = b->next) { + Base *base_next = NULL; + ViewLayer *view_layer = (ViewLayer *)freestyle_scene->view_layers.first; + for (Base *b = (Base *)view_layer->object_bases.first; b; b = base_next) { + base_next = b->next; Object *ob = b->object; - void *data = ob->data; char *name = ob->id.name; #if 0 if (G.debug & G_DEBUG_FREESTYLE) { @@ -173,20 +193,19 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer() } #endif switch (ob->type) { - case OB_MESH: - BKE_libblock_free(freestyle_bmain, ob); - BKE_libblock_free(freestyle_bmain, data); - break; case OB_CAMERA: - BKE_libblock_free(freestyle_bmain, ob); - BKE_libblock_free(freestyle_bmain, data); freestyle_scene->camera = NULL; + ATTR_FALLTHROUGH; + case OB_MESH: + BKE_scene_collections_object_remove(freestyle_bmain, + freestyle_scene, + ob, + true); break; default: cerr << "Warning: unexpected object in the scene: " << name[0] << name[1] << ":" << (name + 2) << endl; } } - BLI_freelistN(&freestyle_scene->base); // release materials Link *lnk = (Link *)freestyle_bmain->mat.first; @@ -194,21 +213,13 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer() while (lnk) { Material *ma = (Material*)lnk; - // We want to retain the linestyle mtexs, so let's detach them first - for (int a = 0; a < MAX_MTEX; a++) { - if (ma->mtex[a]) { - ma->mtex[a] = NULL; - } - else { - break; // Textures are ordered, no empty slots between two textures - } - } lnk = lnk->next; - BKE_libblock_free(freestyle_bmain, ma); + BKE_id_free(freestyle_bmain, ma); } - if (_use_shading_nodes) - BLI_ghash_free(_nodetree_hash, NULL, NULL); + BLI_ghash_free(_nodetree_hash, NULL, NULL); + + DEG_graph_free(freestyle_depsgraph); FreeStrokeGroups(); } @@ -450,89 +461,13 @@ void BlenderStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const { - if (_use_shading_nodes) { - bNodeTree *nt = iStrokeRep->getNodeTree(); - Material *ma = (Material *)BLI_ghash_lookup(_nodetree_hash, nt); - if (!ma) { - ma = BlenderStrokeRenderer::GetStrokeShader(freestyle_bmain, nt, false); - BLI_ghash_insert(_nodetree_hash, nt, ma); - } - - if (STREQ(freestyle_scene->r.engine, RE_engine_id_CYCLES)) { - PointerRNA scene_ptr, freestyle_scene_ptr; - RNA_pointer_create(NULL, &RNA_Scene, old_scene, &scene_ptr); - RNA_pointer_create(NULL, &RNA_Scene, freestyle_scene, &freestyle_scene_ptr); - - PointerRNA cycles_ptr = RNA_pointer_get(&scene_ptr, "cycles"); - PointerRNA freestyle_cycles_ptr = RNA_pointer_get(&freestyle_scene_ptr, "cycles"); - - int flag; - RNA_STRUCT_BEGIN(&freestyle_cycles_ptr, prop) - { - flag = RNA_property_flag(prop); - if (flag & PROP_HIDDEN) - continue; - RNA_property_copy(&freestyle_cycles_ptr, &cycles_ptr, prop, -1); - } - RNA_STRUCT_END; - - RNA_boolean_set(&freestyle_cycles_ptr, "film_transparent", 1); - } - - iStrokeRep->setMaterial(ma); - } - else { - bool has_mat = false; - int a = 0; - - // Look for a good existing material - for (Link *lnk = (Link *)freestyle_bmain->mat.first; lnk; lnk = lnk->next) { - Material *ma = (Material*)lnk; - bool texs_are_good = true; - // as soon as textures differ it's not the right one - for (int a = 0; a < MAX_MTEX; a++) { - if (ma->mtex[a] != iStrokeRep->getMTex(a)) { - texs_are_good = false; - break; - } - } - - if (texs_are_good) { - iStrokeRep->setMaterial(ma); - has_mat = true; - break; // if textures are good, no need to search anymore - } - } - - // If still no material, create one - if (!has_mat) { - Material *ma = BKE_material_add(freestyle_bmain, "stroke_material"); - DAG_relations_tag_update(freestyle_bmain); - ma->mode |= MA_VERTEXCOLP; - ma->mode |= MA_TRANSP; - ma->mode |= MA_SHLESS; - ma->vcol_alpha = 1; - - id_us_min(&ma->id); - - // Textures - while (iStrokeRep->getMTex(a)) { - ma->mtex[a] = (MTex *)iStrokeRep->getMTex(a); - - // We'll generate both with tips and without tips - // coordinates, on two different UV layers. - if (ma->mtex[a]->texflag & MTEX_TIPS) { - BLI_strncpy(ma->mtex[a]->uvname, uvNames[1], sizeof(ma->mtex[a]->uvname)); - } - else { - BLI_strncpy(ma->mtex[a]->uvname, uvNames[0], sizeof(ma->mtex[a]->uvname)); - } - a++; - } - - iStrokeRep->setMaterial(ma); - } + bNodeTree *nt = iStrokeRep->getNodeTree(); + Material *ma = (Material *)BLI_ghash_lookup(_nodetree_hash, nt); + if (!ma) { + ma = BlenderStrokeRenderer::GetStrokeShader(freestyle_bmain, nt, false); + BLI_ghash_insert(_nodetree_hash, nt, ma); } + iStrokeRep->setMaterial(ma); const vector<Strip*>& strips = iStrokeRep->getStrips(); const bool hasTex = iStrokeRep->hasTex(); @@ -671,8 +606,8 @@ int BlenderStrokeRenderer::get_stroke_count() const void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex) { #if 0 - Object *object_mesh = BKE_object_add(freestyle_bmain, freestyle_scene, OB_MESH); - DAG_relations_tag_update(freestyle_bmain); + Object *object_mesh = BKE_object_add(freestyle_bmain, freestyle_scene, (ViewLayer *)freestyle_scene->view_layers.first, OB_MESH); + DEG_relations_tag_update(freestyle_bmain); #else Object *object_mesh = NewMesh(); #endif @@ -697,17 +632,13 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex) if (hasTex) { // First UV layer - CustomData_add_layer_named(&mesh->pdata, CD_MTEXPOLY, CD_CALLOC, NULL, mesh->totpoly, uvNames[0]); CustomData_add_layer_named(&mesh->ldata, CD_MLOOPUV, CD_CALLOC, NULL, mesh->totloop, uvNames[0]); - CustomData_set_layer_active(&mesh->pdata, CD_MTEXPOLY, 0); CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 0); BKE_mesh_update_customdata_pointers(mesh, true); loopsuv[0] = mesh->mloopuv; // Second UV layer - CustomData_add_layer_named(&mesh->pdata, CD_MTEXPOLY, CD_CALLOC, NULL, mesh->totpoly, uvNames[1]); CustomData_add_layer_named(&mesh->ldata, CD_MLOOPUV, CD_CALLOC, NULL, mesh->totloop, uvNames[1]); - CustomData_set_layer_active(&mesh->pdata, CD_MTEXPOLY, 1); CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 1); BKE_mesh_update_customdata_pointers(mesh, true); loopsuv[1] = mesh->mloopuv; @@ -919,7 +850,6 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex) Object *BlenderStrokeRenderer::NewMesh() const { Object *ob; - Base *base; char name[MAX_ID_NAME]; unsigned int mesh_id = get_stroke_mesh_id(); @@ -927,18 +857,15 @@ Object *BlenderStrokeRenderer::NewMesh() const ob = BKE_object_add_only_object(freestyle_bmain, OB_MESH, name); BLI_snprintf(name, MAX_ID_NAME, "0%08xME", mesh_id); ob->data = BKE_mesh_add(freestyle_bmain, name); - ob->lay = 1; - base = BKE_scene_base_add(freestyle_scene, ob); - DAG_relations_tag_update(freestyle_bmain); -#if 0 - BKE_scene_base_deselect_all(scene); - BKE_scene_base_select(scene, base); -#else - (void)base; -#endif + Collection *collection_master = BKE_collection_master(freestyle_scene); + BKE_collection_object_add(freestyle_bmain, collection_master, ob); + DEG_graph_tag_relations_update(freestyle_depsgraph); - DAG_id_tag_update_ex(freestyle_bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + DEG_graph_id_tag_update(freestyle_bmain, + freestyle_depsgraph, + &ob->id, + ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); return ob; } @@ -955,6 +882,8 @@ Render *BlenderStrokeRenderer::RenderScene(Render * /*re*/, bool render) #endif Render *freestyle_render = RE_NewSceneRender(freestyle_scene); + ViewLayer *view_layer = (ViewLayer *)freestyle_scene->view_layers.first; + DEG_graph_relations_update(freestyle_depsgraph, freestyle_bmain, freestyle_scene, view_layer); RE_RenderFreestyleStrokes(freestyle_render, freestyle_bmain, freestyle_scene, render && get_stroke_count() > 0); diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h index eff0e2f255c..80a408aecf6 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h @@ -25,6 +25,7 @@ #include "../system/FreestyleConfig.h" extern "C" { +struct Depsgraph; struct GHash; struct Main; struct Material; @@ -72,6 +73,7 @@ protected: Main *freestyle_bmain; Scene *old_scene; Scene *freestyle_scene; + Depsgraph *freestyle_depsgraph; bContext *_context; float _width, _height; float _z, _z_delta; diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 7ffe2c75823..f750645893a 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -37,29 +37,31 @@ extern "C" { #include "MEM_guardedalloc.h" #include "DNA_camera_types.h" +#include "DNA_collection_types.h" #include "DNA_freestyle_types.h" -#include "DNA_group_types.h" #include "DNA_material_types.h" #include "DNA_text_types.h" +#include "BKE_context.h" #include "BKE_freestyle.h" #include "BKE_global.h" #include "BKE_library.h" #include "BKE_linestyle.h" -#include "BKE_main.h" +#include "BKE_scene.h" #include "BKE_text.h" -#include "BKE_context.h" #include "BLT_translation.h" #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_math_color_blend.h" #include "BLI_callbacks.h" #include "BPY_extern.h" +#include "DEG_depsgraph_query.h" + #include "renderpipeline.h" -#include "pixelblending.h" #include "FRS_freestyle.h" @@ -279,19 +281,19 @@ static bool test_edge_type_conditions(struct edge_type_condition *conditions, return true; } -static void prepare(Render *re, SceneRenderLayer *srl) +static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) { // load mesh re->i.infostr = IFACE_("Freestyle: Mesh loading"); re->stats_draw(re->sdh, &re->i); re->i.infostr = NULL; - if (controller->LoadMesh(re, srl)) // returns if scene cannot be loaded or if empty + if (controller->LoadMesh(re, view_layer, depsgraph)) // returns if scene cannot be loaded or if empty return; if (re->test_break(re->tbh)) return; // add style modules - FreestyleConfig *config = &srl->freestyleConfig; + FreestyleConfig *config = &view_layer->freestyle_config; if (G.debug & G_DEBUG_FREESTYLE) { cout << "\n=== Rendering options ===" << endl; @@ -353,9 +355,9 @@ static void prepare(Render *re, SceneRenderLayer *srl) if (lineset->flags & FREESTYLE_LINESET_ENABLED) { if (G.debug & G_DEBUG_FREESTYLE) { cout << " " << layer_count+1 << ": " << lineset->name << " - " << - (lineset->linestyle ? (lineset->linestyle->id.name + 2) : "<NULL>") << endl; + (lineset->linestyle ? (lineset->linestyle->id.name + 2) : "<NULL>") << endl; } - char *buffer = create_lineset_handler(srl->name, lineset->name); + char *buffer = create_lineset_handler(view_layer->name, lineset->name); controller->InsertStyleModule(layer_count, lineset->name, buffer); controller->toggleLayer(layer_count, true); MEM_freeN(buffer); @@ -441,10 +443,10 @@ static void prepare(Render *re, SceneRenderLayer *srl) } // set diffuse and z depth passes - RenderLayer *rl = RE_GetRenderLayer(re->result, srl->name); + RenderLayer *rl = RE_GetRenderLayer(re->result, view_layer->name); bool diffuse = false, z = false; for (RenderPass *rpass = (RenderPass *)rl->passes.first; rpass; rpass = rpass->next) { - if (STREQ(rpass->name, RE_PASSNAME_DIFFUSE)) { + if (STREQ(rpass->name, RE_PASSNAME_DIFFUSE_COLOR)) { controller->setPassDiffuse(rpass->rect, rpass->rectx, rpass->recty); diffuse = true; } @@ -469,7 +471,7 @@ static void prepare(Render *re, SceneRenderLayer *srl) controller->ComputeViewMap(); } -void FRS_composite_result(Render *re, SceneRenderLayer *srl, Render *freestyle_render) +void FRS_composite_result(Render *re, ViewLayer *view_layer, Render *freestyle_render) { RenderLayer *rl; float *src, *dest, *pixSrc, *pixDest; @@ -499,7 +501,7 @@ void FRS_composite_result(Render *re, SceneRenderLayer *srl, Render *freestyle_r } #endif - rl = RE_GetRenderLayer(re->result, srl->name); + rl = RE_GetRenderLayer(re->result, view_layer->name); if (!rl) { if (G.debug & G_DEBUG_FREESTYLE) { cout << "No destination render layer to composite to" << endl; @@ -526,19 +528,19 @@ void FRS_composite_result(Render *re, SceneRenderLayer *srl, Render *freestyle_r pixSrc = src + 4 * (rectx * y + x); if (pixSrc[3] > 0.0) { pixDest = dest + 4 * (rectx * y + x); - addAlphaOverFloat(pixDest, pixSrc); + blend_color_mix_float(pixDest, pixDest, pixSrc); } } } } -static int displayed_layer_count(SceneRenderLayer *srl) +static int displayed_layer_count(ViewLayer *view_layer) { int count = 0; - switch (srl->freestyleConfig.mode) { + switch (view_layer->freestyle_config.mode) { case FREESTYLE_CONTROL_SCRIPT_MODE: - for (FreestyleModuleConfig *module = (FreestyleModuleConfig *)srl->freestyleConfig.modules.first; + for (FreestyleModuleConfig *module = (FreestyleModuleConfig *)view_layer->freestyle_config.modules.first; module; module = module->next) { @@ -547,7 +549,7 @@ static int displayed_layer_count(SceneRenderLayer *srl) } break; case FREESTYLE_CONTROL_EDITOR_MODE: - for (FreestyleLineSet *lineset = (FreestyleLineSet *)srl->freestyleConfig.linesets.first; + for (FreestyleLineSet *lineset = (FreestyleLineSet *)view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) { @@ -559,9 +561,11 @@ static int displayed_layer_count(SceneRenderLayer *srl) return count; } -int FRS_is_freestyle_enabled(SceneRenderLayer *srl) +int FRS_is_freestyle_enabled(ViewLayer *view_layer) { - return (!(srl->layflag & SCE_LAY_DISABLE) && srl->layflag & SCE_LAY_FRS && displayed_layer_count(srl) > 0); + return ((view_layer->flag & VIEW_LAYER_RENDER) && + (view_layer->flag & VIEW_LAYER_FREESTYLE) && + displayed_layer_count(view_layer) > 0); } void FRS_init_stroke_renderer(Render *re) @@ -583,7 +587,7 @@ void FRS_begin_stroke_rendering(Render *re) init_camera(re); } -Render *FRS_do_stroke_rendering(Render *re, SceneRenderLayer *srl, int render) +Render *FRS_do_stroke_rendering(Render *re, ViewLayer *view_layer, int render) { Render *freestyle_render = NULL; @@ -592,21 +596,26 @@ Render *FRS_do_stroke_rendering(Render *re, SceneRenderLayer *srl, int render) RenderMonitor monitor(re); controller->setRenderMonitor(&monitor); - controller->setViewMapCache((srl->freestyleConfig.flags & FREESTYLE_VIEW_MAP_CACHE) ? true : false); + controller->setViewMapCache((view_layer->freestyle_config.flags & FREESTYLE_VIEW_MAP_CACHE) ? true : false); if (G.debug & G_DEBUG_FREESTYLE) { cout << endl; cout << "----------------------------------------------------------" << endl; - cout << "| " << (re->scene->id.name + 2) << "|" << srl->name << endl; + cout << "| " << (re->scene->id.name + 2) << "|" << view_layer->name << endl; cout << "----------------------------------------------------------" << endl; } + /* Create depsgraph and evaluate scene. */ + ViewLayer *scene_view_layer = (ViewLayer*)BLI_findstring(&re->scene->view_layers, view_layer->name, offsetof(ViewLayer, name)); + Depsgraph *depsgraph = DEG_graph_new(re->scene, scene_view_layer, DAG_EVAL_RENDER); + BKE_scene_graph_update_tagged(depsgraph, re->main); + // prepare Freestyle: // - load mesh // - add style modules // - set parameters // - compute view map - prepare(re, srl); + prepare(re, view_layer, depsgraph); if (re->test_break(re->tbh)) { controller->CloseFile(); @@ -621,7 +630,7 @@ Render *FRS_do_stroke_rendering(Render *re, SceneRenderLayer *srl, int render) re->i.infostr = IFACE_("Freestyle: Stroke rendering"); re->stats_draw(re->sdh, &re->i); re->i.infostr = NULL; - g_freestyle.scene = re->scene; + g_freestyle.scene = DEG_get_evaluated_scene(depsgraph); int strokeCount = controller->DrawStrokes(); if (strokeCount > 0) { freestyle_render = controller->RenderStrokes(re, true); @@ -631,13 +640,15 @@ Render *FRS_do_stroke_rendering(Render *re, SceneRenderLayer *srl, int render) // composite result if (freestyle_render) { - FRS_composite_result(re, srl, freestyle_render); + FRS_composite_result(re, view_layer, freestyle_render); RE_FreeRenderResult(freestyle_render->result); freestyle_render->result = NULL; } } } + DEG_graph_free(depsgraph); + return freestyle_render; } diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp index ecf3b3b21b9..611766787f9 100644 --- a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp +++ b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp @@ -25,9 +25,9 @@ #if defined(__GNUC__) && (__GNUC__ >= 3) // hash_map is not part of the C++ standard anymore; // hash_map.h has been kept though for backward compatibility -# include <hash_map.h> +# include <hash_map.h> #else -# include <hash_map> +# include <hash_map> #endif #endif diff --git a/source/blender/freestyle/intern/python/BPy_MediumType.cpp b/source/blender/freestyle/intern/python/BPy_MediumType.cpp index cca287a8349..21e30ea4e19 100644 --- a/source/blender/freestyle/intern/python/BPy_MediumType.cpp +++ b/source/blender/freestyle/intern/python/BPy_MediumType.cpp @@ -37,7 +37,7 @@ PyDoc_STRVAR(MediumType_doc, "media-medium:\n" "\n" "* Stroke.DRY_MEDIUM: To simulate a dry medium such as Pencil or Charcoal.\n" -"* Stroke.HUMID_MEDIUM: To simulate ink painting (color substraction blending).\n" +"* Stroke.HUMID_MEDIUM: To simulate ink painting (color subtraction blending).\n" "* Stroke.OPAQUE_MEDIUM: To simulate an opaque medium (oil, spray...)."); PyTypeObject MediumType_Type = { diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp index e449e6dcd01..3ce5e66f028 100644 --- a/source/blender/freestyle/intern/python/BPy_SShape.cpp +++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp @@ -181,7 +181,7 @@ PyDoc_STRVAR(SShape_name_doc, static PyObject *SShape_name_get(BPy_SShape *self, void *UNUSED(closure)) { - return PyUnicode_FromString(self->ss->getName()); + return PyUnicode_FromString(self->ss->getName().c_str()); } static int SShape_name_set(BPy_SShape *self, PyObject *value, void *UNUSED(closure)) diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp index 372f26200e1..bf7e385b91e 100644 --- a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp +++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp @@ -289,7 +289,7 @@ PyDoc_STRVAR(ViewShape_name_doc, static PyObject *ViewShape_name_get(BPy_ViewShape *self, void *UNUSED(closure)) { - return PyUnicode_FromString(self->vs->getName()); + return PyUnicode_FromString(self->vs->getName().c_str()); } PyDoc_STRVAR(ViewShape_library_path_doc, @@ -299,10 +299,7 @@ PyDoc_STRVAR(ViewShape_library_path_doc, static PyObject *ViewShape_library_path_get(BPy_ViewShape *self, void *UNUSED(closure)) { - const char *name = self->vs->getLibraryPath(); - if (!name) - Py_RETURN_NONE; - return PyUnicode_FromString(name); + return PyUnicode_FromString(self->vs->getLibraryPath().c_str()); } PyDoc_STRVAR(ViewShape_id_doc, diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp index 0e3b98c75b6..4c59c1cb66f 100644 --- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp +++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp @@ -47,7 +47,6 @@ IndexedFaceSet::IndexedFaceSet() : Rep() _MISize = 0; _TIndices = NULL; _TISize = 0; - _displayList = 0; } IndexedFaceSet::IndexedFaceSet(float *iVertices, unsigned iVSize, float *iNormals, unsigned iNSize, @@ -146,8 +145,6 @@ IndexedFaceSet::IndexedFaceSet(float *iVertices, unsigned iVSize, float *iNormal _TISize = iTISize; _TIndices = iTIndices; } - - _displayList = 0; } IndexedFaceSet::IndexedFaceSet(const IndexedFaceSet& iBrother) : Rep(iBrother) @@ -211,8 +208,6 @@ IndexedFaceSet::IndexedFaceSet(const IndexedFaceSet& iBrother) : Rep(iBrother) _TIndices = new unsigned[_TISize]; memcpy(_TIndices, iBrother.tindices(), _TISize * sizeof(unsigned)); } - - _displayList = 0; } IndexedFaceSet::~IndexedFaceSet() @@ -272,10 +267,6 @@ IndexedFaceSet::~IndexedFaceSet() delete[] _TIndices; _TIndices = NULL; } - - // should find a way to deallocates the displayList - // glDeleteLists(GLuint list, GLSizei range) - _displayList = 0; } void IndexedFaceSet::accept(SceneVisitor& v) diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h index 9b28e680a8e..2482de2a6c7 100644 --- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h +++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h @@ -146,8 +146,6 @@ public: std::swap(_MISize, ioOther._MISize); std::swap(_TISize, ioOther._TISize); - std::swap(_displayList, ioOther._displayList); - Rep::swap(ioOther); } @@ -169,12 +167,6 @@ public: /*! Compute the Bounding Box */ virtual void ComputeBBox(); - /*! modifiers */ - inline void setDisplayList(unsigned int index) - { - _displayList = index; - } - /*! Accessors */ virtual const float *vertices() const { @@ -276,11 +268,6 @@ public: return _TISize; } - inline unsigned int displayList() const - { - return _displayList; - } - protected: float *_Vertices; float *_Normals; @@ -307,8 +294,6 @@ protected: unsigned _MISize; unsigned _TISize; - unsigned int _displayList; - #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:IndexedFaceSet") #endif diff --git a/source/blender/freestyle/intern/scene_graph/NodeSceneRenderLayer.cpp b/source/blender/freestyle/intern/scene_graph/NodeViewLayer.cpp index d4b8d6f7a21..99f1ce556e2 100644 --- a/source/blender/freestyle/intern/scene_graph/NodeSceneRenderLayer.cpp +++ b/source/blender/freestyle/intern/scene_graph/NodeViewLayer.cpp @@ -14,18 +14,18 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/** \file blender/freestyle/intern/scene_graph/NodeSceneRenderLayer.cpp +/** \file blender/freestyle/intern/scene_graph/NodeViewLayer.cpp * \ingroup freestyle * \brief Class to represent a scene render layer in Blender. */ -#include "NodeSceneRenderLayer.h" +#include "NodeViewLayer.h" namespace Freestyle { -void NodeSceneRenderLayer::accept(SceneVisitor& v) +void NodeViewLayer::accept(SceneVisitor& v) { - v.visitNodeSceneRenderLayer(*this); + v.visitNodeViewLayer(*this); } } /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/scene_graph/NodeSceneRenderLayer.h b/source/blender/freestyle/intern/scene_graph/NodeViewLayer.h index 62b822b725a..5d2cd3a5ba8 100644 --- a/source/blender/freestyle/intern/scene_graph/NodeSceneRenderLayer.h +++ b/source/blender/freestyle/intern/scene_graph/NodeViewLayer.h @@ -14,38 +14,38 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __FREESTYLE_NODE_SCENE_RENDER_LAYER_H__ -#define __FREESTYLE_NODE_SCENE_RENDER_LAYER_H__ +#ifndef __FREESTYLE_NODE_VIEW_LAYER_H__ +#define __FREESTYLE_NODE_VIEW_LAYER_H__ -/** \file blender/freestyle/intern/scene_graph/NodeSceneRenderLayer.h +/** \file blender/freestyle/intern/scene_graph/NodeViewLayer.h * \ingroup freestyle - * \brief Class to represent a scene render layer in Blender. + * \brief Class to represent a view layer in Blender. */ #include "Node.h" extern "C" { -#include "DNA_scene_types.h" /* for Scene and SceneRenderLayer */ +#include "DNA_scene_types.h" /* for Scene and ViewLayer */ } using namespace std; namespace Freestyle { -class NodeSceneRenderLayer : public Node +class NodeViewLayer : public Node { public: - inline NodeSceneRenderLayer(Scene& scene, SceneRenderLayer& srl) : Node(), _Scene(scene), _SceneRenderLayer(srl) {} - virtual ~NodeSceneRenderLayer() {} + inline NodeViewLayer(Scene& scene, ViewLayer& view_layer) : Node(), _Scene(scene), _ViewLayer(view_layer) {} + virtual ~NodeViewLayer() {} inline struct Scene& scene() const { return _Scene; } - inline struct SceneRenderLayer& sceneRenderLayer() const + inline struct ViewLayer& sceneLayer() const { - return _SceneRenderLayer; + return _ViewLayer; } /*! Accept the corresponding visitor */ @@ -54,9 +54,9 @@ public: protected: Scene& _Scene; - SceneRenderLayer& _SceneRenderLayer; + ViewLayer& _ViewLayer; }; } /* namespace Freestyle */ -#endif // __FREESTYLE_NODE_SCENE_RENDER_LAYER_H__ +#endif // __FREESTYLE_NODE_VIEW_LAYER_H__ diff --git a/source/blender/freestyle/intern/scene_graph/Rep.h b/source/blender/freestyle/intern/scene_graph/Rep.h index f15bd09c933..f68426c13b8 100644 --- a/source/blender/freestyle/intern/scene_graph/Rep.h +++ b/source/blender/freestyle/intern/scene_graph/Rep.h @@ -24,6 +24,8 @@ * \date 25/01/2002 */ +#include <string> + #include "FrsMaterial.h" #include "SceneVisitor.h" @@ -34,6 +36,8 @@ #include "../system/Id.h" #include "../system/Precision.h" +using namespace std; + namespace Freestyle { using namespace Geometry; @@ -44,8 +48,6 @@ public: inline Rep() : BaseObject() { _Id = 0; - _Name = 0; - _LibraryPath = 0; _FrsMaterial = 0; } @@ -128,12 +130,12 @@ public: return _Id; } - inline const char *getName() const + inline const string& getName() const { return _Name; } - inline const char *getLibraryPath() const + inline const string& getLibraryPath() const { return _LibraryPath; } @@ -154,12 +156,12 @@ public: _Id = id; } - inline void setName(const char *name) + inline void setName(const string& name) { _Name = name; } - inline void setLibraryPath(const char *path) + inline void setLibraryPath(const string& path) { _LibraryPath = path; } @@ -172,8 +174,8 @@ public: private: BBox<Vec3f> _BBox; Id _Id; - const char *_Name; - const char *_LibraryPath; + string _Name; + string _LibraryPath; FrsMaterial *_FrsMaterial; }; diff --git a/source/blender/freestyle/intern/scene_graph/SceneHash.cpp b/source/blender/freestyle/intern/scene_graph/SceneHash.cpp index 7679d3e9528..e95dadf361e 100644 --- a/source/blender/freestyle/intern/scene_graph/SceneHash.cpp +++ b/source/blender/freestyle/intern/scene_graph/SceneHash.cpp @@ -31,14 +31,14 @@ string SceneHash::toString() return ss.str(); } -void SceneHash::visitNodeSceneRenderLayer(NodeSceneRenderLayer& node) +void SceneHash::visitNodeViewLayer(NodeViewLayer& node) { struct RenderData *r = &node.scene().r; adler32((unsigned char *)&r->xsch, sizeof(r->xsch)); // resolution_x adler32((unsigned char *)&r->ysch, sizeof(r->ysch)); // resolution_y adler32((unsigned char *)&r->size, sizeof(r->size)); // resolution_percentage - struct FreestyleConfig *config = &node.sceneRenderLayer().freestyleConfig; + struct FreestyleConfig *config = &node.sceneLayer().freestyle_config; adler32((unsigned char *)&config->flags, sizeof(config->flags)); adler32((unsigned char *)&config->crease_angle, sizeof(config->crease_angle)); adler32((unsigned char *)&config->sphere_radius, sizeof(config->sphere_radius)); diff --git a/source/blender/freestyle/intern/scene_graph/SceneHash.h b/source/blender/freestyle/intern/scene_graph/SceneHash.h index 429563df67b..6e086135c6d 100644 --- a/source/blender/freestyle/intern/scene_graph/SceneHash.h +++ b/source/blender/freestyle/intern/scene_graph/SceneHash.h @@ -22,7 +22,7 @@ */ #include "IndexedFaceSet.h" -#include "NodeSceneRenderLayer.h" +#include "NodeViewLayer.h" #include "NodeCamera.h" #include "SceneVisitor.h" @@ -45,7 +45,7 @@ public: virtual ~SceneHash() {} VISIT_DECL(NodeCamera) - VISIT_DECL(NodeSceneRenderLayer) + VISIT_DECL(NodeViewLayer) VISIT_DECL(IndexedFaceSet) string toString(); diff --git a/source/blender/freestyle/intern/scene_graph/SceneVisitor.h b/source/blender/freestyle/intern/scene_graph/SceneVisitor.h index 5a4cf94e645..0d2a4a893c8 100644 --- a/source/blender/freestyle/intern/scene_graph/SceneVisitor.h +++ b/source/blender/freestyle/intern/scene_graph/SceneVisitor.h @@ -52,7 +52,7 @@ class NodeLight; class NodeCamera; class NodeDrawingStyle; class NodeTransform; -class NodeSceneRenderLayer; +class NodeViewLayer; class Rep; class LineRep; @@ -84,7 +84,7 @@ public: VISIT_COMPLETE_DEF(NodeCamera) VISIT_COMPLETE_DEF(NodeDrawingStyle) VISIT_COMPLETE_DEF(NodeTransform) - VISIT_COMPLETE_DEF(NodeSceneRenderLayer) + VISIT_COMPLETE_DEF(NodeViewLayer) VISIT_COMPLETE_DEF(Rep) VISIT_COMPLETE_DEF(LineRep) diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h index ee558f3820d..34741acb844 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.h +++ b/source/blender/freestyle/intern/stroke/Stroke.h @@ -40,8 +40,7 @@ #endif extern "C" { -#include "DNA_material_types.h" - +struct MTex; struct bNodeTree; } @@ -300,9 +299,12 @@ private: typedef std::map<const char *, Vec2f, StringUtils::ltstr> Vec2fMap; typedef std::map<const char *, Vec3f, StringUtils::ltstr> Vec3fMap; - float _color[3]; //! the color - float _alpha; //! alpha - float _thickness[2]; //! the thickness on the right and on the left of the backbone vertex (the stroke is oriented) + //! the color + float _color[3]; + //! alpha + float _alpha; + //! the thickness on the right and on the left of the backbone vertex (the stroke is oriented) + float _thickness[2]; bool _visible; realMap *_userAttributesReal; Vec2fMap *_userAttributesVec2f; @@ -519,7 +521,7 @@ public: // Implementation of Interface1D /*! The different blending modes available to similate the interaction media-medium. */ typedef enum { DRY_MEDIUM, /*!< To simulate a dry medium such as Pencil or Charcoal.*/ - HUMID_MEDIUM, /*!< To simulate ink painting (color substraction blending).*/ + HUMID_MEDIUM, /*!< To simulate ink painting (color subtraction blending).*/ OPAQUE_MEDIUM, /*!< To simulate an opaque medium (oil, spray...).*/ } MediumType; diff --git a/source/blender/freestyle/intern/stroke/TextStrokeRenderer.cpp b/source/blender/freestyle/intern/stroke/TextStrokeRenderer.cpp index 534593120a5..4b918cd21bc 100644 --- a/source/blender/freestyle/intern/stroke/TextStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/stroke/TextStrokeRenderer.cpp @@ -14,9 +14,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -# include "TextStrokeRenderer.h" -# include "Canvas.h" -# include "StrokeIterators.h" +#include "TextStrokeRenderer.h" +#include "Canvas.h" +#include "StrokeIterators.h" namespace Freestyle { diff --git a/source/blender/freestyle/intern/stroke/TextStrokeRenderer.h b/source/blender/freestyle/intern/stroke/TextStrokeRenderer.h index 025e4d3d7a2..9da0edbf966 100644 --- a/source/blender/freestyle/intern/stroke/TextStrokeRenderer.h +++ b/source/blender/freestyle/intern/stroke/TextStrokeRenderer.h @@ -34,9 +34,9 @@ #ifndef TEXTSTROKERENDERER_H #define TEXTSTROKERENDERER_H -# include "StrokeRenderer.h" -# include "../system/FreestyleConfig.h" -# include <fstream> +#include "StrokeRenderer.h" +#include "../system/FreestyleConfig.h" +#include <fstream> namespace Freestyle { diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h index e5b55e60445..0a165ca1302 100644 --- a/source/blender/freestyle/intern/system/PythonInterpreter.h +++ b/source/blender/freestyle/intern/system/PythonInterpreter.h @@ -80,7 +80,7 @@ public: Text *text = BKE_text_load(&_freestyle_bmain, fn, G_MAIN->name); if (text) { ok = BPY_execute_text(_context, text, reports, false); - BKE_libblock_delete(&_freestyle_bmain, text); + BKE_id_delete(&_freestyle_bmain, text); } else { BKE_reportf(reports, RPT_ERROR, "Cannot open file: %s", fn); diff --git a/source/blender/freestyle/intern/view_map/Silhouette.h b/source/blender/freestyle/intern/view_map/Silhouette.h index 06ac561b402..366d1c995b7 100644 --- a/source/blender/freestyle/intern/view_map/Silhouette.h +++ b/source/blender/freestyle/intern/view_map/Silhouette.h @@ -1411,8 +1411,8 @@ private: vector<SVertex*> _verticesList; // list of all vertices vector<FEdge*> _edgesList; // list of all edges Id _Id; - const char *_Name; - const char *_LibraryPath; + string _Name; + string _LibraryPath; BBox<Vec3r> _BBox; vector<FrsMaterial> _FrsMaterials; @@ -1432,8 +1432,6 @@ public: userdata = NULL; _importance = 0.0f; _ViewShape = NULL; - _Name = NULL; - _LibraryPath = NULL; } /*! Copy constructor */ @@ -1887,13 +1885,13 @@ public: } /*! Returns the name of the Shape. */ - inline const char *getName() const + inline const string& getName() const { return _Name; } /*! Returns the library path of the Shape. */ - inline const char *getLibraryPath() const + inline const string& getLibraryPath() const { return _LibraryPath; } @@ -1906,13 +1904,13 @@ public: } /*! Sets the name of the shape.*/ - inline void setName(const char *name) + inline void setName(const string& name) { _Name = name; } /*! Sets the library path of the shape.*/ - inline void setLibraryPath(const char *path) + inline void setLibraryPath(const string& path) { _LibraryPath = path; } diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h index 206c6d2cf8d..1726090c692 100644 --- a/source/blender/freestyle/intern/view_map/ViewMap.h +++ b/source/blender/freestyle/intern/view_map/ViewMap.h @@ -1562,13 +1562,13 @@ public: } /*! Returns the ViewShape name. */ - inline const char *getName() const + inline const string& getName() const { return _SShape->getName(); } /*! Returns the ViewShape library path. */ - inline const char *getLibraryPath() const + inline const string& getLibraryPath() const { return _SShape->getLibraryPath(); } diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.h b/source/blender/freestyle/intern/winged_edge/WEdge.h index 8c47dc7f7ff..77b61acad4a 100644 --- a/source/blender/freestyle/intern/winged_edge/WEdge.h +++ b/source/blender/freestyle/intern/winged_edge/WEdge.h @@ -1020,8 +1020,8 @@ protected: vector<WEdge *> _EdgeList; vector<WFace *> _FaceList; int _Id; - const char *_Name; - const char *_LibraryPath; + string _Name; + string _LibraryPath; static unsigned _SceneCurrentId; #if 0 Vec3f _min; @@ -1040,8 +1040,6 @@ public: #endif _Id = _SceneCurrentId; _SceneCurrentId++; - _Name = 0; - _LibraryPath = 0; } /*! copy constructor */ @@ -1121,12 +1119,12 @@ public: } #endif - inline const char *getName() const + inline const string& getName() const { return _Name; } - inline const char *getLibraryPath() const + inline const string& getLibraryPath() const { return _LibraryPath; } @@ -1175,12 +1173,12 @@ public: _FrsMaterials = iMaterials; } - inline void setName(const char *name) + inline void setName(const string& name) { _Name = name; } - inline void setLibraryPath(const char *path) + inline void setLibraryPath(const string& path) { _LibraryPath = path; } |