feat: distance-based LOD for trail rendering#48
Open
MikePehel wants to merge 1 commit intomavlink:mainfrom
Open
feat: distance-based LOD for trail rendering#48MikePehel wants to merge 1 commit intomavlink:mainfrom
MikePehel wants to merge 1 commit intomavlink:mainfrom
Conversation
Add level-of-detail segment skipping for both directional trails and speed ribbons. Segments are culled based on squared distance to camera: - >400m: render every 2nd segment - >1500m: render every 4th segment This uses only float arithmetic (no sqrt) so it's essentially free. In benchmarks with 64 drones and speed ribbons enabled, LOD reduces median frame time by ~12% (8.7ms → 7.7ms at 1080p). The vertex savings from LOD give us headroom to increase the trail buffer from 1800 to 2700 samples (1.5×) without any performance regression. Longer trails improve situational awareness in multi-drone scenarios where vehicles may be spread across a wide area. Pure C float math — no platform-specific code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sqrt), so the LOD check itself is essentially freeBenchmark results (64 drones, speed ribbon, 1080p, 30s run)
LOD consistently saves ~1ms per frame (~12%) with ribbons enabled. The larger buffer adds negligible cost (<0.3ms difference at same LOD setting).
Changes
src/vehicle.c: LOD skip logic in both trail rendering loops,TRAIL_MAX1800 → 2700src/vehicle.h:extern bool trail_lod_enableddeclarationTest plan