googlevr / poly-sample-android

Poly API sample for Android
Apache License 2.0
25 stars 22 forks source link

Is ShortBuffer sufficient to store so many vertices? #6

Open wangjiangchuan opened 6 years ago

wangjiangchuan commented 6 years ago

Have you ever think about that the shortbuffer may cause overflow problems? If one obj file has excessive faces and vertices, suppose 150000 vertices, the shortbuffer will be insufficient to store so many indices, so that some will be left out. If you try specific ASSET_IN, the problem will occur. private static final String ASSET_ID = "dOw_r7NaZpT";

btco commented 6 years ago

That's true! Yes, this code won't render models with that many vertices. I'll change the documentation to make that clear. Thanks!

ytaminE commented 6 years ago

Maybe I met the same problem. PolySampleAndroid keeps stopping when I changed the ASSET_ID to "9ycLAR71SmR" and there was a "ArrayIndexOutOfBoundsException" for the code "vertices.get(index)".

LogCat:

03-05 16:22:00.522 4891-4910/com.example.polysample D/PolySample: Starting to download data files, # files: 2 03-05 16:22:00.835 4891-4910/com.example.polysample D/PolySample: Finished downloading Bedroom.mtl from https://poly.googleapis.com/downloads/9ycLAR71SmR/5nQqQxzXMCa/Bedroom.mtl 03-05 16:22:00.950 4891-4910/com.example.polysample D/PolySample: Finished downloading Bedroom.obj from https://poly.googleapis.com/downloads/9ycLAR71SmR/5nQqQxzXMCa/Bedroom.obj 03-05 16:22:00.952 4891-4910/com.example.polysample D/PolySample: All data files downloaded. 03-05 16:22:00.953 4891-4910/com.example.polysample D/PolySample: Processing: Bedroom.obj, length:161878 03-05 16:22:01.098 4891-4902/com.example.polysample I/zygote: Background concurrent copying GC freed 517(123KB) AllocSpace objects, 8(936KB) LOS objects, 49% free, 2030KB/3MB, paused 515us total 125.836ms 03-05 16:22:01.233 4891-4896/com.example.polysample I/zygote: Do partial code cache collection, code=30KB, data=19KB 03-05 16:22:01.234 4891-4896/com.example.polysample I/zygote: After code cache collection, code=27KB, data=18KB 03-05 16:22:01.234 4891-4896/com.example.polysample I/zygote: Increasing code cache capacity to 128KB 03-05 16:22:01.717 4891-4910/com.example.polysample D/PolySample: Processing: Bedroom.mtl, length:949 03-05 16:22:01.719 4891-4910/com.example.polysample D/PolySample: Will apply translation: (42855.063, -16897.580, 145083.781) and scale 3.9557177E-5 03-05 16:22:01.726 4891-4910/com.example.polysample E/AndroidRuntime: FATAL EXCEPTION: Worker Process: com.example.polysample, PID: 4891 java.lang.ArrayIndexOutOfBoundsException: length=617; index=-9 at java.util.ArrayList.get(ArrayList.java:439) at com.example.polysample.ObjGeometry.getVertex(ObjGeometry.java:149) at com.example.polysample.RawObject.convertObjAndMtl(RawObject.java:103) at com.example.polysample.MainActivity.processDataFiles(MainActivity.java:236) at com.example.polysample.MainActivity.access$300(MainActivity.java:39) at com.example.polysample.MainActivity$2.onPolyDownloadFinished(MainActivity.java:190) at com.example.polysample.AsyncFileDownloader$2.run(AsyncFileDownloader.java:144) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.os.HandlerThread.run(HandlerThread.java:65) 03-05 16:22:02.138 4891-4912/com.example.polysample D/EGL_emulation: eglMakeCurrent: 0xe3e4bd00: ver 2 0 (tinfo 0xe3e3c7f0)