Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Flawed Logic?

Author
Message
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 6th Mar 2010 08:17 Edited at: 6th Mar 2010 08:18
Alright, Here is the code and maybe I can explain what is supposed to happen.


That creates a grid of 1x1 blocks with any given multiplier I specify, so if its 10, there will be 10x10x10 blocks etc..



That will look at any one block I specify, figure out the surrounding 6 blocks, above below left right front back, if all 6 blocks are present it should hide the middle block since you wouldnt be able to see it, sort of a culling system since everything is in a grid. and it does so like this


The a,b,c is just for my debug purposes to see exactly how many blocks it hides, skips, and if it just bypasses the entire thing.

The issue here is that in the figuring of the surrounding blocks it isnt doing it right, see attached screenshot...

if it origionally creates a 10x10x10 grid of squares the inside 8x8x8 squares should get hidden which will stil appear to the user that there is a large solid 10x10x10 grid of blocks when really there isnt, this greatly improves performance...if it only worked properly.

if this section isnt commented out in the function that checks if it should hide or not the entire thing skips every block it checks, the purpose of the commented out code is so that you don't try and access say myBlocks[-10].



I MUST be doing SOMETHING wrong but i just cannot find what that is, if there is anyone that could give this a onceover that would be GREATLY appreciated as I cannot move further without this thx thx

Add me to your MSN!

Attachments

Login to view attachments
Cetobasilius
14
Years of Service
User Offline
Joined: 29th Dec 2009
Location: Mexico
Posted: 6th Mar 2010 19:54
I dont know whats wrong but i can suggest something, you can first do it in 2 Dimensions! itll be easier to understand! ill see if i can experiment myself

hi
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 6th Mar 2010 21:38
See thats the thing, It should be working! to get the forward and backward block you just add/subtract 1 from the array, left and right block you just add/subtract the multiplier, to get the above and below block you just add/subtract the multiplier times the multiplier, it all makes sense on paper....

[0][1][2]
[3][4][5]
[6][7][8]

if your looking at block 4, and the multiplier is 3, what i said above applies.

Add me to your MSN!
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 6th Mar 2010 22:01
I think the problem lies in the parameters that you pass to the CheckBlock function. Make a little calculation. The i loop value can range from 0 to 999. In the CheckBlock function, you add or deduct 1, 10 and 100 to this. So the results will be:

If i is zero, then -1, 1, -10, 10, -100, 100.
If i is 999, then 998, 1000, 989, 1009, 899, 1099.

But you want all the values to fall between 1000 and 2000, since you pass these values to MinBlock and MaxBlock. They will never fall in this range, even with the highest value of i, some of them are below 1000. Therefore the check will skip all the blocks.

I hope my calculations were correct, but check your boundary values. Place breakpoints into the program and check the values of the left, right, etc. variables for a few loop values to see why they are excluded by the "if" statement.

Also, I may be wrong but in these statements:



Shouldn't the left/right and above/below offsets be calculated the other way around? When you generate the grid, Z is the innermost loop, then Y, then X is the outermost loop. That means that the X offsets should be the farthest away from each other, so (Mult*Mult) should belong to left/right direction.
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 6th Mar 2010 22:30 Edited at: 7th Mar 2010 00:30
Even if they should be switched around it will give the same outcome (for the meantime) until i start to do specific things to those blocks, but right now it just checks to see if the block is present.


But when I remove the function to check the values if they fall within the range it gives me the result you see in this screenshot, if a value was to fall outside the range it should mean that that is an outside block and wouldnt get hidden anyways, right?

EDIT: maybe you misread the code? it checks the value to make sure it is higher than 1000 and lower than 2000, so if you were looking at block 500 it should fall within this range and pass through..

EDIT: EDIT: I misread my own code, I thought i was looking at the model number and i was actually looking at the array number for the class lol, i adjusted the minimum and maximum to 0 and 1000 and it works now, but the same outcome in this screenshot......i dont even have an inclination to why...

EDIT: EDIT: EDIT: OH MAN! Strike of inspiration and I fixed it, all im going to say is you have too 'think outside the box'

Add me to your MSN!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-20 03:32:17
Your offset time is: 2024-11-20 03:32:17