⚡ Performance & Optimization
When building UI systems that track 3D world objects, performance is often the biggest bottleneck. Calculating screen projections, checking distance, and updating UI widgets for hundreds of markers every frame can quickly destroy a game’s frame rate.
MageIt World Markers was built from the ground up to solve these exact bottlenecks using industry-standard optimization techniques.
1. Time-Sliced Visibility Testing (Chunking)
Section titled “1. Time-Sliced Visibility Testing (Chunking)”Calculating distance to determine marker visibility is computationally expensive.
- The Solution: The subsystem uses a variable called
MarkerVisibilityTestChunkSize(default: 10). Instead of testing every single marker every frame, the plugin processes checks in small batches (“chunks”) across multiple frames. This guarantees a perfectly smooth frame rate while keeping the UI responsive.
2. Math Optimizations (Squared Distances)
Section titled “2. Math Optimizations (Squared Distances)”Calculating true distances requires the Square Root mathematical operation (sqrt()), which is notoriously slow for
CPUs when executed hundreds of times per tick.
- The Solution: The plugin’s core API relies heavily on Squared Distances
(
GetDistanceToPlayerSquared(),CrosshairInteractionRadiusSquared). By comparing squared values instead of true distances, the plugin avoids the CPU penalty entirely, making crosshair interactions and distance-culling incredibly lightweight.
3. Efficient Architecture
Section titled “3. Efficient Architecture”- ULocalPlayerSubsystem: By inheriting from
ULocalPlayerSubsystem, the plugin avoids the overhead of spawning invisible “Manager Actors” into your world. The subsystem exists solely in memory, tied directly to the player, and requires zero manual lifecycle management. - Event-Driven UI: The
UMageItWorldMarkerWidgetdoes not use the heavyNativeTickfunction to update its state. Instead, it is purely event-driven. It only recalculates logic when the subsystem explicitly tells it that its position, visibility, or focus state has changed. - Compile-Time Speed: The plugin’s C++ source code strictly adheres to the IWYU (Include What You Use) principle, utilizing Forward Declarations wherever possible. This ensures that adding this plugin to a C++ project will not bloat your compilation times.