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>2013-01-04 03:27:20 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-01-04 03:27:20 +0400
commitec78eb353f71341f84999f47a7222becaadb8598 (patch)
tree0ae6937bcd59f93e0cec512f7b902686cf210e22 /source/blender/freestyle/intern/application
parent699da2fb0d9012cef5e45cc1b547a01fd92dbc1c (diff)
New command-line option --debug-freestyle to enable verbose debug messages
on the console during Freestyle rendering. The debug prints are turned off by default now. Errors are still printed on the console. A patch set implementing this functionality was provided by Bastien Montagne. Many thanks! :)
Diffstat (limited to 'source/blender/freestyle/intern/application')
-rw-r--r--source/blender/freestyle/intern/application/AppCanvas.cpp16
-rw-r--r--source/blender/freestyle/intern/application/Controller.cpp116
2 files changed, 101 insertions, 31 deletions
diff --git a/source/blender/freestyle/intern/application/AppCanvas.cpp b/source/blender/freestyle/intern/application/AppCanvas.cpp
index 6e47a52b76f..06391717bb9 100644
--- a/source/blender/freestyle/intern/application/AppCanvas.cpp
+++ b/source/blender/freestyle/intern/application/AppCanvas.cpp
@@ -145,8 +145,12 @@ void AppCanvas::readColorPixels(int x,int y,int w, int h, RGBImage& oImage) cons
int recty = _pass_z.height;
float xfac = ((float)rectx) / ((float)(xmax - xmin));
float yfac = ((float)recty) / ((float)(ymax - ymin));
- //printf("readColorPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch,
- // xmax - xmin, ymax - ymin, rectx, recty, (int)(xfac * 100.0f));
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("readColorPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch,
+ xmax - xmin, ymax - ymin, rectx, recty, (int)(xfac * 100.0f));
+ }
+#endif
int ii, jj;
for (int j = 0; j < h; j++) {
jj = (int)((y - ymin + j) * yfac);
@@ -178,8 +182,12 @@ void AppCanvas::readDepthPixels(int x,int y,int w, int h, GrayImage& oImage) con
int recty = _pass_z.height;
float xfac = ((float)rectx) / ((float)(xmax - xmin));
float yfac = ((float)recty) / ((float)(ymax - ymin));
- //printf("readDepthPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch,
- // xmax - xmin, ymax - ymin, rectx, recty, (int)(xfac * 100.0f));
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("readDepthPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch,
+ xmax - xmin, ymax - ymin, rectx, recty, (int)(xfac * 100.0f));
+ }
+#endif
int ii, jj;
for (int j = 0; j < h; j++) {
jj = (int)((y - ymin + j) * yfac);
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index a8bc4cf2987..662686c2524 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -68,6 +68,8 @@
#include "../blender_interface/BlenderStrokeRenderer.h"
#include "../blender_interface/BlenderStyleModule.h"
+#include "BKE_global.h"
+
// XXX Not inside an "extern C" block???
#include "DNA_freestyle_types.h"
@@ -227,19 +229,26 @@ int Controller::LoadMesh(Render *re, SceneRenderLayer* srl)
NodeGroup *blenderScene = loader.Load();
if (blenderScene == NULL) {
- cout << "Cannot load scene" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Cannot load scene" << endl;
+ }
return 1;
}
if (blenderScene->numberOfChildren() < 1) {
- cout << "Empty scene" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Empty scene" << endl;
+ }
blenderScene->destroy();
delete blenderScene;
return 1;
}
- cout << "Scene loaded" << endl;
- printf("Mesh cleaning : %lf\n", _Chrono.stop());
+ real duration = _Chrono.stop();
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Scene loaded" << endl;
+ printf("Mesh cleaning : %lf\n", duration);
+ }
_SceneNumFaces += loader.numFacesRead();
if (loader.minEdgeSize() < _minEdgeSize) {
@@ -267,7 +276,10 @@ int Controller::LoadMesh(Render *re, SceneRenderLayer* srl)
blenderScene->accept(wx_builder);
_winged_edge = wx_builder.getWingedEdge();
- printf("WEdge building : %lf\n", _Chrono.stop());
+ duration = _Chrono.stop();
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("WEdge building : %lf\n", duration);
+ }
#if 0
_pView->setDebug(_DebugNode);
@@ -288,9 +300,11 @@ int Controller::LoadMesh(Render *re, SceneRenderLayer* srl)
_ListOfModels.push_back("Blender_models");
- cout << "Triangles nb : " << _SceneNumFaces << endl;
_bboxDiag = (_RootNode->bbox().getMax()-_RootNode->bbox().getMin()).norm();
- cout << "Bounding Box : " << _bboxDiag << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Triangles nb : " << _SceneNumFaces << endl;
+ cout << "Bounding Box : " << _bboxDiag << endl;
+ }
ClearRootNode();
@@ -430,37 +444,66 @@ void Controller::ComputeViewMap()
// 3D context is on.
Vec3r vp(freestyle_viewpoint[0], freestyle_viewpoint[1], freestyle_viewpoint[2]);
- //cout << "mv" << endl;
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "mv" << endl;
+ }
+#endif
real mv[4][4];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
mv[i][j] = freestyle_mv[i][j];
- //cout << mv[i][j] << " ";
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << mv[i][j] << " ";
+ }
+#endif
+ }
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << endl;
}
- //cout << endl;
+#endif
}
- //cout << "\nproj" << endl;
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\nproj" << endl;
+ }
+#endif
real proj[4][4];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
proj[i][j] = freestyle_proj[i][j];
- //cout << proj[i][j] << " ";
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << proj[i][j] << " ";
+ }
+#endif
}
- //cout << endl;
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << endl;
+ }
+#endif
}
int viewport[4];
for (int i = 0; i < 4; i++)
viewport[i] = freestyle_viewport[i];
- //cout << "\nfocal:" << _pView->GetFocalLength() << endl << endl;
-
+#if 0
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\nfocal:" << _pView->GetFocalLength() << endl << endl;
+ }
+#endif
// Flag the WXEdge structure for silhouette edge detection:
//----------------------------------------------------------
- cout << "\n=== Detecting silhouette edges ===" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\n=== Detecting silhouette edges ===" << endl;
+ }
_Chrono.start();
edgeDetector.setViewpoint(Vec3r(vp));
@@ -476,7 +519,9 @@ void Controller::ComputeViewMap()
edgeDetector.processShapes(*_winged_edge);
real duration = _Chrono.stop();
- printf("Feature lines : %lf\n", duration);
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("Feature lines : %lf\n", duration);
+ }
if (_pRenderMonitor->testBreak())
return;
@@ -500,13 +545,17 @@ void Controller::ComputeViewMap()
#endif
sTesselator3d.setNature(_edgeTesselationNature);
- cout << "\n=== Building the view map ===" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\n=== Building the view map ===" << endl;
+ }
_Chrono.start();
// Build View Map
_ViewMap = vmBuilder.BuildViewMap(*_winged_edge, _VisibilityAlgo, _EPSILON, _RootNode->bbox(), _SceneNumFaces);
_ViewMap->setScene3dBBox(_RootNode->bbox());
- printf("ViewMap edge count : %i\n", _ViewMap->viewedges_size());
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("ViewMap edge count : %i\n", _ViewMap->viewedges_size());
+ }
// Tesselate the 3D edges:
_SilhouetteNode = sTesselator3d.Tesselate(_ViewMap);
@@ -519,7 +568,9 @@ void Controller::ComputeViewMap()
#endif
duration = _Chrono.stop();
- printf("ViewMap building : %lf\n", duration);
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ printf("ViewMap building : %lf\n", duration);
+ }
_pView->AddSilhouette(_SilhouetteNode);
#if 0
@@ -595,8 +646,11 @@ void Controller::ComputeSteerableViewMap()
#endif
pm = offscreenBuffer.renderPixmap(_pView->width(), _pView->height());
- if (pm.isNull())
- cout << "BuildViewMap Warning: couldn't render the steerable ViewMap" << endl;
+ if (pm.isNull()) {
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "BuildViewMap Warning: couldn't render the steerable ViewMap" << endl;
+ }
+ }
//pm.save(QString("steerable") + QString::number(i) + QString(".bmp"), "BMP");
// FIXME!! Lost of time !
qimg = pm.toImage();
@@ -770,12 +824,16 @@ void Controller::DrawStrokes()
if (_ViewMap == 0)
return;
- cout << "\n=== Stroke drawing ===" << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "\n=== Stroke drawing ===" << endl;
+ }
_Chrono.start();
_Canvas->Draw();
real d = _Chrono.stop();
- cout << "Strokes generation : " << d << endl;
- cout << "Stroke count : " << _Canvas->stroke_count << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Strokes generation : " << d << endl;
+ cout << "Stroke count : " << _Canvas->stroke_count << endl;
+ }
resetModified();
DeleteViewMap();
}
@@ -791,11 +849,15 @@ Render* Controller::RenderStrokes(Render *re)
BlenderStrokeRenderer* blenderRenderer = new BlenderStrokeRenderer(re, ++_render_count);
_Canvas->Render(blenderRenderer);
real d = _Chrono.stop();
- cout << "Temporary scene generation: " << d << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Temporary scene generation: " << d << endl;
+ }
_Chrono.start();
Render* freestyle_render = blenderRenderer->RenderScene(re);
d = _Chrono.stop();
- cout << "Stroke rendering : " << d << endl;
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Stroke rendering : " << d << endl;
+ }
delete blenderRenderer;
return freestyle_render;