r/gameenginedevs

Architecture advice

Hi!
I am building a game engine in C++. The architectural style I am using is OOP with composition, also known as a "bag-style" ECS. The main difference from a classic ECS is that entities are not just IDs but rather own their components and can operate on them via Add, Remove, Get, and so on. The components themselves consist of data and behavior, and the systems are interested in specific entities that have specific components. For example, the Render system needs entities with Transform and Sprite components.

The current architecture is designed around the fact that this is C++ and there is no garbage collector. Additionally, it is not a good idea to destroy entities in the middle of the main loop. Because of this, I created an EntityManager that can create entities, mark entities for removal, flush pending entities, check if an entity is alive, and return a raw pointer to an entity so you can access it. The whole thing works because the manager uses EntityIds, meaning you cannot have dangling pointers. The manager also manages the entities' lifetimes so it always flushes them at the end of the frame.

For now everything is good, but after adding the BaseComponent and all the logic into the entity, I reached a point where adding or removing a component changes the entity's signature. A signature is a bitset where every index represents a different component, like Transform, Collider, or Sprite. If the bit is 0, the entity does not have it; if it is 1, it does. When this changes, every system needs to check the entity so it can add it if it now suits the criteria, remove it if it does not, or simply ignore it.

To achieve this, I either need something like a RegisterManager and make it a singleton, or I need to make every entity hold a pointer or reference to this RegisterManager, which feels wasteful. At the same time, singletons or making the pointer or reference static inside the entities are considered bad practices. I also want my components to have unique, recyclable IDs just like my entities. To do that, I need to make something like a ComponentFactory. When a component is destroyed, it should notify this factory to recycle the ID, which means the factory either has to be a singleton too or the entities will have to hold yet another extra pointer. One fix is to create an event bus to handle cases like this, but then again, either the event bus is a singleton or everything that uses it must hold a pointer or reference to it.

So my question is, is there a pattern or hierarchy I can follow to avoid this repetition of every entity holding a pointer to the same system, or should I just stop listening to the posts online that say singletons are bad because of multithreading and unit testing, and just make a few?

Thanks in advance!

reddit.com
u/Outside-Text-9273 — 11 hours ago

Q: Custom game engine starting point

Hey guys, I am trying to make a game engine just for study purposes and to deep-dive into scalable, performance based applications. But I’m confused right now. So far, I have implemented a logging system, it’s a wrapper for spdlog and I have also implemented verbosity levels and custom log category macros based on the UE source code. Now, to start, I want to build a module manager system and custom allocators. But I don’t know what my starting point should be custom allocators? Base class interfaces? Module manager? I’m stuck in an unorganized mass.

reddit.com
u/MrArshaX — 1 day ago
▲ 82 r/gameenginedevs+11 crossposts

Progress on my threejs Voxel engine

I've fully redone the engine for my game AresRPG, I aim for an immersive world! this is a browser based MMORPG on Sui

u/Sceat — 1 day ago
▲ 202 r/gameenginedevs+2 crossposts

Redundancy seen in AAA game engines

Ever wonder what the compiler actually spits out when you use those generic math library functions for every single case because you couldn't be bothered enough writing a specialized, hardcoded implementation?

I've been reversing game engines to study how they constructed their fundamental Transformation matrices and handled temporal jitter logic when I spotted a lot of avoidable overhead and "over-engineering" across multiple engines, the main culprit being the heavy, general-purpose math wrappers being used everywhere for every little thing... That said expect no performance gain this is simply for fun that I wrote this blog!

I’ll theorize how the original C++ code was written, show the unoptimized reality of what the compiler spat out, and then showcase how it could have been better optimized.

zero-irp.github.io
u/zer0_1rp — 4 days ago

Do you think its realistic to expect that a major part of PC gamers would have RT capable GPUs by 2032 to integrate certain RT features by default?

Hi everyone, im really curious about implementing two ray traced features into my game engine: RT shadows and RTAO. Both are really cheap, and if done well, could run on toaster level Turing cards. I would like to implement them as a default rendering feature, as its both visually better than other techniques and easier to build around as a developer.

