diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2014-07-25 08:26:24 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2015-07-20 00:17:54 +0300 |
commit | 67057865405700572b29e1e3ba1f660c9be39152 (patch) | |
tree | ee1e43069eab9beb6b77de29d8175697b551243d /source/blender/freestyle/intern | |
parent | 431cee2ba0ee8d45e0c0104c72bb1ad3d1f0d238 (diff) |
Freestyle: minor optimization for space from mesh importing to feature edge detection.
Several class member variables were removed (at the cost of computing their values
when retrieved) or changed to a type of smaller size. Also fixed whitespace.
Diffstat (limited to 'source/blender/freestyle/intern')
7 files changed, 58 insertions, 17 deletions
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp index 9827ec68c5d..5ec8b545b4c 100644 --- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp +++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp @@ -55,8 +55,10 @@ void FEdgeXDetector::processShapes(WingedEdge& we) if (_pRenderMonitor && _pRenderMonitor->testBreak()) break; wxs = dynamic_cast<WXShape*>(*it); +#if 0 wxs->bbox(Min, Max); _bbox_diagonal = (Max - Min).norm(); +#endif if (_changes) { vector<WFace*>& wfaces = wxs->GetFaceList(); for (vector<WFace*>::iterator wf = wfaces.begin(), wfend = wfaces.end(); wf != wfend; ++wf) { @@ -117,7 +119,11 @@ void FEdgeXDetector::preProcessShape(WXShape *iWShape) _minKr = FLT_MAX; _maxKr = -FLT_MAX; _nPoints = 0; +#if 0 _meanEdgeSize = iWShape->getMeanEdgeSize(); +#else + _meanEdgeSize = iWShape->ComputeMeanEdgeSize(); +#endif vector<WFace*>& wfaces = iWShape->GetFaceList(); vector<WFace*>::iterator f, fend; diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h index 8170fc5baab..9087d05939a 100644 --- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h +++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h @@ -58,7 +58,9 @@ public: _pProgressBar = NULL; _pRenderMonitor = NULL; _computeViewIndependent = true; +#if 0 _bbox_diagonal = 1.0; +#endif _meanEdgeSize = 0; _computeRidgesAndValleys = true; _computeSuggestiveContours = true; @@ -211,7 +213,9 @@ public: protected: Vec3r _Viewpoint; +#if 0 real _bbox_diagonal; // diagonal of the current processed shape bbox +#endif //oldtmp values bool _computeViewIndependent; real _meanK1; diff --git a/source/blender/freestyle/intern/winged_edge/Nature.h b/source/blender/freestyle/intern/winged_edge/Nature.h index 99a3f902cd0..b1b5c88df5a 100644 --- a/source/blender/freestyle/intern/winged_edge/Nature.h +++ b/source/blender/freestyle/intern/winged_edge/Nature.h @@ -34,6 +34,7 @@ namespace Freestyle { namespace Nature { /* XXX Why not using enums??? */ +/* In order to optimize for space (enum is int) - T.K. */ typedef unsigned short VertexNature; /*! true for any 0D element */ diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.cpp b/source/blender/freestyle/intern/winged_edge/WEdge.cpp index de166531d8b..261aac67c9d 100644 --- a/source/blender/freestyle/intern/winged_edge/WEdge.cpp +++ b/source/blender/freestyle/intern/winged_edge/WEdge.cpp @@ -472,8 +472,10 @@ WShape::WShape(WShape& iBrother) _Id = iBrother.GetId(); _Name = iBrother._Name; _FrsMaterials = iBrother._FrsMaterials; +#if 0 _meanEdgeSize = iBrother._meanEdgeSize; iBrother.bbox(_min, _max); +#endif vector<WVertex *>& vertexList = iBrother.getVertexList(); vector<WVertex *>::iterator v = vertexList.begin(), vend = vertexList.end(); for (; v != vend; ++v) { @@ -681,8 +683,10 @@ WFace *WShape::MakeFace(vector<WVertex *>& iVertexList, vector<bool>& iFaceEdgeM // means that we just created a new edge and that we must add it to the shape's edges list edge->setId(_EdgeList.size()); AddEdge(edge); +#if 0 // compute the mean edge value: _meanEdgeSize += edge->GetaOEdge()->GetVec().norm(); +#endif } edge->setMark(*mit); @@ -696,4 +700,16 @@ WFace *WShape::MakeFace(vector<WVertex *>& iVertexList, vector<bool>& iFaceEdgeM return face; } +real WShape::ComputeMeanEdgeSize() const +{ + real meanEdgeSize = 0.0; + for (vector<WEdge *>::const_iterator it = _EdgeList.begin(), itend = _EdgeList.end(); + it != itend; + it++) + { + meanEdgeSize += (*it)->GetaOEdge()->GetVec().norm(); + } + return meanEdgeSize / _EdgeList.size(); +} + } /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.h b/source/blender/freestyle/intern/winged_edge/WEdge.h index 97c282e1910..9b04333123e 100644 --- a/source/blender/freestyle/intern/winged_edge/WEdge.h +++ b/source/blender/freestyle/intern/winged_edge/WEdge.h @@ -72,7 +72,7 @@ protected: vector<WEdge*> _EdgeList; WShape *_Shape; // the shape to which the vertex belongs bool _Smooth; // flag to indicate whether the Vertex belongs to a smooth edge or not - int _Border; // 1 -> border, 0 -> no border, -1 -> not set + short _Border; // 1 -> border, 0 -> no border, -1 -> not set public: void *userdata; // designed to store specific user data @@ -467,7 +467,6 @@ public: return _angle; } - /*! modifiers */ #if 0 inline void SetaCWEdge(WOEdge *pe) @@ -552,7 +551,7 @@ class WEdge 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) + short _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 @@ -633,7 +632,7 @@ public: return _pbOEdge; } - inline int GetNumberOfOEdges() + inline short GetNumberOfOEdges() { return _nOEdges; } @@ -700,7 +699,7 @@ public: } } - inline void setNumberOfOEdges(int n) + inline void setNumberOfOEdges(short n) { _nOEdges = n; } @@ -1027,15 +1026,21 @@ protected: int _Id; const char *_Name; static unsigned _SceneCurrentId; +#if 0 Vec3r _min; Vec3r _max; +#endif vector<FrsMaterial> _FrsMaterials; +#if 0 real _meanEdgeSize; +#endif public: inline WShape() { +#if 0 _meanEdgeSize = 0; +#endif _Id = _SceneCurrentId; _SceneCurrentId++; } @@ -1092,11 +1097,13 @@ public: return _Id; } +#if 0 inline void bbox(Vec3r& min, Vec3r& max) { min = _min; max = _max; } +#endif inline const FrsMaterial& frs_material(unsigned i) const { @@ -1108,10 +1115,12 @@ public: return _FrsMaterials; } +#if 0 inline const real getMeanEdgeSize() const { return _meanEdgeSize; } +#endif inline const char *getName() const { @@ -1144,11 +1153,13 @@ public: _Id = id; } +#if 0 inline void setBBox(const Vec3r& min, const Vec3r& max) { _min = min; _max = max; } +#endif inline void setFrsMaterial(const FrsMaterial& frs_material, unsigned i) { @@ -1240,6 +1251,7 @@ public: } } +#if 0 inline void ComputeBBox() { _min = _VertexList[0]->GetVertex(); @@ -1256,12 +1268,17 @@ public: } } } +#endif +#if 0 inline real ComputeMeanEdgeSize() { _meanEdgeSize = _meanEdgeSize / _EdgeList.size(); return _meanEdgeSize; } +#else + real ComputeMeanEdgeSize() const; +#endif protected: /*! Builds the face passed as argument (which as already been allocated) diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.h b/source/blender/freestyle/intern/winged_edge/WXEdge.h index 3c9ec7a7e3d..6e48860272a 100644 --- a/source/blender/freestyle/intern/winged_edge/WXEdge.h +++ b/source/blender/freestyle/intern/winged_edge/WXEdge.h @@ -99,7 +99,6 @@ public: #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:WXVertex") #endif - }; @@ -117,7 +116,7 @@ private: // flag to indicate whether the edge is a silhouette edge or not WXNature _nature; // 0: the order doesn't matter. 1: the order is the orginal one. -1: the order is not good - int _order; + short _order; // A front facing edge is an edge for which the bording face which is the nearest from the viewpoint is front. // A back facing edge is the opposite. bool _front; @@ -177,7 +176,7 @@ public: return _front; } - inline int order() const + inline short order() const { return _order; } @@ -206,7 +205,6 @@ public: #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:WXEdge") #endif - }; /********************************** @@ -221,11 +219,10 @@ public: class WXSmoothEdge { public: - typedef enum { - EDGE_EDGE, - VERTEX_EDGE, - EDGE_VERTEX, - } Configuration; + typedef unsigned short Configuration; + static const Configuration EDGE_EDGE = 1; + static const Configuration VERTEX_EDGE = 2; + static const Configuration EDGE_VERTEX = 3; WOEdge *_woea; // Oriented edge from which the silhouette edge starts WOEdge *_woeb; // Oriented edge where the silhouette edge ends @@ -403,7 +400,7 @@ public: return _ClosestPointIndex; } - inline Nature::EdgeNature nature() const + inline WXNature nature() const { return _Nature; } @@ -700,7 +697,6 @@ public: #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:WXFace") #endif - }; @@ -801,7 +797,6 @@ public: #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:WXShape") #endif - }; /* diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp index df990a3468f..2be46abc87d 100644 --- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp +++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp @@ -177,10 +177,12 @@ bool WingedEdgeBuilder::buildWShape(WShape& shape, IndexedFaceSet& ifs) if (shape.GetFaceList().size() == 0) // this may happen due to degenerate triangles return false; +#if 0 // compute bbox shape.ComputeBBox(); // compute mean edge size: shape.ComputeMeanEdgeSize(); +#endif // Parse the built winged-edge shape to update post-flags set<Vec3r> normalsSet; |