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.

Newcomers DBPro Corner / Objects - How many can u create

Author
Message
Maelstrom
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: United Kingdom
Posted: 1st Apr 2004 13:39
Hi

Is there a limit to the number of objects that can be created. below is a section of my code which sets up 3 arrays and types. Later on in my code i create an object for each of these arrays totaling about 1250 object. It seems that after these objects have been created my code slows down to a crawl. I'm not even displaying all the object a once either. The program is just a few boxes which shoot up into the air and explode.

My PC Spec is AMD 2.4 with 512 Ram and Gforce 4 Ti 4200.

I doubt that i have explained this sufficently, so if there are other details which you need to know then please ask.


type smokeframe
smokeobj as integer
FollowObj as integer
fade# as float
size# as float
inuse as integer
SmokeCounter as integer
Loopreached as integer
ObjHide as integer
endtype

dim smoketrail(20,40) as smokeframe : rem 800 objects

type explodefx
x# as float
y# as float
z# as float
obj as integer
xx# as float
yy# as float
zz# as float
Force as integer
fade# as float
inuse as integer
endtype

dim explode(20,20) as explodefx : rem 400 objects


type Bangfx
x# as float
y# as float
z# as float
frame as integer
obj as integer
inuse as integer
endtype

dim bang(20) as bangfx : rem 20 objects
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 1st Apr 2004 13:54
classic is near 65000
pro is near 3 million

if your using a simple bit of code like this as your main


do

rem blah
sync
loop

and not cleaning up after yourself, each time u test it theres a chance your not flushing memory hence creating a slowdown.


clean up after yourself each time by destroying media after it has completed.

a good solution to this is a main like this


disable escapekey : while escapekey()=0

sync
endwhile

rem clean up here

if the boxes are not textured and using gourad shading (grey) it can appear to move slower than a simple textured object.


if your using a certain sync rate or moving them slowly with a small amount of movement they will appear slower.

if your camera range is massive like 25000 instead of sub 5000 it can be a performance hit.

depends on what your using classic or pro to guess other problems.


BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Apr 2004 13:57
DB can handle that many objects. The rest is down to you, how you code and what your machine is capable of.

You haven't shown the guts of your code. But for example, if you have a loop of 100 lines of code, processed once for each smoke trail, you are already running 80,000 lines of code between each sync.

This is just an example...work out for yourself how many lines of code are being processed. And take a look at the complexity of the instructions. This is basic checking, but may give you some idea as to what's going on.

I often time different sections of my code to see where the bottlenecks are.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
Maelstrom
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: United Kingdom
Posted: 1st Apr 2004 14:27 Edited at: 1st Apr 2004 14:48
Thanks for posts Indi and BatVink. I have tried some of those ideas, even stopping some effects from running to see where the slow down is. I guess fault finding comes with experience.

I've included the rest of the code incase you have any ideas or have time to tell me where i'm going wrong. All comments will be most welcome.

Using DBPro



Media can be got from:
http://maelstromhome.mysite.freeserve.com/pics/bang.rar

Arrow keys move camera - space sets things going.

These Functions setup and create effects:
SetupSmokeTrail()
CreateExplodeFrags()
CreateExplosionBang()

These Functions asign an effect slot to object i.e missiles:
InitialiseSmokeTrail(Object Number)
InitialiseExplodeFrags(Object Number)
InitialiseExplodebang(Object Number)

These Functions run effects until the effect has finished.
RunExplodefrags()
RunExplosionBang()
RunSmokeTrail()

Thanks
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Apr 2004 17:05
In RunSmokeTrail() as an example, you have a nested loop. So you can multiply one by the other and this will get you your linecount...

so you potentially have 40 * 20 * 5(lines) = 4,000 lines of code, just for the internal loop. This also includes manipulating objects, such as scaling and fading, so it's not just simple number crunching.

This is one example of the many nested loops you have, you might find it interesting to time a few of these to see just how long they are taking.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 1st Apr 2004 17:38
I think the limit is 65350 or something...


We need help! Email us! join@eternaldestinyonline.com
Maelstrom
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: United Kingdom
Posted: 1st Apr 2004 18:48
Batvink

