Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-12-04 02:17:49 +0300
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-12-04 02:17:49 +0300
commita9e50bde82acb3befa179213a458d8e1f8844aea (patch)
tree37a43a68d125a4be5b462bc533bd89dcdcba1937 /source/blender/freestyle/intern/application
parent1bfcba31d2e1010a912f9cd283e348b833e43a27 (diff)
A few attempts to reduce the amount of memory consumption in Freestyle.
* Made changes to the Controller so that dynamically allocated memory areas (e.g. imported mesh data, winged edges, and a view map) are released soon after they become unnecessary. * Added a new feature edge selection criterion based on image border. When the "Selection by Image Border" option is enabled, feature edges are selected only if they are within the border of the image being rendered. The border is defined either by the frame size or a border region (specified by the Shift-B key in a 3D View window). When large scenes are rendered, this clipping by the image border leads to less memory consumption. * Enabled the "Silhouette", "Border", and "Crease" edge types of the Selection by Edge Types option by default. When no edge types are specified, all feature edges including "Ridge", "Valley" and "Suggestive Contour" are detected at the cost of extra memory consumption. Disabling these three edge types and enabling some other edge type leads to less memory consumption. This change is intended to help new Freestyle users by providing a typical, low memory consumption default setting. * Slightly rearranged the UI controls for feature edge selection.
Diffstat (limited to 'source/blender/freestyle/intern/application')
-rwxr-xr-xsource/blender/freestyle/intern/application/Controller.cpp109
-rwxr-xr-xsource/blender/freestyle/intern/application/Controller.h11
2 files changed, 69 insertions, 51 deletions
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index e26e001e5ab..bcb902817bf 100755
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -295,34 +295,68 @@ int Controller::LoadMesh(Render *re, SceneRenderLayer* srl)
cout << "Triangles nb : " << _SceneNumFaces << endl;
_bboxDiag = (_RootNode->bbox().getMax()-_RootNode->bbox().getMin()).norm();
cout << "Bounding Box : " << _bboxDiag << endl;
+
+ ClearRootNode();
+
return 0;
}
-
void Controller::CloseFile()
{
WShape::setCurrentId(0);
- _pView->DetachModel();
_ListOfModels.clear();
- if(NULL != _RootNode)
- {
- int ref = _RootNode->destroy();
- if(0 == ref)
- _RootNode->addRef();
-
- _RootNode->clearBBox();
- }
-
- _pView->DetachSilhouette();
- if (NULL != _SilhouetteNode)
- {
- int ref = _SilhouetteNode->destroy();
- if(0 == ref)
+
+ // We deallocate the memory:
+ ClearRootNode();
+ DeleteWingedEdge();
+ DeleteViewMap();
+
+ // clears the canvas
+ _Canvas->Clear();
+
+ // soc: reset passes
+ setPassDiffuse(NULL, 0, 0);
+ setPassZ(NULL, 0, 0);
+}
+
+void Controller::ClearRootNode()
+{
+ _pView->DetachModel();
+ if(NULL != _RootNode)
{
- delete _SilhouetteNode;
- _SilhouetteNode = NULL;
+ int ref = _RootNode->destroy();
+ if(0 == ref)
+ _RootNode->addRef();
+ _RootNode->clearBBox();
}
- }
+}
+
+void Controller::DeleteWingedEdge()
+{
+ if(_winged_edge)
+ {
+ delete _winged_edge;
+ _winged_edge = NULL;
+ }
+
+ // clears the grid
+ _Grid.clear();
+ _SceneNumFaces = 0;
+ _minEdgeSize = DBL_MAX;
+}
+
+void Controller::DeleteViewMap()
+{
+ _pView->DetachSilhouette();
+ if (NULL != _SilhouetteNode)
+ {
+ int ref = _SilhouetteNode->destroy();
+ if(0 == ref) {
+ delete _SilhouetteNode;
+ _SilhouetteNode = NULL;
+ }
+ }
+
// if(NULL != _ProjectedSilhouette)
// {
// int ref = _ProjectedSilhouette->destroy();
@@ -340,43 +374,21 @@ void Controller::CloseFile()
// delete _VisibleProjectedSilhouette;
// _VisibleProjectedSilhouette = NULL;
// }
- // }
-
- _pView->DetachDebug();
- if(NULL != _DebugNode)
- {
+ // }
+
+ _pView->DetachDebug();
+ if(NULL != _DebugNode) {
int ref = _DebugNode->destroy();
if(0 == ref)
- _DebugNode->addRef();
+ _DebugNode->addRef();
}
-
- if(_winged_edge) {
- delete _winged_edge;
- _winged_edge = NULL;
- }
- // We deallocate the memory:
- if(NULL != _ViewMap)
- {
+ if(NULL != _ViewMap) {
delete _ViewMap;
_ViewMap = 0;
}
-
- // clears the canvas
- _Canvas->Clear();
-
- // clears the grid
- _Grid.clear();
- _SceneNumFaces = 0;
- _minEdgeSize = DBL_MAX;
-
- // soc: reset passes
- setPassDiffuse(NULL, 0, 0);
- setPassZ(NULL, 0, 0);
}
-
-
void Controller::ComputeViewMap()
{
@@ -527,6 +539,8 @@ void Controller::ComputeViewMap()
}
// Reset Style modules modification flags
resetModified(true);
+
+ DeleteWingedEdge();
}
void Controller::ComputeSteerableViewMap(){
@@ -699,6 +713,7 @@ void Controller::ResetRenderCount()
Render* Controller::RenderStrokes(Render *re) {
BlenderStrokeRenderer* blenderRenderer = new BlenderStrokeRenderer(re, ++_render_count);
_Canvas->Render( blenderRenderer );
+ DeleteViewMap();
Render* freestyle_render = blenderRenderer->RenderScene(re);
delete blenderRenderer;
diff --git a/source/blender/freestyle/intern/application/Controller.h b/source/blender/freestyle/intern/application/Controller.h
index dfff7d7079c..a278b10a090 100755
--- a/source/blender/freestyle/intern/application/Controller.h
+++ b/source/blender/freestyle/intern/application/Controller.h
@@ -94,6 +94,9 @@ public:
void RemoveStyleModule(unsigned index);
void ReloadStyleModule(unsigned index, const char * iFileName);
void Clear();
+ void ClearRootNode();
+ void DeleteWingedEdge();
+ void DeleteViewMap();
void toggleLayer(unsigned index, bool iDisplay);
void setModified(unsigned index, bool iMod);
void resetModified(bool iMod=false);
@@ -106,10 +109,10 @@ public:
NodeGroup* BuildRep(vector<ViewEdge*>::iterator vedges_begin,
vector<ViewEdge*>::iterator vedges_end) ;
- NodeGroup* debugNode() {return _DebugNode;}
- AppView * view() {return _pView;}
- NodeGroup* debugScene() {return _DebugNode;}
- Grid& grid() {return _Grid;}
+ //NodeGroup* debugNode() {return _DebugNode;}
+ //AppView * view() {return _pView;}
+ //NodeGroup* debugScene() {return _DebugNode;}
+ //Grid& grid() {return _Grid;}
void toggleVisibilityAlgo();