🛠️

Unreal Engine Code Review Insights

May 9, 2025

Code Review Series - Unreal Engine Developer

Introduction

  • Presenter: TH
  • Context: Code review series where viewers send code for review.
  • Current review of a 23-year-old developer's code, using a virtual machine (VM) for safety.
  • Developer's background: Works with Unreal Engine, wanted to improve C++ skills by building a game engine from scratch.

Game Engine Overview

  • Developer: Axel
  • Libraries used: Glad and STB image.
  • Platform-specific: Only supports Windows, no Mac or Linux support.
  • The game engine project is named "Greg engine."
  • Example game: "Basket Man" - a simple game included in the project.

Educational Approach

  • Building a game engine from scratch is educational but resource-intensive.
  • Not using third-party libraries can limit progress but provides deep learning.

Code Structure and Architecture

  • Project Organization: The project consists of a static library (Greg engine) and an executable (Basket Man).
  • Level Management:
    • Levels are stored as unique pointers in the engine and returned as references.
    • Concerns about using raw pointers and references instead of shared pointers for better resource management.
  • Component System:
    • Components are managed as unique pointers, which could lead to fragmented memory.
    • Suggestion to store components as continuous blocks of memory for better performance.

Window and Rendering

  • Window Management:
    • Uses low-level Windows API for window management.
    • Custom windowing code is typical for educational purposes but not for production.
  • Rendering:
    • Current rendering uses individual vertex arrays for each sprite, which is not efficient.
    • Recommendation to use a single vertex array setup with transformation matrices for efficiency.

Math Library

  • Developer provided custom matrix classes and math functionality.
  • Suggestion to use established libraries like GLM for better performance and accuracy.

Code Review Observations

  • Some static functions and data structures that should ideally be instance-based.
  • Use of static physics and camera systems, which might be better as level-specific instances.
  • Issues with warnings and errors due to missing includes and data type mismatches.
  • Some unconventional approaches to memory management and data structuring.

Rendering Performance Concerns

  • Inefficiencies noted in sprite rendering due to repeated allocations and setups.
  • Importance of batch rendering techniques for performance improvement.

Conclusion

  • Overall, the code serves as a strong educational tool.
  • Suggestions for improvement in terms of architecture, use of libraries, and rendering strategy.
  • Encouragement to continue exploring and refining the engine for learning purposes.

Additional Resources

  • Mention of Code Rabbit AI, a tool for automated code review, suitable for learning and project development.