Difference between revisions of "Chipmunk integration"

From X-Moto
Jump to: navigation, search
(enumerating chipmunk features which may be implemented in xmoto)
(updated with changes since first merge)
Line 1: Line 1:
 
==News==
 
==News==
* Getting close to meeting requirements for merge into main branch
+
* First feature set merged into xmoto trunk!
 
* [[inkscape-dev|Inksmoto svn]] version supports new Chipmunk features
 
* [[inkscape-dev|Inksmoto svn]] version supports new Chipmunk features
 +
 +
==Features from first round of development==
 +
* Interactions between Chipmunk objects and:
 +
** Other Chipmunk objects in the level
 +
** Player Wheels
 +
** Terrain
 +
* Physical Properties specified per object in level file:
 +
** Mass
 +
** Friction
 +
** Elasticity
 +
* Multiplayer/Multiscene support (not as fast as 1-player, but may be optimised in time)
 +
* Responsive to scripted changes in Gravity
  
 
==Getting Started==
 
==Getting Started==
 
===Installation===
 
===Installation===
Follow the regular [[Build_from_SVN | Subversion build instructions]] with the one change being the repository path below:
+
Follow the regular [[Build_from_SVN | Subversion build instructions]]. If you wish to try the latest experimental code, then make one change being the repository path below:
  
 
  svn co svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/branches/chipmunk chipxmoto
 
  svn co svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/branches/chipmunk chipxmoto
  
 
===Configpath Change requirement===
 
===Configpath Change requirement===
The database requires an upgrade, so until the chipmunk branch is merged with the main trunk if you wish to run both versions then you will need to specify different config paths. E.g.
+
The database requires an upgrade, so until development stops, or at least the level file changes do, to run both versions then you will need to specify different config paths. E.g.
  
 
  ./xmoto --configpath ~/.xmotophysics
 
  ./xmoto --configpath ~/.xmotophysics
Line 20: Line 32:
 
  http://download.tuxfamily.org/xmoto/xmoto/dev/chipmunk_levels
 
  http://download.tuxfamily.org/xmoto/xmoto/dev/chipmunk_levels
  
==Features Going into Merge 1==
+
Not all are 'playable' in the sense that a number just demonstrate bugs or compare physics settings between ODE/Chipmunk.
* Interactions between Chipmunk objects and:
 
** Other Chipmunk objects in the level
 
** Player Wheels
 
** Terrain
 
* Physical Properties specified per object in level file:
 
** Mass
 
** Friction
 
** Elasticity
 
* Multiplayer/Multiscene support (not as fast as 1-player, but may be optimised in time)
 
* Responsive to scripted changes in Gravity
 
  
 
=== Dynamic Objects ===
 
=== Dynamic Objects ===
Line 41: Line 43:
 
* SetPhysicsBlockTranslation(block, fX, fY, period, startTime, endTime, maxForce)
 
* SetPhysicsBlockTranslation(block, fX, fY, period, startTime, endTime, maxForce)
 
* SetPhysicsBlockSelfRotation(block, period, startTime, endTime, maxTorque)
 
* SetPhysicsBlockSelfRotation(block, period, startTime, endTime, maxTorque)
 +
* SetPhysicsBlockPos(block, fX, fY)
 +
 +
The maxForce and maxTorque would be defining how much potential power the object will have to reach its desired state. The chipmunk scripting commands will differ in this regard, in that a particular position in space cannot be guaranteed, because there may be something in the way.
 +
 +
''SetPhysicsBlockPos()'' is in the development branch.
 +
 +
== Background Interactions ==
 +
 +
Physics objects can be made 'background' objects also. Code in the development branch supports interactions:
 +
* Between background physics objects and regular physics objects/terrain
 +
* Not between background physics objects and the player
 +
 +
The level 'Chipmunk Playground 4' demonstrates a use of this with the swinging hanging cages.
 +
 +
== Circle Support ==
 +
 +
Chipmunk optimises collisions involving circles. In the development branch some (very) preliminary code towards that end has been added. Previously all circles were treated as interpolated polygons and passed to the collision code in that way.
 +
 +
Initial tests between ChipmunkBallpit/ChipmunkBallpitCircles show differences in handling and speed.
 +
 +
Unexpectedly, speed improvements were not realised. Possible explanations for this are:
 +
* Increased number of interactions - polygons find a 'rest' state quicker than circles
 +
