I was wondering how to recognize if two things on the scene are live duplicates (fore example to avoid calculationg pfusical properties of an object several times over) and I found out that the toString() method seems to display the unique ID of any object. So I wrote a little script that prints out:
The first two are "Cube 1" and "Cube 1.2" and they do have the sme ID.
My questions are:
1) Is that a good way of recognizing liveduplicates or is there something in AoI built for that?
2) Where do those codes come from? Java has a lottery machine? (Not that it really would matter, but just asking.)
Okay: Two questions. Second first, as it provides some background to the answer to your real question.
Those Strings are created by the java runtime. They are based on the
This is not a good method to determine live duplicates for the following reasons:
There does not currently seem to be a built-in way to determine whether two objects are live duplicates. My approach to the problem would be as follows: (java-ish pseudo-code)
/Given that you have an ObjectInfo & Object3d reference to the item
that you want to find duplicates of, call it myObjectInfo /
/The first part of this line makes sure that we don't compare our existing
reference to itself. That would always return true, probably not what you want.
if ((object != myObjectInfo) && (object.object == myObjectInfo.object))
addToListOfDuplicates(object); //Implement this as you see fit :)
If there is a better way to do this, perhaps Peter can comment?
Two objects are live duplicates if both ObjectInfos refer to the same Object3D. So just check
if (object1.object == object2.object)
Thanks. Seems to make sense. :)
Log in to post a comment.