forked from omiya-bonsai/STOPWATCH-FluidBox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFluidBoxConfig.h
More file actions
101 lines (89 loc) · 4.25 KB
/
Copy pathFluidBoxConfig.h
File metadata and controls
101 lines (89 loc) · 4.25 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once
#include <stddef.h>
#include <stdint.h>
namespace fluidbox_config {
// Performance/quality. The solver uses fixed-size arrays, so changing this
// value changes both CPU cost and static RAM use without fragmenting the heap.
constexpr size_t kParticleCount = 400;
constexpr size_t kMaxNeighborPairs = kParticleCount * 32;
constexpr uint16_t kSimulationHz = 40;
// A measured frame costs about 32 ms, so 30 Hz is the highest safe initial
// target once rendering runs independently on the other core.
constexpr uint16_t kRenderHz = 30;
constexpr uint16_t kImuHz = 100;
constexpr uint8_t kRenderTaskCore = 0;
constexpr uint8_t kRenderTaskPriority = 1;
constexpr uint32_t kRenderTaskStackBytes = 6144;
// 3-D neighbour grid. Each cell must remain at least kSmoothingRadius wide.
constexpr int kGridX = 10;
constexpr int kGridY = 10;
constexpr int kGridZ = 2;
// Active Water tuning group (future Oil/Jelly presets can replace this block).
// Keep these coupled values together and change one category per measurement.
constexpr float kRestSpacing = 27.0f;
constexpr float kSmoothingRadius = 45.0f;
constexpr float kTimeScale = 0.085f;
constexpr float kMaxScaledDt = 0.0022f;
constexpr float kPressure = 400000.0f;
constexpr float kNearPressure = 800000.0f;
constexpr float kMaxPairDisplacement = 3.5f;
constexpr float kViscositySigma = 38.0f;
constexpr float kViscosityBeta = 0.025f;
// The M5StopWatch is round, so the virtual enclosure is a shallow cylinder
// with rounded front/back joins instead of FluidBox's rectangular enclosure.
constexpr float kBoxRadiusRatio = 0.485f;
constexpr float kBoxDepth = 96.0f;
constexpr float kWallMargin = 5.0f;
constexpr float kFrontFillet = 8.0f;
constexpr float kBackFillet = 24.0f;
constexpr float kWallRestitution = 0.20f;
constexpr float kWallFriction = 0.965f;
constexpr float kWallJitter = 0.20f;
// Motion. Acceleration samples supplied by M5Unified are in g; gyro samples
// are degrees/second. Low-pass acceleration gives the gravity direction and
// the high-pass remainder supplies shake inertia.
constexpr float kGravityAcceleration = 140000.0f;
constexpr float kShakeAccelerationPerG = 90000.0f;
constexpr float kGravityLowPassHz = 1.2f;
constexpr float kRotationGain = 0.65f;
// The official M5StopWatch demo swaps BMI270 X/Y when exposing display axes.
// These switches make real-device correction possible without solver edits.
constexpr bool kImuSwapXY = true;
constexpr bool kImuInvertX = false;
constexpr bool kImuInvertY = false;
constexpr bool kImuInvertZ = false;
// Projection and particle appearance.
constexpr float kProjectionFocal = 260.0f;
constexpr float kParticleRadius = 8.25f;
constexpr int kMaxDrawRadius = 11;
constexpr int kSpeedLevels = 64;
constexpr int kDepthLevels = 16;
constexpr float kSpeedColorMax = 5000.0f;
constexpr float kSpeedColorGamma = 0.55f;
constexpr float kFarDepthBrightness = 0.60f;
constexpr bool kHighlightsEnabled = true;
constexpr float kHighlightLift = 0.55f;
// Display. Rotation zero matches the M5StopWatch factory coordinate system.
constexpr uint8_t kDisplayRotation = 0;
constexpr uint8_t kDisplayBrightness = 230;
constexpr uint32_t kSerialStatsPeriodMs = 1000;
// Keep parameter edits inside the assumptions used by fixed-size storage,
// scheduler division, grid indexing, and LUT interpolation.
static_assert(kParticleCount > 0 && kParticleCount <= 32767,
"particle count must fit the signed grid links");
static_assert(kMaxNeighborPairs <= 65535,
"neighbor pair count must fit the public statistics type");
static_assert(kSimulationHz > 0 && kRenderHz > 0 && kImuHz > 0,
"scheduler rates must be non-zero");
static_assert(kRenderTaskCore <= 1, "ESP32-S3 core index must be 0 or 1");
static_assert(kGridX > 0 && kGridY > 0 && kGridZ > 0,
"grid dimensions must be non-zero");
static_assert(kSmoothingRadius > 0.0f && kRestSpacing > 0.0f,
"solver radii must be positive");
static_assert(kBoxDepth > 2.0f * kWallMargin,
"virtual depth must leave usable interior space");
static_assert(kDepthLevels > 1 && kSpeedLevels > 1,
"colour LUTs require at least two levels");
static_assert(kSpeedColorMax > 0.0f && kProjectionFocal > 0.0f,
"projection and colour scales must be positive");
} // namespace fluidbox_config