diff options
author | Jason Wilkins <Jason.A.Wilkins@gmail.com> | 2014-10-07 19:39:17 +0400 |
---|---|---|
committer | Jason Wilkins <Jason.A.Wilkins@gmail.com> | 2014-10-07 19:39:17 +0400 |
commit | 189c2e9277d4abd3b750a5a60ef42549dcfe359d (patch) | |
tree | 1430a845f4aab56b9133c3d8c6ffac09ee6dd92a /source/blender/freestyle/intern/view_map | |
parent | 771bad9c6abaad4b742935e5d55067f281287650 (diff) | |
parent | 1519b6a23e0341e25bf5a5c714f9f3d119ab8781 (diff) |
Merge branch 'master' into soc-2014-viewport_contextsoc-2014-viewport_context
Diffstat (limited to 'source/blender/freestyle/intern/view_map')
5 files changed, 83 insertions, 18 deletions
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp index 9c9cd88f188..a5e526fc490 100644 --- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp +++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp @@ -63,14 +63,14 @@ void FEdgeXDetector::processShapes(WingedEdge& we) WXFace *wxf = dynamic_cast<WXFace*>(*wf); wxf->Clear(); } - _computeViewIndependant = true; + _computeViewIndependent = true; } - else if (!(wxs)->getComputeViewIndependantFlag()) { + else if (!(wxs)->getComputeViewIndependentFlag()) { wxs->Reset(); - _computeViewIndependant = false; + _computeViewIndependent = false; } else { - _computeViewIndependant = true; + _computeViewIndependent = true; } preProcessShape(wxs); if (progressBarDisplay) @@ -97,8 +97,8 @@ void FEdgeXDetector::processShapes(WingedEdge& we) if (progressBarDisplay) _pProgressBar->setProgress(_pProgressBar->getProgress() + 1); - wxs->setComputeViewIndependantFlag(false); - _computeViewIndependant = false; + wxs->setComputeViewIndependentFlag(false); + _computeViewIndependent = false; _changes = false; // reset user data @@ -187,8 +187,8 @@ void FEdgeXDetector::computeCurvatures(WXVertex *vertex) CurvatureInfo *C; float radius = _sphereRadius * _meanEdgeSize; - // view independant stuff - if (_computeViewIndependant) { + // view independent stuff + if (_computeViewIndependent) { C = new CurvatureInfo(); vertex->setCurvatures(C); OGF::NormalCycle ncycle; @@ -333,7 +333,7 @@ void FEdgeXDetector::ProcessSilhouetteEdge(WXEdge *iEdge) ///////// void FEdgeXDetector::processBorderShape(WXShape *iWShape) { - if (!_computeViewIndependant) + if (!_computeViewIndependent) return; // Make a pass on the edges to detect the BORDER vector<WEdge*>::iterator we, weend; @@ -358,7 +358,7 @@ void FEdgeXDetector::ProcessBorderEdge(WXEdge *iEdge) ///////// void FEdgeXDetector::processCreaseShape(WXShape *iWShape) { - if (!_computeViewIndependant) + if (!_computeViewIndependent) return; // Make a pass on the edges to detect the CREASE @@ -390,7 +390,7 @@ void FEdgeXDetector::processRidgesAndValleysShape(WXShape *iWShape) // Don't forget to add the built layer to the face at the end of the ProcessFace: //iFace->AddSmoothLayer(faceLayer); - if (!_computeViewIndependant) + if (!_computeViewIndependent) return; // Here the curvatures must already have been computed @@ -684,7 +684,7 @@ void FEdgeXDetector::postProcessSuggestiveContourFace(WXFace *iFace) //////////////////// void FEdgeXDetector::processMaterialBoundaryShape(WXShape *iWShape) { - if (!_computeViewIndependant) + if (!_computeViewIndependent) return; // Make a pass on the edges to detect material boundaries vector<WEdge*>::iterator we, weend; diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h index 8adf685a6eb..8170fc5baab 100644 --- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h +++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h @@ -57,7 +57,7 @@ public: { _pProgressBar = NULL; _pRenderMonitor = NULL; - _computeViewIndependant = true; + _computeViewIndependent = true; _bbox_diagonal = 1.0; _meanEdgeSize = 0; _computeRidgesAndValleys = true; @@ -213,7 +213,7 @@ protected: Vec3r _Viewpoint; real _bbox_diagonal; // diagonal of the current processed shape bbox //oldtmp values - bool _computeViewIndependant; + bool _computeViewIndependent; real _meanK1; real _meanKr; real _minK1; diff --git a/source/blender/freestyle/intern/view_map/Silhouette.h b/source/blender/freestyle/intern/view_map/Silhouette.h index d838b98c1a8..94b00157ccd 100644 --- a/source/blender/freestyle/intern/view_map/Silhouette.h +++ b/source/blender/freestyle/intern/view_map/Silhouette.h @@ -378,6 +378,17 @@ public: _FEdges.push_back(iFEdge); } + /*! Remove an FEdge from the list of edges emanating from this SVertex. */ + inline void RemoveFEdge(FEdge *iFEdge) + { + for (vector<FEdge *>::iterator fe = _FEdges.begin(), fend = _FEdges.end(); fe != fend; fe++) { + if (iFEdge == (*fe)) { + _FEdges.erase(fe); + break; + } + } + } + /* replaces edge 1 by edge 2 in the list of edges */ inline void Replace(FEdge *e1, FEdge *e2) { @@ -441,6 +452,10 @@ public: /*! angle in radians */ inline real curvature2d_as_angle() const; #endif + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:SVertex") +#endif }; /**********************************/ @@ -518,6 +533,8 @@ protected: bool _isInImage; + bool _isTemporary; + public: /*! A field that can be used by the user to store any data. * This field must be reseted afterwards using ResetUserData(). @@ -538,6 +555,7 @@ public: _occludeeEmpty = true; _isSmooth = false; _isInImage = true; + _isTemporary = false; } /*! Builds an FEdge going from vA to vB. */ @@ -554,6 +572,7 @@ public: _occludeeEmpty = true; _isSmooth = false; _isInImage = true; + _isTemporary = false; } /*! Copy constructor */ @@ -573,6 +592,7 @@ public: _occludeeEmpty = iBrother._occludeeEmpty; _isSmooth = iBrother._isSmooth; _isInImage = iBrother._isInImage; + _isTemporary = iBrother._isTemporary; iBrother.userdata = this; userdata = 0; } @@ -708,6 +728,11 @@ public: return _isInImage; } + inline bool isTemporary() const + { + return _isTemporary; + } + /* modifiers */ /*! Sets the first SVertex. */ inline void setVertexA(SVertex *vA) @@ -803,6 +828,11 @@ public: _isInImage = iFlag; } + inline void setTemporary(bool iFlag) + { + _isTemporary = iFlag; + } + /* checks whether two FEdge have a common vertex. * Returns a pointer on the common vertex if it exists, NULL otherwise. */ @@ -931,6 +961,10 @@ public: * The sampling with which we want to iterate over points of this FEdge. */ virtual inline Interface0DIterator pointsEnd(float t = 0.0f); + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:FEdge") +#endif }; // @@ -1241,6 +1275,10 @@ public: { _bFaceMark = iFaceMark; } + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:FEdgeSharp") +#endif }; /*! Class defining a smooth edge. This kind of edge typically runs across a face of the input mesh. It can be @@ -1353,6 +1391,10 @@ public: { _FrsMaterialIndex = i; } + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:FEdgeSmooth") +#endif }; diff --git a/source/blender/freestyle/intern/view_map/ViewMap.cpp b/source/blender/freestyle/intern/view_map/ViewMap.cpp index fd5ebb99f72..6bb0082e379 100644 --- a/source/blender/freestyle/intern/view_map/ViewMap.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMap.cpp @@ -63,6 +63,30 @@ ViewMap::~ViewMap() _VEdges.clear(); } +void ViewMap::Clean() +{ + vector<FEdge*> tmpEdges; + + for (vector<ViewShape*>::iterator vs = _VShapes.begin(), vsend = _VShapes.end(); vs != vsend; vs++) { + vector<FEdge*>& edges = (*vs)->sshape()->getEdgeList(); + for (vector<FEdge*>::iterator it = edges.begin(), itend = edges.end(); it != itend; it++) { + if ((*it)->isTemporary()) { + (*it)->setTemporary(false); // avoid being counted multiple times + tmpEdges.push_back(*it); + } + } + } + + for (vector<FEdge*>::iterator it = tmpEdges.begin(), itend = tmpEdges.end(); it != itend; it++) { + for (vector<ViewShape*>::iterator vs = _VShapes.begin(), vsend = _VShapes.end(); vs != vsend; vs++) { + (*vs)->sshape()->RemoveEdge(*it); + } + (*it)->vertexA()->RemoveFEdge(*it); + (*it)->vertexB()->RemoveFEdge(*it); + delete (*it); + } +} + ViewShape *ViewMap::viewShape(unsigned id) { int index = _shapeIdToIndex[id]; diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h index d87341503fa..0ee1864e086 100644 --- a/source/blender/freestyle/intern/view_map/ViewMap.h +++ b/source/blender/freestyle/intern/view_map/ViewMap.h @@ -236,6 +236,9 @@ public: /* connects a FEdge to the graph trough a SVertex */ //FEdge *Connect(FEdge *ioEdge, SVertex *ioVertex); + /* Clean temporary FEdges created by chaining */ + virtual void Clean(); + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:ViewMap") #endif @@ -369,7 +372,6 @@ public: #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:ViewVertex") #endif - }; /**********************************/ @@ -642,7 +644,6 @@ public: #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:TVertex") #endif - }; @@ -859,7 +860,6 @@ public: #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:NonTVertex") #endif - }; /**********************************/ @@ -1379,7 +1379,6 @@ public: #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:ViewEdge") #endif - }; |