It just hit me... I remember! HORRIBLE speed loss when switching to 1.20 from 1.13. At the time, I wasn't going to use 1.20 any more and go back to 1.13. I know what you are talking about. But I think there is a solution that will allow you to take advantage of the new material commands and still run your old code.
I remember running old code in 1.20 and the performance being cut in half - or even more! There was a solution... but I can only vaguely remember it - and stupidly, I didn't write it down - but I think I know what it is.
It had to do with the built in DBC collision. I think that if you have a lot of objects set up with
SET OBJECT COLLISION TO BOXES or SPHERES
and let's say your main player is using the test
if object collision(player,0)
where all objects are being tested, then the game runs less than half as fast in 1.20 as compared to 1.13.
Try the following snippet in 1.13 and 1.20 and note the speed difference:
set display mode 800,600,32
sync on
sync rate 0
hide mouse
rem make a matrix for reference
make matrix 1,1000,1000,25,25
rem make a bunch of cubes
for obj=1 to 100
make object cube obj,25
position object obj,rnd(1000),13,rnd(1000)
set object collision to boxes obj
next obj
rem make a player object
make object cube 200,25
color object 200,rgb(255,0,0)
set object collision to boxes 200
position object 200,0,13,0
rem main
do
text 0,0,"fps = "+str$(screen fps())
rem test for collision
bang=object collision(200,0)
if bang
text 0,40,"Colliding with "+str$(bang)
endif
gosub _move_camera
sync
loop
`----------------------------------------------------------------
_move_camera:
move object 200,(upkey()-downkey())*5
yang#=wrapvalue(object angle y(200)+mousemovex())
yrotate object 200,yang#
set camera to follow object position x(200),object position y(200),object position z(200),yang#,170,100,10,1
return
`----------------------------------------------------------------
Now there are a couple of easy fixes for this (depending on the complexity needed for your collision environment).
For the above code, if I replace SET OBJECT COLLISION TO BOXES with
MAKE OBJECT COLLISION BOX, my performance is going to nearly QUADRUPLE for both 1.13 and 1.20. 1.20 and 1.13 will have the same performance.
Here's the adjusted code. Trying running it in both 1.13 and 1.20 and notice the marked performance increase:
set display mode 800,600,32
sync on
sync rate 0
hide mouse
rem make a matrix for reference
make matrix 1,1000,1000,25,25
rem make a bunch of cubes
for obj=1 to 100
make object cube obj,25
position object obj,rnd(1000),13,rnd(1000)
`set object collision to boxes obj
make object collision box obj,-12.5,-12.5,-12.5,12.5,12.5,12.5,0
next obj
rem make a player object
make object cube 200,25
color object 200,rgb(255,0,0)
`set object collision to boxes 200
make object collision box 200,-12.5,-12.5,-12.5,12.5,12.5,12.5,0
position object 200,0,13,0
rem main
do
text 0,0,"fps = "+str$(screen fps())
rem test for collision
bang=object collision(200,0)
if bang
text 0,40,"Colliding with "+str$(bang)
endif
gosub _move_camera
sync
loop
`----------------------------------------------------------------
_move_camera:
move object 200,(upkey()-downkey())*5
yang#=wrapvalue(object angle y(200)+mousemovex())
yrotate object 200,yang#
set camera to follow object position x(200),object position y(200),object position z(200),yang#,170,100,10,1
return
`----------------------------------------------------------------
If your environment is more complex, then combine as many objects as you can into 1 object. Set these groups collision to POLYGONS.
The fastest collision in DBC is STATIC COLLISION. You do not need static objects to use static collision. If you use the grouping I mentioned above, try and make some of the objects static. But make sure that the static objects only take up about 1000 to 2000 polygons or less otherwise your performance will go down.
So, I think it is how DBC 1.20 handles collision for those specific commands:
SET OBJECT COLLISION TO BOXES
and
SET OBJECT COLLISION TO SPHERES
Unless you have only a couple of objects, I would recommend never using either of those if you want to use 1.20 but instead use
MAKE OBJECT COLLISION BOX
MAKE STATIC OLLISION BOX
and
SET OBJECT COLLISION TO POLYGONS
I hope this helps. There are of course a few other optimizations:
*If an object doesn't need collision testing, turn it's collision off. All objects by default in dbc have their collision on, so after loading them or creating them, turn the collision off.
*Objects that aren't in view - hide them, and turn their collision off. If they are in and out of view constantly, then don't turn on and off the collision, that will slow things down.
*Instead of collision or in addition to collision, use a lookup table (an array) that defines areas that are passable or impassable. This is extremely fast and very useful for rectangular grid like areas.
For example, if you had a city, and it was impossible to pass through city blocks, but possible to pass through streets and such, you might make a grid where passable areas have a certain number (maybe 1) and impassable areas have a certain number (maybe 0). The array is set up relative to the world grid - maybe
And based on the entity's position, you figure out which grid square they are on or trying to go to, and you look up the value in the array. A visual of what values are stored in the array could be:
=======
|1|1|1|
|0|0|1|
|0|0|1|
|1|1|1|
=======
If the upper left hand corner is world(1,1), then the value returned is 1 which could be a road and therefore that position is passable. But just below it at world(1,2), the value is 0 so it's a city block or some other impassable thing.
*Use a collision DLL
Anyway, all of these things can be used to help performance - at the very least match what you experienced in 1.13 but still allow you to use the new commands available in 1.20.
Enjoy your day.