diff options
Diffstat (limited to 'source/blender/freestyle/intern/winged_edge')
7 files changed, 57 insertions, 18 deletions
diff --git a/source/blender/freestyle/intern/winged_edge/Nature.h b/source/blender/freestyle/intern/winged_edge/Nature.h index 52c9c60d8c7..62171fae111 100755 --- a/source/blender/freestyle/intern/winged_edge/Nature.h +++ b/source/blender/freestyle/intern/winged_edge/Nature.h @@ -71,6 +71,8 @@ namespace Nature { static const EdgeNature SUGGESTIVE_CONTOUR = (1 << 5); // 32 /*! true for material boundaries */ static const EdgeNature MATERIAL_BOUNDARY = (1 << 6); // 64 + /*! true for user-defined edge marks */ + static const EdgeNature EDGE_MARK = (1 << 7); // 128 } // end of namespace Nature diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.cpp b/source/blender/freestyle/intern/winged_edge/WEdge.cpp index a5918fd8400..6ef99186a2c 100755 --- a/source/blender/freestyle/intern/winged_edge/WEdge.cpp +++ b/source/blender/freestyle/intern/winged_edge/WEdge.cpp @@ -258,6 +258,7 @@ WFace::WFace(WFace& iBrother) _VerticesTexCoords = iBrother._VerticesTexCoords; _Id = iBrother.GetId(); _FrsMaterialIndex = iBrother._FrsMaterialIndex; + _Mark = iBrother._Mark; userdata = NULL; iBrother.userdata = new facedata; ((facedata*)(iBrother.userdata))->_copy = this; @@ -624,12 +625,12 @@ WShape::WShape(WShape& iBrother) } } -WFace* WShape::MakeFace(vector<WVertex*>& iVertexList, unsigned iMaterial) +WFace* WShape::MakeFace(vector<WVertex*>& iVertexList, vector<bool>& iFaceEdgeMarksList, unsigned iMaterial) { // allocate the new face WFace *face = instanciateFace(); - WFace *result = MakeFace(iVertexList, iMaterial, face); + WFace *result = MakeFace(iVertexList, iFaceEdgeMarksList, iMaterial, face); if (0 == result) { delete face; return 0; @@ -637,10 +638,10 @@ WFace* WShape::MakeFace(vector<WVertex*>& iVertexList, unsigned iMaterial) return result; } -WFace * WShape::MakeFace(vector<WVertex*>& iVertexList, vector<Vec3r>& iNormalsList, vector<Vec2r>& iTexCoordsList, unsigned iMaterial) +WFace * WShape::MakeFace(vector<WVertex*>& iVertexList, vector<Vec3r>& iNormalsList, vector<Vec2r>& iTexCoordsList, vector<bool>& iFaceEdgeMarksList, unsigned iMaterial) { // allocate the new face - WFace *face = MakeFace(iVertexList, iMaterial); + WFace *face = MakeFace(iVertexList, iFaceEdgeMarksList, iMaterial); if(0 == face) @@ -654,7 +655,7 @@ WFace * WShape::MakeFace(vector<WVertex*>& iVertexList, vector<Vec3r>& iNormalsL return face; } -WFace* WShape::MakeFace(vector<WVertex*>& iVertexList, unsigned iMaterial, WFace *face) +WFace* WShape::MakeFace(vector<WVertex*>& iVertexList, vector<bool>& iFaceEdgeMarksList, unsigned iMaterial, WFace *face) { int id = _FaceList.size(); @@ -702,6 +703,10 @@ WFace* WShape::MakeFace(vector<WVertex*>& iVertexList, unsigned iMaterial, WFace normal.normalize(); face->setNormal(normal); + vector<bool>::iterator mit = iFaceEdgeMarksList.begin(); + face->setMark(*mit); + mit++; + // vertex pointers used to build each edge vector<WVertex*>::iterator va, vb; @@ -734,6 +739,9 @@ WFace* WShape::MakeFace(vector<WVertex*>& iVertexList, unsigned iMaterial, WFace // compute the mean edge value: _meanEdgeSize += edge->GetaOEdge()->GetVec().norm(); } + + edge->setMark(*mit); + mit++; } // Add the face to the shape's faces list: diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.h b/source/blender/freestyle/intern/winged_edge/WEdge.h index abb6263ae69..dc920448add 100755 --- a/source/blender/freestyle/intern/winged_edge/WEdge.h +++ b/source/blender/freestyle/intern/winged_edge/WEdge.h @@ -372,6 +372,7 @@ protected: WOEdge *_paOEdge; // first oriented edge WOEdge *_pbOEdge; // second oriented edge int _nOEdges; // number of oriented edges associated with this edge. (1 means border edge) + bool _Mark; // user-specified edge mark for feature edge detection int _Id; // Identifier for the edge public: @@ -448,6 +449,7 @@ public: inline WOEdge * GetaOEdge() {return _paOEdge;} inline WOEdge * GetbOEdge() {return _pbOEdge;} inline int GetNumberOfOEdges() {return _nOEdges;} + inline bool GetMark() {return _Mark;} inline int GetId() {return _Id;} inline WVertex * GetaVertex() {return _paOEdge->GetaVertex();} inline WVertex * GetbVertex() {return _paOEdge->GetbVertex();} @@ -480,6 +482,7 @@ public: } } inline void setNumberOfOEdges(int n) {_nOEdges = n;} + inline void setMark(bool mark) {_Mark = mark;} inline void setId(int id) {_Id = id;} virtual void ResetUserData() {userdata = 0;} }; @@ -505,6 +508,7 @@ protected: int _Id; unsigned _FrsMaterialIndex; + bool _Mark; // Freestyle face mark (if true, feature edges on this face are ignored) public: void *userdata; @@ -520,6 +524,7 @@ public: inline Vec3r& GetNormal() {return _Normal;} inline int GetId() {return _Id;} inline unsigned frs_materialIndex() const {return _FrsMaterialIndex;} + inline bool GetMark() const {return _Mark;} const FrsMaterial& frs_material() ; /*! The vertex of index i corresponds to the a vertex @@ -663,6 +668,7 @@ public: inline void setTexCoordsList(const vector<Vec2r>& iTexCoordsList) {_VerticesTexCoords = iTexCoordsList;} inline void setId(int id) {_Id = id;} inline void setFrsMaterialIndex(unsigned iMaterialIndex) {_FrsMaterialIndex = iMaterialIndex;} + inline void setMark(bool iMark) {_Mark = iMark;} /*! designed to build a specialized WEdge * for use in MakeEdge @@ -791,7 +797,7 @@ public: * iMaterialIndex * The material index for this face */ - virtual WFace * MakeFace(vector<WVertex*>& iVertexList, unsigned iMaterialIndex); + virtual WFace * MakeFace(vector<WVertex*>& iVertexList, vector<bool>& iFaceEdgeMarksList, unsigned iMaterialIndex); /*! adds a new face to the shape. The difference with * the previous method is that this one is designed @@ -814,7 +820,7 @@ public: * The list of tex coords, iTexCoordsList[i] corresponding to the * normal of the vertex iVertexList[i] for that face. */ - virtual WFace * MakeFace(vector<WVertex*>& iVertexList, vector<Vec3r>& iNormalsList, vector<Vec2r>& iTexCoordsList, unsigned iMaterialIndex); + virtual WFace * MakeFace(vector<WVertex*>& iVertexList, vector<Vec3r>& iNormalsList, vector<Vec2r>& iTexCoordsList, vector<bool>& iFaceEdgeMarksList, unsigned iMaterialIndex); inline void AddEdge(WEdge *iEdge) {_EdgeList.push_back(iEdge);} inline void AddFace(WFace* iFace) {_FaceList.push_back(iFace);} @@ -892,7 +898,7 @@ protected: * face * The Face that is filled in */ - virtual WFace * MakeFace(vector<WVertex*>& iVertexList, unsigned iMaterialIndex, WFace *face); + virtual WFace * MakeFace(vector<WVertex*>& iVertexList, vector<bool>& iFaceEdgeMarksList, unsigned iMaterialIndex, WFace *face); }; diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp index ff567aee06a..d238749570c 100755 --- a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp +++ b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp @@ -258,9 +258,9 @@ void WXFace::ComputeCenter() /**********************************/ -WFace* WXShape::MakeFace(vector<WVertex*>& iVertexList, unsigned iMaterialIndex) +WFace* WXShape::MakeFace(vector<WVertex*>& iVertexList, vector<bool>& iFaceEdgeMarksList, unsigned iMaterialIndex) { - WFace *face = WShape::MakeFace(iVertexList, iMaterialIndex); + WFace *face = WShape::MakeFace(iVertexList, iFaceEdgeMarksList, iMaterialIndex); if(0 == face) return 0; @@ -277,9 +277,9 @@ WFace* WXShape::MakeFace(vector<WVertex*>& iVertexList, unsigned iMaterialIndex) return face; } -WFace * WXShape::MakeFace(vector<WVertex*>& iVertexList, vector<Vec3r>& iNormalsList, vector<Vec2r>& iTexCoordsList, unsigned iMaterialIndex) +WFace * WXShape::MakeFace(vector<WVertex*>& iVertexList, vector<Vec3r>& iNormalsList, vector<Vec2r>& iTexCoordsList, vector<bool>& iFaceEdgeMarksList, unsigned iMaterialIndex) { - WFace *face = WShape::MakeFace(iVertexList, iNormalsList, iTexCoordsList, iMaterialIndex); + WFace *face = WShape::MakeFace(iVertexList, iNormalsList, iTexCoordsList, iFaceEdgeMarksList, iMaterialIndex); // Vec3r center; // for(vector<WVertex*>::iterator wv=iVertexList.begin(),wvend=iVertexList.end(); diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.h b/source/blender/freestyle/intern/winged_edge/WXEdge.h index 9ec8fd4bddb..1734ad1b41f 100755 --- a/source/blender/freestyle/intern/winged_edge/WXEdge.h +++ b/source/blender/freestyle/intern/winged_edge/WXEdge.h @@ -499,7 +499,7 @@ public: * determines the face's edges orientation and (so) the * face orientation. */ - virtual WFace * MakeFace(vector<WVertex*>& iVertexList, unsigned iMaterialIndex); + virtual WFace * MakeFace(vector<WVertex*>& iVertexList, vector<bool>& iFaceEdgeMarksList, unsigned iMaterialIndex); /*! adds a new face to the shape. The difference with * the previous method is that this one is designed @@ -520,7 +520,7 @@ public: * The list of tex coords, iTexCoordsList[i] corresponding to the * normal of the vertex iVertexList[i] for that face. */ - virtual WFace * MakeFace(vector<WVertex*>& iVertexList, vector<Vec3r>& iNormalsList, vector<Vec2r>& iTexCoordsList, unsigned iMaterialIndex); + virtual WFace * MakeFace(vector<WVertex*>& iVertexList, vector<Vec3r>& iNormalsList, vector<Vec2r>& iTexCoordsList, vector<bool>& iFaceEdgeMarksList, unsigned iMaterialIndex); /*! Reset all edges and vertices flags (which might * have been set up on a previous pass) diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp index a0a80b7ef64..40c14eafe72 100755 --- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp +++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp @@ -102,6 +102,8 @@ void WingedEdgeBuilder::buildWShape(WShape& shape, IndexedFaceSet& ifs) { // else if(_current_frs_material) // shape.setFrsMaterial(*_current_frs_material); + const IndexedFaceSet::FaceEdgeMark *faceEdgeMarks = ifs.faceEdgeMarks(); + // sets the current WShape to shape _current_wshape = &shape; @@ -128,6 +130,7 @@ void WingedEdgeBuilder::buildWShape(WShape& shape, IndexedFaceSet& ifs) { new_normals, frs_materials, texCoords, + faceEdgeMarks, vindices, nindices, mindices, @@ -139,6 +142,7 @@ void WingedEdgeBuilder::buildWShape(WShape& shape, IndexedFaceSet& ifs) { new_normals, frs_materials, texCoords, + faceEdgeMarks, vindices, nindices, mindices, @@ -150,6 +154,7 @@ void WingedEdgeBuilder::buildWShape(WShape& shape, IndexedFaceSet& ifs) { new_normals, frs_materials, texCoords, + faceEdgeMarks, vindices, nindices, mindices, @@ -163,6 +168,7 @@ void WingedEdgeBuilder::buildWShape(WShape& shape, IndexedFaceSet& ifs) { mindices += numVertexPerFace[index]; if(tindices) tindices += numVertexPerFace[index]; + faceEdgeMarks++; } delete[] new_vertices; @@ -219,6 +225,7 @@ void WingedEdgeBuilder::buildTriangleStrip( const real *vertices, const real *normals, vector<FrsMaterial>& iMaterials, const real *texCoords, + const IndexedFaceSet::FaceEdgeMark *iFaceEdgeMarks, const unsigned *vindices, const unsigned *nindices, const unsigned *mindices, @@ -232,6 +239,7 @@ void WingedEdgeBuilder::buildTriangleStrip( const real *vertices, vector<WVertex *> triangleVertices; vector<Vec3r> triangleNormals; vector<Vec2r> triangleTexCoords; + vector<bool> triangleFaceEdgeMarks; while(nDoneVertices < nvertices) { @@ -270,10 +278,14 @@ void WingedEdgeBuilder::buildTriangleStrip( const real *vertices, triangleTexCoords.push_back(Vec2r(texCoords[tindices[nTriangle+1]], texCoords[tindices[nTriangle+1]+1])); } } + triangleFaceEdgeMarks.push_back((iFaceEdgeMarks[nTriangle/3] & IndexedFaceSet::FACE_MARK) != 0); + triangleFaceEdgeMarks.push_back((iFaceEdgeMarks[nTriangle/3] & IndexedFaceSet::EDGE_MARK_V1V2) != 0); + triangleFaceEdgeMarks.push_back((iFaceEdgeMarks[nTriangle/3] & IndexedFaceSet::EDGE_MARK_V2V3) != 0); + triangleFaceEdgeMarks.push_back((iFaceEdgeMarks[nTriangle/3] & IndexedFaceSet::EDGE_MARK_V3V1) != 0); if(mindices) - currentShape->MakeFace(triangleVertices, triangleNormals, triangleTexCoords, mindices[nTriangle/3]); + currentShape->MakeFace(triangleVertices, triangleNormals, triangleTexCoords, triangleFaceEdgeMarks, mindices[nTriangle/3]); else - currentShape->MakeFace(triangleVertices, triangleNormals, triangleTexCoords, 0); + currentShape->MakeFace(triangleVertices, triangleNormals, triangleTexCoords, triangleFaceEdgeMarks, 0); nDoneVertices++; // with a strip, each triangle is one vertex more nTriangle++; } @@ -283,6 +295,7 @@ void WingedEdgeBuilder::buildTriangleFan( const real *vertices, const real *normals, vector<FrsMaterial>& iMaterials, const real *texCoords, + const IndexedFaceSet::FaceEdgeMark *iFaceEdgeMarks, const unsigned *vindices, const unsigned *nindices, const unsigned *mindices, @@ -295,6 +308,7 @@ void WingedEdgeBuilder::buildTriangles(const real *vertices, const real *normals, vector<FrsMaterial>& iMaterials, const real *texCoords, + const IndexedFaceSet::FaceEdgeMark *iFaceEdgeMarks, const unsigned *vindices, const unsigned *nindices, const unsigned *mindices, @@ -304,6 +318,7 @@ void WingedEdgeBuilder::buildTriangles(const real *vertices, vector<WVertex *> triangleVertices; vector<Vec3r> triangleNormals; vector<Vec2r> triangleTexCoords; + vector<bool> triangleFaceEdgeMarks; // Each triplet of vertices is considered as an independent triangle for(unsigned i = 0; i < nvertices / 3; i++) @@ -321,11 +336,16 @@ void WingedEdgeBuilder::buildTriangles(const real *vertices, triangleTexCoords.push_back(Vec2r(texCoords[tindices[3*i+1]],texCoords[tindices[3*i+1]+1])); triangleTexCoords.push_back(Vec2r(texCoords[tindices[3*i+2]], texCoords[tindices[3*i+2]+1])); } + + triangleFaceEdgeMarks.push_back((iFaceEdgeMarks[i] & IndexedFaceSet::FACE_MARK) != 0); + triangleFaceEdgeMarks.push_back((iFaceEdgeMarks[i] & IndexedFaceSet::EDGE_MARK_V1V2) != 0); + triangleFaceEdgeMarks.push_back((iFaceEdgeMarks[i] & IndexedFaceSet::EDGE_MARK_V2V3) != 0); + triangleFaceEdgeMarks.push_back((iFaceEdgeMarks[i] & IndexedFaceSet::EDGE_MARK_V3V1) != 0); } if(mindices) - currentShape->MakeFace(triangleVertices, triangleNormals, triangleTexCoords, mindices[0]); + currentShape->MakeFace(triangleVertices, triangleNormals, triangleTexCoords, triangleFaceEdgeMarks, mindices[0]); else - currentShape->MakeFace(triangleVertices, triangleNormals, triangleTexCoords,0); + currentShape->MakeFace(triangleVertices, triangleNormals, triangleTexCoords, triangleFaceEdgeMarks, 0); } diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h index 6bd515aef0b..8e9d0122e35 100755 --- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h +++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h @@ -114,6 +114,7 @@ class LIB_WINGED_EDGE_EXPORT WingedEdgeBuilder : public SceneVisitor const real *normals, vector<FrsMaterial>& iMaterials, const real *texCoords, + const IndexedFaceSet::FaceEdgeMark *iFaceEdgeMarks, const unsigned *vindices, const unsigned *nindices, const unsigned *mindices, @@ -124,6 +125,7 @@ class LIB_WINGED_EDGE_EXPORT WingedEdgeBuilder : public SceneVisitor const real *normals, vector<FrsMaterial>& iMaterials, const real *texCoords, + const IndexedFaceSet::FaceEdgeMark *iFaceEdgeMarks, const unsigned *vindices, const unsigned *nindices, const unsigned *mindices, @@ -134,6 +136,7 @@ class LIB_WINGED_EDGE_EXPORT WingedEdgeBuilder : public SceneVisitor const real *normals, vector<FrsMaterial>& iMaterials, const real *texCoords, + const IndexedFaceSet::FaceEdgeMark *iFaceEdgeMarks, const unsigned *vindices, const unsigned *nindices, const unsigned *mindices, |