As a quick checkup, I wanted to see how the current market is like according to to Steam. Since I'm not good at Python, I let Claude make me a CSV reader for the data, so beware of possible inaccuracies. But this is the number of users that have ray tracing capable GPUs according to Steam:

The method of checking was if the name included \"RTX\", or \"ARC\", or \"RX\" followed by a number greater or equal to 6000

As we can see by the graph, the number of users with ray tracing capable GPUs is rising steadily. In addition to that, as far as I'm aware, no GPU vendor manufactures non ray tracing GPUs anymore, which means that it will only get higher from now on.

By now, a small number of games like Indiana Jones and Doom have shipped with ray tracing as a requirement. And so my question for this discussion: Can an indie developer in 2032 ship out a game with mandatory Ray traced shadows and RTAO?

Edit: spelling

reddit.com
u/TheWidrolo — 3 days ago
▲ 7 r/gameenginedevs+2 crossposts

Training an Agent to walk using Procedural Animation in my Game Engine

I am creating my own game/simulation engine since the last year. Currently i am working on procedural animation and i am having some trouble with it.

The agent can learn to balance itself easily but when i try to teach it to walk, it just can't do it. It moves only about 0.5 on x-axis and then falls down or the episode ends(due to maximum time limit). I am kind of new to this procedural animation stuff but i've seen some videos of it.

Can anyone tell me what's the problem with my agent here? The max reward won't rise after a few episodes. I am using Box2D for physics and LibTorch to train the network. The renderer is made by me using OpenGL and i am trying to train it to walk from scratch.

I don't think that the problem is in physics or other parts of my engine. Because i've already did pendulum and double pendulum balancing and training the agent to stand without falling down. But i can't get it to walk. I've tried different reward functions but those did not work so i added a very simple reward that can tell the agent to always move forward. Here is my current reward related code : -

// Forward velocity reward
float reward = vel.x * 0.1f;

// Penalize falling - if root body angle is too large
float angle = rootBody->GetAngle();
if (std::abs(angle) > 1.2f) // ~70 degrees
{
reward -= 1.0f;
brainComponent.done = true; // end episode on fall
}

Btw i am using the PPO algorithm here. If this much info is not enough, feel free to ask me. It would be nice to hear your suggestions if you've worked on this kind of problem before.

https://reddit.com/link/1umh562/video/jsw7otnv31bh1/player

reddit.com
u/ZealousidealDesk3261 — 2 days ago

I built a 150kb game with my custom JavaScript engine that runs instantly in any modern web browser at 60 FPS - quick gameplay trailer

I've been building NULLFRAME for about a year. It basically started as a free browser game inspired by Superhot and Super Meat Boy, but after a year of development in my spare time I think it's turned into something pretty good.

One thing I'm quite proud of is that it's built 100% from scratch with my own engine, written entirely in vanilla JavaScript - no frameworks or third party engines. The whole game weighs in at around 150kb and all graphics and sound effects are dynamically generated via code. There are no sprites etc and I think it gives it quite a unique look and feel.

It runs instantly in any modern browser at 60fps (provided you have a reasonable CPU) and there's a map editor where you can create your own challenges and share them instantly via a URL - the map data is all encoded into the URL using my own custom compression system, so nothing is stored on the server. My friends have been experimenting with it for a few months and say its great fun.

As mentioned, gameplay borrows elements of both Superhot and Super Meat Boy, though I like to think it has its own style. Gameplay requires careful strategy, but it also allows you to enjoy some carnage from time to time too.

I'm planning on releasing for free later this year. I'm a dev of 25 years, and nowadays I basically just build the odd game for fun. I think possibly it has some commercial appeal, but I have no idea about marketing games.

Just to clarify:

- the anime intro was produced by a commercial animation studio specifically for the game (I know people get suspicious, so wanted to be clear).

- trailer music purchased from AudioJungle

- Some additional ambient effects in the trailer sourced from Pixabay and then modified by me.

u/Suitable-Season-4847 — 2 days ago

Carrots game Engine ( no code )

