Page 1 of 1

Scene stats

Posted: Mon Mar 18, 2013 5:32 pm
by tescott
Here's a simple script to display stats relating to your scene.

Code: Select all

bool staticBodyFilter(body b)
{
   return (b.getType() == 0);
}

bool kinematicBodyFilter(body b)
{
   return (b.getType() == 1);
}

bool dynamicBodyFilter(body b)
{
   return (b.getType() == 2);
}

bool sensorFilter(fixture f)
{
   return (f.isSensor());
}

void main()
{
   print("Scene statistics");
   print("------------------");
   
   body [] bodies = ab();
   print("Body count: " + bodies.length);
   print("- static: " + filterBodies(bodies,staticBodyFilter).length);
   print("- kinematic: " + filterBodies(bodies,kinematicBodyFilter).length);
   print("- dynamic: " + filterBodies(bodies,dynamicBodyFilter).length);
   
   fixture [] fixtures = af();
   print("Fixture count: " + fixtures.length);
   print("- Sensor: " + filterFixtures(fixtures,sensorFilter).length);
   
   joint [] joints = aj();
   print("Joint count: " + joints.length);
   
   image [] images = ai();
   print("Image count: " + images.length);
}
Edit: got rid of extra newlines.

--tim

Re: Scene stats

Posted: Mon Mar 18, 2013 11:26 pm
by tescott
So, there's one deceptive bit about this script I guess. If you have a concave fixture, that counts as multiple fixtures in the emitted .JSON file vs. a single fixture in the .RUBE file. I couldn't understand why I was seeing a discrepancy until I realized I had concave fixtures in place.

--tim