Negative triangles and vertices count?

So, I was playing with generative geometries and suff, however, to my surprise I got into a situation with negative triangles count!

How is that possible? I keep pressing my “generate geometry” button, the other counters increase but this one keeps falling down! I wathced and it fell below zero! And keeps falling each time I press the button. Then I notice that Vertices was falling too… and I pressed the button several more times:

What is happening? How this can be negative?

What version of the engine are you using? The github master (which is WIP and not meant for production)?

Nope, it’s the one available through the official maven. As far as I remember, that was the last stabile of 3.0. I am currently investigating the issue, since I don’t get my geometry displayed, and it bugs me. What is interesting - it worked OK like the day before yesterday… I did some changes to the code that I did not keep the exact track of, but I never thought it would bring to this… So now I am backtracing what I did that brought to this.

Haha! You would not believe that! I had an error in my code which discarded all the meshes that I generated and put the result of new Mesh() into the Geometry!

So, the code

Geometry g1 =  new Geometry("s", new Mesh());
g1.setMaterial(someMaterial);
getRootNode().attachChild(g1);

will cause your Triangles and Vertices counts to go down by -1! And in my original scene I had like 20+ objects and that’s why it was falling more rapidly. Crazy :smile:

Seems like a bug in our stats tracking, really.

I think the number of triangles of an empty mesh is defaulted to -1

Probably… but that’s incorrect since the number of triangles in an empty mesh is 0. :slight_smile:

Actually maybe user forgot to call updateCounts().
Anyway I added a bug in the system for this.

Well, that’s going to be true because in normal usage it’s automatic. Just apparently not in the empty mesh case.

And to be fair, I guess this isn’t an “empty” case as it’s a “no data” case… so it’s fine to throw an error.

Rendering the geometry should probably also throw an error in that case.