2424class Shape (PickleMixin , TypingAttrMixing , object ):
2525 """Base class for all the shapes.
2626
27- You usually dont want to create instances of this class directly but use
27+ You usually don't want to create instances of this class directly but use
2828 one of the specialized shapes instead (:py:class:`Circle`,
2929 :py:class:`Poly` or :py:class:`Segment`).
3030
31- All the shapes can be copied and pickled. If you copy/pickle a shape the
31+ All the shapes can be copied and pickled. If you copy/pickle a shape, the
3232 body (if any) will also be copied.
3333 """
3434
@@ -79,7 +79,7 @@ def shapefree(cp_shape: ffi.CData) -> None:
7979
8080 @property
8181 def _id (self ) -> int :
82- """Unique id of the Shape
82+ """Unique id of the Shape.
8383
8484 .. note::
8585 Experimental API. Likely to change in future major, minor orpoint
@@ -102,8 +102,8 @@ def _set_mass(self, mass: float) -> None:
102102 _set_mass ,
103103 doc = """The mass of this shape.
104104
105- This is useful when you let Pymunk calculate the total mass and inertia
106- of a body from the shapes attached to it. (Instead of setting the body
105+ This is useful when you let Pymunk calculate the total mass and inertia
106+ of a body from the shapes attached to it. (Instead of setting the body
107107 mass and inertia directly)
108108 """ ,
109109 )
@@ -118,9 +118,9 @@ def _set_density(self, density: float) -> None:
118118 _get_density ,
119119 _set_density ,
120120 doc = """The density of this shape.
121-
122- This is useful when you let Pymunk calculate the total mass and inertia
123- of a body from the shapes attached to it. (Instead of setting the body
121+
122+ This is useful when you let Pymunk calculate the total mass and inertia
123+ of a body from the shapes attached to it. (Instead of setting the body
124124 mass and inertia directly)
125125 """ ,
126126 )
@@ -168,7 +168,7 @@ def _set_collision_type(self, t: int) -> None:
168168 _set_collision_type ,
169169 doc = """User defined collision type for the shape.
170170
171- See :py:meth:`Space.add_collision_handler` function for more
171+ See :py:meth:`Space.add_collision_handler` function for more
172172 information on when to use this property.
173173 """ ,
174174 )
@@ -295,7 +295,7 @@ def update(self, transform: Transform) -> BB:
295295 return BB (_bb .l , _bb .b , _bb .r , _bb .t )
296296
297297 def cache_bb (self ) -> BB :
298- """Update and returns the bounding box of this shape"""
298+ """Update and returns the bounding box of this shape. """
299299 _bb = cp .cpShapeCacheBB (self ._shape )
300300 return BB (_bb .l , _bb .b , _bb .r , _bb .t )
301301
@@ -391,7 +391,7 @@ def _hashid(self, v: int) -> None:
391391 cp .cpShapeSetHashID (self ._shape , v )
392392
393393 def __getstate__ (self ) -> _State :
394- """Return the state of this object
394+ """Return the state of this object.
395395
396396 This method allows the usage of the :mod:`copy` and :mod:`pickle`
397397 modules with this class.
@@ -407,9 +407,9 @@ def __getstate__(self) -> _State:
407407
408408
409409class Circle (Shape ):
410- """A circle shape defined by a radius
410+ """A circle shape defined by a radius.
411411
412- This is the fastest and simplest collision shape
412+ This is the fastest and simplest collision shape.
413413 """
414414
415415 _pickle_attrs_init = Shape ._pickle_attrs_init + ["radius" , "offset" ]
@@ -445,7 +445,7 @@ def unsafe_set_radius(self, r: float) -> None:
445445
446446 @property
447447 def radius (self ) -> float :
448- """The Radius of the circle"""
448+ """The Radius of the circle. """
449449 return cp .cpCircleShapeGetRadius (self ._shape )
450450
451451 def unsafe_set_offset (self , o : Tuple [float , float ]) -> None :
@@ -468,7 +468,7 @@ def offset(self) -> Vec2d:
468468
469469
470470class Segment (Shape ):
471- """A line segment shape between two points
471+ """A line segment shape between two points.
472472
473473 Meant mainly as a static shape. Can be beveled in order to give them a
474474 thickness.
@@ -483,7 +483,7 @@ def __init__(
483483 b : Tuple [float , float ],
484484 radius : float ,
485485 ) -> None :
486- """Create a Segment
486+ """Create a Segment.
487487
488488 It is legal to send in None as body argument to indicate that this
489489 shape is not attached to a body. However, you must attach it to a body
@@ -516,7 +516,7 @@ def _get_b(self) -> Vec2d:
516516 def unsafe_set_endpoints (
517517 self , a : Tuple [float , float ], b : Tuple [float , float ]
518518 ) -> None :
519- """Set the two endpoints for this segment
519+ """Set the two endpoints for this segment.
520520
521521 .. note::
522522 This change is only picked up as a change to the position
@@ -535,7 +535,7 @@ def normal(self) -> Vec2d:
535535 return Vec2d (v .x , v .y )
536536
537537 def unsafe_set_radius (self , r : float ) -> None :
538- """Set the radius of the segment
538+ """Set the radius of the segment.
539539
540540 .. note::
541541 This change is only picked up as a change to the position
@@ -547,7 +547,7 @@ def unsafe_set_radius(self, r: float) -> None:
547547
548548 @property
549549 def radius (self ) -> float :
550- """The radius/thickness of the segment"""
550+ """The radius/thickness of the segment. """
551551 return cp .cpSegmentShapeGetRadius (self ._shape )
552552
553553 def set_neighbors (
@@ -564,7 +564,7 @@ def set_neighbors(
564564
565565
566566class Poly (Shape ):
567- """A convex polygon shape
567+ """A convex polygon shape.
568568
569569 Slowest, but most flexible collision shape.
570570 """
@@ -578,14 +578,16 @@ def __init__(
578578 ) -> None :
579579 """Create a polygon.
580580
581- A convex hull will be calculated from the vertexes automatically.
581+ A convex hull will be calculated from the vertexes automatically. Note
582+ that concave ones will be converted to a convex hull using the Quickhull
583+ algorithm.
582584
583585 Adding a small radius will bevel the corners and can significantly
584586 reduce problems where the poly gets stuck on seams in your geometry.
585587
586588 It is legal to send in None as body argument to indicate that this
587589 shape is not attached to a body. However, you must attach it to a body
588- before adding the shape to a space or used for a space shape query.
590+ before adding the shape to a space or using for a space shape query.
589591
590592 .. note::
591593 Make sure to put the vertices around (0,0) or the shape might
@@ -615,8 +617,8 @@ def __init__(
615617
616618 :param Body body: The body to attach the poly to
617619 :param [(float,float)] vertices: Define a convex hull of the polygon
618- with a counterclockwise winding.
619- :param Transform transform: Transform will be applied to every vertex.
620+ with a counterclockwise winding
621+ :param Transform transform: Transform will be applied to every vertex
620622 :param float radius: Set the radius of the poly shape
621623
622624 """
@@ -652,10 +654,10 @@ def radius(self) -> float:
652654 def create_box (
653655 body : Optional ["Body" ], size : Tuple [float , float ] = (10 , 10 ), radius : float = 0
654656 ) -> "Poly" :
655- """Convenience function to create a box given a width and height.
657+ """Convenience function to create a box with given width and height.
656658
657659 The boxes will always be centered at the center of gravity of the
658- body you are attaching them to. If you want to create an off-center
660+ body you are attaching them to. If you want to create an off-center
659661 box, you will need to use the normal constructor Poly(...).
660662
661663 Adding a small radius will bevel the corners and can significantly
@@ -680,7 +682,7 @@ def create_box_bb(body: Optional["Body"], bb: BB, radius: float = 0) -> "Poly":
680682 """Convenience function to create a box shape from a :py:class:`BB`.
681683
682684 The boxes will always be centered at the center of gravity of the
683- body you are attaching them to. If you want to create an off-center
685+ body you are attaching them to. If you want to create an off-center
684686 box, you will need to use the normal constructor Poly(..).
685687
686688 Adding a small radius will bevel the corners and can significantly
@@ -700,7 +702,7 @@ def create_box_bb(body: Optional["Body"], bb: BB, radius: float = 0) -> "Poly":
700702 return self
701703
702704 def get_vertices (self ) -> List [Vec2d ]:
703- """Get the vertices in local coordinates for the polygon
705+ """Get the vertices in local coordinates for the polygon.
704706
705707 If you need the vertices in world coordinates then the vertices can be
706708 transformed by adding the body position and each vertex rotated by the
@@ -722,8 +724,8 @@ def get_vertices(self) -> List[Vec2d]:
722724 :rtype: [:py:class:`Vec2d`]
723725 """
724726 verts = []
725- l = cp .cpPolyShapeGetCount (self ._shape )
726- for i in range (l ):
727+ lines = cp .cpPolyShapeGetCount (self ._shape )
728+ for i in range (lines ):
727729 v = cp .cpPolyShapeGetVert (self ._shape , i )
728730 verts .append (Vec2d (v .x , v .y ))
729731 return verts
@@ -748,7 +750,7 @@ def unsafe_set_vertices(
748750 cp .cpPolyShapeSetVerts (self ._shape , len (vertices ), vertices , transform )
749751
750752 def __getstate__ (self ) -> _State :
751- """Return the state of this object
753+ """Return the state of this object.
752754
753755 This method allows the usage of the :mod:`copy` and :mod:`pickle`
754756 modules with this class.
0 commit comments