Insert the entity into this or the appropriate child. This also acts as thinking (recursively). Using :py:meth:`.insert_and_think` iteratively is slightly less efficient but has more predictable performance than initializing with a large number of entities t
(self, entity)
| 277 | |
| 278 | |
| 279 | def insert_and_think(self, entity): |
| 280 | """ |
| 281 | Insert the entity into this or the appropriate child. |
| 282 | |
| 283 | This also acts as thinking (recursively). Using :py:meth:`.insert_and_think` |
| 284 | iteratively is slightly less efficient but has more predictable performance |
| 285 | than initializing with a large number of entities then thinking is slightly |
| 286 | faster but may hang. Both may exceed recursion depth if :py:attr:`.max_depth` |
| 287 | is too large. |
| 288 | |
| 289 | :param entity: the entity to insert |
| 290 | :type entity: :class:`.QuadTreeEntity` |
| 291 | """ |
| 292 | if not self.children and len(self.entities) == self.bucket_size and self.depth < self.max_depth: |
| 293 | self.split() |
| 294 | |
| 295 | quad = self.get_quadrant(entity) if self.children else -1 |
| 296 | if quad < 0: |
| 297 | self.entities.append(entity) |
| 298 | else: |
| 299 | self.children[quad].insert_and_think(entity) |
| 300 | |
| 301 | def retrieve_collidables(self, entity, predicate = None): |
| 302 | """ |