Notifications
Clear all

[Closed] Question about comparing transform matrices

I am writing a script to find out if two objects exist on top of each other, like an accidental clone, where the objects are perfectly coinstanced.

Best way to go about this? Comparing positions? transforms? and then comparing faces/vertices? What do you all think?

3 Replies
1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

In 99.9% of the cases, comparing .transforms (best done by converting both .transform values to strings and then comparing), .min and .max of world bounding box, .center point and vertex and face counts is enough.

The center of a geometry object is the average of all its vertices. So if you have the same vertex count AND the same face count and the center matches, then chances are the geometry and topology are identical. Adding to it the world bounding box ensures the object’s general shape is the same.

To get the vertex and face counts, use GetTriMeshFaceCount() which returns an array of the vertex and face counts.

To run through your scenes and stop vray raybias errors in that case? Yeah it depends on what you’re trying to compare – you could do a broad level where you measure transforms and then based on that go into mesh checks but possibly the transforms will get you a long way first – you’d probably have to compare face normals since they’re the coplanar bits but it’s going to be nasty enough calculation wise.

Perfect answers from both of you. Many thanks.

-Colin