Skip to content

Commit ac41383

Browse files
committed
Remove IDebugDraw, because btIDebugDraw is not an interface
1 parent 083ca36 commit ac41383

28 files changed

+280
-463
lines changed

BulletSharp/Collision/CollisionWorld.cs

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ public class CollisionWorld : IDisposable
611611
{
612612
internal IntPtr Native;
613613

614-
internal IDebugDraw _debugDrawer;
614+
private DebugDraw _debugDrawer;
615615
private BroadphaseInterface _broadphase;
616616
private Dispatcher _dispatcher;
617617
private DispatcherInfo _dispatchInfo;
@@ -846,36 +846,15 @@ public BroadphaseInterface Broadphase
846846

847847
public AlignedCollisionObjectArray CollisionObjectArray { get; protected set; }
848848

849-
public IDebugDraw DebugDrawer
849+
public DebugDraw DebugDrawer
850850
{
851851
get => _debugDrawer;
852852
set
853853
{
854-
if (_debugDrawer != null)
854+
if (_debugDrawer != value)
855855
{
856-
if (_debugDrawer == value) {
857-
return;
858-
}
859-
860-
// Clear IDebugDraw wrapper
861-
if (!(_debugDrawer is DebugDraw)) {
862-
//btIDebugDrawer_delete(btCollisionWorld_getDebugDrawer(Native));
863-
}
864-
}
865-
866-
_debugDrawer = value;
867-
if (value == null) {
868-
btCollisionWorld_setDebugDrawer(Native, IntPtr.Zero);
869-
return;
870-
}
871-
872-
DebugDraw cast = value as DebugDraw;
873-
if (cast != null) {
874-
btCollisionWorld_setDebugDrawer(Native, cast._native);
875-
} else {
876-
// Create IDebugDraw wrapper, remember to delete it
877-
IntPtr wrapper = DebugDraw.CreateWrapper(value, false);
878-
btCollisionWorld_setDebugDrawer(Native, wrapper);
856+
_debugDrawer = value;
857+
btCollisionWorld_setDebugDrawer(Native, value != null ? value._native : IntPtr.Zero);
879858
}
880859
}
881860
}

BulletSharp/Collision/ConvexCast.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public class CastResult : IDisposable
1010
{
1111
internal IntPtr Native;
1212

13+
private DebugDraw _debugDrawer;
14+
1315
internal CastResult(IntPtr native)
1416
{
1517
Native = native;
@@ -41,10 +43,14 @@ public float AllowedPenetration
4143
set => btConvexCast_CastResult_setAllowedPenetration(Native, value);
4244
}
4345

44-
public IDebugDraw DebugDrawer
46+
public DebugDraw DebugDrawer
4547
{
46-
get => BulletSharp.DebugDraw.GetManaged(btConvexCast_CastResult_getDebugDrawer(Native));
47-
set => btConvexCast_CastResult_setDebugDrawer(Native, BulletSharp.DebugDraw.GetUnmanaged(value));
48+
get => _debugDrawer;
49+
set
50+
{
51+
_debugDrawer = value;
52+
btConvexCast_CastResult_setDebugDrawer(Native, value != null ? value._native : IntPtr.Zero);
53+
}
4854
}
4955

5056
public float Fraction

BulletSharp/Collision/ConvexPenetrationDepthSolver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ internal ConvexPenetrationDepthSolver(IntPtr native)
1515

1616
public bool CalcPenDepth(VoronoiSimplexSolver simplexSolver, ConvexShape convexA,
1717
ConvexShape convexB, Matrix transA, Matrix transB, out Vector3 v, out Vector3 pa,
18-
out Vector3 pb, IDebugDraw debugDraw)
18+
out Vector3 pb, DebugDraw debugDraw)
1919
{
2020
return btConvexPenetrationDepthSolver_calcPenDepth(Native, simplexSolver.Native,
2121
convexA.Native, convexB.Native, ref transA, ref transB, out v, out pa,
22-
out pb, DebugDraw.GetUnmanaged(debugDraw));
22+
out pb, debugDraw != null ? debugDraw._native : IntPtr.Zero);
2323
}
2424

2525
public void Dispose()

BulletSharp/Collision/DiscreteCollisionDetectorInterface.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ internal DiscreteCollisionDetectorInterface(IntPtr native)
120120
Native = native;
121121
}
122122

