Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonno.5000 authored and Jonno.5000 committed Dec 21, 2010
1 parent ff9d923 commit d8ff941
Show file tree
Hide file tree
Showing 24 changed files with 918 additions and 1,104 deletions.
929 changes: 91 additions & 838 deletions Box2C/Box2C.cpp

Large diffs are not rendered by default.

16 changes: 1 addition & 15 deletions Box2C/Box2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,12 @@

typedef b2World cb2world;
typedef b2Body cb2body;
typedef b2BodyDef cb2bodydef;
typedef b2Joint cb2joint;
typedef b2JointDef cb2jointdef;
typedef b2Fixture cb2fixture;
typedef b2FixtureDef cb2fixturedef;
typedef b2Contact cb2contact;
typedef b2Vec2 cb2vec2;
typedef b2Manifold cb2manifold;
typedef b2ContactImpulse cb2contactimpulse;
typedef b2Shape cb2shape;
typedef b2CircleShape cb2circleshape;
typedef b2PolygonShape cb2polygonshape;
typedef b2Filter cb2filter;
typedef b2RayCastOutput cb2raycastoutput;
typedef b2RayCastInput cb2raycastinput;
Expand All @@ -35,15 +29,6 @@ typedef b2JointEdge cb2jointedge;
typedef b2ContactEdge cb2contactedge;
typedef b2WorldManifold cb2worldmanifold;
typedef b2Transform cb2transform;
typedef b2RevoluteJointDef cb2revolutejointdef;
typedef b2DistanceJointDef cb2distancejointdef;
typedef b2FrictionJointDef cb2frictionjointdef;
typedef b2GearJointDef cb2gearjointdef;
typedef b2LineJointDef cb2linejointdef;
typedef b2MouseJointDef cb2mousejointdef;
typedef b2PrismaticJointDef cb2prismaticjointdef;
typedef b2PulleyJointDef cb2pulleyjointdef;
typedef b2WeldJointDef cb2weldjointdef;
typedef b2GearJoint cb2gearjoint;
typedef b2DistanceJoint cb2distancejoint;
typedef b2FrictionJoint cb2frictionjoint;
Expand All @@ -53,6 +38,7 @@ typedef b2LineJoint cb2linejoint;
typedef b2RevoluteJoint cb2revolutejoint;
typedef b2PrismaticJoint cb2prismaticjoint;
typedef b2Version cb2version;
typedef b2ClipVertex cb2clipvertex;

#define QUICK_GET_SETTER(getname,setname,ptrtype,type,member) \
type getname (ptrtype *me) \
Expand Down
218 changes: 1 addition & 217 deletions Box2C/mod.def
Original file line number Diff line number Diff line change
Expand Up @@ -45,74 +45,6 @@ EXPORTS
cb2querycallback_create
cb2querycallback_destroy

b2bodydef_constructor
b2bodydef_destroy
b2bodydef_setuserdata
b2bodydef_getuserdata
b2bodydef_setposition
b2bodydef_getposition
b2bodydef_setangle
b2bodydef_getangle
b2bodydef_setlinearvelocity
b2bodydef_getlinearvelocity
b2bodydef_setlineardamping
b2bodydef_getlineardamping
b2bodydef_setangulardamping
b2bodydef_getangulardamping
b2bodydef_setallowsleep
b2bodydef_getallowsleep
b2bodydef_setawake
b2bodydef_getawake
b2bodydef_setfixedrotation
b2bodydef_getfixedrotation
b2bodydef_setbullet
b2bodydef_getbullet
b2bodydef_setbodytype
b2bodydef_getbodytype
b2bodydef_setactive
b2bodydef_getactive
b2bodydef_setinertiascale
b2bodydef_getinertiascale

b2fixturedef_constructor
b2fixturedef_destroy
b2fixturedef_setshape
b2fixturedef_getuserdata
b2fixturedef_setuserdata
b2fixturedef_getfriction
b2fixturedef_setfriction
b2fixturedef_getrestitution
b2fixturedef_setrestitution
b2fixturedef_getdensity
b2fixturedef_setdensity
b2fixturedef_getissensor
b2fixturedef_setissensor
b2fixturedef_getfiltercategorybits
b2fixturedef_setfiltercategorybits
b2fixturedef_getfiltermaskbits
b2fixturedef_setfiltermaskbits
b2fixturedef_getfiltergroupindex
b2fixturedef_setfiltergroupindex

b2shape_gettype
b2shape_getradius
b2shape_setradius
b2circleshape_constructor
b2circleshape_destroy
b2circleshape_getposition
b2circleshape_setposition
b2polygonshape_constructor
b2polygonshape_destroy
b2polygonshape_getcentroid
b2polygonshape_setcentroid
b2polygonshape_getvertexcount
b2polygonshape_setvertexcount
b2polygonshape_getvertex
b2polygonshape_setvertex
b2polygonshape_set
b2polygonshape_getnormal
b2polygonshape_setnormal