* XMoto collision system may be bottleneck
 +
* Hundreds of circles together (e.g. a ballpit) may not be the best test
 +
 +
Despite this less than ideal start, support for circles will continue as there are cases where they may be useful. e.g. ball rolling down slope -- less likely to get 'stuck' on vertices.
 +
 +
==Features expected for the second merge==
 +
* Scriptable physics objects
 +
* Background interactions
  
The maxForce and maxTorque would be defining how much power the object will have to reach its desired state. The chipmunk scripting commands will differ in this regard, in that a particular position in space cannot be guaranteed, because there may be something in the way.
 
  
 
==Other Chipmunk Features==
 
==Other Chipmunk Features==
Line 52: Line 83:
 
** Groove joints
 
** Groove joints
 
* Circles - fastest type of collision object
 
* Circles - fastest type of collision object
 +
* Springs

Revision as of 14:12, 3 May 2008

News

  • First feature set merged into xmoto trunk!
  • Inksmoto svn version supports new Chipmunk features

Features from first round of development

  • Interactions between Chipmunk objects and:
    • Other Chipmunk objects in the level
    • Player Wheels
    • Terrain
  • Physical Properties specified per object in level file:
    • Mass
    • Friction
    • Elasticity
  • Multiplayer/Multiscene support (not as fast as 1-player, but may be optimised in time)
  • Responsive to scripted changes in Gravity

Getting Started

Installation

Follow the regular Subversion build instructions. If you wish to try the latest experimental code, then make one change being the repository path below:

svn co svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/branches/chipmunk chipxmoto

Configpath Change requirement

The database requires an upgrade, so until development stops, or at least the level file changes do, to run both versions then you will need to specify different config paths. E.g.

./xmoto --configpath ~/.xmotophysics

XMoto will create this directory for you if it does not already exist

Test levels

You can find them at

http://download.tuxfamily.org/xmoto/xmoto/dev/chipmunk_levels

Not all are 'playable' in the sense that a number just demonstrate bugs or compare physics settings between ODE/Chipmunk.

Dynamic Objects

Experimental code for interactions between scripted dynamic objects and chipmunk physics objects has been removed. The reason for this is that dynamic objects in XMoto are 'teleported' into position, whereas objects in Chipmunk require force and torque parameters -- these two models are incompatible and resulted in some spectacular bugs.

Rather than support these interactions badly, it was decided not to support them at all -- both types of objects will ignore each other and thus should be used carefully if required in the same level.

Scriptable Chipmunk Physics Objects

These will stay as close as possible to the existing script API developed for dynamic objects e.g.:

  • SetPhysicsBlockTranslation(block, fX, fY, period, startTime, endTime, maxForce)
  • SetPhysicsBlockSelfRotation(block, period, startTime, endTime, maxTorque)
  • SetPhysicsBlockPos(block, fX, fY)

The maxForce and maxTorque would be defining how much potential power the object will have to reach its desired state. The chipmunk scripting commands will differ in this regard, in that a particular position in space cannot be guaranteed, because there may be something in the way.

SetPhysicsBlockPos() is in the development branch.

Background Interactions

Physics objects can be made 'background' objects also. Code in the development branch supports interactions:

  • Between background physics objects and regular physics objects/terrain
  • Not between background physics objects and the player

The level 'Chipmunk Playground 4' demonstrates a use of this with the swinging hanging cages.

Circle Support

Chipmunk optimises collisions involving circles. In the development branch some (very) preliminary code towards that end has been added. Previously all circles were treated as interpolated polygons and passed to the collision code in that way.

Initial tests between ChipmunkBallpit/ChipmunkBallpitCircles show differences in handling and speed.

Unexpectedly, speed improvements were not realised. Possible explanations for this are:

  • Increased number of interactions - polygons find a 'rest' state quicker than circles
  • XMoto collision system may be bottleneck
  • Hundreds of circles together (e.g. a ballpit) may not be the best test

Despite this less than ideal start, support for circles will continue as there are cases where they may be useful. e.g. ball rolling down slope -- less likely to get 'stuck' on vertices.

Features expected for the second merge

  • Scriptable physics objects
  • Background interactions


Other Chipmunk Features

These will be tested and may be phased in over time and future releases:

  • Joints
    • Pin joints
    • Pivot joints
    • Slide joints
    • Groove joints
  • Circles - fastest type of collision object
  • Springs