Hello everyone, Our team is currently developing a game engine called Carrots Engine, and one of the biggest challenges we've encountered isn't technical—it's convincing developers to try a new tool in the first place. The game engine space is already dominated by mature solutions with large communities, extensive documentation, and years of production use. This led us to an interesting question: What actually makes a new game engine worth trying? As developers, what factors matter most to you? Performance? Workflow? Documentation? Open-source development? Visual scripting? Community size? Long-term trust and maintenance? Something else entirely? We're currently evaluating our roadmap and would genuinely appreciate feedback from experienced developers about what they consider essential before investing time in a new engine. For anyone curious about the project, here's what we're working on: Open-source development 2D and 3D workflows Multiplayer support Visual game creation tools Project: https://github.com/Carrotstudio0/Carrots-Game-Engine/releases I'm less interested in promoting the engine and more interested in understanding how developers evaluate new tools today. Looking forward to hearing your perspectives.

https://preview.redd.it/qyt34pabeyah1.png?width=1086&format=png&auto=webp&s=8ee38a6708b8c59e75ff4286e3253c34b20b2c0c

https://preview.redd.it/li8ogsabeyah1.jpg?width=1553&format=pjpg&auto=webp&s=dfa9d3184c35081522778283786f90c202d4e3d9

https://preview.redd.it/pueolxabeyah1.png?width=1919&format=png&auto=webp&s=0a2061c05a182f55d44b008c64fccc7e94d48ab3

https://preview.redd.it/k4hqmyabeyah1.jpg?width=1748&format=pjpg&auto=webp&s=8c9279751c7e17727c7b6c7322499373d4811889

https://preview.redd.it/c9d6f0bbeyah1.jpg?width=794&format=pjpg&auto=webp&s=6f425c4badbbc0d1af74219ccc5afe1c2bbd79aa

https://preview.redd.it/oa9482bbeyah1.png?width=720&format=png&auto=webp&s=04b8e4b50f27664d0a091b78732bdf0b3a741e34

reddit.com
u/Ok-Disaster548 — 3 days ago
▲ 17 r/gameenginedevs+1 crossposts

Hey Guys I have been working on my Game Engine for almost 5 years, and this is the second episode in the series where I go over how i added lighting, check it out its really interesting!!

youtu.be
u/ValousN — 2 days ago

Reflection System Better Than Unreal's

https://preview.redd.it/z4dja2f4rxah1.png?width=903&format=png&auto=webp&s=286841b52ea2983fa22b8d11bb925eb019f2c3d4

Fully Generated Code

This is the reflection system in my game engine.

I'm currently building an ECS and a component-based architecture similar to Unity in C++, so I created this reflection system to make everything easier.

Without any manual registration, you can expose data simply by writing [[export]]. You can also combine attributes, for example:

[[export, range(min, max)]]

The architecture is somewhat similar to C#'s attribute system (or at least that's what I was aiming for). It automatically generates .generated.hxx files inside the .generated/ directory.

I built it using Clang and LLVM.

These videos were very useful resources while developing it:

https://youtu.be/YhzKDiQe1To?si=TR51WKoKEkzwOlj7

https://youtu.be/IR_L1xf4PrU?si=xcZB5DYYPLFsCcdL

reddit.com
u/Single_Tailor_7310 — 3 days ago

Stress testing my Python engine

900 skeleton models loaded in and running a steady 30fps with about ~18% gpu usage.

Obviously not the most optimised but I will definetly be working on engine performance.

u/KlutzyAd8601 — 4 days ago

Looking for people to make DirectX12 Engine Together

Hello everyone!
I'm looking for someone who enjoys graphics programming and engine development and want to build something together. My goal isn't to create "project with contributors," but to work as a team, learn from each other, discuss engine architecture, graphics, rendering, tooling, and generally grow as better software engineers.

This is the project:
https://github.com/TheColGateMann4/Teleios-Engine

If you are interested feel free to send me a message here, or add me on discord. My @ there is "thecolgatemann"

https://preview.redd.it/b2y40x2mcpah1.png?width=1599&format=png&auto=webp&s=b3141519861f920428290233b24f34b92910b8b6

reddit.com
u/Prestigious_Lake_161 — 4 days ago