• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
cozzie

Entity manager size

10 posts in this topic

Hi all,

While working out the design of my entity manager (yet to be implemented) for my 3d engine, something got me thinking.

Up till this moment I thought I needed to redo my renderqueue, to make it possible to add extra mesh instances (linked to game objects), sort everything again etc., after changes are done in the entitymanager.

 

But then I thought, let's say you have a level of a game, you will now on forehand how many game objects will be in the level, same for 'bad guys'/ enemies etc. Ok, there will be less, depending on the state of the game objects. But not taking mesh instances into account in a sorted list is easy (just leave out the ones that are not visible, for rendering, culling, physics etc).

 

In short; do you see reasons why to have both an entity manager and renderqueue that are able to add new game objects (entities) / mesh instances (renderqueue)?

 

The only reason I could think of is having a multiplayer game where new players are added. On the other hand, you can then take a 'max' of players and use these 'slots' so you don't need to add anyway (just 'enable'/ make them visible when needed).

 

Any input is appreciated, since it will help me decide if redoing my renderqueue is worth all the effort.

Edited by cozzie
0

Share this post


Link to post
Share on other sites

I guess it depends on what kind of game you are building. For instance, in a RPG, are your spells considered to be their own entities? If so whenever you cast a spell (eg a fireball), you will have to create a new entity. The same applies to summoned creatures. I thought about the same issue. I'm building a turn-based tactical game and for instance if a spaceship fires a missile that takes more than one turn to reach the target, I'd like the player to be able to select it, so it would have to be an entity in its own regards.

1

Share this post


Link to post
Share on other sites


In short; do you see reasons why to have both an entity manager and renderqueue that are able to add new game objects (entities) / mesh instances (renderqueue)?

A render queue is usually a thing where renderables that are actually to be rendered just now are collected. It is filled with rendering jobs (to use the most abstract term here) resulting from iterating the scene and passing visibility culling. The queued jobs will be sorted by some engine dependent criterions. It will be re-build for the next loop run (if we let coherency mechanisms aside). As such, a render queue doesn't know what game objects are, and hence there is no meaning in comparing it with the entity manager. This is decoupling in action, so to say.

 

IMHO "new game objects" defines a game object that is added to the scene. For sure this has an impact on the game object management, but it should not have an impact on the render queue. If the object is in the scene, and it passes visibility culling, then it is (indirectly, but nevertheless) added on-the-fly to the render queue.

 

Do you have another definition of render queue? 

1

Share this post


Link to post
Share on other sites

Thanks both.

My definition of the renderqueue is mostly the same, except this part "it will be re-build for the next loop run". I don't do this currently, I just loop through all sorted renderables and fill an index with the indices of renderables that are visible. Those are rendered.

 

I only sort / re-build at initial startup, if I would do this say each frame (or 2) then the question would be answered and I would simply add the representation of new game objects (mesh instances) to the renderqueue and sort everything again.

 

Currectly/ when knowing the number of game objects (and their representation through mesh instances), I only have to build and sort the renderqueue once (other then just looping through them and picking the visible ones). Performance wise this could be an advantage, not having to rebuild and sort each frame.

 

On the 'cons' side, I have to be prepared for enough game objects, leading to mesh instances, to manage the whole scene.

 

As you said, the issue indeed is not with game object management, I don't need sorting etc. there. That would be 'just' a std::vector of my game object class.

Edited by cozzie
0

Share this post


Link to post
Share on other sites

Handling a variable number of items in your render queue shouldn't present any architectural difficulty. Just use a vector instead of a fixed array.

 

The question is do you want to support variable numbers of meshes being drawn over the course of your game. Not allowing it would be a strange limitation, since you pretty much already have all the functionality you need to implement it: a basic implementation could just "re-evaluate" the objects each frame and resort them. If sorting performance ever becomes an issue, then you could add more logic/complexity to address that.

 

Not allowing the creation/deletion of gameobjects over the course of a game seems like an onerous limitation. It might force to make less-that-ideal choices about how to implement various game features.

1

Share this post


Link to post
Share on other sites

Thanks phil_t. That sounds logical. Maybe I can find a way to 'insert' new objects in the renderqeue efficiently, otherwise I'll sort on material groups, materials and meshes etc. ONLY after an object is inserted. It doesn't seem necessary to 're-sort' when an object is 'removed' or nothing changes.

0

Share this post


Link to post
Share on other sites

Without knowing the kind of game you making, it's difficult to say. But if the sorting bothers you have you thought about a bubble sort?

 

Say an object appears nearby: it gets sent to the end of the render queue, where a single pass bubble sort is performed every frame. It will very quickly find it's right location in the queue (maybe for front to back rendering). And it's a really cheap way of sorting. The only time it really matters if when other objects are in direct line of sight - which will only be a small number anyway.

0

Share this post


Link to post
Share on other sites

Alternatively, maintain several types of lists, sort them individually and then splice them together at the end.

1

Share this post


Link to post
Share on other sites
That's a good suggestion. If I know (flag) which objects in the renderqueue are static, I could have 2 lists. In the end it's the question which performs better, just add/ insert and sort the whole thing versus having 2 lists and merging/ sorting them.

On the other hand, it might be useful for other reason two, too have a separate "bucket" for all dynamic objects (where insertion etc. Is expected)
0

Share this post


Link to post
Share on other sites

What if you have security cameras / picture-in-picture, or planar-reflectors (mirrors/water), or shadow-mapping? All of those require an extra "camera", which means the "renderable entities" have to be drawn again, but perhaps with a completely different sorting order.

There's a good reason that most games have more that a single 'view' of the scene wink.png

2

Share this post


Link to post
Share on other sites
Thanks hodgman. That confirms my feeling that it's good to think ahead and have more mesh instance indices with groups of objects. So I can go through then for different purposes (like the ones you mentioned).
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0