Assembling entities in an ECS? Scripting languages?

Started by
10 comments, last by TheChubu 10 years ago


Wouldn't that defeat the purpose of an ECS? I mean, having logic leaking into the components?

There's a number of benefits of removing logic from components: it makes them more re-usable, it prevents them from having any dependencies they have on each other.

It also allows you to have external code that reasons about them as a group. For instance, if your all your rendering code does is call a Render method on every entity's Renderable component, then it has no way of intelligently sorting things by material, efficiently culling things, or changing the underlying rendering mechanisms (fwd rendering vs deferred rendering, etc...).

In this case JordanBonser's case isn't quite like that. There is an additional abstraction, since the component just contains a Mesh object, and that is the one with logic. But having a Render method on Mesh still has the same issue as above. In my opinion it would be better just to have the Mesh object expose a material, vertex buffers, etc..., and then have external rendering code that can do with those as it pleases.

Advertisement

So what you're bassically saying is to create a single Mesh component, and put there the data in Geometry, GeometryIndices, WorldTransform, Material and probably Texture components.

But then, wouldn't I have something like:

renderable = new Renderable()

if (mesh.hasTexture)

renderable.texture = createTexture();

if (mesh.hasIndices)

renderable.indices = createIndices();

And so on for each attribute that may or may not be there?

The thing about fine graining components is that the Submitters only upload the kind of entity they're interested in. So its a single upload() call with the data and thats it. The Submitters call different kinds of upload() methods accordingly to the entities they're interested in. So TexturedSubmitter uses the upload() that has texture in it.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

This topic is closed to new replies.

Advertisement