From c57f3a6ed00aad777871a35da2d35e2a0b67f01a Mon Sep 17 00:00:00 2001 From: isolin Date: Wed, 9 Nov 2022 22:01:08 +0000 Subject: [PATCH] Debug overlay improved --- Agro/IrradianceClient.cs | 25 +++++++++++++------- HUD/Simulation.cs | 5 ++-- addons/multiagent_system/MultiagentSystem.cs | 4 ++-- agroeco-mts3 | 2 +- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Agro/IrradianceClient.cs b/Agro/IrradianceClient.cs index b344d4b..51de59c 100644 --- a/Agro/IrradianceClient.cs +++ b/Agro/IrradianceClient.cs @@ -1,5 +1,6 @@ //#define EXPORT_OBJ //#define EXPORT_BIN +//#define USE_TRIANGLES using System.Net; using System.Net.Http.Headers; using System.Numerics; @@ -164,19 +165,21 @@ void DoTick(uint timestep, IList formations, IList obstac var meshFileFullPath = Path.Combine("..", "agroeco-mts3", meshFileName); #endif var ooc = offsetCounter; -// using var meshBinaryStream = new MemoryStream(); -// offsetCounter = ExportAsTriangles(formations, obstacles, ooc, meshBinaryStream -// #if EXPORT_OBJ -// , objWriter, obji -// #endif -// ); - using var primBinaryStream = new MemoryStream(); - offsetCounter = ExportAsPrimitives(formations, obstacles, ooc, primBinaryStream); + using var binaryStream = new MemoryStream(); +#if USE_TRIANGLES + offsetCounter = ExportAsTriangles(formations, obstacles, ooc, binaryStream +#if EXPORT_OBJ + , objWriter, obji +#endif + ); +#else + offsetCounter = ExportAsPrimitives(formations, obstacles, ooc, binaryStream); +#endif var startTime = SW.ElapsedMilliseconds; SW.Start(); - primBinaryStream.TryGetBuffer(out var byteBuffer); + binaryStream.TryGetBuffer(out var byteBuffer); #if EXPORT_BIN //if (timestep == 1999) { @@ -228,7 +231,11 @@ byte[] DebugIrr(uint timestep, IList formations, IList ob if (Singleton.IsOnline) { using var primBinaryStream = new MemoryStream(); +#if USE_TRIANGLES + var offsetCounter = ExportAsTriangles(formations, obstacles, 0, primBinaryStream); +#else var offsetCounter = ExportAsPrimitives(formations, obstacles, 0, primBinaryStream); +#endif primBinaryStream.TryGetBuffer(out var byteBuffer); if (offsetCounter > 0) { diff --git a/HUD/Simulation.cs b/HUD/Simulation.cs index a8b9fe2..704d34c 100644 --- a/HUD/Simulation.cs +++ b/HUD/Simulation.cs @@ -131,12 +131,13 @@ public void DebugIrradiance(bool flag) var o = SceneCamera.GlobalTranslation; var v = GetViewport().Size; var matrix = new float[] { o.x, o.y, o.z, b.z.x, b.z.y, b.z.z, SceneCamera.Fov, v.x, v.y }; - var imgData = IrradianceClient.DebugIrradiance(World.Timestep, World.Formations, World.Obstacles, matrix); var image = new Image(); var texture = new ImageTexture(); + + var imgData = IrradianceClient.DebugIrradiance(World.Timestep, World.Formations, World.Obstacles, matrix); if (imgData != null) - image.CreateFromData((int)Math.Round(v.x), (int)Math.Round(v.y), false, Image.Format.Rgbaf, imgData); + image.CreateFromData((int)Math.Round(v.x), (int)Math.Round(v.y), false, Image.Format.Rgbf, imgData); else image.CreateFromData(2, 2, false, Image.Format.R8, new byte[]{255, 255, 255, 255}); diff --git a/addons/multiagent_system/MultiagentSystem.cs b/addons/multiagent_system/MultiagentSystem.cs index 15d2405..ff8f22e 100755 --- a/addons/multiagent_system/MultiagentSystem.cs +++ b/addons/multiagent_system/MultiagentSystem.cs @@ -64,9 +64,9 @@ public override void _Ready() fieldSize.Z = 5; var plants = new List(); - for(float x = 0.5f; x < fieldSize.X; x += 1f) + //for(float x = 0.5f; x < fieldSize.X; x += 1f) for(float z = 0.5f; z < fieldSize.Z; z += 1f) - plants.Add(new(){ Position = new (x, -0.01f, z) }); + plants.Add(new(){ Position = new ( fieldSize.X * 0.5f, -0.01f, z) }); var obstacles = new ObstacleRequest[] { new(){ Type = "Wall", Length = 5f, Height = 3.2f, Position = new(2.5f, 0f, 1.0f)}, diff --git a/agroeco-mts3 b/agroeco-mts3 index 6fe1c63..baf7a05 160000 --- a/agroeco-mts3 +++ b/agroeco-mts3 @@ -1 +1 @@ -Subproject commit 6fe1c63437d5d1090d6d06a28f2d510c05e69b2d +Subproject commit baf7a05ec653fe03649787ed3916a2ed026f6c12