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>2012-07-17 03:29:12 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-07-17 03:29:12 +0400
commit5a581c1fd116c51df13e09c5c320feba48d069bb (patch)
tree91df14a7a43b19af4ecac736460cbbd8c1b1e291 /source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
parent9d2a957a0d440b07d1a5e9e0ee5fb613d93637d9 (diff)
Better handling of the ESC key during Freestyle rendering.
This commit is meant to improve the response of the ESC key for stopping Freestyle rendering throughout the rendering process. The rendering with Freestyle consists of several steps including: (1) mesh data loading, (2) winged edge construction, (3) silhouette edge detection, (4) view map construction, and (5) stroke drawing. All these steps have been extended to frequently check if the ESC key is pressed, so that users can abort time-consuming rendering at any point of time.
Diffstat (limited to 'source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp')
-rwxr-xr-xsource/blender/freestyle/intern/view_map/ViewMapBuilder.cpp45
1 files changed, 39 insertions, 6 deletions
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
index 242b769e8b5..d503daa3696 100755
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
@@ -378,7 +378,7 @@ cout << "\t\tIs occluder" << endl;
// a QI of 22 because 3 out of 6 occluders have QI <= 22.
template <typename G, typename I>
-static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilon)
+static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilon, RenderMonitor *iRenderMonitor)
{
vector<ViewEdge*>& vedges = ioViewMap->ViewEdges();
@@ -391,6 +391,8 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, G& grid, real epsilo
unsigned maxIndex, maxCard;
unsigned qiMajority;
for(vector<ViewEdge*>::iterator ve=vedges.begin(), veend=vedges.end(); ve!=veend; ve++) {
+ if (iRenderMonitor && iRenderMonitor->testBreak())
+ break;
#if logging > 0
cout << "Processing ViewEdge " << (*ve)->getId() << endl;
#endif
@@ -538,7 +540,7 @@ cout << "\tConclusion: QI = " << maxIndex << ", " << (*ve)->occluders_size() <<
}
template <typename G, typename I>
-static void computeDetailedVisibility(ViewMap *ioViewMap, G& grid, real epsilon)
+static void computeDetailedVisibility(ViewMap *ioViewMap, G& grid, real epsilon, RenderMonitor *iRenderMonitor)
{
vector<ViewEdge*>& vedges = ioViewMap->ViewEdges();
@@ -551,6 +553,8 @@ static void computeDetailedVisibility(ViewMap *ioViewMap, G& grid, real epsilon)
unsigned maxIndex, maxCard;
unsigned qiMajority;
for(vector<ViewEdge*>::iterator ve=vedges.begin(), veend=vedges.end(); ve!=veend; ve++) {
+ if (iRenderMonitor && iRenderMonitor->testBreak())
+ break;
#if logging > 0
cout << "Processing ViewEdge " << (*ve)->getId() << endl;
#endif
@@ -1115,6 +1119,9 @@ void ViewMapBuilder::computeInitialViewEdges(WingedEdge& we)
for (vector<WShape*>::const_iterator it = wshapes.begin();
it != wshapes.end();
it++) {
+ if (_pRenderMonitor && _pRenderMonitor->testBreak())
+ break;
+
// create the embedding
psShape = new SShape;
psShape->setId((*it)->GetId());
@@ -1151,6 +1158,8 @@ void ViewMapBuilder::computeCusps(ViewMap *ioViewMap){
for(;
ve!=veend;
++ve){
+ if (_pRenderMonitor && _pRenderMonitor->testBreak())
+ break;
if((!((*ve)->getNature() & Nature::SILHOUETTE)) || (!((*ve)->fedgeA()->isSmooth())))
continue;
FEdge *fe = (*ve)->fedgeA();
@@ -1236,10 +1245,10 @@ void ViewMapBuilder::ComputeCumulativeVisibility(ViewMap *ioViewMap,
if ( _orthographicProjection ) {
BoxGrid grid(*source, *density, ioViewMap, _viewpoint, _EnableQI);
- computeCumulativeVisibility<BoxGrid, BoxGrid::Iterator>(ioViewMap, grid, epsilon);
+ computeCumulativeVisibility<BoxGrid, BoxGrid::Iterator>(ioViewMap, grid, epsilon, _pRenderMonitor);
} else {
SphericalGrid grid(*source, *density, ioViewMap, _viewpoint, _EnableQI);
- computeCumulativeVisibility<SphericalGrid, SphericalGrid::Iterator>(ioViewMap, grid, epsilon);
+ computeCumulativeVisibility<SphericalGrid, SphericalGrid::Iterator>(ioViewMap, grid, epsilon, _pRenderMonitor);
}
}
@@ -1265,10 +1274,10 @@ void ViewMapBuilder::ComputeDetailedVisibility(ViewMap *ioViewMap,
if ( _orthographicProjection ) {
BoxGrid grid(*source, *density, ioViewMap, _viewpoint, _EnableQI);
- computeDetailedVisibility<BoxGrid, BoxGrid::Iterator>(ioViewMap, grid, epsilon);
+ computeDetailedVisibility<BoxGrid, BoxGrid::Iterator>(ioViewMap, grid, epsilon, _pRenderMonitor);
} else {
SphericalGrid grid(*source, *density, ioViewMap, _viewpoint, _EnableQI);
- computeDetailedVisibility<SphericalGrid, SphericalGrid::Iterator>(ioViewMap, grid, epsilon);
+ computeDetailedVisibility<SphericalGrid, SphericalGrid::Iterator>(ioViewMap, grid, epsilon, _pRenderMonitor);
}
}
@@ -1378,6 +1387,8 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
ve!=veend;
ve++)
{
+ if (_pRenderMonitor && _pRenderMonitor->testBreak())
+ break;
#if logging > 0
cout << "Processing ViewEdge " << (*ve)->getId() << endl;
#endif
@@ -1525,6 +1536,9 @@ void ViewMapBuilder::ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real ep
ve!=veend;
ve++)
{
+ if (_pRenderMonitor && _pRenderMonitor->testBreak())
+ break;
+
festart = (*ve)->fedgeA();
fe = (*ve)->fedgeA();
qiMajority = 1;
@@ -1653,6 +1667,9 @@ void ViewMapBuilder::ComputeVeryFastRayCastingVisibility(ViewMap *ioViewMap, rea
ve!=veend;
ve++)
{
+ if (_pRenderMonitor && _pRenderMonitor->testBreak())
+ break;
+
set<ViewShape*> occluders;
fe = (*ve)->fedgeA();
@@ -2136,6 +2153,9 @@ void ViewMapBuilder::ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsi
sv!=svend;
sv++)
{
+ if (_pRenderMonitor && _pRenderMonitor->testBreak())
+ break;
+
const vector<FEdge*>& vedges = (*sv)->fedges();
for(vector<FEdge*>::const_iterator sve=vedges.begin(), sveend=vedges.end();
@@ -2159,6 +2179,19 @@ void ViewMapBuilder::ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsi
vsegments.clear();
}
+ if (_pRenderMonitor && _pRenderMonitor->testBreak()) {
+ // delete segments
+ if(!segments.empty()){
+ vector<segment* >::iterator s, send;
+ for(s=segments.begin(),send=segments.end();
+ s!=send;
+ s++){
+ delete *s;
+ }
+ }
+ return;
+ }
+
// reset userdata:
for(fe=ioEdges.begin(), fend=ioEdges.end();
fe!=fend;