Blender  V3.3
BLI_astar.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2014 Blender Foundation. All rights reserved. */
3 
4 #pragma once
5 
11 #include "BLI_utildefines.h"
12 
13 #include "BLI_bitmap.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /* -------------------------------------------------------------------- */
20 
21 typedef struct BLI_AStarGNLink {
22  int nodes[2];
23  float cost;
24 
25  void *custom_data;
27 
28 typedef struct BLI_AStarGNode {
29  struct ListBase neighbor_links;
30 
31  void *custom_data;
33 
34 typedef struct BLI_AStarSolution {
35  /* Final 'most useful' data. */
38  int steps;
40  int *prev_nodes;
43 
44  void *custom_data;
45 
46  /* Mostly runtime data. */
48  float *g_costs;
49  int *g_steps;
50 
51  struct MemArena *mem; /* Memory arena. */
53 
54 typedef struct BLI_AStarGraph {
55  int node_num;
57 
58  void *custom_data;
59 
60  struct MemArena *mem; /* Memory arena. */
62 
69 void BLI_astar_node_init(BLI_AStarGraph *as_graph, int node_index, void *custom_data);
79  BLI_AStarGraph *as_graph, int node1_index, int node2_index, float cost, void *custom_data);
84 
94  BLI_AStarSolution *as_solution,
95  void *custom_data);
106 void BLI_astar_solution_free(BLI_AStarSolution *as_solution);
107 
119 typedef float (*astar_f_cost)(BLI_AStarGraph *as_graph,
120  BLI_AStarSolution *as_solution,
121  BLI_AStarGNLink *link,
122  int node_idx_curr,
123  int node_idx_next,
124  int node_idx_dst);
125 
134 void BLI_astar_graph_init(BLI_AStarGraph *as_graph, int node_num, void *custom_data);
135 void BLI_astar_graph_free(BLI_AStarGraph *as_graph);
145  int node_index_src,
146  int node_index_dst,
147  astar_f_cost f_cost_cb,
148  BLI_AStarSolution *r_solution,
149  int max_steps);
150 
151 #ifdef __cplusplus
152 }
153 #endif
typedef float(TangentPoint)[2]
struct BLI_AStarGNode BLI_AStarGNode
struct BLI_AStarGNLink BLI_AStarGNLink
bool BLI_astar_graph_solve(BLI_AStarGraph *as_graph, int node_index_src, int node_index_dst, astar_f_cost f_cost_cb, BLI_AStarSolution *r_solution, int max_steps)
Definition: astar.c:144
float(* astar_f_cost)(BLI_AStarGraph *as_graph, BLI_AStarSolution *as_solution, BLI_AStarGNLink *link, int node_idx_curr, int node_idx_next, int node_idx_dst)
Definition: BLI_astar.h:119
void BLI_astar_solution_clear(BLI_AStarSolution *as_solution)
Definition: astar.c:95
struct BLI_AStarGraph BLI_AStarGraph
void BLI_astar_node_init(BLI_AStarGraph *as_graph, int node_index, void *custom_data)
Definition: astar.c:40
void BLI_astar_node_link_add(BLI_AStarGraph *as_graph, int node1_index, int node2_index, float cost, void *custom_data)
Definition: astar.c:45
void BLI_astar_solution_init(BLI_AStarGraph *as_graph, BLI_AStarSolution *as_solution, void *custom_data)
Definition: astar.c:71
void BLI_astar_graph_init(BLI_AStarGraph *as_graph, int node_num, void *custom_data)
Definition: astar.c:120
int BLI_astar_node_link_other_node(BLI_AStarGNLink *lnk, int idx)
Definition: astar.c:66
void BLI_astar_solution_free(BLI_AStarSolution *as_solution)
Definition: astar.c:112
void BLI_astar_graph_free(BLI_AStarGraph *as_graph)
Definition: astar.c:136
struct BLI_AStarSolution BLI_AStarSolution
unsigned int BLI_bitmap
Definition: BLI_bitmap.h:16
void * custom_data
Definition: BLI_astar.h:31
struct ListBase neighbor_links
Definition: BLI_astar.h:29
BLI_AStarGNode * nodes
Definition: BLI_astar.h:56
void * custom_data
Definition: BLI_astar.h:58
struct MemArena * mem
Definition: BLI_astar.h:60
BLI_AStarGNLink ** prev_links
Definition: BLI_astar.h:42
struct MemArena * mem
Definition: BLI_astar.h:51
float * g_costs
Definition: BLI_astar.h:48
void * custom_data
Definition: BLI_astar.h:44
BLI_bitmap * done_nodes
Definition: BLI_astar.h:47