If I run into other gotchas, I'll add them to the script.
Code: Select all
// Scene analysis checker
//
// This function iterates through all the fixtures in the scene and compares their
// vertices. If the world coordinates are identical between two or more fixtures, the
// fixture is exactly overlapping which may not be desired (copy and paste issue?)
//
// A text line is emitted and the fixtures are selected.
//
void checkForIdenticalFixtures()
{
fixture [] fixtures = af();
print("\nIdentical fixture test...");
// iterate through all fixtures in the scene...
for (uint i = 0; i < fixtures.length; i++)
{
fixture baseFix = fixtures[i];
for (uint j = i + 1; j < fixtures.length; j++)
{
fixture testFix = fixtures[j];
if (baseFix.getNumVertices() == testFix.getNumVertices())
{
uint vertexCount = baseFix.getNumVertices();
bool identical = true; // assume identical vertices
for (uint k = 0; k < vertexCount; k++)
{
if ((baseFix.getVertex(k).wx != testFix.getVertex(k).wx) ||
(baseFix.getVertex(k).wy != testFix.getVertex(k).wy))
{
identical = false;
break; // out of vertice check loop
}
}
if (identical)
{
baseFix.select();
testFix.select();
print("Identical fixture vertices found. BodyA/Fix: "
+ baseFix.getBody().getName() + "/"
+ baseFix.getName() + " BodyB/Fix: "
+ testFix.getBody().getName() + "/"
+ testFix.getName());
}
}
}
}
}
void main()
{
checkForIdenticalFixtures();
print("Check done.");
}