@@ -685,6 +685,47 @@ public static void assertNotNull(Object o, String errorMessage) {
685685 }
686686 }
687687
688+ public static void dumpArray (Object [] array ) {
689+ if (array == null ) {
690+ System .err .println ("null" );
691+ return ;
692+ }
693+ for (int i = 0 ; i < array .length ; i ++) {
694+ Object o = array [i ];
695+ System .err .print (i + ": " );
696+ if (o instanceof Quaternion ) {
697+ Quaternion q = (Quaternion ) o ;
698+ System .err .print ("(" );
699+ if (q .getX () > 0.00001 ) System .err .print (q .getX () + ", " );
700+ else System .err .print ("0.0, " );
701+ if (q .getY () > 0.00001 ) System .err .print (q .getY () + ", " );
702+ else System .err .print ("0.0, " );
703+ if (q .getZ () > 0.00001 ) System .err .print (q .getZ () + ", " );
704+ else System .err .print ("0.0, " );
705+ if (q .getW () > 0.00001 ) System .err .print (q .getW () + ", " );
706+ else System .err .print ("0.0, " );
707+ System .err .println (")" );
708+ } else {
709+ System .err .println (o .toString () + ", " );
710+ }
711+ }
712+ System .err .println ("" );
713+ }
714+
715+ public static void dumpArray (float [] array ) {
716+ if (array == null ) {
717+ System .err .println ("null" );
718+ return ;
719+ }
720+
721+ for (int i = 0 ; i < array .length ; i ++) {
722+ float o = array [i ];
723+ System .err .println (i + ": " + o );
724+ }
725+
726+ System .err .println ("" );
727+ }
728+
688729 public static Spatial findCommonAncestor (List <Spatial > spatials ) {
689730 Map <Spatial , List <Spatial >> flatParents = new HashMap <>();
690731
@@ -704,6 +745,9 @@ public static Spatial findCommonAncestor(List<Spatial> spatials) {
704745 while (true ) {
705746 for (Spatial spatial : flatParents .keySet ()) {
706747 List <Spatial > parents = flatParents .get (spatial );
748+ if (parents .isEmpty ()) {
749+ continue ;
750+ }
707751 if (index == parents .size ()) {
708752 //we reached the end of a spatial hierarchy let's return;
709753 return lastCommonParent ;
0 commit comments