Skip to content

Commit

Permalink
merged physics
Browse files Browse the repository at this point in the history
  • Loading branch information
2of3 committed Apr 16, 2014
2 parents 774f443 + 4e8fd40 commit b2826b9
Show file tree
Hide file tree
Showing 39 changed files with 738 additions and 668 deletions.
2 changes: 2 additions & 0 deletions Engine.sln
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebXirkit", "src\Engine\Xir
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysicsTest", "src\Engine\Examples\PhysicsTest\PhysicsTest.csproj", "{CB5B28E9-5E30-453B-9878-ADC1E0D708D8}"
ProjectSection(ProjectDependencies) = postProject
{F7AD2BB5-D2B0-4697-BDDB-4CC26152A6B6} = {F7AD2BB5-D2B0-4697-BDDB-4CC26152A6B6}
{8B0453B6-D8E0-4189-80C8-9E0F8C9130E9} = {8B0453B6-D8E0-4189-80C8-9E0F8C9130E9}
EndProjectSection
EndProject
Expand All @@ -338,6 +339,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SceneViewer", "src\Engine\E
{32D5C521-6CC4-4DCF-BFA1-199043E938DC} = {32D5C521-6CC4-4DCF-BFA1-199043E938DC}
{4A183140-3153-4F7E-A692-F4E3EF2CFA0A} = {4A183140-3153-4F7E-A692-F4E3EF2CFA0A}
{7E796695-4174-471A-BBE8-3CAF39904588} = {7E796695-4174-471A-BBE8-3CAF39904588}
{B7FAC89A-4E75-4EAC-BBC3-BBDB89C94B8A} = {B7FAC89A-4E75-4EAC-BBC3-BBDB89C94B8A}
{F7AD2BB5-D2B0-4697-BDDB-4CC26152A6B6} = {F7AD2BB5-D2B0-4697-BDDB-4CC26152A6B6}
{0A06B3EA-5934-4373-854A-B4D6E7E1FE16} = {0A06B3EA-5934-4373-854A-B4D6E7E1FE16}
{81B3A7F0-F8E4-45D0-BE69-B869C9B1803E} = {81B3A7F0-F8E4-45D0-BE69-B869C9B1803E}
Expand Down
Binary file modified ExternalBinaries/BulletSharp.dll
Binary file not shown.
2 changes: 2 additions & 0 deletions src/Engine/Common/ICollisionShapeImp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fusee.Math;

namespace Fusee.Engine
{
public interface ICollisionShapeImp
{
float Margin { get; set; }
float3 LocalScaling { get; set; }
object UserObject { get; set; }
}
}
5 changes: 3 additions & 2 deletions src/Engine/Common/IDynamicWorldImp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Fusee.Engine
{
public interface IDynamicWorldImp
{
float3 Gravity { get; set; }

IRigidBodyImp AddRigidBody(float mass, float3 position, float3 orientation, ICollisionShapeImp colShape/*, float3 intertia*/);
IRigidBodyImp GetRigidBody(int i);
Expand All @@ -17,7 +18,7 @@ public interface IDynamicWorldImp
IPoint2PointConstraintImp AddPoint2PointConstraint(IRigidBodyImp rigidBodyA, float3 pivotInA);
IPoint2PointConstraintImp AddPoint2PointConstraint(IRigidBodyImp rigidBodyA, IRigidBodyImp rigidBodyB, float3 pivotInA, float3 pivotInB);

IPoint2PointConstraintImp GetConstraint(int i);
//IPoint2PointConstraintImp GetConstraint(int i);

IHingeConstraintImp AddHingeConstraint(IRigidBodyImp rigidBodyA, float4x4 frameInA, bool useReferenceFrameA);
IHingeConstraintImp AddHingeConstraint(IRigidBodyImp rigidBodyA, float3 pivotInA, float3 axisInA, bool useReferenceFrameA);
Expand Down Expand Up @@ -56,7 +57,7 @@ public interface IDynamicWorldImp
IEmptyShapeImp AddEmptyShape();

IConvexHullShapeImp AddConvexHullShape();
IConvexHullShapeImp AddConvexHullShape(float3[] points);
IConvexHullShapeImp AddConvexHullShape(float3[] points, bool optimized);

IStaticPlaneShapeImp AddStaticPlaneShape(float3 planeNormal, float planeConstant);

Expand Down
8 changes: 6 additions & 2 deletions src/Engine/Common/IRigidBodyImp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ public interface IRigidBodyImp
float3 AngularFactor { get; set; }

//"physic Matrial"
float Bounciness { get; set; }
float Restitution { get; set; }
float Friction { get; set; }

void SetDrag(float linearDrag, float anglularDrag);
float LinearDrag { get; }
float AngularDrag { get; }

ICollisionShapeImp CollisionShape { get; set; }

object UserObject { get; set; }

void OnCollision();
void OnCollision(IRigidBodyImp other);
}
}
2 changes: 1 addition & 1 deletion src/Engine/Core/BoxShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public float3 HalfExtents
}

