$darkmode
#include "trail_renderer.h"#include "gl_common.h"#include "log.h"#include "nbody.h"#include "profiler.h"#include "shader.h"#include "utils.h"#include <cglm/vec3.h>#include <math.h>#include <string.h>Enumerations | |
| enum | { MAX_TRAIL_VERTICES = NBODY_MAX_BODIES * ((TRAIL_MAX_POINTS * 2) + 4) } |
Functions | |
| static void | ring_push (TrailRing *ring, const double pos[3], float timestamp) |
| static void | ring_get (const TrailRing *ring, int age, vec3 out) |
| static float | ring_get_timestamp (const TrailRing *ring, int age) |
| bool | trail_renderer_init (TrailRenderer *trail, int body_count) |
| Initializes trail renderer resources. More... | |
| void | trail_renderer_set_color (TrailRenderer *trail, int body_index, const vec3 color) |
| Sets the trail color for a specific body. More... | |
| void | trail_renderer_cleanup (TrailRenderer *trail) |
| Releases all GPU resources. More... | |
| void | trail_renderer_clear (TrailRenderer *trail) |
| Clears all recorded trail data (e.g., on simulation reset). More... | |
| void | trail_renderer_record (TrailRenderer *trail, const NBodySim *sim, float delta_time) |
| Records current positions from the simulation. More... | |
| static int | build_ribbon (const TrailRing *ring, const vec3 color, const vec3 cam_pos, float body_radius, float hdr_intensity, float max_width, float current_time, float trail_duration, TrailVertex *out) |
| void | trail_renderer_draw (TrailRenderer *trail, mat4 view, mat4 proj, vec3 cam_pos) |
| Builds ribbon geometry and renders all trails. More... | |
| float | trail_renderer_get_duration (const TrailRenderer *trail) |
| Returns the current trail duration in seconds. More... | |
| void | trail_renderer_set_duration (TrailRenderer *trail, float duration) |
| Sets the trail duration in seconds (clamped to valid range). More... | |
Variables | |
| static const float | EPSILON = 1e-6F |
| static const float | MIN_BODY_RADIUS = 0.3F |
| static const float | HALF = 0.5F |
|
static |
|
static |
|
static |
|
static |
| void trail_renderer_cleanup | ( | TrailRenderer * | tr | ) |
Releases all GPU resources.
| tr | Pointer to the trail renderer. |
| void trail_renderer_clear | ( | TrailRenderer * | tr | ) |
Clears all recorded trail data (e.g., on simulation reset).
| tr | Pointer to the trail renderer. |
| void trail_renderer_draw | ( | TrailRenderer * | tr, |
| mat4 | view, | ||
| mat4 | proj, | ||
| vec3 | cam_pos | ||
| ) |
Builds ribbon geometry and renders all trails.
Must be called while the HDR framebuffer is active (before post-process). Sets up additive blending and depth-read-no-write internally.
| tr | Pointer to the trail renderer. |
| view | View matrix. |
| proj | Projection matrix. |
| cam_pos | Camera world position. |
| float trail_renderer_get_duration | ( | const TrailRenderer * | trail | ) |
Returns the current trail duration in seconds.
| bool trail_renderer_init | ( | TrailRenderer * | tr, |
| int | body_count | ||
| ) |
Initializes trail renderer resources.
| tr | Pointer to the trail renderer. |
| body_count | Number of bodies to track. |
| void trail_renderer_record | ( | TrailRenderer * | tr, |
| const NBodySim * | sim, | ||
| float | delta_time | ||
| ) |
Records current positions from the simulation.
Should be called every frame. Internally rate-limits sampling.
| tr | Pointer to the trail renderer. |
| sim | Pointer to the N-body simulation. |
| delta_time | Frame delta time. |
| void trail_renderer_set_color | ( | TrailRenderer * | tr, |
| int | body_index, | ||
| const vec3 | color | ||
| ) |
Sets the trail color for a specific body.
| tr | Pointer to the trail renderer. |
| body_index | Body index. |
| color | HDR emissive color (values > 1.0 are valid for bloom). |
| void trail_renderer_set_duration | ( | TrailRenderer * | trail, |
| float | duration | ||
| ) |
Sets the trail duration in seconds (clamped to valid range).
|
static |
|
static |
|
static |