Skip to content

Interactive 2D wave optics simulator. Turn any image into a refractive scene, add sources, watch waves refract, diffract and interfere. Probes, intensity maps, video export.

C#

The importer keeps a source without a picked position enabled

Alexander Graef3ce801e2f0b8
diff --git a/CLAUDE.md b/CLAUDE.md
index a61d6ad..b0afdfd 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -120,7 +120,9 @@ FrameStore: native memory up to the budget, the rest in a temp file (%LOCALAPPDA
- **Colour schemes** are stop lists in `.wdscheme` XML, shipped ones embedded, user ones in
`%LOCALAPPDATA%\WaveDudeNext\ColorSchemes`, project ones in the `.wdproj`; an in-house picker edits stops;
renaming a project scheme repoints its layers. **The scene image** is embedded and follows its file on disk;
- the "glowing edges" outline overlays the pictures. **Import** of Jeroen's `configuration.json` is key for key.
+ the "glowing edges" outline overlays the pictures. **Import** of Jeroen's `configuration.json` is key for key; a source whose position was
+ never picked (`has_position` false) stays enabled at its x/y, since his program simulated it there (Example 11's
+ lattice came in disabled and ran black until 2026-10-16).
**Languages**: four string tables, live switch; converter output needs the language as an extra binding input.
- **Export**: field, intensity or both, a still of the shown frame, from the current run when fresh and full,
else a run is made first; PNG/JPEG sequences, MPEG-1, OpenDML AVI, H.264 MP4 via Media Foundation (the only
diff --git a/WaveDudeNext/Model/LegacyProject.cs b/WaveDudeNext/Model/LegacyProject.cs
index 5959af2..9a8236b 100644
--- a/WaveDudeNext/Model/LegacyProject.cs
+++ b/WaveDudeNext/Model/LegacyProject.cs
@@ -29,7 +29,7 @@ namespace WaveDudeNext.Model;
/// <list type="bullet">
/// <item><description>scene: mode, size, damping (enabled + size → <see cref="Scene.DampingEdge"/>, 0 when off), image sources, object sources, refractive index. A scene image given by a path relative to the folder is embedded when the file exists (<see cref="Scene.ImageData"/>), else the path is kept and noted.</description></item>
/// <item><description>simulation: steps, interval, solver (4th-order Laplacian, wave speed, time decay, frequency scale, intensity scale); the preview/export flags, schemes, brightness and black levels go to <see cref="Display"/>, the video settings to <see cref="Video"/>. The GPU flag is ignored (an application setting here).</description></item>
-/// <item><description>object sources: one <see cref="Source"/> each; a composite one gets a <see cref="SourceArray"/>, with the random amounts only when the composite mode is "randomize" and the flag is on. The stored emitter elements are not read: they are regenerated from the project seed, so a randomised array differs from the original (noted). A source without a position, or switched off, is imported disabled.</description></item>
+/// <item><description>object sources: one <see cref="Source"/> each; a composite one gets a <see cref="SourceArray"/>, with the random amounts only when the composite mode is "randomize" and the flag is on. The stored emitter elements are not read: they are regenerated from the project seed, so a randomised array differs from the original (noted). A source switched off is imported disabled; one whose position was never picked (<c>has_position</c> false) stays enabled at its x/y, as his program ran it (noted).</description></item>
/// <item><description>probes: one <see cref="Probe"/> each, named "Probe n"; "start after step" is 0 unless its flag is on; a scene-level <c>use_probes</c> of false deactivates them all.</description></item>
/// </list>
/// The project gets a fresh seed and the file's description. Thread-free; the caller owns the result.
@@ -176,12 +176,14 @@ public static class LegacyProject
}
source.X = Int(item, "x", 0);
source.Y = Int(item, "y", 0);
- // a source the author never placed has no position to simulate at; it comes in switched off
- bool hasPosition = Bool(item, "has_position", true);
- source.Enabled = Bool(item, "source_on", true) && hasPosition;
- if (!hasPosition)
+ // "has_position" only says whether the author picked the position; his program simulates a saved source
+ // at x/y either way (its default is 100, 100) and only leaves its marker undrawn, so the source stays on
+ // (2026-10-16, after Example 11's lattice, which has no picked position, came in disabled and the run was
+ // black; an earlier rule had switched such a source off)
+ source.Enabled = Bool(item, "source_on", true);
+ if (!Bool(item, "has_position", true))
{
- notes?.Add($"Source '{source.Name}' had no position in the original project and is imported disabled.");
+ notes?.Add($"Source '{source.Name}' had no picked position in the original project; it ran at ({source.X}, {source.Y}) there and does here.");
}
source.DetachAfter = Bool(item, "detach_source", false) ? Int(item, "detach_after_steps", 1000) : Source.NeverDetach;
source.Frequency = Int(item, "frequency", Source.DefaultLevel);
diff --git a/_tools/library_check/Program.cs b/_tools/library_check/Program.cs
index 60d9214..a995485 100644
--- a/_tools/library_check/Program.cs
+++ b/_tools/library_check/Program.cs
@@ -1452,6 +1452,13 @@ internal static class Program
Check(p.Probes[0] is { StartAfter: 600, Window: 3000, Layer: ProbeLayer.Intensity, Measurement: ProbeMeasurement.Value } && p.Probes[1] is { StartAfter: 600, Measurement: ProbeMeasurement.IntegratedValue, Kind: ProbeKind.Line }, "Example 3: start-after steps kept when their flag is on, intensity measurements");
Check(p.Sources[0] is { Array: null, DetachAfter: 670, PulseWidth: 70, OffWidth: 100, Frequency: 200 } && p.Simulation.TimeDecay == 8 && p.Display.Intensity.ColorScheme == "Copper", "a single detaching source (its unused array settings ignored), decay 8, Copper");
Check(p.Scene.Mode == SceneMode.Image && p.Scene.ImageData == null && notes.Count == 1, "image mode with the image missing: one note");
+ // Example 11's only source is a composite lattice whose position was never picked (has_position false) and
+ // which the author's program simulated at its default (100, 100) all the same: it must come in enabled, or
+ // the run is black (2026-10-16)
+ notes.Clear();
+ p = LegacyProject.Import(Path.Combine(root, "Wave_Dude_Examples", "Example11_Fluorescent_emitter", "configuration.json"), notes, out _);
+ Check(p.Sources.Count == 1 && p.Sources[0] is { Enabled: true, X: 100, Y: 100, Array: { SizeX: 41, SizeY: 21 } } && notes.Any(n => n.Contains("no picked position")),
+ "Example 11: the lattice without a picked position comes in enabled at (100, 100), noted");
bool refused = false;
string newer = Path.Combine(Path.GetTempPath(), "library_check-newer.json");