mosp :: collide :: World :: Class World
[hide private]
[frames] | no frames]

Class World

source code


A set of all walkable elements in the simulated world, e. g. streets and public places.


Authors:
F. Ludwig, P. Tute, B. Henne
Instance Methods [hide private]
 
__init__(self, grid_size=100)
Initialize collision grid.
source code
 
add(self, obj)
Adds an object to the world.
source code
 
calculate_grid(self, cache_base_path=None)
Calculates the collision grid of the World.
source code
 
collide_circle(self, x, y, radius)
Checks all registered walkable objects for collision that are in grid segments which collide with the specified circle.
source code
 
collide_circle_impl0(self, x, y, radius)
Checks all registered walkable objects for a collision with a given circle.
source code
 
collide_circle_impl1(self, x, y, radius)
Checks all registered walkable objects for collision that are in grid segments which collide with the specified circle.
source code
 
collide_circle_impl2(self, x, y, radius)
Checks all registered walkable objects for collision that are in grid segments which collide with the specified circle.
source code
 
collide_polygon(self, corners)
Checks all registered walkable objects for a collision with a given polygon.
source code
 
collide_rectangle(self, x_min, y_min, x_max, y_max)
Checks all registered walkable objects for a collision with a given rectangle.
source code
 
update(self, items)
Updates an object of the world.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, grid_size=100)
(Constructor)

source code 

Initialize collision grid.

grid_size determines maximum collision region. Collision range/region/radius must be lower or equal the grid_size. World.obj is the set of walkable elements. calculate_grid() must be called after all objects have been loaded.

Overrides: object.__init__

calculate_grid(self, cache_base_path=None)

source code 

Calculates the collision grid of the World.

This method must be called after all world objects have been added to the World. It calculate which objects are in which grid segment. Calculation is done by colliding each object with each grid segment. Determining a grid grid segment by coordinates is done by integer maths. A grid segment is represented by its west and south border, e.g. grid_size=50, p=(127.9; 33.2) => segment is x=100, y=0.

collide_circle(self, x, y, radius)

source code 

Checks all registered walkable objects for collision that are in grid segments which collide with the specified circle.

This method first determines all concerned grid segments and finally only collides objects located in these segments. This implementation uses Line.collide to determine neighbor segments by colliding circle with segment boundaries.

collide_circle_impl0(self, x, y, radius)

source code 

Checks all registered walkable objects for a collision with a given circle. Simplest implementation, least performance.

collide_circle_impl1(self, x, y, radius)

source code 

Checks all registered walkable objects for collision that are in grid segments which collide with the specified circle.

This method first determines all concerned grid segments and finally only collides objects located in these segments. This implementation uses sub/add/abs to determine neighbor segments by checking coordinates.

collide_circle_impl2(self, x, y, radius)

source code 

Checks all registered walkable objects for collision that are in grid segments which collide with the specified circle.

This method first determines all concerned grid segments and finally only collides objects located in these segments. This implementation uses Line.collide to determine neighbor segments by colliding circle with segment boundaries.

collide_polygon(self, corners)

source code 

Checks all registered walkable objects for a collision with a given polygon.

Status: not implemented