Is this allowed? For Next Loop

Started by JBR, July 21, 2021, 00:45:57

Previous topic - Next topic

JBR

For part% = 0 To Part_Max-1

        Local word% = Part_Alive%( part/32 )

        If word = 0 Then part = part + 32 : Goto nnext_particle

                .nnext_particle
                Next



Basically a bit for each particle. If the 32 bits (integer) are all 0 then can I add 32 to the loop counter and jump to Next? It seems to work but not sure if 'legal'?

Saves me checking 32 bits individually when the whole 32 bits are zero.

Thanks, Jim.



STEVIE G

It'll work but its a bit of a hack. Always avoid goto myself. 

Can you explain  more about how this particle system works as I'm sure there will be better alternatives?

Pakz

#2
If you wish to jump to the next cycle in a loop you can use the Continue command.

edit: I checked. It seems blitz3d does not have this Continue command. So the goto is the thing to use :)

What I also did was to create a If check and a variable set to true or false on the code below if that needs or does not need to be exectuted. But I think goto's are faster anyway.

JBR

Quote from: STEVIE G on July 21, 2021, 07:35:35
It'll work but its a bit of a hack. Always avoid goto myself. 

Can you explain  more about how this particle system works as I'm sure there will be better alternatives?

Hi Stevie I have space for 64K particles and 8 surfaces of 8192 quads.

I think I was over stressing the Graphics Card or communication to Graphics Card.

I've changes to 64K particles and 2 surfaces of 8192. i.e. most drawn is 16K.

I've done a dot product check and find I can get a good reduction (a third) by checking for >= 0.6 rather than >0.0

>=0.6 is good enough to get visible particles visible!

I'm using Krischans code to make the particle quad facing forwards always. I don't fully understand it but it works.

I feel I've got a good system atm. But any advice is appreciated.

Jim