ObjToJme bug fix

Hi all,

Regarding my post in the bug forum about the ArrayIndexOutOfBounds exception that is thrown from max. I have created a very very short bug fix for it. (The bug report is here : http://www.mojomonkeycoding.com/jmeforum/viewtopic.php?t=1210 )



Here is the fix:





public void processLine(String s) { …



} else if ("g".equals(parts[0])) {
         // see what the material name is
         // if there isn't a name, assume its the
         // default group
         try {
            if (materialNames.get(parts[1]) != null
                  && materialNames.get(parts[1]) != null)
               curGroup = (MaterialGrouping) materialNames.get(parts[1]);
            else
               setDefaultGroup();
         } catch (ArrayIndexOutOfBoundsException aioobe) {
            setDefaultGroup();
         }
         return;
      } else if ("f".equals(parts[0])) {



All obj models exported from max (max version 7.0 in compliance with the obj 4.0 format) now work.

DP

I don’t like catching ArrayIndexOutOfBoundsException personally. Maybe it’s better to add a “parts.length>=2 &&” inside the if statement?

yer, u could do it that way too…



so the code would be:



} else if ("g".equals(parts[0])) {
         // see what the material name is
         // if there isn't a name, assume its the
         // default group
         if (parts.length >= 2 && materialNames.get(parts[1]) != null
                && materialNames.get(parts[1]) != null)
             curGroup = (MaterialGrouping) materialNames.get(parts[1]);
          else
             setDefaultGroup();
         return;
      } else if ("f".equals(parts[0])) {



DP

I just ran into this problem as well. Any reason why this patch should not be rolled into the main codebase?

No reason, that should be patched.

thanks…took ya a while, but you been busy :slight_smile:



DP

Well, I haven’t patched it yet, just saying it should be done sometime. :slight_smile:

I’ve gone ahead and committed the fix to CVS. Everything should work correctly now. :slight_smile: