From 243e430eabc7fbab3113f5721474ed3aae959cda Mon Sep 17 00:00:00 2001 From: emil28092005 Date: Thu, 18 Jun 2026 22:25:11 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20auto-detect=20sphere=20from=20model=20pa?= =?UTF-8?q?th=20=E2=80=94=20correct=20sphere=20colliders?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AiCommandProcessor: checks if modelPath contains 'sphere' (case-insensitive) - If detected as sphere: uses DynamicSphere physics body (was DynamicBox) - Works with both shape='sphere' parameter and modelPath='Content/sphere.obj' - No need to explicitly pass shape parameter when loading sphere.obj --- src/Engine.AI/AiCommandProcessor.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Engine.AI/AiCommandProcessor.cs b/src/Engine.AI/AiCommandProcessor.cs index 1d2cb64..7995fef 100644 --- a/src/Engine.AI/AiCommandProcessor.cs +++ b/src/Engine.AI/AiCommandProcessor.cs @@ -79,8 +79,11 @@ public sealed class AiCommandProcessor private AiCommandResult SpawnModel(SpawnModelCommand command) { + var isSphere = command.Shape == "sphere" || + command.ModelPath.Contains("sphere", StringComparison.OrdinalIgnoreCase); + Mesh mesh; - if (command.Shape == "sphere") + if (isSphere) { var r = MathF.Max(MathF.Max(command.Scale.X, command.Scale.Y), command.Scale.Z) * 0.5f; mesh = ProceduralMesh.CreateSphere(r, 24, 12, new Vector3(0.5f, 0.6f, 0.9f)); @@ -97,7 +100,7 @@ public sealed class AiCommandProcessor if (command.Physics) { var maxScale = MathF.Max(MathF.Max(command.Scale.X, command.Scale.Y), command.Scale.Z); - if (command.Shape == "sphere") + if (isSphere) { entity.Set(RigidBody.DynamicSphere(maxScale * 0.5f, mass: maxScale * 2f)); } @@ -107,7 +110,7 @@ public sealed class AiCommandProcessor } } - return AiCommandResult.Ok($"Spawned entity '{command.Name}' with shape '{command.Shape}' (id {(ulong)entity.Id})."); + return AiCommandResult.Ok($"Spawned entity '{command.Name}' ({(isSphere ? "sphere" : "cube")}) (id {(ulong)entity.Id})."); } private AiCommandResult SetTransform(SetTransformCommand command)