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.

DarkBASIC Professional Discussion / Slow code execution

Years of Service
User Offline
Joined: 19th Sep 2002
Posted: 24th Sep 2002 22:28
I've just tried adding a loop to process the nearest object to the camera. I've 500 objects (yes I know it's a lot but they are needed) with a few line to work out the distance of each object. There code works fine but the frame rate drops from around 60 - 20 fps to around 5 fps

After a bit of playing around it appears it's the loop it's self that causing the slow down. Trying a for next loop for 500 with nothing in the loop still causes the slowdown.

It must be able to process faster than this. After all there's processing power to draw a huge bsp map plus 500 objects with all the maths that goes with it and still play a mp3 while getting not bad frame rates.

Anyone else having these sort of problems?

global NearDist as float
global NearestObject as integer

function ProcessObjects
local n as integer
local dx# as float
local dy# as float
local dz# as float
local dist# as float

NearDist = 999999
NearestObject = -1

for n = 1 to 500
dx#=camera position x(0)-object position x(n)
dy#=camera position y(0)-object position y(n)
dz#=camera position z(0)-object position z(n)
if dist#

Login to post a reply

Server time is: 2019-11-17 20:40:25
Your offset time is: 2019-11-17 20:40:25