Skip to content

Commit

Permalink
Debug overlay improved
Browse files Browse the repository at this point in the history
  • Loading branch information
isolin committed Nov 9, 2022
1 parent e139681 commit c57f3a6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
25 changes: 16 additions & 9 deletions Agro/IrradianceClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//#define EXPORT_OBJ
//#define EXPORT_BIN
//#define USE_TRIANGLES
using System.Net;
using System.Net.Http.Headers;
using System.Numerics;
Expand Down Expand Up @@ -164,19 +165,21 @@ void DoTick(uint timestep, IList<IFormation> formations, IList<IObstacle> 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)
{
Expand Down Expand Up @@ -228,7 +231,11 @@ byte[] DebugIrr(uint timestep, IList<IFormation> formations, IList<IObstacle> 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)
{
Expand Down
5 changes: 3 additions & 2 deletions HUD/Simulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand Down
4 changes: 2 additions & 2 deletions addons/multiagent_system/MultiagentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public override void _Ready()
fieldSize.Z = 5;

var plants = new List<PlantRequest>();
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)},
Expand Down
2 changes: 1 addition & 1 deletion agroeco-mts3

0 comments on commit c57f3a6

Please sign in to comment.