123-
public void GetClosestPoints(ClosestPointInput input, Result output, IDebugDraw debugDraw,
123+
public void GetClosestPoints(ClosestPointInput input, Result output, DebugDraw debugDraw,
124124
bool swapResults = false)
125125
{
126126
btDiscreteCollisionDetectorInterface_getClosestPoints(Native, input.Native,
127-
output.Native, DebugDraw.GetUnmanaged(debugDraw), swapResults);
127+
output.Native, debugDraw != null ? debugDraw._native : IntPtr.Zero, swapResults);
128128
}
129129

130130
public void Dispose()

BulletSharp/Collision/Dispatcher.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public float ConvexConservativeDistanceThreshold
3737
set => btDispatcherInfo_setConvexConservativeDistanceThreshold(Native, value);
3838
}
3939

40-
public IDebugDraw DebugDraw
40+
public DebugDraw DebugDraw
4141
{
42-
get => BulletSharp.DebugDraw.GetManaged(btDispatcherInfo_getDebugDraw(Native));
43-
set => btDispatcherInfo_setDebugDraw(Native, BulletSharp.DebugDraw.GetUnmanaged(value));
42+
get => DebugDraw.GetManaged(btDispatcherInfo_getDebugDraw(Native));
43+
set => btDispatcherInfo_setDebugDraw(Native, value != null ? value._native : IntPtr.Zero);
4444
}
4545

4646
public bool DeterministicOverlappingPairs

BulletSharp/Collision/GjkPairDetector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ public GjkPairDetector(ConvexShape objectA, ConvexShape objectB, int shapeTypeA,
2727
}
2828

2929
public void GetClosestPointsNonVirtual(ClosestPointInput input, Result output,
30-
IDebugDraw debugDraw)
30+
DebugDraw debugDraw)
3131
{
3232
btGjkPairDetector_getClosestPointsNonVirtual(Native, input.Native,
33-
output.Native, DebugDraw.GetUnmanaged(debugDraw));
33+
output.Native, debugDraw != null ? debugDraw._native : IntPtr.Zero);
3434
}
3535

3636
public void SetIgnoreMargin(bool ignoreMargin)

BulletSharp/Dynamics/ConstraintSolver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ internal ConstraintSolver(IntPtr native, bool preventDelete)
2121
_preventDelete = preventDelete;
2222
}
2323

24-
public void AllSolved(ContactSolverInfo __unnamed0, IDebugDraw __unnamed1)
24+
public void AllSolved(ContactSolverInfo __unnamed0, DebugDraw __unnamed1)
2525
{
26-
btConstraintSolver_allSolved(Native, __unnamed0.Native, DebugDraw.GetUnmanaged(__unnamed1));
26+
btConstraintSolver_allSolved(Native, __unnamed0.Native, __unnamed1 != null ? __unnamed1._native : IntPtr.Zero);
2727
}
2828

2929
public void PrepareSolve(int __unnamed0, int __unnamed1)

BulletSharp/Dynamics/Featherstone/MultiBodyConstraint.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public void CreateConstraintRows(MultiBodyConstraintArray constraintRows,
2626
data.Native, infoGlobal.Native);
2727
}
2828
*/
29-
public void DebugDraw(IDebugDraw drawer)
29+
public void DebugDraw(DebugDraw drawer)
3030
{
31-
btMultiBodyConstraint_debugDraw(Native, BulletSharp.DebugDraw.GetUnmanaged(drawer));
31+
btMultiBodyConstraint_debugDraw(Native, drawer._native);
3232
}
3333

3434
public void FinalizeMultiDof()

BulletSharp/Dynamics/IAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace BulletSharp
77
{
88
public interface IAction
99
{
10-
void DebugDraw(IDebugDraw debugDrawer);
10+
void DebugDraw(DebugDraw debugDrawer);
1111
void UpdateAction(CollisionWorld collisionWorld, float deltaTimeStep);
1212
}
1313

BulletSharp/Dynamics/KinematicCharacterController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ public virtual void UpdateAction(CollisionWorld collisionWorld, float deltaTime)
445445
}
446446

447447
///btActionInterface interface
448-
public void DebugDraw(IDebugDraw debugDrawer)
448+
public void DebugDraw(DebugDraw debugDrawer)
449449
{
450450
}
451451

0 commit comments

Comments
 (0)