b2fixture_gettype
b2fixture_getshape
b2fixture_setsensor
Expand All @@ -137,6 +69,7 @@ EXPORTS
b2body_createfixture
b2body_createfixturefromshape
b2body_destroyfixture
b2body_gettransform
b2body_settransform
b2body_getposition
b2body_getangle
Expand Down Expand Up @@ -204,155 +137,6 @@ EXPORTS
b2contact_getfixtureb
b2contact_evaluate

b2jointdef_gettype
b2jointdef_getuserdata
b2jointdef_setuserdata
b2jointdef_getbodya
b2jointdef_setbodya
b2jointdef_getbodyb
b2jointdef_setbodyb
b2jointdef_getcollideconnected
b2jointdef_setcollideconnected

b2revolutejointdef_constructor
b2revolutejointdef_destroy
b2revolutejointdef_getlocalanchora
b2revolutejointdef_setlocalanchora
b2revolutejointdef_getlocalanchorb
b2revolutejointdef_setlocalanchorb
b2revolutejointdef_getreferenceangle
b2revolutejointdef_setreferenceangle
b2revolutejointdef_getenablelimit
b2revolutejointdef_setenablelimit
b2revolutejointdef_getlowerangle
b2revolutejointdef_setlowerangle
b2revolutejointdef_getupperangle
b2revolutejointdef_setupperangle
b2revolutejointdef_getenablemotor
b2revolutejointdef_setenablemotor
b2revolutejointdef_getmotorspeed
b2revolutejointdef_setmotorspeed
b2revolutejointdef_getmaxmotortorque
b2revolutejointdef_setmaxmotortorque

b2distancejointdef_constructor
b2distancejointdef_destroy
b2distancejointdef_getlocalanchora
b2distancejointdef_setlocalanchora
b2distancejointdef_getlocalanchorb
b2distancejointdef_setlocalanchorb
b2distancejointdef_getlength
b2distancejointdef_setlength
b2distancejointdef_getfrequency
b2distancejointdef_setfrequency
b2distancejointdef_getdampingratio
b2distancejointdef_setdampingratio

b2frictionjointdef_constructor
b2frictionjointdef_destroy
b2frictionjointdef_getlocalanchora
b2frictionjointdef_setlocalanchora
b2frictionjointdef_getlocalanchorb
b2frictionjointdef_setlocalanchorb
b2frictionjointdef_getmaxforce
b2frictionjointdef_setmaxforce
b2frictionjointdef_getmaxtorque
b2frictionjointdef_setmaxtorque

b2gearjointdef_constructor
b2gearjointdef_destroy
b2gearjointdef_getjoint1
b2gearjointdef_setjoint1
b2gearjointdef_getjoint2
b2gearjointdef_setjoint2
b2gearjointdef_getratio
b2gearjointdef_setratio

b2linejointdef_constructor
b2linejointdef_destroy
b2linejointdef_getlocalanchora
b2linejointdef_setlocalanchora
b2linejointdef_getlocalanchorb
b2linejointdef_setlocalanchorb
b2linejointdef_getlocalaxisa
b2linejointdef_setlocalaxisa
b2linejointdef_getenablelimit
b2linejointdef_setenablelimit
b2linejointdef_getlowertranslation
b2linejointdef_setlowertranslation
b2linejointdef_getuppertranslation
b2linejointdef_setuppertranslation
b2linejointdef_getenablemotor
b2linejointdef_setenablemotor
b2linejointdef_getmaxmotorforce
b2linejointdef_setmaxmotorforce
b2linejointdef_getmotorspeed
b2linejointdef_setmotorspeed

b2mousejointdef_constructor
b2mousejointdef_destroy
b2mousejointdef_gettarget
b2mousejointdef_settarget
b2mousejointdef_getmaxforce
b2mousejointdef_setmaxforce
b2mousejointdef_getfrequency
b2mousejointdef_setfrequency
b2mousejointdef_getdampingratio
b2mousejointdef_setdampingratio

b2prismaticjointdef_constructor
b2prismaticjointdef_destroy
b2prismaticjointdef_getlocalanchora
b2prismaticjointdef_setlocalanchora
b2prismaticjointdef_getlocalaxis1
b2prismaticjointdef_setlocalaxis1
b2prismaticjointdef_getlocalanchorb
b2prismaticjointdef_setlocalanchorb
b2prismaticjointdef_getreferenceangle
b2prismaticjointdef_setreferenceangle
b2prismaticjointdef_getenablelimit
b2prismaticjointdef_setenablelimit
b2prismaticjointdef_getlowertranslation
b2prismaticjointdef_setlowertranslation
b2prismaticjointdef_getuppertranslation
b2prismaticjointdef_setuppertranslation
b2prismaticjointdef_getenablemotor
b2prismaticjointdef_setenablemotor
b2prismaticjointdef_getmaxmotorforce
b2prismaticjointdef_setmaxmotorforce
b2prismaticjointdef_getmotorspeed
b2prismaticjointdef_setmotorspeed

