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.

AppGameKit Classic Chat / Instance and Clone speed boost?

Author
Message
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 5th Mar 2017 15:46 Edited at: 5th Mar 2017 17:39
Hi all, been quite awhile since I posted here, but I'm currently having a look at AppGameKit V2 again and am struggling a little with performance issues.

From past experience in DB I have always found instances to run significantly faster than directly created/loaded objects. However in AppGameKit, going from a simple create object loop to a create instance loop I'm not seeing massive differences. Cloning the object rather than instancing, again seems to make little to no difference to speed. Am I missing something? A grid of planes 188x88 is really slowing things down, whichever way I try and I would really want to support at least 200x200 ideally. The only advantage I can see of using an instance or clone here is the fact I can simply delete the original object rather than all of the planes when exiting. Otherwise, I'm seeing no performance gain at all, and I'm unsure if deleting the instance object only will cause memory leaks down the line or not, so I still have code to delete them all in a loop as well.

I seem to remember DB being massively faster when instancing or cloning objects...

Here's a quick example of what i'm trying to do.

That's the basics I'm using to create my floor. It's using clone object here, but rem that out and rem in instance object and you will get similar results. Similar for making them on the fly, but you want to rem the rotate as well as the createobject line to get them orientated. Obviously when you are using thousands of objects like this I want as much speed as I can squeeze out of it. I also need the individual tiles rather than a single plain, for input reasons (selecting a tile to place another object on), otherwise I could speed things up considerably . Whatever I choose here, I get similar performance I'm fairly old school, but this code should be pretty easy to read through I've taken all array parts out and left it as basic as possible(not actually tested the snippet though).

I was hoping for a massive increase in speed when changing to instances/clones but seeing no real difference

Q6600. Nvidia 260GTX. 8 Gig Ram.
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 6th Mar 2017 07:36 Edited at: 6th Mar 2017 08:17
@DVader, maybe it is not in your snipped, but "floorid=floorid+1" is strange, when floorid is not set before.

For better RAM usage you want "InstanceObject". You could think about your input. You don't realy need Tiles to position your object. If you are using RayCast, you could test, where the Ray hits the realy big plane and dived that result and multiply it by your raster and the object, you want to pose could placed like you would had Tiles.

There are also more than one performance to increase.

- Loading-Time
- Runtime

Maybe your graphics card is a good one and you can't see the performance boost at all. But on a notebook with integrated graphics the instances are "created" much faster than anything else.

200 x 200 = 40 000.

I think, for what you maybe want to do, you have to think about optimaziation a little bit more. If objects in the distance, you can make them disappear (SetObjectVisible)

You also could group objects and replace them. Maybe you have Objects, you can't realy see, because a Mountain or Building is in the way. So you don't have to draw them. If you are in a Building, you could make all objects outside the building invisible and use no transperent windows. So you can't look outside.
You also could think of ground objects, which are moving with you. Like a SkyBox. Maybe you only need 10 x 10 Planes, but you can Set the Position of the Objects while you are walking or moving.

Like [1][2][3][X][5][6][7] and if you walk to [5] it will look like [2][3][4][X][6][7][1], and next [3][4][5][X][7][1][2], so you would see in this example anytime 3 tiles left from you and right from you in every direction and staying on one. But you can move 100 Tiles away, but you don't need as much as you used.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 6th Mar 2017 14:52 Edited at: 6th Mar 2017 18:07
Yeah I missed setting the floorid to 0 at the start when writing the snippet, well spotted, it is in the actual code I'm using though I'm using that to force the object numbers to ones I want to use rather than automatic numbering.

The app I'm making isn't actually a game its a 3D database of sorts. The grid idea is what I would normally use in a 2D app but as it's 3D I wasn't sure how I could achieve the same result. As I can stack objects above the floor plane it seemed the best solution was to use the objects as an easy way to place the next down. I'm not quite sure how I could do that using a grid system for the floor. I also need each floor tile to make zones with different colours, walkways between etc. All being editable on the fly. I'm not the best with 3D stuff so try to make it as simple as it can be

I have thought about hiding objects at a set distance or even just reducing the draw distance down, perhaps that's the easy way to ensure a reasonable speed on maps bigger than 64x64. Even hidden objects slow the system down though as I have tested blank maps with different amounts of hidden objects.

Your right though, I do need to figure a way to make that floor a single plain to get a good boost in speed. I was hoping instances or clones would make a bigger difference to keep my life easier. I'll have to look more into the raycast commands to try a grid type system as you say.

It's a pity there's no way to speed things up as you can in 2D by keeping draw calls down to minimum. I was hoping clone object would possibly do that. You could do wonders with 2D simply by using an atlas texture for all sprites.

Thanks for ideas. I'll have to force myself to look at selection again and some way to reduce the floorcount

Edit- Just to let you know, I've had a look and found getting the co-ords of the raycast is a lot easier than I expected I've now got a single plane with a grid system. I'll need to work around the zone issue with a generated texture I think. Even with many objects on the floor I can run a 200x200 map at around 30 fps or so at the moment. A blank one flats out at the 60 max I have set for obvious reasons

I'm actually surprised it was as easy to get working in the end, although it did take an hour or so before it was perfect, the default offset of objects was causing issues with the line up and plane size. Sorted it out though

Q6600. Nvidia 260GTX. 8 Gig Ram.

Login to post a reply

Server time is: 2024-11-24 19:48:41
Your offset time is: 2024-11-24 19:48:41