Home | Trees | Indices | Help |
|
---|
|
object --+ | Space
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
Properties | |
shapes A list of the shapes added to this space |
|
static_shapes A list of the static shapes added to this space |
|
bodies A list of the bodies added to this space |
|
constraints A list of the constraints added to this space |
|
gravity Default gravity to supply when integrating rigid body motions. |
|
damping Default damping to supply when integrating rigid body motions. |
|
Inherited from |
Method Details |
Create a new instace of the Space If the objects in your Space does not have any elasticity set elastic_iterations to 0 to gain a little speedup.
|
Remove one or many shapes, bodies or constraints from the space Note When removing objects from the space, make sure you remove any other objects that reference it. For instance, when you remove a body, remove the joints and shapes attached to it. |
The spatial hashes used by pymunk's collision detection are fairly size sensitive. dim is the size of the hash cells. Setting dim to the average objects size is likely to give the best performance. count is the suggested minimum number of cells in the hash table. Bigger is better, but only to a point. Setting count to ~10x the number of objects in the hash is probably a good starting point. Because static shapes are only rehashed when you request it, it's possible to use a much higher count argument to resize_static_hash() than to resize_active_hash(). Doing so will use more memory though. |
The spatial hashes used by pymunk's collision detection are fairly size sensitive. dim is the size of the hash cells. Setting dim to the average objects size is likely to give the best performance. count is the suggested minimum number of cells in the hash table. Bigger is better, but only to a point. Setting count to ~10x the number of objects in the hash is probably a good starting point. |
|
|
Add a collision handler for given collision type pair. Whenever a shapes with collision_type a and collision_type b collide, these callbacks will be used to process the collision. None can be provided for callbacks you do not wish to implement, however pymunk will call it's own default versions for these and not the default ones you've set up for the Space. If you need to fall back on the space's default callbacks, you'll have to provide them individually to each handler definition.
|
|
|
Add a function to be called last in the next simulation step. Post step callbacks are the place where you can break the rules about removing objects from within a callback. In fact, their primary function is to help you safely remove objects from the space that were destroyed or disabled during the step. Post step callbacks are registered as a function and an object used as a key. You can only register one post step callback per object. This prevents you from removing an object more than once. For instance, say that you get a collision callback between a bullet and object A. The bullet and object A are destroyed, so you add a post step callback for each to remove. In the same step, the same bullet also hit object B and you add two more callbacks, one for object B and a second for the bullet. This is actually just fine, and the callback to remove the bullet will only be called once!
|
Query space at point filtering out matches with the given layers and group. Return a list of found shapes. If you don't want to filter out any matches, use -1 for the layers and 0 as the group.
|
|
Query space along the line segment from start to end filtering out matches with the given layers and group. Segment queries are like ray casting, but because pymunk uses a spatial hash to process collisions, it cannot process infinitely long queries like a ray. In practice this is still very fast and you don't need to worry too much about the performance as long as you aren't using very long segments for your queries.
|
|
Property Details |
shapesA list of the shapes added to this space
|
static_shapesA list of the static shapes added to this space
|
bodiesA list of the bodies added to this space
|
constraintsA list of the constraints added to this space
|
gravityDefault gravity to supply when integrating rigid body motions.
|
dampingDefault damping to supply when integrating rigid body motions.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Mar 07 22:17:52 2010 | http://epydoc.sourceforge.net |