Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresTraks committed Oct 5, 2016
1 parent 1aeff0e commit fb8f061
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 157 deletions.
53 changes: 27 additions & 26 deletions BulletSharpPInvoke/Dynamics/RaycastVehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,24 @@ public RaycastVehicle(VehicleTuning tuning, RigidBody chassis, IVehicleRaycaster

public WheelInfo AddWheel(Vector3 connectionPointCS, Vector3 wheelDirectionCS0, Vector3 wheelAxleCS, float suspensionRestLength, float wheelRadius, VehicleTuning tuning, bool isFrontWheel)
{
WheelInfoConstructionInfo ci = new WheelInfoConstructionInfo();

ci.ChassisConnectionCS = connectionPointCS;
ci.WheelDirectionCS = wheelDirectionCS0;
ci.WheelAxleCS = wheelAxleCS;
ci.SuspensionRestLength = suspensionRestLength;
ci.WheelRadius = wheelRadius;
ci.SuspensionStiffness = tuning.SuspensionStiffness;
ci.WheelsDampingCompression = tuning.SuspensionCompression;
ci.WheelsDampingRelaxation = tuning.SuspensionDamping;
ci.FrictionSlip = tuning.FrictionSlip;
ci.IsFrontWheel = isFrontWheel;
ci.MaxSuspensionTravelCm = tuning.MaxSuspensionTravelCm;
ci.MaxSuspensionForce = tuning.MaxSuspensionForce;

Array.Resize<WheelInfo>(ref wheelInfo, wheelInfo.Length + 1);
WheelInfo wheel = new WheelInfo(ci);
var ci = new WheelInfoConstructionInfo()
{
ChassisConnectionCS = connectionPointCS,
WheelDirectionCS = wheelDirectionCS0,
WheelAxleCS = wheelAxleCS,
SuspensionRestLength = suspensionRestLength,
WheelRadius = wheelRadius,
IsFrontWheel = isFrontWheel,
SuspensionStiffness = tuning.SuspensionStiffness,
WheelsDampingCompression = tuning.SuspensionCompression,
WheelsDampingRelaxation = tuning.SuspensionDamping,
FrictionSlip = tuning.FrictionSlip,
MaxSuspensionTravelCm = tuning.MaxSuspensionTravelCm,
MaxSuspensionForce = tuning.MaxSuspensionForce
};

Array.Resize(ref wheelInfo, wheelInfo.Length + 1);
var wheel = new WheelInfo(ci);
wheelInfo[wheelInfo.Length - 1] = wheel;

UpdateWheelTransformsWS(wheel, false);
Expand Down Expand Up @@ -373,10 +374,10 @@ public void UpdateFriction(float timeStep)
if (numWheel == 0)
return;

Array.Resize<Vector3>(ref forwardWS, numWheel);
Array.Resize<Vector3>(ref axle, numWheel);
Array.Resize<float>(ref forwardImpulse, numWheel);
Array.Resize<float>(ref sideImpulse, numWheel);
Array.Resize(ref forwardWS, numWheel);
Array.Resize(ref axle, numWheel);
Array.Resize(ref forwardImpulse, numWheel);
Array.Resize(ref sideImpulse, numWheel);

int numWheelsOnGround = 0;

Expand Down Expand Up @@ -724,23 +725,23 @@ void UpdateWheelTransformsWS(WheelInfo wheel, bool interpolatedTransform)

public class DefaultVehicleRaycaster : IVehicleRaycaster
{
private DynamicsWorld m_dynamicsWorld;
private DynamicsWorld _dynamicsWorld;

public DefaultVehicleRaycaster(DynamicsWorld world)
{
m_dynamicsWorld = world;
_dynamicsWorld = world;
}

public Object CastRay(ref Vector3 from, ref Vector3 to, VehicleRaycasterResult result)
public object CastRay(ref Vector3 from, ref Vector3 to, VehicleRaycasterResult result)
{
// RayResultCallback& resultCallback;
using (var rayCallback = new ClosestRayResultCallback(ref from, ref to))
{
m_dynamicsWorld.RayTestRef(ref from, ref to, rayCallback);
_dynamicsWorld.RayTestRef(ref from, ref to, rayCallback);

if (rayCallback.HasHit)
{
RigidBody body = RigidBody.Upcast(rayCallback.CollisionObject);
var body = RigidBody.Upcast(rayCallback.CollisionObject);
if (body != null && body.HasContactResponse)
{
result.HitPointInWorld = rayCallback.HitPointWorld;
Expand Down
2 changes: 1 addition & 1 deletion BulletSharpPInvoke/Dynamics/VehicleRaycaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class VehicleRaycasterResult

public interface IVehicleRaycaster
{
Object CastRay(ref Vector3 from, ref Vector3 to, VehicleRaycasterResult result);
object CastRay(ref Vector3 from, ref Vector3 to, VehicleRaycasterResult result);
}
}
2 changes: 1 addition & 1 deletion BulletSharpPInvoke/Math/Matrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct Matrix : IEquatable<Matrix>, IFormattable
/// <summary>
/// The size of the <see cref="SlimMath.Matrix"/> type, in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf(typeof(Matrix));
public const int SizeInBytes = 16 * sizeof(float);

/// <summary>
/// A <see cref="SlimMath.Matrix"/> with all of its components set to zero.
Expand Down
2 changes: 1 addition & 1 deletion BulletSharpPInvoke/Math/Quaternion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct Quaternion : IEquatable<Quaternion>, IFormattable
/// <summary>
/// The size of the <see cref="SlimMath.Quaternion"/> type, in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf(typeof(Quaternion));
public const int SizeInBytes = 4 * sizeof(float);

/// <summary>
/// A <see cref="SlimMath.Quaternion"/> with all of its components set to zero.
Expand Down
2 changes: 1 addition & 1 deletion BulletSharpPInvoke/Math/Vector3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public struct Vector3 : IEquatable<Vector3>, IFormattable
/// <summary>
/// The size of the <see cref="Vector3"/> type, in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf(typeof(Vector3));
public const int SizeInBytes = 3 * sizeof(float);

/// <summary>
/// A <see cref="Vector3"/> with all of its components set to zero.
Expand Down
2 changes: 1 addition & 1 deletion BulletSharpPInvoke/Math/Vector4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public struct Vector4 : IEquatable<Vector4>, IFormattable
/// <summary>
/// The size of the <see cref="SlimMath.Vector4"/> type, in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf(typeof(Vector4));
public const int SizeInBytes = 4 * sizeof(float);

/// <summary>
/// A <see cref="SlimMath.Vector4"/> with all of its components set to zero.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public ConvexcastBatch(float rayLength, float z, float minY, float maxY)
for (int i = 0; i < NumRays; i++)
{
Matrix transform = Matrix.RotationY(alpha * i);
var direction = Vector3.TransformCoordinate(new Vector3(1.0f, 0.0f, 0.0f), transform);
var direction = Vector3.TransformCoordinate(Vector3.UnitX, transform);

_rays[i] = new Ray
{
Expand Down
Loading

0 comments on commit fb8f061

Please sign in to comment.