forked from omega13a/stargen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccretionRecorder.h
More file actions
60 lines (52 loc) · 2.01 KB
/
Copy pathAccretionRecorder.h
File metadata and controls
60 lines (52 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef ACCRETION_RECORDER_H
#define ACCRETION_RECORDER_H
#include <utility>
#include <vector>
#include "structs.h" // dust, planet
/**
* @brief Passive recorder for the accretion process, used by the viewer's
* "formation" visualization. It is OPT-IN: accrete only captures frames when a
* recorder pointer is set (default null), so the normal generation path
* (stargen, the harness, goldens) is byte-identical and determinism is unchanged.
* It only READS state and copies it -- no RNG, no mutation of the accretion.
*/
struct AccretionBand {
double inner; // AU
double outer; // AU
bool hasDust;
bool hasGas;
};
struct AccretionBody {
double a; // semi-major axis, AU
double e; // eccentricity
double mass; // solar masses
};
struct AccretionFrame {
std::vector<AccretionBand> bands;
std::vector<AccretionBody> bodies;
};
class AccretionRecorder {
public:
std::vector<AccretionFrame> frames;
/** Append a snapshot of the current dust lanes and planetesimal list. */
void capture(const std::vector<dust>& dust_bands, planet* head) {
AccretionFrame f;
f.bands.reserve(dust_bands.size());
for (const auto& b : dust_bands) {
// peekInnerEdge() (not getInnerEdge()) -- the latter mutates the band
// when inner>=outer, which would perturb the deterministic accretion.
double inner = static_cast<double>(b.peekInnerEdge());
double outer = static_cast<double>(b.getOuterEdge());
if (inner >= outer) {
continue; // degenerate/empty band; nothing to draw
}
f.bands.push_back({inner, outer, b.getDustPresent(), b.getGasPresent()});
}
for (planet* p = head; p != nullptr; p = p->next_planet) {
f.bodies.push_back({static_cast<double>(p->getA()), static_cast<double>(p->getE()),
static_cast<double>(p->getMass())});
}
frames.push_back(std::move(f));
}
};
#endif // ACCRETION_RECORDER_H