[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51777] trunk/blender/source/gameengine/ Ketsji/KX_KetsjiEngine.cpp: BGE: Committing patch #32291 " Updated profiling layout for BGE" from Angus Hollands (agoose77).

Mitchell Stokes mogurijin at gmail.com
Tue Oct 30 23:45:16 CET 2012


Revision: 51777
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51777
Author:   moguri
Date:     2012-10-30 22:45:08 +0000 (Tue, 30 Oct 2012)
Log Message:
-----------
BGE: Committing patch #32291 "Updated profiling layout for BGE" from Angus Hollands (agoose77). This patch adds a headers for the profiling information and for the debug properties so they are no longer jumbled together. It also modifies how debug properties are displayed; changes "swap" to "Frametime"; and changes the display from seconds to ms, which is much more useful.

In addition to this patch, I've also modified the precision of the numbers displayed in the profiling information to make things a little cleaner.

Modified Paths:
--------------
    trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp

Modified: trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp	2012-10-30 21:06:25 UTC (rev 51776)
+++ trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp	2012-10-30 22:45:08 UTC (rev 51777)
@@ -1436,9 +1436,18 @@
 void KX_KetsjiEngine::RenderDebugProperties()
 {
 	STR_String debugtxt;
-	int xcoord = 10;	// mmmm, these constants were taken from blender source
-	int ycoord = 14;	// to 'mimic' behavior
+	int title_xmargin = -7;
+	int title_y_top_margin = 4;
+	int title_y_bottom_margin = 2;
 
+	int const_xindent = 4;
+	int const_ysize = 14;
+
+	int xcoord = 12;	// mmmm, these constants were taken from blender source
+	int ycoord = 17;	// to 'mimic' behavior
+	
+	int profile_indent = 64;
+
 	float tottime = m_logger->GetAverage();
 	if (tottime < 1e-6f) {
 		tottime = 1e-6f;
@@ -1448,19 +1457,44 @@
 	RAS_Rect viewport;
 	m_canvas->SetViewPort(0, 0, int(m_canvas->GetWidth()), int(m_canvas->GetHeight()));
 	
+	if (m_show_framerate || m_show_profile)	{
+		/* Title for profiling("Profile") */
+		debugtxt.Format("Profile");
+		m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
+									debugtxt.Ptr(),
+									xcoord + const_xindent + title_xmargin, // Adds the constant x indent (0 for now) to the title x margin
+									ycoord,
+									m_canvas->GetWidth() /* RdV, TODO ?? */,
+									m_canvas->GetHeight() /* RdV, TODO ?? */);
+
+		// Increase the indent by default increase
+		ycoord += const_ysize;
+		// Add the title indent afterwards
+		ycoord += title_y_bottom_margin;
+	}
+
 	/* Framerate display */
 	if (m_show_framerate) {
-		debugtxt.Format("swap : %.3f (%.3f frames per second)", tottime, 1.0/tottime);
+		debugtxt.Format("Frametime :");
 		m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, 
 									debugtxt.Ptr(),
-									xcoord,
+									xcoord + const_xindent,
 									ycoord, 
-									m_canvas->GetWidth() /* RdV, TODO ?? */, 
+									m_canvas->GetWidth() /* RdV, TODO ?? */,
 									m_canvas->GetHeight() /* RdV, TODO ?? */);
-		ycoord += 14;
+		
+		debugtxt.Format("%5.1fms (%5.1f fps)", tottime * 1000.f, 1.0/tottime);
+		m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, 
+									debugtxt.Ptr(),
+									xcoord + const_xindent + profile_indent,
+									ycoord,
+									m_canvas->GetWidth() /* RdV, TODO ?? */,
+									m_canvas->GetHeight() /* RdV, TODO ?? */);
+		// Increase the indent by default increase
+		ycoord += const_ysize;
 	}
 
-	/* Profile and framerate display */
+	/* Profile display */
 	if (m_show_profile)
 	{
 		for (int j = tc_first; j < tc_numCategories; j++)
@@ -1468,23 +1502,43 @@
 			debugtxt.Format(m_profileLabels[j]);
 			m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
 			                            debugtxt.Ptr(),
-			                            xcoord,ycoord,
+			                            xcoord + const_xindent,
+										ycoord,
 			                            m_canvas->GetWidth(),
 			                            m_canvas->GetHeight());
+
 			double time = m_logger->GetAverage((KX_TimeCategory)j);
-			debugtxt.Format("%.3fms (%2.2f %%)", time*1000.f, time/tottime * 100.f);
+
+			debugtxt.Format("%5.2fms (%2d%%)", time*1000.f, (int)(time/tottime * 100.f));
 			m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
 			                            debugtxt.Ptr(),
-			                            xcoord + 60, ycoord,
+			                            xcoord + const_xindent + profile_indent, ycoord,
 			                            m_canvas->GetWidth(),
 			                            m_canvas->GetHeight());
-			ycoord += 14;
+			ycoord += const_ysize;
 		}
 	}
+	// Add the ymargin for titles below the other section of debug info
+	ycoord += title_y_top_margin;
 
 	/* Property display*/
 	if (m_show_debug_properties && m_propertiesPresent)
 	{
+
+		/* Title for debugging("Debug properties") */
+		debugtxt.Format("Debug Properties");
+		m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, 
+									debugtxt.Ptr(),
+									xcoord + const_xindent + title_xmargin, // Adds the constant x indent (0 for now) to the title x margin
+									ycoord, 
+									m_canvas->GetWidth() /* RdV, TODO ?? */, 
+									m_canvas->GetHeight() /* RdV, TODO ?? */);
+
+		// Increase the indent by default increase
+		ycoord += const_ysize;
+		// Add the title indent afterwards
+		ycoord += title_y_bottom_margin;
+
 		KX_SceneList::iterator sceneit;
 		for (sceneit = m_scenes.begin();sceneit != m_scenes.end() ; sceneit++)
 		{
@@ -1519,11 +1573,11 @@
 					}
 					m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, 
 													debugtxt.Ptr(),
-													xcoord,
+													xcoord + const_xindent,
 													ycoord,
 													m_canvas->GetWidth(),
 													m_canvas->GetHeight());
-					ycoord += 14;
+					ycoord += const_ysize;
 				}
 				else
 				{
@@ -1531,14 +1585,14 @@
 					if (propval)
 					{
 						STR_String text = propval->GetText();
-						debugtxt = objname + "." + propname + " = " + text;
+						debugtxt = objname + ": '" + propname + "' = " + text;
 						m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, 
 													debugtxt.Ptr(),
-													xcoord,
+													xcoord + const_xindent,
 													ycoord,
 													m_canvas->GetWidth(),
 													m_canvas->GetHeight());
-						ycoord += 14;
+						ycoord += const_ysize;
 					}
 				}
 			}




More information about the Bf-blender-cvs mailing list