Space class

Inheritance

Constructors

Space()

Properties

hashCode int
The hash code for this object.
no setterinherited
isLocked bool
returns true from inside a callback when objects cannot be added/removed.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addBody({required Body body}) Body
Add a rigid body to the simulation.
addCollisionHandler({required int aType, required int bType}) CollisionHandler
Create or return the existing collision handler for the specified pair of collision types. If wildcard handlers are used with either of the collision types, it's the responibility of the custom handler to invoke the wildcard handlers.
addConstraint<T extends Constraint>({required T constraint}) → T
Add a constraint to the simulation.
addDefaultCollisionHandler() CollisionHandler
Create or return the existing collision handler that is called for all collisions that are not handled by a more specific collision handler.
addPostStepCallback<T>(T liquid2dType, void postStepFunc(Space space, T liquid2dType)) bool
Schedule a post-step callback to be called when cpSpaceStep() finishes. You can only register one callback per unique value for @c key. Returns true only if @c key has never been scheduled before. It's possible to pass @c NULL for @c func if you only want to mark @c key as being used.
addShape({required Shape shape}) Shape
Add a collision shape to the simulation. If the shape is attached to a static body, it will be added as a static shape.
addWildcardHandler({required int type}) CollisionHandler
Create or return the existing wildcard collision handler for the specified type.
debugDraw({required void debugDrawCirlceFunc(Vector2 pos, double angle, double radius, Color outlineColor, Color fillColor), required void debugDrawSegmentFunc(Vector2 a, Vector2 b, Color color), required void debugDrawFatSegmentFunc(Vector2 a, Vector2 b, double radius, Color outlineColor, Color fillColor), required void debugDrawPolygonFunc(List<Vector2> verts, double radius, Color outlineColor, Color fillColor), required void debugDrawDotFunc(double size, Vector2 pos, Color color), required int debugDrawFlag, required Color colorForShape(Shape shape), required Color shapeOutlineColor, required Color constraintColor, required Color collisionPointColor}) → void
Debug draw the current state of the space using the supplied drawing options.
destroy() → void
Destroy a Space.
eachBody(void bodyFunc(Body body)) → void
Call @c func for each body in the space.
eachConstraint(void constraintFunc(Constraint constraint)) → void
Call @c func for each shape in the space.
eachShape(void shapeFunc(Shape shape)) → void
Call @c func for each shape in the space.
getCollisionBias() double
Determines how fast overlapping shapes are pushed apart. Expressed as a fraction of the error remaining after each second. Defaults to pow(1.0 - 0.1, 60.0) meaning that Chipmunk fixes 10% of overlap each frame at 60Hz.
getCollisionPersistence() int
Number of frames that contact information should persist. Defaults to 3. There is probably never a reason to change this value.
getCollisionSlop() double
Amount of encouraged penetration between colliding shapes. Used to reduce oscillating contacts and keep the collision cache warm. Defaults to 0.1. If you have poor simulation quality, increase this number as much as possible without allowing visible amounts of overlap.
getCurrentTimeStep() double
Returns the current (or most recent) time step used with the given space. Useful from callbacks if your time step is not a compile-time global.
getDamping() double
Damping rate expressed as the fraction of velocity bodies retain each second. A value of 0.9 would mean that each body's velocity will drop 10% per second. The default value is 1.0, meaning no damping is applied. @note This damping value is different than those of cpDampedSpring and cpDampedRotarySpring.
getData<T>() → T?
User definable data pointer. Generally this points to your game's controller or game state class so you can access it when given a cpSpace reference in a callback.
getGravity() → Vector2
Gravity to pass to rigid bodies when integrating velocity.
getIdleSpeedThreshold() double
Speed threshold for a body to be considered idle. The default value of 0 means to let the space guess a good threshold based on gravity.
getIterations() int
Number of iterations to use in the impulse solver to solve contacts and other constraints.
getSleepTimeThreshold() double
Time a group of bodies must remain idle in order to fall asleep. Enabling sleeping also implicitly enables the the contact graph. The default value of INFINITY disables the sleeping algorithm.
getStaticBody() Body
The Space provided static body for a given cpSpace. This is merely provided for convenience and you are not required to use it.
isContainsBody(Body body) bool
Test if a rigid body has been added to the space.
isContainsConstraint(Constraint constraint) bool
Test if a constraint has been added to the space.
isContainsShape(Shape shape) bool
Test if a collision shape has been added to the space.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pointQuery({required Vector2 point, required double maxDistance, required ShapeFilter filter, required void pointQueryFunc(Shape shape, Vector2 point, double distance, Vector2 gradient)}) → void
Query the space at a point and call @c func for each shape found.
pointQueryNearest({required Vector2 mouse, required double radius, required ShapeFilter filter}) → (Shape, PointQueryInfo)
Query the space at a point and return the nearest shape found. Returns NULL if no shapes were found.
rectQuery({required Rect rect, required ShapeFilter filter, required void rectQueryFunc(Shape shape)}) → void
Perform a fast rectangle query on the space calling @c func for each shape found. Only the shape's bounding boxes are checked for overlap, not their full shape.
reindexShape(Shape shape) → void
Update the collision detection data for a specific shape in the space.
reindexShapeForBody(Body body) → void
Update the collision detection data for all shapes attached to a body.
reindexStatic() → void
Update the collision detection info for the static shapes in the space.
removeBody({required Body body}) → void
Remove a rigid body from the simulation.
removeConstraint({required Constraint constraint}) → void
Remove a constraint from the simulation.
removeData() → void
User definable data pointer. Generally this points to your game's controller or game state class so you can access it when given a cpSpace reference in a callback.
removeShape({required Shape shape}) → void
Remove a collision shape from the simulation.
segmentQuery({required Vector2 start, required Vector2 end, required double radius, required ShapeFilter filter, required void queryFunc(Shape shape, Vector2 point, Vector2 normal, double alpha)}) → void
Perform a directed line segment query (like a raycast) against the space calling @c func for each shape intersected.
segmentQueryFirst({required Vector2 start, required Vector2 end, required double radius, required ShapeFilter filter}) → (Shape, SegmentQueryInfo)
Perform a directed line segment query (like a raycast) against the space and return the first shape hit. Returns NULL if no shapes were hit.
setCollisionBias(double collisionBias) → void
Determines how fast overlapping shapes are pushed apart. Expressed as a fraction of the error remaining after each second. Defaults to pow(1.0 - 0.1, 60.0) meaning that Chipmunk fixes 10% of overlap each frame at 60Hz.
setCollisionPersistence(int collisionPersistence) → void
Number of frames that contact information should persist. Defaults to 3. There is probably never a reason to change this value.
setCollisionSlop({required double collisionSlop}) → void
Amount of encouraged penetration between colliding shapes. Used to reduce oscillating contacts and keep the collision cache warm. Defaults to 0.1. If you have poor simulation quality, increase this number as much as possible without allowing visible amounts of overlap.
setDamping({required double damping}) → void
Damping rate expressed as the fraction of velocity bodies retain each second. A value of 0.9 would mean that each body's velocity will drop 10% per second. The default value is 1.0, meaning no damping is applied. @note This damping value is different than those of cpDampedSpring and cpDampedRotarySpring.
setData<T>(T data) → void
User definable data pointer. Generally this points to your game's controller or game state class so you can access it when given a cpSpace reference in a callback.
setGravity({required Vector2 gravity}) → void
Gravity to pass to rigid bodies when integrating velocity.
setIdleSpeedThreshold(double idleSpeedThreshold) → void
Speed threshold for a body to be considered idle. The default value of 0 means to let the space guess a good threshold based on gravity.
setIternation({required int iterations}) → void
Number of iterations to use in the impulse solver to solve contacts and other constraints.
setSleepTimeThreshold({required double sleepTimeThreshold}) → void
Time a group of bodies must remain idle in order to fall asleep. Enabling sleeping also implicitly enables the the contact graph. The default value of INFINITY disables the sleeping algorithm.
shapeQuery({required Shape shape, required void shapeQueryFunc(Shape shape, ContactPointSet points)}) bool
Query a space for any shapes overlapping the given shape and call @c func for each shape found.
step({required double dt}) → void
Step the space forward in time by @c dt.
toString() String
A string representation of this object.
inherited
useSpatialHash({required double dim, required int count}) → void
Switch the space to use a spatial has as it's spatial index.

Operators

operator ==(Object other) bool
The equality operator.
inherited