Scene stats

Let us know if you have a nice R.U.B.E script to share!
Post Reply
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Scene stats

Post 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
Last edited by tescott on Sat Mar 23, 2013 7:47 pm, edited 1 time in total.
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Re: Scene stats

Post 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
Post Reply