b2pulleyjointdef_constructor
b2pulleyjointdef_destroy
b2pulleyjointdef_getgroundanchora
b2pulleyjointdef_setgroundanchora
b2pulleyjointdef_getgroundanchorb
b2pulleyjointdef_setgroundanchorb
b2pulleyjointdef_getlocalanchora
b2pulleyjointdef_setlocalanchora
b2pulleyjointdef_getlocalanchorb
b2pulleyjointdef_setlocalanchorb
b2pulleyjointdef_getlengtha
b2pulleyjointdef_setlengtha
b2pulleyjointdef_getmaxlengtha
b2pulleyjointdef_setmaxlengtha
b2pulleyjointdef_getlengthb
b2pulleyjointdef_setlengthb
b2pulleyjointdef_getmaxlengthb
b2pulleyjointdef_setmaxlengthb
b2pulleyjointdef_getratio
b2pulleyjointdef_setratio

b2weldjointdef_constructor
b2weldjointdef_destroy
b2weldjointdef_getlocalanchora
b2weldjointdef_setlocalanchora
b2weldjointdef_getlocalanchorb
b2weldjointdef_setlocalanchorb
b2weldjointdef_getreferenceangle
b2weldjointdef_setreferenceangle

b2joint_gettype
b2joint_getbodya
b2joint_getbodyb
Expand Down
15 changes: 15 additions & 0 deletions Box2CS/Body/Body.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ static class NativeMethods
[DllImport(Box2DSettings.Box2CDLLName)]
public static extern void b2body_settransform(IntPtr body, Vec2 position, float angle);

[DllImport(Box2DSettings.Box2CDLLName)]
public static extern void b2body_gettransform(IntPtr body, out Transform transform);

[DllImport(Box2DSettings.Box2CDLLName)]
public static extern void b2body_getposition(IntPtr body, out Vec2 outPtr);

Expand Down Expand Up @@ -425,6 +428,18 @@ public void SetTransform(Vec2 position, float angle)
NativeMethods.b2body_settransform(_bodyPtr, position, angle);
}

public Transform Transform
{
get
{
Transform temp;

NativeMethods.b2body_gettransform(_bodyPtr, out temp);

return temp;
}
}

public Vec2 Position
{
get { Vec2 temp; NativeMethods.b2body_getposition(_bodyPtr, out temp); return temp; }
Expand Down
19 changes: 19 additions & 0 deletions Box2CS/Box2D/Math.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,24 @@ public bool Contains(AABB aabb)
result = result && aabb._upperBound.y <= _upperBound.y;
return result;
}

public static bool TestOverlap(AABB a, AABB b)
{
var d1 = b.LowerBound - a.UpperBound;
var d2 = a.LowerBound - b.UpperBound;

if (d1.x > 0.0f || d1.y > 0.0f)
return false;

if (d2.x > 0.0f || d2.y > 0.0f)
return false;

return true;
}

public bool Overlaps(AABB b)
{
return TestOverlap(this, b);
}
};
}
36 changes: 32 additions & 4 deletions Box2CS/Contacts/ContactListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,50 @@ public ContactListener()

void BeginContactInternal(IntPtr contact)
{
BeginContact(Contact.FromPtr(contact));
try
{
BeginContact(Contact.FromPtr(contact));
}
catch (Exception ex)
{
throw ex;
}
}

void EndContactInternal(IntPtr contact)
{
EndContact(Contact.FromPtr(contact));
try
{
EndContact(Contact.FromPtr(contact));
}
catch (Exception ex)
{
throw ex;
}
}

void PreSolveInternal(IntPtr contact, IntPtr oldManifold)
{
PreSolve(Contact.FromPtr(contact), (Manifold)Marshal.PtrToStructure(oldManifold, typeof(Manifold)));
try
{
PreSolve(Contact.FromPtr(contact), (Manifold)Marshal.PtrToStructure(oldManifold, typeof(Manifold)));
}
catch (Exception ex)
{
throw ex;
}
}

void PostSolveInternal(IntPtr contact, IntPtr impulse)
{
PostSolve(Contact.FromPtr(contact), (ContactImpulse)Marshal.PtrToStructure(impulse, typeof(ContactImpulse)));
try
{
PostSolve(Contact.FromPtr(contact), (ContactImpulse)Marshal.PtrToStructure(impulse, typeof(ContactImpulse)));
}
catch (Exception ex)
{
throw ex;
}
}

public abstract void BeginContact(Contact contact);
Expand Down
2 changes: 1 addition & 1 deletion Box2CS/Joints/Joint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ internal Joint(IntPtr ptr)
internal static Joint FromPtr(IntPtr ptr)
{
if (ptr == IntPtr.Zero)
return null;
throw new Exception("Invalid joint ptr (locked world?)");

switch ((EJointType)NativeMethods.b2joint_gettype(ptr))
{
Expand Down
Loading

0 comments on commit d8ff941

Please sign in to comment.