From 5dc463a9f2c1791c65c1326484fc30c688aed4bb Mon Sep 17 00:00:00 2001 From: Abdiel Lopez <48071553+PaperPrototype@users.noreply.github.com> Date: Fri, 24 Apr 2026 04:55:18 -0400 Subject: [PATCH 1/5] All primitive colliders working --- .../Physics/Colliders/BoxCollider.cs | 8 +++++ .../Physics/Colliders/CapsuleCollider.cs | 8 +++++ .../Physics/Colliders/ConeCollider.cs | 8 +++++ .../Physics/Colliders/CylinderCollider.cs | 8 +++++ .../Physics/Colliders/MeshCollider.cs | 36 +++++++++++++++++++ .../Physics/Colliders/SphereCollider.cs | 8 +++++ 6 files changed, 76 insertions(+) diff --git a/Prowl.Runtime/Components/Physics/Colliders/BoxCollider.cs b/Prowl.Runtime/Components/Physics/Colliders/BoxCollider.cs index 1cb1c9897..7a610eb2a 100644 --- a/Prowl.Runtime/Components/Physics/Colliders/BoxCollider.cs +++ b/Prowl.Runtime/Components/Physics/Colliders/BoxCollider.cs @@ -27,4 +27,12 @@ public Float3 Size } public override RigidBodyShape[] CreateShapes() => [new BoxShape(Maths.Max(size.X, 0.01f), Maths.Max(size.Y, 0.01f), Maths.Max(size.Z, 0.01f))]; + + public override void DrawGizmos() + { + Float4x4 matrix = Float4x4.CreateTRS(Transform.Position, Transform.Rotation * Quaternion.FromEuler(Rotation), Transform.LossyScale); + Debug.PushMatrix(matrix); + Debug.DrawWireCube(Center, size * 0.5f, Color.Green); + Debug.PopMatrix(); + } } diff --git a/Prowl.Runtime/Components/Physics/Colliders/CapsuleCollider.cs b/Prowl.Runtime/Components/Physics/Colliders/CapsuleCollider.cs index 5b15b233e..47d12c0f4 100644 --- a/Prowl.Runtime/Components/Physics/Colliders/CapsuleCollider.cs +++ b/Prowl.Runtime/Components/Physics/Colliders/CapsuleCollider.cs @@ -36,4 +36,12 @@ public float Height } public override RigidBodyShape[] CreateShapes() => [new CapsuleShape(Maths.Max(radius, 0.01f), Maths.Max(height, 0.01f))]; + + public override void DrawGizmos() + { + Float4x4 matrix = Float4x4.CreateTRS(Transform.Position, Transform.Rotation * Quaternion.FromEuler(Rotation), Transform.LossyScale); + Debug.PushMatrix(matrix); + Debug.DrawWireCapsule(Center + new Float3(0, -height * 0.5f, 0), Center + new Float3(0, height * 0.5f, 0), radius, Color.Green); + Debug.PopMatrix(); + } } diff --git a/Prowl.Runtime/Components/Physics/Colliders/ConeCollider.cs b/Prowl.Runtime/Components/Physics/Colliders/ConeCollider.cs index c6ea5e82f..ba4c52a1c 100644 --- a/Prowl.Runtime/Components/Physics/Colliders/ConeCollider.cs +++ b/Prowl.Runtime/Components/Physics/Colliders/ConeCollider.cs @@ -36,4 +36,12 @@ public float Height } public override RigidBodyShape[] CreateShapes() => [new ConeShape(Maths.Max(radius, 0.01f), Maths.Max(height, 0.01f))]; + + public override void DrawGizmos() + { + Float4x4 matrix = Float4x4.CreateTRS(Transform.Position, Transform.Rotation * Quaternion.FromEuler(Rotation), Transform.LossyScale); + Debug.PushMatrix(matrix); + Debug.DrawWireCone(Center + new Float3(0, -height * 0.5f, 0), new Float3(0, height, 0), radius, Color.Green); + Debug.PopMatrix(); + } } diff --git a/Prowl.Runtime/Components/Physics/Colliders/CylinderCollider.cs b/Prowl.Runtime/Components/Physics/Colliders/CylinderCollider.cs index e87d56ef1..d0e14a757 100644 --- a/Prowl.Runtime/Components/Physics/Colliders/CylinderCollider.cs +++ b/Prowl.Runtime/Components/Physics/Colliders/CylinderCollider.cs @@ -36,4 +36,12 @@ public float Height } public override RigidBodyShape[] CreateShapes() => [new CylinderShape(Maths.Max(radius, 0.01f), Maths.Max(height, 0.01f))]; + + public override void DrawGizmos() + { + Float4x4 matrix = Float4x4.CreateTRS(Transform.Position, Transform.Rotation * Quaternion.FromEuler(Rotation), Transform.LossyScale); + Debug.PushMatrix(matrix); + Debug.DrawWireCylinder(Center, Quaternion.Identity, radius, height, Color.Green); + Debug.PopMatrix(); + } } diff --git a/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs b/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs index c9ba5b1e1..a75b18131 100644 --- a/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs +++ b/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs @@ -8,6 +8,7 @@ using Prowl.Echo; using Prowl.Runtime.Resources; +using Prowl.Vector; namespace Prowl.Runtime; @@ -96,6 +97,41 @@ public override void OnEnable() } } + public override void DrawGizmos() + { + var m = mesh.Res; + if (m == null) + { + var mr = GetComponent(); + if (mr != null) m = mr.Mesh.Res; + } + if (m == null) return; + + Float3[] vertices = m.Vertices; + uint[] indices = m.Indices; + if (vertices == null || indices == null) return; + + Float4x4 matrix = Float4x4.CreateTRS(Transform.Position, Transform.Rotation * Quaternion.FromEuler(Rotation), Transform.LossyScale); + Debug.PushMatrix(matrix); + + for (int i = 0; i + 2 < indices.Length; i += 3) + { + uint i0 = indices[i], i1 = indices[i + 1], i2 = indices[i + 2]; + if (i0 >= vertices.Length || i1 >= vertices.Length || i2 >= vertices.Length) + continue; + + Float3 v0 = vertices[i0] + Center; + Float3 v1 = vertices[i1] + Center; + Float3 v2 = vertices[i2] + Center; + + Debug.DrawLine(v0, v1, Color.Green); + Debug.DrawLine(v1, v2, Color.Green); + Debug.DrawLine(v2, v0, Color.Green); + } + + Debug.PopMatrix(); + } + private static List ToTriangleList(Mesh mesh) { var vertices = mesh.Vertices; diff --git a/Prowl.Runtime/Components/Physics/Colliders/SphereCollider.cs b/Prowl.Runtime/Components/Physics/Colliders/SphereCollider.cs index 0ffc91309..ae5e85987 100644 --- a/Prowl.Runtime/Components/Physics/Colliders/SphereCollider.cs +++ b/Prowl.Runtime/Components/Physics/Colliders/SphereCollider.cs @@ -25,4 +25,12 @@ public float Radius } public override RigidBodyShape[] CreateShapes() => [new SphereShape(Maths.Max(radius, 0.01f))]; + + public override void DrawGizmos() + { + Float4x4 matrix = Float4x4.CreateTRS(Transform.Position, Transform.Rotation * Quaternion.FromEuler(Rotation), Transform.LossyScale); + Debug.PushMatrix(matrix); + Debug.DrawWireSphere(Center, radius, Color.Green); + Debug.PopMatrix(); + } } From 3bf58ba3bfd03332b5285cb97bad3394fc06b57a Mon Sep 17 00:00:00 2001 From: Abdiel Lopez <48071553+PaperPrototype@users.noreply.github.com> Date: Fri, 24 Apr 2026 05:26:30 -0400 Subject: [PATCH 2/5] Update MeshCollider.cs --- .../Physics/Colliders/MeshCollider.cs | 127 +++++++++++++++++- 1 file changed, 123 insertions(+), 4 deletions(-) diff --git a/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs b/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs index a75b18131..789c74c4a 100644 --- a/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs +++ b/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs @@ -1,7 +1,9 @@ // This file is part of the Prowl Game Engine // Licensed under the MIT License. See the LICENSE file in the project root for details. +using System; using System.Collections.Generic; +using System.Reflection; using Jitter2.Collision.Shapes; using Jitter2.LinearMath; @@ -46,6 +48,43 @@ public bool Convex } } + // Cached convex hull shape for gizmo drawing — rebuilt when mesh or convex flag changes. + [SerializeIgnore] private ConvexHullShape? _cachedConvexShape; + + // Reflection fields for ConvexHullShape internals, initialized once. + private static bool s_reflectionReady; + private static FieldInfo? s_hullVerticesField; // ConvexHullShape.vertices (CHullVector[]) + private static FieldInfo? s_hullIndicesField; // ConvexHullShape.indices (CHullTriangle[]) + private static FieldInfo? s_hullShiftField; // ConvexHullShape.shifted (JVector — hull centroid) + private static FieldInfo? s_chullVertexField; // CHullVector.Vertex (JVector) + private static FieldInfo? s_chullIndexAField; // CHullTriangle.IndexA (UInt16) + private static FieldInfo? s_chullIndexBField; // CHullTriangle.IndexB + private static FieldInfo? s_chullIndexCField; // CHullTriangle.IndexC + + private int convexGizmosDrawCount = 0; + private int concaveGizmosDrawCount = 0; + + private static void EnsureReflection() + { + if (s_reflectionReady) return; + s_reflectionReady = true; + + const BindingFlags F = BindingFlags.NonPublic | BindingFlags.Instance; + s_hullVerticesField = typeof(ConvexHullShape).GetField("vertices", F); + s_hullIndicesField = typeof(ConvexHullShape).GetField("indices", F); + s_hullShiftField = typeof(ConvexHullShape).GetField("shifted", F); + + if (s_hullVerticesField?.FieldType.GetElementType() is Type vt) + s_chullVertexField = vt.GetField("Vertex", BindingFlags.Public | BindingFlags.Instance); + + if (s_hullIndicesField?.FieldType.GetElementType() is Type it) + { + s_chullIndexAField = it.GetField("IndexA", BindingFlags.Public | BindingFlags.Instance); + s_chullIndexBField = it.GetField("IndexB", BindingFlags.Public | BindingFlags.Instance); + s_chullIndexCField = it.GetField("IndexC", BindingFlags.Public | BindingFlags.Instance); + } + } + public override RigidBodyShape[] CreateShapes() { var m = mesh.Res; @@ -83,6 +122,13 @@ public override RigidBodyShape[] CreateShapes() } } + public override void OnValidate() + { + _cachedConvexShape = null; + base.OnValidate(); + Debug.Log("OnInvalidate called"); + } + public override void OnEnable() { base.OnEnable(); @@ -107,13 +153,37 @@ public override void DrawGizmos() } if (m == null) return; + Float4x4 matrix = Float4x4.CreateTRS(Transform.Position, Transform.Rotation * Quaternion.FromEuler(Rotation), Transform.LossyScale); + Debug.PushMatrix(matrix); + + if (convex) + { + DrawConvexHullGizmo(m); + convexGizmosDrawCount++; + if (convexGizmosDrawCount <= 10) + { + Debug.LogWarning("DrawConvexHullGizmo"); + } + } + else + { + DrawMeshWireframeGizmo(m); + concaveGizmosDrawCount++; + if (concaveGizmosDrawCount <= 10) + { + Debug.LogWarning("DrawMeshWireframeGizmo"); + } + } + + Debug.PopMatrix(); + } + + private void DrawMeshWireframeGizmo(Mesh m) + { Float3[] vertices = m.Vertices; uint[] indices = m.Indices; if (vertices == null || indices == null) return; - Float4x4 matrix = Float4x4.CreateTRS(Transform.Position, Transform.Rotation * Quaternion.FromEuler(Rotation), Transform.LossyScale); - Debug.PushMatrix(matrix); - for (int i = 0; i + 2 < indices.Length; i += 3) { uint i0 = indices[i], i1 = indices[i + 1], i2 = indices[i + 2]; @@ -128,8 +198,57 @@ public override void DrawGizmos() Debug.DrawLine(v1, v2, Color.Green); Debug.DrawLine(v2, v0, Color.Green); } + } - Debug.PopMatrix(); + private void DrawConvexHullGizmo(Mesh m) + { + if (_cachedConvexShape == null) + { + var triangles = ToTriangleList(m); + if (triangles.Count == 0) return; + _cachedConvexShape = new ConvexHullShape(triangles); + } + + EnsureReflection(); + + if (s_hullVerticesField == null || s_hullIndicesField == null || + s_chullVertexField == null || s_chullIndexAField == null || + s_chullIndexBField == null || s_chullIndexCField == null) + return; + + var hullVerts = (Array?)s_hullVerticesField.GetValue(_cachedConvexShape); + var hullTris = (Array?)s_hullIndicesField.GetValue(_cachedConvexShape); + var shift = s_hullShiftField?.GetValue(_cachedConvexShape) is JVector sv ? sv : JVector.Zero; + + if (hullVerts == null || hullTris == null) return; + + for (int i = 0; i < hullTris.Length; i++) + { + object? tri = hullTris.GetValue(i); + if (tri == null) continue; + + int ia = (ushort)(s_chullIndexAField.GetValue(tri) ?? (ushort)0); + int ib = (ushort)(s_chullIndexBField.GetValue(tri) ?? (ushort)0); + int ic = (ushort)(s_chullIndexCField.GetValue(tri) ?? (ushort)0); + + object? va = hullVerts.GetValue(ia); + object? vb = hullVerts.GetValue(ib); + object? vc = hullVerts.GetValue(ic); + if (va == null || vb == null || vc == null) continue; + + // Stored vertices are shifted to centroid-at-origin; add shift to recover mesh-local positions. + var jva = (JVector)(s_chullVertexField.GetValue(va) ?? JVector.Zero) + shift; + var jvb = (JVector)(s_chullVertexField.GetValue(vb) ?? JVector.Zero) + shift; + var jvc = (JVector)(s_chullVertexField.GetValue(vc) ?? JVector.Zero) + shift; + + Float3 a = new Float3(jva.X, jva.Y, jva.Z) + Center; + Float3 b = new Float3(jvb.X, jvb.Y, jvb.Z) + Center; + Float3 c = new Float3(jvc.X, jvc.Y, jvc.Z) + Center; + + Debug.DrawLine(a, b, Color.Green); + Debug.DrawLine(b, c, Color.Green); + Debug.DrawLine(c, a, Color.Green); + } } private static List ToTriangleList(Mesh mesh) From 0d73faa9d8de7ed69073efa01faebdaf23f4245d Mon Sep 17 00:00:00 2001 From: Abdiel Lopez <48071553+PaperPrototype@users.noreply.github.com> Date: Fri, 24 Apr 2026 11:30:46 -0400 Subject: [PATCH 3/5] Convex MeshCollider debug gizmo now working --- .../Physics/Colliders/MeshCollider.cs | 89 +++---------------- 1 file changed, 10 insertions(+), 79 deletions(-) diff --git a/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs b/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs index 789c74c4a..e87c641a6 100644 --- a/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs +++ b/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs @@ -1,9 +1,7 @@ // This file is part of the Prowl Game Engine // Licensed under the MIT License. See the LICENSE file in the project root for details. -using System; using System.Collections.Generic; -using System.Reflection; using Jitter2.Collision.Shapes; using Jitter2.LinearMath; @@ -51,40 +49,6 @@ public bool Convex // Cached convex hull shape for gizmo drawing — rebuilt when mesh or convex flag changes. [SerializeIgnore] private ConvexHullShape? _cachedConvexShape; - // Reflection fields for ConvexHullShape internals, initialized once. - private static bool s_reflectionReady; - private static FieldInfo? s_hullVerticesField; // ConvexHullShape.vertices (CHullVector[]) - private static FieldInfo? s_hullIndicesField; // ConvexHullShape.indices (CHullTriangle[]) - private static FieldInfo? s_hullShiftField; // ConvexHullShape.shifted (JVector — hull centroid) - private static FieldInfo? s_chullVertexField; // CHullVector.Vertex (JVector) - private static FieldInfo? s_chullIndexAField; // CHullTriangle.IndexA (UInt16) - private static FieldInfo? s_chullIndexBField; // CHullTriangle.IndexB - private static FieldInfo? s_chullIndexCField; // CHullTriangle.IndexC - - private int convexGizmosDrawCount = 0; - private int concaveGizmosDrawCount = 0; - - private static void EnsureReflection() - { - if (s_reflectionReady) return; - s_reflectionReady = true; - - const BindingFlags F = BindingFlags.NonPublic | BindingFlags.Instance; - s_hullVerticesField = typeof(ConvexHullShape).GetField("vertices", F); - s_hullIndicesField = typeof(ConvexHullShape).GetField("indices", F); - s_hullShiftField = typeof(ConvexHullShape).GetField("shifted", F); - - if (s_hullVerticesField?.FieldType.GetElementType() is Type vt) - s_chullVertexField = vt.GetField("Vertex", BindingFlags.Public | BindingFlags.Instance); - - if (s_hullIndicesField?.FieldType.GetElementType() is Type it) - { - s_chullIndexAField = it.GetField("IndexA", BindingFlags.Public | BindingFlags.Instance); - s_chullIndexBField = it.GetField("IndexB", BindingFlags.Public | BindingFlags.Instance); - s_chullIndexCField = it.GetField("IndexC", BindingFlags.Public | BindingFlags.Instance); - } - } - public override RigidBodyShape[] CreateShapes() { var m = mesh.Res; @@ -159,20 +123,10 @@ public override void DrawGizmos() if (convex) { DrawConvexHullGizmo(m); - convexGizmosDrawCount++; - if (convexGizmosDrawCount <= 10) - { - Debug.LogWarning("DrawConvexHullGizmo"); - } } else { DrawMeshWireframeGizmo(m); - concaveGizmosDrawCount++; - if (concaveGizmosDrawCount <= 10) - { - Debug.LogWarning("DrawMeshWireframeGizmo"); - } } Debug.PopMatrix(); @@ -209,41 +163,18 @@ private void DrawConvexHullGizmo(Mesh m) _cachedConvexShape = new ConvexHullShape(triangles); } - EnsureReflection(); - - if (s_hullVerticesField == null || s_hullIndicesField == null || - s_chullVertexField == null || s_chullIndexAField == null || - s_chullIndexBField == null || s_chullIndexCField == null) - return; - - var hullVerts = (Array?)s_hullVerticesField.GetValue(_cachedConvexShape); - var hullTris = (Array?)s_hullIndicesField.GetValue(_cachedConvexShape); - var shift = s_hullShiftField?.GetValue(_cachedConvexShape) is JVector sv ? sv : JVector.Zero; - - if (hullVerts == null || hullTris == null) return; + // ShapeHelper.Tessellate is the same API Jitter uses in RigidBody.DebugDraw. + // It generates an approximation of the shape surface via spherical subdivision + // projected onto the support function — no reflection required. + List hullTris = ShapeHelper.Tessellate(_cachedConvexShape, 2); + JVector shift = _cachedConvexShape.Shift; - for (int i = 0; i < hullTris.Length; i++) + foreach (var tri in hullTris) { - object? tri = hullTris.GetValue(i); - if (tri == null) continue; - - int ia = (ushort)(s_chullIndexAField.GetValue(tri) ?? (ushort)0); - int ib = (ushort)(s_chullIndexBField.GetValue(tri) ?? (ushort)0); - int ic = (ushort)(s_chullIndexCField.GetValue(tri) ?? (ushort)0); - - object? va = hullVerts.GetValue(ia); - object? vb = hullVerts.GetValue(ib); - object? vc = hullVerts.GetValue(ic); - if (va == null || vb == null || vc == null) continue; - - // Stored vertices are shifted to centroid-at-origin; add shift to recover mesh-local positions. - var jva = (JVector)(s_chullVertexField.GetValue(va) ?? JVector.Zero) + shift; - var jvb = (JVector)(s_chullVertexField.GetValue(vb) ?? JVector.Zero) + shift; - var jvc = (JVector)(s_chullVertexField.GetValue(vc) ?? JVector.Zero) + shift; - - Float3 a = new Float3(jva.X, jva.Y, jva.Z) + Center; - Float3 b = new Float3(jvb.X, jvb.Y, jvb.Z) + Center; - Float3 c = new Float3(jvc.X, jvc.Y, jvc.Z) + Center; + // Hull vertices are CoM-centered; add Shift to convert back to mesh-local space. + Float3 a = new Float3(tri.V0.X + shift.X, tri.V0.Y + shift.Y, tri.V0.Z + shift.Z) + Center; + Float3 b = new Float3(tri.V1.X + shift.X, tri.V1.Y + shift.Y, tri.V1.Z + shift.Z) + Center; + Float3 c = new Float3(tri.V2.X + shift.X, tri.V2.Y + shift.Y, tri.V2.Z + shift.Z) + Center; Debug.DrawLine(a, b, Color.Green); Debug.DrawLine(b, c, Color.Green); From f8d067c0a628b37ad6e2c02d977374d30e712173 Mon Sep 17 00:00:00 2001 From: Abdiel Lopez <48071553+PaperPrototype@users.noreply.github.com> Date: Fri, 24 Apr 2026 11:46:14 -0400 Subject: [PATCH 4/5] Cache ShapeHelper.Tessellate --- .../Components/Physics/Colliders/MeshCollider.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs b/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs index e87c641a6..3b7db101f 100644 --- a/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs +++ b/Prowl.Runtime/Components/Physics/Colliders/MeshCollider.cs @@ -46,8 +46,9 @@ public bool Convex } } - // Cached convex hull shape for gizmo drawing — rebuilt when mesh or convex flag changes. + // Cached convex hull shape and its tessellation for gizmo drawing — rebuilt when mesh or convex flag changes. [SerializeIgnore] private ConvexHullShape? _cachedConvexShape; + [SerializeIgnore] private List? _cachedHullTris; public override RigidBodyShape[] CreateShapes() { @@ -89,6 +90,7 @@ public override RigidBodyShape[] CreateShapes() public override void OnValidate() { _cachedConvexShape = null; + _cachedHullTris = null; base.OnValidate(); Debug.Log("OnInvalidate called"); } @@ -163,13 +165,10 @@ private void DrawConvexHullGizmo(Mesh m) _cachedConvexShape = new ConvexHullShape(triangles); } - // ShapeHelper.Tessellate is the same API Jitter uses in RigidBody.DebugDraw. - // It generates an approximation of the shape surface via spherical subdivision - // projected onto the support function — no reflection required. - List hullTris = ShapeHelper.Tessellate(_cachedConvexShape, 2); + _cachedHullTris ??= ShapeHelper.Tessellate(_cachedConvexShape, 2); JVector shift = _cachedConvexShape.Shift; - foreach (var tri in hullTris) + foreach (JTriangle tri in _cachedHullTris) { // Hull vertices are CoM-centered; add Shift to convert back to mesh-local space. Float3 a = new Float3(tri.V0.X + shift.X, tri.V0.Y + shift.Y, tri.V0.Z + shift.Z) + Center; From aced4048c23939f181a38fbb5d44ddc066a05ee6 Mon Sep 17 00:00:00 2001 From: Abdiel Lopez <48071553+PaperPrototype@users.noreply.github.com> Date: Mon, 27 Apr 2026 09:11:40 -0400 Subject: [PATCH 5/5] Completely remove IDebugDrawer --- .../Physics/Constraints/PhysicsConstraint.cs | 11 +---- .../Physics/Constraints/PhysicsJoint.cs | 10 +---- .../Components/Physics/Rigidbody3D.cs | 4 +- Prowl.Runtime/Physics/JitterGizmosDrawer.cs | 40 ------------------- 4 files changed, 3 insertions(+), 62 deletions(-) delete mode 100644 Prowl.Runtime/Physics/JitterGizmosDrawer.cs diff --git a/Prowl.Runtime/Components/Physics/Constraints/PhysicsConstraint.cs b/Prowl.Runtime/Components/Physics/Constraints/PhysicsConstraint.cs index 2f5375976..7829af47a 100644 --- a/Prowl.Runtime/Components/Physics/Constraints/PhysicsConstraint.cs +++ b/Prowl.Runtime/Components/Physics/Constraints/PhysicsConstraint.cs @@ -73,16 +73,7 @@ public override void OnValidate() public override void DrawGizmos() { - Constraint constraint = GetConstraint(); - if (constraint != null && GameObject?.Scene?.Physics?.World != null) - { - try - { - constraint.DebugDraw(JitterGizmosDrawer.Instance); - } - catch (NotImplementedException) - { } - } + // TODO DrawGizmos } /// diff --git a/Prowl.Runtime/Components/Physics/Constraints/PhysicsJoint.cs b/Prowl.Runtime/Components/Physics/Constraints/PhysicsJoint.cs index 03fd67e90..5735bba03 100644 --- a/Prowl.Runtime/Components/Physics/Constraints/PhysicsJoint.cs +++ b/Prowl.Runtime/Components/Physics/Constraints/PhysicsJoint.cs @@ -36,14 +36,6 @@ protected override void DestroyConstraint() public override void DrawGizmos() { - if (joint != null && GameObject?.Scene?.Physics?.World != null) - { - try - { - joint.DebugDraw(JitterGizmosDrawer.Instance); - } - catch (NotImplementedException) - { } - } + // TODO DrawGizmos } } diff --git a/Prowl.Runtime/Components/Physics/Rigidbody3D.cs b/Prowl.Runtime/Components/Physics/Rigidbody3D.cs index bc641836a..dbb49f0aa 100644 --- a/Prowl.Runtime/Components/Physics/Rigidbody3D.cs +++ b/Prowl.Runtime/Components/Physics/Rigidbody3D.cs @@ -364,9 +364,7 @@ public override void FixedUpdate() public override void DrawGizmos() { - if (_body == null || _body.Handle.IsZero) return; - - _body.DebugDraw(JitterGizmosDrawer.Instance); + // TODO DrawGizmos } public override void OnEnable() diff --git a/Prowl.Runtime/Physics/JitterGizmosDrawer.cs b/Prowl.Runtime/Physics/JitterGizmosDrawer.cs deleted file mode 100644 index d6c8e6317..000000000 --- a/Prowl.Runtime/Physics/JitterGizmosDrawer.cs +++ /dev/null @@ -1,40 +0,0 @@ -// This file is part of the Prowl Game Engine -// Licensed under the MIT License. See the LICENSE file in the project root for details. - -using Jitter2; -using Jitter2.LinearMath; - -using Prowl.Vector; - -namespace Prowl.Runtime; - -public class JitterGizmosDrawer : IDebugDrawer -{ - static JitterGizmosDrawer m_Instance; - public static JitterGizmosDrawer Instance => m_Instance ??= new(); - public Color color { get; set; } = new Color(0, 255, 0, 128); - - public void DrawPoint(in JVector p) - { - Float3 center = new(p.X, p.Y, p.Z); - Debug.DrawSphere(center, 0.1f, color, 8); - } - - public void DrawSegment(in JVector pA, in JVector pB) - { - Float3 a = new(pA.X, pA.Y, pA.Z); - Float3 b = new(pB.X, pB.Y, pB.Z); - Debug.DrawLine(a, b, color); - } - - public void DrawTriangle(in JVector pA, in JVector pB, in JVector pC) - { - Float3 a = new(pA.X, pA.Y, pA.Z); - Float3 b = new(pB.X, pB.Y, pB.Z); - Float3 c = new(pC.X, pC.Y, pC.Z); - //Debug.DrawTriangle(a, b, c, color); - Debug.DrawLine(a, b, color); - Debug.DrawLine(b, c, color); - Debug.DrawLine(c, a, color); - } -}