Skip to content

stdlib/flowfieldView source ↗

flowfield

14 items · generated by scribe fromstdlib/flowfield.fd· synced 2026-11-15

stdlib/flowfield14 items

Contents

Flowfield

pub struct Flowfield {

Fields:

NameType
widthi64
heighti64
distanceVec<i64>
dir_xVec<i64>
dir_yVec<i64>
target_xi64
target_yi64
computedbool

Defined at line 24


flowfield_create

Create a new empty flowfield (all cells unvisited).

pub fn flowfield_create(width: i64, height: i64) -> Flowfield {

Parameters:

  • width: i64
  • height: i64

Returns: Flowfield

Defined at line 41


flowfield_set_target

Set the destination/target cell.

pub fn flowfield_set_target(ff: & mut Flowfield, x: i64, y: i64) -> void {

Parameters:

  • ff: & mut Flowfield
  • x: i64
  • y: i64

Returns: void

Defined at line 61


flowfield_set_blocked

Mark a cell as blocked (impassable).

pub fn flowfield_set_blocked(ff: & mut Flowfield, x: i64, y: i64) -> void {

Parameters:

  • ff: & mut Flowfield
  • x: i64
  • y: i64

Returns: void

Defined at line 71


flowfield_set_passable

Mark a cell as passable (clear blocked status).

pub fn flowfield_set_passable(ff: & mut Flowfield, x: i64, y: i64) -> void {

Parameters:

  • ff: & mut Flowfield
  • x: i64
  • y: i64

Returns: void

Defined at line 80


flowfield_is_blocked

Check if a cell is blocked.

pub fn flowfield_is_blocked(ff: Flowfield, x: i64, y: i64) -> bool {

Parameters:

  • ff: Flowfield
  • x: i64
  • y: i64

Returns: bool

Defined at line 89


flowfield_compute

Compute the distance field using BFS from the target. Uses a simple queue (Vec with head index) since Fides has no deque yet.

pub fn flowfield_compute(ff: & mut Flowfield) -> void {

Parameters:

  • ff: & mut Flowfield

Returns: void

Defined at line 104


flowfield_compute_dirs

Compute direction vectors from the distance field. Each cell’s direction points toward the neighbor with the lowest distance.

pub fn flowfield_compute_dirs(ff: & mut Flowfield) -> void {

Parameters:

  • ff: & mut Flowfield

Returns: void

Defined at line 176


flowfield_get_dir

Get the direction vector at a cell. Returns (dx, dy). The vector is normalized (one of: (0,0), (±1,0), (0,±1)).

pub fn flowfield_get_dir(ff: Flowfield, x: i64, y: i64) -> (i64, i64) {

Parameters:

  • ff: Flowfield
  • x: i64
  • y: i64

Returns: (i64, i64)

Defined at line 245


flowfield_get_distance

Get the distance to the target from a cell. -1 = blocked, -2 = unreachable.

pub fn flowfield_get_distance(ff: Flowfield, x: i64, y: i64) -> i64 {

Parameters:

  • ff: Flowfield
  • x: i64
  • y: i64

Returns: i64

Defined at line 254


flowfield_has_path

Check if a cell has a valid path to the target.

pub fn flowfield_has_path(ff: Flowfield, x: i64, y: i64) -> bool {

Parameters:

  • ff: Flowfield
  • x: i64
  • y: i64

Returns: bool

Defined at line 262


flowfield_is_computed

Check if the flowfield has been computed.

pub fn flowfield_is_computed(ff: Flowfield) -> bool {

Parameters:

  • ff: Flowfield

Returns: bool

Defined at line 271


flowfield_add_cost

Add a cost penalty to a cell (higher = less desirable path).

pub fn flowfield_add_cost(ff: & mut Flowfield, x: i64, y: i64, cost: i64) -> void {

Parameters:

  • ff: & mut Flowfield
  • x: i64
  • y: i64
  • cost: i64

Returns: void

Defined at line 281


flowfield_reset

Reset the flowfield (clear distances and directions, keep blocked tiles).

pub fn flowfield_reset(ff: & mut Flowfield) -> void {

Parameters:

  • ff: & mut Flowfield

Returns: void

Defined at line 295


Generated by scribe, the Fides documentation generator