I see what your saying regards the RunSmokeTrail() loop. This together with the RunExplosionBang() and RunExplodefrags() would increase the length of the main loop considerable. I haven't done anything with timing yet so as to get the time each of these functions would take, so any tips/code snippets would be appreciated.

One thing i still can't get my head around is that if you Rem the
InitialiseSmokeTrail() and RunSmokeTrail() functions out in the main loop you would think the whole thing would run quicker. It doesn't seem to though. It only run quicker if you rem the SetupSmokeTrail()Function before the main loop starts. In my newbie mind it shouldn't make a difference to the speed of the main loop as the Function is called before the main loop starts. This is why i wondered about object limits.
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 1st Apr 2004 19:52
Perhaps setup is activating some feature that requires more processing power?

Maelstrom
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: United Kingdom
Posted: 1st Apr 2004 20:35 Edited at: 1st Apr 2004 20:39
Zircher

After your comment i've changed some of the setting to try and gauge if the setup would require more power. It look's like the answer is yes. Although the 3 setup functions before the main loop arn't very complex it seems that my AMD 2.4 with 512 Ram and Gforce 4 Ti 4200 isn't enough to load 1250 object into memory without causing a serious drop in FPS.

It doesn't matter if i launch 20,10 or 1 missile i always get around 6fps at some point. After reducing the amount of effect (i.e 10 fragments instead of 20) thing do seem to speed up. Bang goes that idea then of loading all effect before the game starts. I'll have to think of another solution.

I suppose the answer to my own question is the theoretical limit is about 65000ish but the practicle limit is your PC spec.

Is there a way within DBPro you can tell how much CPU,Memory is being used??
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Apr 2004 20:50 Edited at: 1st Apr 2004 20:51
On the timing issue, you can do something as simple as:



This will print the number of milliseconds between the 2 points. Do a series of these (changing the text position for each, obviously!) and you'll build up the picture pretty quickly.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
Maelstrom
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: United Kingdom
Posted: 1st Apr 2004 20:56
So time1 = Timer() would be the 1st command inside your main loop and text(5,5, "Time taken = " + str$(Timer() - time1)) would be the last. Thanks, i'll go and try it out now.
Maelstrom
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: United Kingdom
Posted: 1st Apr 2004 22:47 Edited at: 1st Apr 2004 22:48
I tried the timing suggestion. I couldn't see much change in the retuned time value other than 0. So i change it a little to this:

timetaken=Timer()- time1
if timetaken=>1 then t=t+1
text 5,5,str$(timetaken)+" "+str$(t)+" "+str$(timer())

I did use higher values in the statement timetaken=>1 but that didn't seem make much difference and whether it was 1 - 15 milliseconds the time difference was about 1 t millisecond every 1500 or so timer() increments. This rate didn't change when i launched my effect laden missiles in the air. I did notice that as my app slowed down to a crawl the timer() value was incrementing in jumps of 300 but then the t value was still only >1 milliseconds every 1500 or so timer() increments.

Where am i going wrong???
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Apr 2004 23:43
The idea is to put the timer around your loop, so you can see how long it takes to do the 800 iterations, or how ever many it happens to be. The DB timer is not accurate enough to measure down to a millisecond.

If you need more accurate timing to get into the finer detail, you will need one of the Timer DLLs that Rob K or TCA created.

You can also check the timing around the SYNC, this will give you an idea of how well the hardware is coping.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
Maelstrom
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: United Kingdom
Posted: 2nd Apr 2004 03:12
Ok, i've downloaded IanM dll and have put the Hitimer to work.

The SetupSmokeTrail()took 21 milliseconds to complete

Either side of the RunExplodefrags RunExplosionBang RunSmokeTrail
took 2-3 milliseconds

Around the sync command was 155 milliseconds

So the sync command comes out at the highest but would you say 155 milliseconds is slow. It seems quick to me but to someone more experienced it could seem like forever. What do you think BatVink??

Thanks
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd Apr 2004 10:54
155 milliseconds is very slow. That's 6.45 frames per second.

It looks like the graphics card is struggling to keep up. The code itself equates to 40 iterations / sec, which is reasonable for what you are doing.

I'm no expert on the hardware aspects, maybe someone else can comment on what is causing this.

