map editor help

Forum for the creative side of the game development process: art, music, storyline, gameplay, concepts, etc. Any sort of relevant discussion is welcome here.

Moderator: PC Supremacists

Re: map editor help

Postby eatcomics on Thu Feb 25, 2010 8:37 pm

Moosader wrote:
XianForce wrote:
acerookie1 wrote:thanx moosader! :bow: :worship: :bow: . you should really add this to your 2d map editor book.


For sure... You may want to also consider adding deallocation of a dynamic 3D array... haha


Oy vey. I did, at one time, have a dynamic 3D array working. But MusuGo uses a 1D array lol. :p (it might use three/four separate 1D arrays, even. Laziness...)

that's more efficient than using multidimensional arrays they can take up a lot of memory (although you'd probably be alright to use them)
Image
User avatar
eatcomics
Chaos Rift God
Chaos Rift God
 
Posts: 2070
Joined: Sat Mar 08, 2008 9:52 pm
Location: Flora Illinois

Re: map editor help

Postby GyroVorbis on Mon Mar 08, 2010 1:48 pm

eatcomics wrote:
Moosader wrote:
XianForce wrote:
acerookie1 wrote:thanx moosader! :bow: :worship: :bow: . you should really add this to your 2d map editor book.


For sure... You may want to also consider adding deallocation of a dynamic 3D array... haha


Oy vey. I did, at one time, have a dynamic 3D array working. But MusuGo uses a 1D array lol. :p (it might use three/four separate 1D arrays, even. Laziness...)

that's more efficient than using multidimensional arrays they can take up a lot of memory (although you'd probably be alright to use them)
Actually, it's not. It's stored sequentially in memory, so the only difference between using a giant 1D and 2D arrays is how you are accessing them.

When you do array[3][2], the compiler is moving the pointer "array" (which points to the first object) to the correct location by adding an offset.
array + 3*COL_SIZE*sizeof(object) + 2*sizeof(object)

(the sizeof() is implicit in C/++).

The only difference between that and a one-dimensional array is an extra offset being applied. And I'm guessing that if Rachel really is using a 1D array, she's just applying that offset manually, which means that the chances are the compiler would optimize a 2D array better than a programmer emulating 2D array access.
User avatar
GyroVorbis
ES Computer Engineer
ES Computer Engineer
 
Posts: 8024
Joined: Thu May 20, 2004 3:04 pm
Location: Studio Vorbis, AL

Re: map editor help

Postby K-Bal on Mon Mar 08, 2010 2:43 pm

There are also some low level tricks to avoid demand paging and optimize cache usage when using arrays and those seem more intuitive with 1D arrays. But multi-dimensional arrays are internally 1D arrays like Falco said, so if you are aware of the memory layouts of your data it doesn't make a difference. This is also only important for arrays > 4kb.
User avatar
K-Bal
Chaos Rift Maniac
Chaos Rift Maniac
 
Posts: 562
Joined: Sun Mar 15, 2009 4:21 pm
Location: Germany, Aachen

Re: map editor help

Postby eatcomics on Mon Mar 08, 2010 9:31 pm

GyroVorbis wrote:
eatcomics wrote:
Moosader wrote:
XianForce wrote:
acerookie1 wrote:thanx moosader! :bow: :worship: :bow: . you should really add this to your 2d map editor book.


For sure... You may want to also consider adding deallocation of a dynamic 3D array... haha


Oy vey. I did, at one time, have a dynamic 3D array working. But MusuGo uses a 1D array lol. :p (it might use three/four separate 1D arrays, even. Laziness...)

that's more efficient than using multidimensional arrays they can take up a lot of memory (although you'd probably be alright to use them)
Actually, it's not. It's stored sequentially in memory, so the only difference between using a giant 1D and 2D arrays is how you are accessing them.

When you do array[3][2], the compiler is moving the pointer "array" (which points to the first object) to the correct location by adding an offset.
array + 3*COL_SIZE*sizeof(object) + 2*sizeof(object)

(the sizeof() is implicit in C/++).

The only difference between that and a one-dimensional array is an extra offset being applied. And I'm guessing that if Rachel really is using a 1D array, she's just applying that offset manually, which means that the chances are the compiler would optimize a 2D array better than a programmer emulating 2D array access.

Damn you, my book lied to me, its old I guess it should be expected
Image
User avatar
eatcomics
Chaos Rift God
Chaos Rift God
 
Posts: 2070
Joined: Sat Mar 08, 2008 9:52 pm
Location: Flora Illinois

Previous

Return to Art, Music, and Design

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests