If Not (bx = 0 Or bx = blocksz-1 Or by = 0 Or by = blockszy-1 Or bz = 0 Or bz = blocksz-1) Then GoTo nxt
this line is from my biggest bottleneck, and is part an iteration of every block in a sector to check for visibility
the line isnt executed unless theres a gain, its encapsulated by a byte hardsolid, which is enabled if the sector has solid block-edges all around
if bx <> 0 then
if bx <> blocksz-1 then
if by <> 0 then
if by <> blockszy-1 then
if bz <> 0 then
if bz <> blocksz-1 then
Goto nxt
endif
endif
endif
endif
endif
endif
rolliebollocks wrote:I think it should be if isZero <> 0 then goto nxt because every condition has to be false inside NOT in order to return TRUE and goto nxt.
But the general logic of your test does not appear to be flawed. If any of the values are 0, then it should constitute "being on the boundary". Right?
' If Not (bx = 0) Or (bx = blocksx-1) Or (by = 0) Or (by = blocksy-1) Or (bz = 0) Or (bz = blocksz-1) Then GoTo nxt
' precompute constants once to avoid the repeated decrement
blocksxm1 = blocksx - 1
blocksym1 = blocksy - 1
blockszm1 = blocksz - 1
' keep all "b"s grouped in expression so they can be in register optimised
If (blocksx - 1 - bx) * bx = 0 Then Goto NoGotoNxt
If (blocksy - 1 - by) * by = 0 Then Goto NoGotoNxt
If (blocksz - 1 - bz) * bz = 0 Then Goto NoGotoNxt
Goto nxt
NoGotoNxt:
Maybe you can make the contents of your loop a macro, then call the macro 8 times (for the 8 edge cases -- 4 sides and 4 corners), You could slightly change the contents to fit the edge cases depending using macro parameters and #if...
That doesn't make sense to me. Firstly, you are adding two checks to what was originally 6 checks, and secondly, #if cannot be used like that with numeric values.
That doesn't make sense to me. Firstly, you are adding two checks to what was originally 6 checks, and secondly, #if cannot be used like that with numeric values.
No, you're not adding any checks. You are removing all the checks It'd be kind of like converting this:
for i = 0 to 9
' do stuff
if i = 9 then
' do other stuff
end if
next i
to this:
for i = 0 to 8
dostuffmacro(null)
next i
dostuffmacro(dootherstuff)
You can definitely pass variables to macros... compile-time variables-- ie "null" or "dootherstuff".
Last edited by agamemnus on Apr 09, 2011 17:51, edited 1 time in total.
dim as integer yourewrong = 13
#if yourewrong = 13
do:beep:loop
#endif
And the rest of what you said makes no sense. What did make sense, is wrong.
At any rate, the point of responding in a thread like this is to communicate clearly a possible solution.
for i = 0 to 9
' do stuff
if i = 9 then
' do other stuff
end if
next i
to this:
for i = 0 to 9
dostuffmacro(null)
next i
dostuffmacro(dootherstuff)
I don't understand what you can possibly mean by this. A macro will simply swap out one string of code for another. It only saves time when you are using it as opposed to a function.
How can you "remove all checks" and know if something is at the boundary?