I just tested your original code on my AMD Barton 3000+, 512Mb Ram and Geforce 5200 FX 128 Mb card, and I only get 9 frames/sec when the explosion kicks off

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
Maelstrom
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: United Kingdom
Posted: 2nd Apr 2004 11:55
Looks like i'm going to have to rethink my strategy. The idea for this little experiment was to try and create reuseable moduler code that could easily be incorporated into my game.

I think that creating all these objects at startup is just using to much memory. As the code itself doesn't seem to take much time to run i will probably look at creating each effect as and when its needed and then clearing them after they have been used. It will probably be more efficient to only call the run functions when they are being used and only once every nth loop. The effects are going to have to be much smaller(less fragments/shorter smoke trail). I suppose that's why on some games they test run graphics test to see what your system can handle.
kidsa
20
Years of Service
User Offline
Joined: 8th Dec 2003
Location: MA,usa
Posted: 4th Apr 2004 03:23
3 million?! whoa what was the most someone here ever made?
BearCDPOLD
20
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 4th Apr 2004 09:39
If I remember correctly the files say around 65535 object limit.

Crazy Donut Productions, Current Project: KillZone
Web Site Button Does Not Work, Visit Here: http://www.geocities.com/crazydonutproductions/index.html
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 7th Apr 2004 15:29
I thought the ID number used for the objects was a 2 byte int, therfore the maximum wud indeed be 65535.

Watch this space if you like getting bored...
http://darkbasicpro.thegamecreators.com/?gf=irc <<Visit the chat!.;
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 7th Apr 2004 17:26
only for classic, pro has a lot more


fall down seven times, stand up eight
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 9th Apr 2004 17:46
cool

Watch this space if you like getting bored...
http://darkbasicpro.thegamecreators.com/?gf=irc <<Visit the chat!.;
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 9th Apr 2004 20:48
instanced objects or clones would be faster, the problem is holding so many models on the card (even if they are all only a few polygons each), when you get beyond a certain limit you hit the infamous "object wall", where just a few extra models kill the framerate massivley, you should find it faster to use cloned objects or instances, the trouble with my current efforts in Invaders21c is that animations and some other data are not carried over to either clones or instances, but you do get a worthwhile improvement in the framerates, cheers.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, ATI radeon 9800 pro gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
Maelstrom
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: United Kingdom
Posted: 9th Apr 2004 21:18
Thanks Mentor. Instanced objects - thats a new one to me. I've had to reduce the number of effects especially since i've used these effects in my "Defend the Base" type game. I will give the new command a try and hopefully it will speed thing up a little.

Before i start though, do u know if there will be any issues using Instanced objects and NG collisions??
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 9th Apr 2004 21:44 Edited at: 9th Apr 2004 21:55
I honestly don`t know, I have never used the NG dll, I mostly write games that require few collision tests, strategy or text normaly, I used multiple objects in Invaders21c and haven`t done much more since sorting the speed issue, I just use what comes with the language and cobble up compromises for the bits I can`t get it to do as I want, although for my current project I am attempting to write it in anticipation of P6, in the hopes it will work correctly when compiled under P6 even though it won`t run properly at the moment (if you can understand what I mean).

Mentor.

ps commands are

clone object objnum,sourceobj
instance object objnum,sourceobj

you won`t find instance object in the manual, just in the help system right at the start of basic 3d under clone object, cheers.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, ATI radeon 9800 pro gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 9th Apr 2004 22:18 Edited at: 9th Apr 2004 22:20
addenum cloned objects may be better, instanced objects have issues with DB`s own collision, but I don`t know about the NG dll, check this thread

http://darkbasic.thegamecreators.com/?m=forum_view&t=29424&b=1

cheers.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, ATI radeon 9800 pro gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
Maelstrom
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: United Kingdom
Posted: 9th Apr 2004 23:09
Did a few changes to my game. Clone seems to be ok but i will test it more. Instanced objects - NG goesn't like this. Crashes and returns to windows without so much as a rude message.

I would recommend NG. Its only about £10 and from my limited experience has proved very handy.

Login to post a reply

Server time is: 2024-09-22 04:32:58
Your offset time is: 2024-09-22 04:32:58