//Inherited
public virtual float Margin
public float Margin
{

get
Expand Down
17 changes: 16 additions & 1 deletion src/Engine/Core/CapsuleShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fusee.Math;

namespace Fusee.Engine
{
public class CapsuleShape : CollisionShape
{
internal ICapsuleShapeImp CapsuleShapeImp;

public virtual float Margin
public float Margin
{
get
{
Expand All @@ -23,6 +24,20 @@ public virtual float Margin
}
}

public float3 LocalScaling
{
get
{
var retval = CapsuleShapeImp.LocalScaling;
return retval;
}
set
{
var o = (CapsuleShape)CapsuleShapeImp.UserObject;
o.CapsuleShapeImp.LocalScaling = value;
}
}

public float HalfHeight
{
get
Expand Down
15 changes: 13 additions & 2 deletions src/Engine/Core/CollisionShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fusee.Math;

namespace Fusee.Engine
{
public class CollisionShape
{
internal ICollisionShapeImp ICollisionShapeImp;



public float Margin
public virtual float Margin
{
get { return ICollisionShapeImp.Margin; }
set
Expand All @@ -19,5 +20,15 @@ public float Margin
o.ICollisionShapeImp.Margin = value;
}
}

public virtual float3 LocalScaling
{
get { return ICollisionShapeImp.LocalScaling; }
set
{
var o = (CollisionShape)ICollisionShapeImp.UserObject;
o.ICollisionShapeImp.LocalScaling = value;
}
}
}
}
2 changes: 1 addition & 1 deletion src/Engine/Core/CompoundShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void CalculatePrincipalAxisTransform(float[] masses, float4x4 principal,
}

//Inherited
public virtual float Margin
public float Margin
{

get
Expand Down
17 changes: 16 additions & 1 deletion src/Engine/Core/ConeShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fusee.Math;

namespace Fusee.Engine
{
public class ConeShape : CollisionShape
{
internal IConeShapeImp ConeShapeImp;

public virtual float Margin
public float Margin
{
get
{
Expand All @@ -23,6 +24,20 @@ public virtual float Margin
}
}

public float3 LocalScaling
{
get
{
var retval = ConeShapeImp.LocalScaling;
return retval;
}
set
{
var o = (ConeShape) ConeShapeImp.UserObject;
o.ConeShapeImp.LocalScaling = value;
}
}

public int ConeUpIndex
{
get
Expand Down
4 changes: 3 additions & 1 deletion src/Engine/Core/ConvexHullShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public int GetNumPoints()
return ConvexHullShapeImp.GetNumPoints();
}

public virtual float Margin
public float Margin
{
get
{
Expand All @@ -57,6 +57,8 @@ public virtual float Margin
}
}



public float3 LocalScaling
{
get { return ConvexHullShapeImp.LocalScaling; }
Expand Down
20 changes: 17 additions & 3 deletions src/Engine/Core/CylinderShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class CylinderShape : CollisionShape
{
internal ICylinderShapeImp CylinderShapeImp;

public virtual float Margin
public float Margin
{
get
{
Expand All @@ -19,8 +19,22 @@ public virtual float Margin
}
set
{
var o = (CapsuleShape)CylinderShapeImp.UserObject;
o.CapsuleShapeImp.Margin = value;
var o = (CylinderShape)CylinderShapeImp.UserObject;
o.CylinderShapeImp.Margin = value;
}
}

public float3 LocalScaling
{
get
{
var retval = CylinderShapeImp.LocalScaling;
return retval;
}
set
{
var o = (CylinderShape)CylinderShapeImp.UserObject;
o.CylinderShapeImp.LocalScaling = value;
}
}

Expand Down
13 changes: 9 additions & 4 deletions src/Engine/Core/DynamicWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public DynamicWorld()
_dwi = ImpFactory.CreateIDynamicWorldImp();
}

public float3 Gravity
{
get { return _dwi.Gravity; }
set { _dwi.Gravity = value; }
}

public RigidBody AddRigidBody(float mass, float3 position, float3 orientation, CollisionShape colShape/*, float3 inertia*/)
{
Expand Down Expand Up @@ -140,12 +145,12 @@ public Point2PointConstraint AddPoint2PointConstraint(RigidBody rigidBodyA, Rigi
ip2pci.UserObject = retval;
return retval;
}
public Point2PointConstraint GetConstraint(int i)
/* public Point2PointConstraint GetConstraint(int i)
{
//Point2PointConstraint tp2pci = _dwi.GetConstraint(i).UserObject;
var retval = (Point2PointConstraint)_dwi.GetConstraint(i).UserObject;
return retval;
}
}*/

//HingeConstraint
public HingeConstraint AddHingeConstraint(RigidBody rigidBodyA, float4x4 frameInA, bool useReferenceFrameA = false)
Expand Down Expand Up @@ -370,9 +375,9 @@ public ConvexHullShape AddConvexHullShape()
return retval;
}

public ConvexHullShape AddConvexHullShape(float3[] points)
public ConvexHullShape AddConvexHullShape(float3[] points, bool optimized = true)
{
IConvexHullShapeImp iConvexHullShapeImp = _dwi.AddConvexHullShape(points);
IConvexHullShapeImp iConvexHullShapeImp = _dwi.AddConvexHullShape(points, optimized);
var retval = new ConvexHullShape();
retval.ConvexHullShapeImp = iConvexHullShapeImp;
iConvexHullShapeImp.UserObject = retval;
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Core/MultiSphereShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class MultiSphereShape : CollisionShape
{
internal IMultiSphereShapeImp MultiSphereShapeImp;

public virtual float Margin
public float Margin
{
get
{
Expand Down
Loading

0 comments on commit b2826b9

Please sign in to comment.