[Bf-blender-cvs] [9c8d31520db] blender2.8: Fix curve stats when using modifiers.

Bastien Montagne noreply at git.blender.org
Wed Nov 28 11:29:02 CET 2018


Commit: 9c8d31520db6c675d05bdf41d21c89701088d99e
Author: Bastien Montagne
Date:   Wed Nov 28 11:21:56 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB9c8d31520db6c675d05bdf41d21c89701088d99e

Fix curve stats when using modifiers.

Curve/surface/text final data may be an evaluated mesh instead of a
displist, when some modifiers (constructive ones in particular) are
applied to it.

Note that this is just getting feet wet, whole draw code suffers from
the same issue! :P

===================================================================

M	source/blender/editors/space_info/info_stats.c

===================================================================

diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index 2169040578a..2000618a4ad 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -95,6 +95,30 @@ typedef struct SceneStatsFmt {
 	char totgpstroke[MAX_INFO_NUM_LEN], totgppoint[MAX_INFO_NUM_LEN];
 } SceneStatsFmt;
 
+static bool stats_mesheval(Mesh *me_eval, int sel, int totob, SceneStats *stats)
+{
+	int totvert, totedge, totface, totloop;
+
+	if (me_eval) {
+		totvert = me_eval->totvert;
+		totedge = me_eval->totedge;
+		totface = me_eval->totpoly;
+		totloop = me_eval->totloop;
+
+		stats->totvert += totvert * totob;
+		stats->totedge += totedge * totob;
+		stats->totface += totface * totob;
+		stats->tottri  += poly_to_tri_count(totface, totloop) * totob;
+
+		if (sel) {
+			stats->totvertsel += totvert;
+			stats->totfacesel += totface;
+		}
+		return true;
+	}
+	return false;
+}
+
 static void stats_object(Object *ob, int sel, int totob, SceneStats *stats)
 {
 	switch (ob->type) {
@@ -102,24 +126,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats)
 		{
 			/* we assume evaluated mesh is already built, this strictly does stats now. */
 			Mesh *me_eval = ob->runtime.mesh_eval;
-			int totvert, totedge, totface, totloop;
-
-			if (me_eval) {
-				totvert = me_eval->totvert;
-				totedge = me_eval->totedge;
-				totface = me_eval->totpoly;
-				totloop = me_eval->totloop;
-
-				stats->totvert += totvert * totob;
-				stats->totedge += totedge * totob;
-				stats->totface += totface * totob;
-				stats->tottri  += poly_to_tri_count(totface, totloop) * totob;
-
-				if (sel) {
-					stats->totvertsel += totvert;
-					stats->totfacesel += totface;
-				}
-			}
+			stats_mesheval(me_eval, sel, totob, stats);
 			break;
 		}
 		case OB_LAMP:
@@ -131,6 +138,13 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats)
 		case OB_SURF:
 		case OB_CURVE:
 		case OB_FONT:
+		{
+			Mesh *me_eval = ob->runtime.mesh_eval;
+			if (stats_mesheval(me_eval, sel, totob, stats)) {
+				break;
+			}
+			ATTR_FALLTHROUGH;  /* Falltrough to displist. */
+		}
 		case OB_MBALL:
 		{
 			int totv = 0, totf = 0, tottri = 0;



More information about the Bf-blender-cvs mailing list