Skip to main content

So, if everything that needs to be processed comes from a base class with the think function, the game engine could store everything on a list and, on every frame, loop through it and call that function.

On a first look, this idea is reasonable, but it can take too much resources, if the game has a lot of entities..

Actually putting everything in one big list is usually less than desirable; if you were to group the entities in lists based on, for example, their type, you could better distribute the processing over multiple threads. For example if you know all entities of type Foo never interact with any other entities during the simulation phase, you can offload them entirely. If they were scattered willy-nilly throughout some big singular list this would be much harder to do.

You don't necessarily even need to be deriving everything from a common base class at that point; Source goes fairly overboard with inheritance abuse for wouldwhat could otherwise be implemented as data in that respect.

You will of course always have an upper limit on the number of entities you can process per frame, even if you start offloading work to other cores. There's no way around that, you just need to have an idea of what that limit is in your implementation and takes steps to alleviate it (proper culling of processing phases on objects that won't need them, avoiding over-granularity in objects, et cetera).

So, if everything that needs to be processed comes from a base class with the think function, the game engine could store everything on a list and, on every frame, loop through it and call that function.

On a first look, this idea is reasonable, but it can take too much resources, if the game has a lot of entities..

Actually putting everything in one big list is usually less than desirable; if you were to group the entities in lists based on, for example, their type, you could better distribute the processing over multiple threads. For example if you know all entities of type Foo never interact with any other entities during the simulation phase, you can offload them entirely. If they were scattered willy-nilly throughout some big singular list this would be much harder to do.

You don't necessarily even need to be deriving everything from a common base class at that point; Source goes fairly overboard with inheritance abuse for would could otherwise be implemented as data in that respect.

You will of course always have an upper limit on the number of entities you can process per frame, even if you start offloading work to other cores. There's no way around that, you just need to have an idea of what that limit is in your implementation and takes steps to alleviate it (proper culling of processing phases on objects that won't need them, avoiding over-granularity in objects, et cetera).

So, if everything that needs to be processed comes from a base class with the think function, the game engine could store everything on a list and, on every frame, loop through it and call that function.

On a first look, this idea is reasonable, but it can take too much resources, if the game has a lot of entities..

Actually putting everything in one big list is usually less than desirable; if you were to group the entities in lists based on, for example, their type, you could better distribute the processing over multiple threads. For example if you know all entities of type Foo never interact with any other entities during the simulation phase, you can offload them entirely. If they were scattered willy-nilly throughout some big singular list this would be much harder to do.

You don't necessarily even need to be deriving everything from a common base class at that point; Source goes fairly overboard with inheritance abuse for what could otherwise be implemented as data in that respect.

You will of course always have an upper limit on the number of entities you can process per frame, even if you start offloading work to other cores. There's no way around that, you just need to have an idea of what that limit is in your implementation and takes steps to alleviate it (proper culling of processing phases on objects that won't need them, avoiding over-granularity in objects, et cetera).

Source Link
user1430
user1430

So, if everything that needs to be processed comes from a base class with the think function, the game engine could store everything on a list and, on every frame, loop through it and call that function.

On a first look, this idea is reasonable, but it can take too much resources, if the game has a lot of entities..

Actually putting everything in one big list is usually less than desirable; if you were to group the entities in lists based on, for example, their type, you could better distribute the processing over multiple threads. For example if you know all entities of type Foo never interact with any other entities during the simulation phase, you can offload them entirely. If they were scattered willy-nilly throughout some big singular list this would be much harder to do.

You don't necessarily even need to be deriving everything from a common base class at that point; Source goes fairly overboard with inheritance abuse for would could otherwise be implemented as data in that respect.

You will of course always have an upper limit on the number of entities you can process per frame, even if you start offloading work to other cores. There's no way around that, you just need to have an idea of what that limit is in your implementation and takes steps to alleviate it (proper culling of processing phases on objects that won't need them, avoiding over-granularity in objects, et cetera).