goo.division

class goo.division.BisectDivisionLogic(margin=0.025)[source]

Bases: DivisionLogic

Division logic that uses low-level bmesh operations, i.e. bmesh.ops.bisect_plane to divide a cell along its major axis.

Variables:
  • margin (float) – Distance of margin between divided cells.

  • to_flush (list[tuple[bmesh.types.BMesh, Cell]]) – List of bmesh objects and cells to flush.

flush()[source]

Flush the bmesh objects and cells from the division logic.

make_divide(mother: Cell) tuple[Cell, Cell][source]

Divide a mother cell into two daughter cells.

Parameters:

mother (Cell) – The mother cell to divide.

Returns:

A tuple containing the two daughter cells that will result from the division.

Return type:

tuple[Cell, Cell]

Note

The meshes of the daughter should not be updated at this stage. flush() must be called to update all cells at once so that they do not interfere with each other.

class goo.division.BooleanDivisionLogic[source]

Bases: DivisionLogic

Division logic that creates a plane of division and applies the Boolean modifier to create a division.

Boolean division is depreciated and will be removed in the future. The reason behind this is that it is not possible to apply the Boolean modifier to a cell with physics enabled; therefore leads to instability and simulation failure.

flush()[source]

Finish performing all stored divisions.

make_divide(mother: Cell) tuple[Cell, Cell][source]

Divide a mother cell into two daughter cells.

Parameters:

mother (Cell) – The mother cell to divide.

Returns:

A tuple containing the two daughter cells that will result from the division.

Return type:

tuple[Cell, Cell]

Note

The meshes of the daughter should not be updated at this stage. flush() must be called to update all cells at once so that they do not interfere with each other.

class goo.division.DivisionHandler(division_logic: DivisionLogic, mu: float, sigma: float)[source]

Bases: Handler

Handler for managing cell division processes.

This handler is responsible for managing the division of cells based on the provided division logic. It determines which cells are eligible for division and performs the division process.

Variables:
  • division_logic (DivisionLogic) – The division logic used to execute cell division.

  • mu (float) – Mean metric for determining cell division.

  • sigma (float) – Standard deviation of the metric for determining cell division.

Parameters:
can_divide(cell: Cell) bool[source]

Check if a cell is eligible for division.

This method must be implemented by all subclasses.

Parameters:

cell (Cell) – The cell to check.

Returns:

True if the cell can divide, False otherwise.

Return type:

bool

run(scene, depsgraph)[source]

Run the handler.

This is the function that gets passed to Blender, to be called upon specified events (e.g. post-frame change).

Parameters:
  • scene (bpy.types.Scene) – The Blender scene.

  • depsgraph (bpy.types.Depsgraph) – The dependency graph.

setup(get_cells: Callable[[], list[Cell]], get_diffsystems: Callable[[], list[DiffusionSystem]], dt: float) None[source]

Set up the handler.

Parameters:
  • get_cells (Callable[[], list[Cell]]) – A function that, when called, retrieves the list of cells that may divide.

  • get_diffsystem (Callable[[], DiffusionSystem]) – A function that, when called, retrieves the diffusion system.

  • dt (float) – The time step for the simulation.

  • get_diffsystems (Callable[[], list[DiffusionSystem]])

Return type:

None

update_on_divide(cell: Cell)[source]

Perform updates after a cell has divided.

This method can be overridden by subclasses to perform additional updates (e.g. set a property) after a cell has divided.

Parameters:

cell (Cell) – The cell that has divided.

class goo.division.DivisionLogic[source]

Bases: object

Base class for defining division logic for cells.

flush()[source]

Finish performing all stored divisions.

make_divide(mother: Cell) tuple[Cell, Cell][source]

Divide a mother cell into two daughter cells.

Parameters:

mother (Cell) – The mother cell to divide.

Returns:

A tuple containing the two daughter cells that will result from the division.

Return type:

tuple[Cell, Cell]

Note

The meshes of the daughter should not be updated at this stage. flush() must be called to update all cells at once so that they do not interfere with each other.

class goo.division.SizeDivisionHandler(division_logic: DivisionLogic, mu: float = 50, sigma: float = 0, one_division_only: bool = False)[source]

Bases: DivisionHandler

Division handler that determines eligibility based on size of cell.

Variables:
  • division_logic (DivisionLogic) – see base class.

  • threshold (float) – minimum size of cell able to divide.

  • one_division_only (bool) – if True, cells will only divide once and never again.

Parameters:
  • division_logic (DivisionLogic)

  • mu (float)

  • sigma (float)

  • one_division_only (bool)

can_divide(cell: Cell) bool[source]

Check if a cell is eligible for division.

This method must be implemented by all subclasses.

Parameters:

cell (Cell) – The cell to check.

Returns:

True if the cell can divide, False otherwise.

Return type:

bool

run(scene, depsgraph)

Run the handler.

This is the function that gets passed to Blender, to be called upon specified events (e.g. post-frame change).

Parameters:
  • scene (bpy.types.Scene) – The Blender scene.

  • depsgraph (bpy.types.Depsgraph) – The dependency graph.

setup(get_cells: Callable[[], list[Cell]], get_diffsystem: Callable[[], DiffusionSystem], dt: float) None[source]

Set up the handler.

Parameters:
  • get_cells (Callable[[], list[Cell]]) – A function that, when called, retrieves the list of cells that may divide.

  • get_diffsystem (Callable[[], DiffusionSystem]) – A function that, when called, retrieves the diffusion system.

  • dt (float) – The time step for the simulation.

Return type:

None

update_on_divide(cell: Cell) None[source]

Perform updates after a cell has divided.

This method can be overridden by subclasses to perform additional updates (e.g. set a property) after a cell has divided.

Parameters:

cell (Cell) – The cell that has divided.

Return type:

None

class goo.division.TimeDivisionHandler(division_logic: DivisionLogic, mu: float = 20, sigma: float = 0)[source]

Bases: DivisionHandler

Division handler that determines eligibility based on time from last divsion.

Variables:
  • division_logic (DivisionLogic) – see base class.

  • mu (float) – Time interval between cell divisions.

  • var (float) – Variance in the time interval.

Parameters:
can_divide(cell: Cell) bool[source]

Check if a cell is eligible for division.

This method must be implemented by all subclasses.

Parameters:

cell (Cell) – The cell to check.

Returns:

True if the cell can divide, False otherwise.

Return type:

bool

run(scene, depsgraph)

Run the handler.

This is the function that gets passed to Blender, to be called upon specified events (e.g. post-frame change).

Parameters:
  • scene (bpy.types.Scene) – The Blender scene.

  • depsgraph (bpy.types.Depsgraph) – The dependency graph.

setup(get_cells: Callable[[], list[Cell]], get_diffsystem: Callable[[], DiffusionSystem], dt: float) None[source]

Set up the handler.

Parameters:
  • get_cells (Callable[[], list[Cell]]) – A function that, when called, retrieves the list of cells that may divide.

  • get_diffsystem (Callable[[], DiffusionSystem]) – A function that, when called, retrieves the diffusion system.

  • dt (float) – The time step for the simulation.

Return type:

None

update_on_divide(cell: Cell) None[source]

Perform updates after a cell has divided.

This method can be overridden by subclasses to perform additional updates (e.g. set a property) after a cell has divided.

Parameters:

cell (Cell) – The cell that has divided.

Return type:

None