|
11 | 11 | #include "vsg_gui_component.h" |
12 | 12 | #include "vsg_lighting.h" |
13 | 13 | #include "vsg_materials.h" |
| 14 | +#include "vsg_mooring_lines.h" |
14 | 15 | #include "vsg_radiation_surface.h" |
15 | 16 | #include "vsg_water_surface.h" |
16 | 17 |
|
@@ -128,6 +129,10 @@ void GUIImplVSG::SetWaterGridExtent(double width, double length, double center_x |
128 | 129 | << ", center: (" << center_x << ", " << center_y << ")" << std::endl; |
129 | 130 | } |
130 | 131 |
|
| 132 | +void GUIImplVSG::SetMooringLineProvider(MooringVizProvider provider) { |
| 133 | + mooring_provider_ = std::move(provider); |
| 134 | +} |
| 135 | + |
131 | 136 | void GUIImplVSG::EnsureWaterSurface() { |
132 | 137 | // Require both system and visual system to be valid. |
133 | 138 | if (!system_ || !pVis) { |
@@ -179,9 +184,30 @@ bool GUIImplVSG::IsRunning(double timestep) { |
179 | 184 | return false; |
180 | 185 | } |
181 | 186 |
|
182 | | - // Ensure water surface exists (every frame check; returns early if already done). |
| 187 | + // Reserve a scene-graph group for mooring geometry before the water |
| 188 | + // surface is created, so opaque mooring lines are rendered first and |
| 189 | + // remain visible through the transparent free surface. |
| 190 | + if (mooring_provider_ && !mooring_scene_group_) { |
| 191 | + if (auto scene = pVis->GetVSGScene()) { |
| 192 | + mooring_scene_group_ = vsg::Group::create(); |
| 193 | + scene->addChild(mooring_scene_group_); |
| 194 | + } |
| 195 | + } |
| 196 | + |
183 | 197 | EnsureWaterSurface(); |
184 | 198 |
|
| 199 | + // Mooring line visualisation (lazy-initialised on first valid data). |
| 200 | + if (mooring_provider_) { |
| 201 | + auto line_data = mooring_provider_(); |
| 202 | + if (!line_data.empty()) { |
| 203 | + if (!mooring_viz_) |
| 204 | + mooring_viz_ = std::make_unique<MooringLinesViz>(); |
| 205 | + if (!mooring_viz_->IsInitializedFor(pVis.get())) |
| 206 | + mooring_viz_->Initialize(pVis.get(), line_data, mooring_scene_group_); |
| 207 | + mooring_viz_->Update(line_data); |
| 208 | + } |
| 209 | + } |
| 210 | + |
185 | 211 | // Handle viewer settings changes. |
186 | 212 | if (viewer_settings_ && animated_water_) { |
187 | 213 | // Handle visibility toggle. |
|
0 commit comments