Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TipmyPip, AndrewAMD), 1,151 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Fast array copy #240304
12/10/08 13:20
12/10/08 13:20
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
Hi!
I have two large arrays to store level data, and I need to copy one to another on every frame cycle.
Quote:

for (k = 0; k < 1350; k++)
{
for (i = 0; i < 1350; i++)
{



maparray2[i][k][0] = maparray[i][k][0];
maparray2[i][k][1] = maparray[i][k][1];
maparray2[i][k][2] = maparray[i][k][2];

}
}


But this kills a lot of CPU, maybe someone knows of faster/better way to code such array-to-array copying?

Regards,
Konstantin.


What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: Fast array copy [Re: RyuMaster] #240305
12/10/08 13:23
12/10/08 13:23
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
how about memcpy()? but why do you need to copy the array each frame?

Re: Fast array copy [Re: ventilator] #240306
12/10/08 13:26
12/10/08 13:26
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline
Senior Member
kasimir  Offline
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
this are 5 million Array-Elements!! (5467500)
i think that would be kill every PC...

try to find a better way than this!

Re: Fast array copy [Re: kasimir] #240314
12/10/08 13:57
12/10/08 13:57
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
Eeem... My map is divided into many cells. Every cells holds information which is loaded on level start once (from image using colors), into maparray massive; This array is constant.

(maparray[Xcellposition][Ycellpositon][colorRED])
(maparray[Xcellposition][Ycellpositon][colorBLUE])
(maparray[Xcellposition][Ycellpositon][colorGREEN])

On top of it, every frame some entities are moving. Every entity also has its "map-cell" representation. So, I copy maparray to maparray2, add entity dynamic cell info to maparray2 then, and pass this complete map information for further pathfindings and interactions.


I never used memcpy(), is it safe and easy to play with it?


What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: Fast array copy [Re: RyuMaster] #240317
12/10/08 14:07
12/10/08 14:07
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
1350 is absolute maximum, i think 700-800 will be maximum, but I want to deal with extreme case first


What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: Fast array copy [Re: RyuMaster] #240323
12/10/08 14:19
12/10/08 14:19
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
just a suggestion: store it in a bitmap, since you only have red, green and blue information this would work best. use bitblt to copy the bitmap. for direct access of the bitmap information, you can retreive the pointer to the bitmap data and access it dependent on the format and size of the bitmap. it's some pointer arithmetics but definately fast and viable.

Re: Fast array copy [Re: Joey] #240333
12/10/08 14:59
12/10/08 14:59
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
Hi, Joey!
I was thinking of that at the start. I created bitmap for leveldata. And bitmap panels for entities.

Then I found out, that I can not perform pixel operations on panels.
If I render panel to target, this target can not be locked.
And I can not use only BMAPs for storing data. I need panels, to move BMAP along with entity when it moves. And there are also many problems. The worst one - all pixel operations are very slow.

But I always consider this idea in my head, it is just too hard for me to find performant solution.


What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: Fast array copy [Re: RyuMaster] #240335
12/10/08 15:00
12/10/08 15:00
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
>>for direct access of the bitmap information<<
Or You mean something else by this? Not pixel-read access?


What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: Fast array copy [Re: RyuMaster] #240378
12/10/08 17:55
12/10/08 17:55
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
i'm not quite sure what you're trying to accomplish. if you could be somewhat more precise i think we can help you.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1