Author Topic: Billboarding causes GC [update]  (Read 1571 times)

Offline Irony

  • long
  • ***
  • Posts: 151
    • View Profile
Billboarding causes GC [update]
« on: June 23, 2013, 02:13:15 pm »
After seeking the reason for frequent GCs in my code for half of last night I found it's the ships' engine glow (a semi-transparent plane with additive blending).
To be exact it's the billboarding on them. Removing setBillboarding(true) eliminates nearly all GCs.
I suppose I could do the billboarding calculation myself, but maybe it's possible for you to take a look. Thx!
« Last Edit: June 24, 2013, 09:52:44 am by Irony »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Billboarding causes GC
« Reply #1 on: June 23, 2013, 08:52:19 pm »
Strange, because i'm using bill boarding a lot and never experienced this. I'll look into it...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Billboarding causes GC
« Reply #2 on: June 23, 2013, 09:19:12 pm »
If you are using billboarded child objects, an unoptimized part of the code will be used that creates up to 3 additional matrices per frame. If should be fixed in this version: http://jpct.de/download/beta/jpct_ae.jar. The code is untested...i hope that it still does the same thing just with less instance creations...

Offline Irony

  • long
  • ***
  • Posts: 151
    • View Profile
Re: Billboarding causes GC
« Reply #3 on: June 23, 2013, 10:23:41 pm »
Sorry but no, the children are not where they're supposed to be..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Billboarding causes GC
« Reply #4 on: June 23, 2013, 10:47:41 pm »
Damn...i'll have a look again.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Billboarding causes GC
« Reply #5 on: June 23, 2013, 11:14:41 pm »
Please re-download the beta and try again. This time, i did some tests...it should work now.

Offline Irony

  • long
  • ***
  • Posts: 151
    • View Profile
Re: Billboarding causes GC
« Reply #6 on: June 23, 2013, 11:27:45 pm »
Perfect! Thanks!

Offline Irony

  • long
  • ***
  • Posts: 151
    • View Profile
Re: Billboarding causes GC [update]
« Reply #7 on: June 24, 2013, 09:49:17 am »
Hi Egon,
the billboarding works fine now, but I have a different problem in this beta.
The following error occurs when loading one specific model, however the exact same code works with previous versions of JPCT. Any idea?

06-24 09:43:40.470: I/jPCT-AE(8216): Processing object from 3DS-file: alien_spac
06-24 09:43:40.560: I/jPCT-AE(8216): Object 'alien_spac_jPCT269' created using 2556 polygons and 1465 vertices.
06-24 09:43:40.560: I/jPCT-AE(8216): Loading Texture...
06-24 09:43:40.590: D/dalvikvm(8216): GC_FOR_ALLOC freed 1608K, 42% free 31861K/54407K, paused 28ms
06-24 09:43:40.630: D/dalvikvm(8216): GC_FOR_ALLOC freed <1K, 40% free 32885K/54407K, paused 24ms
06-24 09:43:40.630: I/jPCT-AE(8216): Texture loaded...1048576 bytes/512*512 pixels!
06-24 09:43:40.865: I/size(8216): 0 471.4535
06-24 09:43:40.865: I/jPCT-AE(8216): Loading file from InputStream
06-24 09:43:40.865: I/jPCT-AE(8216): File from InputStream loaded...305 bytes
06-24 09:43:40.985: W/dalvikvm(8216): threadid=13: thread exiting with uncaught exception (group=0x40c5b1f8)
06-24 09:43:40.990: E/AndroidRuntime(8216): FATAL EXCEPTION: GLThread 517
06-24 09:43:40.990: E/AndroidRuntime(8216): java.lang.NullPointerException
06-24 09:43:40.990: E/AndroidRuntime(8216):    at com.threed.jpct.Loader.loadBinaryFile(Loader.java:1200)
06-24 09:43:40.990: E/AndroidRuntime(8216):    at com.threed.jpct.Loader.loadBinaryFile(Loader.java:1124)
06-24 09:43:40.990: E/AndroidRuntime(8216):    at com.threed.jpct.Loader.load3DS(Loader.java:1541)
06-24 09:43:40.990: E/AndroidRuntime(8216):    at com.threed.jpct.Loader.load3DS(Loader.java:165)
06-24 09:43:40.990: E/AndroidRuntime(8216):    at com.ironman_project.space.object.SpaceObject.loadModel(SpaceObject.java:156)
06-24 09:43:40.990: E/AndroidRuntime(8216):    at com.ironman_project.space.object.SpaceObject.setModelAndTexture(SpaceObject.java:98)
06-24 09:43:40.990: E/AndroidRuntime(8216):    at com.ironman_project.space.object.SpaceObject.<init>(SpaceObject.java:118)




Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Billboarding causes GC [update]
« Reply #8 on: June 24, 2013, 10:30:53 am »
Opps...yes, i've changed something in that method to reduce the garbage it creates. I worked fine in my test cases, but something is obviously wrong with it. I'll look into it later today.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Billboarding causes GC [update]
« Reply #9 on: June 24, 2013, 03:28:14 pm »
Please re-download the beta. The nullpointer should be fixed now.

Offline Irony

  • long
  • ***
  • Posts: 151
    • View Profile
Re: Billboarding causes GC [update]
« Reply #10 on: June 24, 2013, 07:46:09 pm »
Works!