Skip to content
Permalink
Browse files

[Physics] Replace Rigidbody's hacky delegate usage

  • Loading branch information
Eideren committed May 24, 2019
1 parent 494b235 commit 28de8941ebccea0e5c33c96e41dd8e4914a6f2e4
@@ -18,16 +18,6 @@ public sealed class RigidbodyComponent : PhysicsSkinnedComponentBase
[DataMemberIgnore]
internal BulletSharp.RigidBody InternalRigidBody;

internal delegate void GetWorldTransformDelegate(out Matrix transform);

[DataMemberIgnore]
internal GetWorldTransformDelegate GetWorldTransformCallback;

internal delegate void SetWorldTransformDelegate(Matrix transform);

[DataMemberIgnore]
internal SetWorldTransformDelegate SetWorldTransformCallback;

[DataMemberIgnore]
internal XenkoMotionState MotionState;

@@ -321,8 +311,6 @@ protected override void OnAttach()

SetupBoneLink();

GetWorldTransformCallback = (out Matrix transform) => RigidBodyGetWorldTransform(out transform);
SetWorldTransformCallback = transform => RigidBodySetWorldTransform(ref transform);
var rbci = new BulletSharp.RigidBodyConstructionInfo(0.0f, MotionState, ColliderShape.InternalShape, Vector3.Zero);
InternalRigidBody = new BulletSharp.RigidBody(rbci)
{
@@ -650,5 +638,32 @@ public Vector3 LinearFactor
InternalRigidBody.LinearFactor = value;
}
}

internal class XenkoMotionState : BulletSharp.MotionState
{
private RigidbodyComponent rigidBody;

public XenkoMotionState(RigidbodyComponent rb)
{
rigidBody = rb;
}

public void Clear()
{
rigidBody = null;
}

public override void GetWorldTransform(out BulletSharp.Math.Matrix transform)
{
rigidBody.RigidBodyGetWorldTransform(out var xenkoMatrix);
transform = xenkoMatrix;
}

public override void SetWorldTransform(ref BulletSharp.Math.Matrix transform)
{
Matrix asXenkoMatrix = transform;
rigidBody.RigidBodySetWorldTransform(ref asXenkoMatrix);
}
}
}
}

This file was deleted.

0 comments on commit 28de894

Please sign in to comment.
You can’t perform that action at this time.