Add getters to navigation servers

Add virtual functions and bind to navigation servers
Implement getters
Add documentation
This commit is contained in:
Nicholas Foo 2023-12-19 19:51:49 +01:00 committed by Yuri Sizov
parent 1f5d4a62e9
commit e7ee672120
14 changed files with 636 additions and 9 deletions

View file

@ -391,6 +391,13 @@ COMMAND_2(region_set_transform, RID, p_region, Transform3D, p_transform) {
region->set_transform(p_transform);
}
Transform3D GodotNavigationServer::region_get_transform(RID p_region) const {
NavRegion *region = region_owner.get_or_null(p_region);
ERR_FAIL_NULL_V(region, Transform3D());
return region->get_transform();
}
COMMAND_2(region_set_enter_cost, RID, p_region, real_t, p_enter_cost) {
NavRegion *region = region_owner.get_or_null(p_region);
ERR_FAIL_NULL(region);
@ -719,6 +726,13 @@ COMMAND_2(agent_set_neighbor_distance, RID, p_agent, real_t, p_distance) {
agent->set_neighbor_distance(p_distance);
}
real_t GodotNavigationServer::agent_get_neighbor_distance(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, 0);
return agent->get_neighbor_distance();
}
COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL(agent);
@ -726,22 +740,43 @@ COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) {
agent->set_max_neighbors(p_count);
}
int GodotNavigationServer::agent_get_max_neighbors(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, 0);
return agent->get_max_neighbors();
}
COMMAND_2(agent_set_time_horizon_agents, RID, p_agent, real_t, p_time_horizon) {
ERR_FAIL_COND_MSG(p_time_horizon < 0.0, "Time horizion must be positive.");
ERR_FAIL_COND_MSG(p_time_horizon < 0.0, "Time horizon must be positive.");
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL(agent);
agent->set_time_horizon_agents(p_time_horizon);
}
real_t GodotNavigationServer::agent_get_time_horizon_agents(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, 0);
return agent->get_time_horizon_agents();
}
COMMAND_2(agent_set_time_horizon_obstacles, RID, p_agent, real_t, p_time_horizon) {
ERR_FAIL_COND_MSG(p_time_horizon < 0.0, "Time horizion must be positive.");
ERR_FAIL_COND_MSG(p_time_horizon < 0.0, "Time horizon must be positive.");
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL(agent);
agent->set_time_horizon_obstacles(p_time_horizon);
}
real_t GodotNavigationServer::agent_get_time_horizon_obstacles(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, 0);
return agent->get_time_horizon_obstacles();
}
COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) {
ERR_FAIL_COND_MSG(p_radius < 0.0, "Radius must be positive.");
NavAgent *agent = agent_owner.get_or_null(p_agent);
@ -750,6 +785,13 @@ COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) {
agent->set_radius(p_radius);
}
real_t GodotNavigationServer::agent_get_radius(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, 0);
return agent->get_radius();
}
COMMAND_2(agent_set_height, RID, p_agent, real_t, p_height) {
ERR_FAIL_COND_MSG(p_height < 0.0, "Height must be positive.");
NavAgent *agent = agent_owner.get_or_null(p_agent);
@ -758,6 +800,13 @@ COMMAND_2(agent_set_height, RID, p_agent, real_t, p_height) {
agent->set_height(p_height);
}
real_t GodotNavigationServer::agent_get_height(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, 0);
return agent->get_height();
}
COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) {
ERR_FAIL_COND_MSG(p_max_speed < 0.0, "Max speed must be positive.");
NavAgent *agent = agent_owner.get_or_null(p_agent);
@ -766,6 +815,13 @@ COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) {
agent->set_max_speed(p_max_speed);
}
real_t GodotNavigationServer::agent_get_max_speed(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, 0);
return agent->get_max_speed();
}
COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL(agent);
@ -773,6 +829,13 @@ COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) {
agent->set_velocity(p_velocity);
}
Vector3 GodotNavigationServer::agent_get_velocity(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, Vector3());
return agent->get_velocity();
}
COMMAND_2(agent_set_velocity_forced, RID, p_agent, Vector3, p_velocity) {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL(agent);
@ -787,6 +850,13 @@ COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position) {
agent->set_position(p_position);
}
Vector3 GodotNavigationServer::agent_get_position(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, Vector3());
return agent->get_position();
}
bool GodotNavigationServer::agent_is_map_changed(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, false);
@ -809,18 +879,39 @@ COMMAND_2(agent_set_avoidance_callback, RID, p_agent, Callable, p_callback) {
}
}
bool GodotNavigationServer::agent_has_avoidance_callback(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, false);
return agent->has_avoidance_callback();
}
COMMAND_2(agent_set_avoidance_layers, RID, p_agent, uint32_t, p_layers) {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL(agent);
agent->set_avoidance_layers(p_layers);
}
uint32_t GodotNavigationServer::agent_get_avoidance_layers(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, 0);
return agent->get_avoidance_layers();
}
COMMAND_2(agent_set_avoidance_mask, RID, p_agent, uint32_t, p_mask) {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL(agent);
agent->set_avoidance_mask(p_mask);
}
uint32_t GodotNavigationServer::agent_get_avoidance_mask(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, 0);
return agent->get_avoidance_mask();
}
COMMAND_2(agent_set_avoidance_priority, RID, p_agent, real_t, p_priority) {
ERR_FAIL_COND_MSG(p_priority < 0.0, "Avoidance priority must be between 0.0 and 1.0 inclusive.");
ERR_FAIL_COND_MSG(p_priority > 1.0, "Avoidance priority must be between 0.0 and 1.0 inclusive.");
@ -829,6 +920,13 @@ COMMAND_2(agent_set_avoidance_priority, RID, p_agent, real_t, p_priority) {
agent->set_avoidance_priority(p_priority);
}
real_t GodotNavigationServer::agent_get_avoidance_priority(RID p_agent) const {
NavAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_NULL_V(agent, 0);
return agent->get_avoidance_priority();
}
RID GodotNavigationServer::obstacle_create() {
MutexLock lock(operations_mutex);
@ -913,12 +1011,26 @@ COMMAND_2(obstacle_set_radius, RID, p_obstacle, real_t, p_radius) {
obstacle->set_radius(p_radius);
}
real_t GodotNavigationServer::obstacle_get_radius(RID p_obstacle) const {
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
ERR_FAIL_NULL_V(obstacle, 0);
return obstacle->get_radius();
}
COMMAND_2(obstacle_set_height, RID, p_obstacle, real_t, p_height) {
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
ERR_FAIL_NULL(obstacle);
obstacle->set_height(p_height);
}
real_t GodotNavigationServer::obstacle_get_height(RID p_obstacle) const {
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
ERR_FAIL_NULL_V(obstacle, 0);
return obstacle->get_height();
}
COMMAND_2(obstacle_set_velocity, RID, p_obstacle, Vector3, p_velocity) {
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
ERR_FAIL_NULL(obstacle);
@ -926,24 +1038,52 @@ COMMAND_2(obstacle_set_velocity, RID, p_obstacle, Vector3, p_velocity) {
obstacle->set_velocity(p_velocity);
}
Vector3 GodotNavigationServer::obstacle_get_velocity(RID p_obstacle) const {
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
ERR_FAIL_NULL_V(obstacle, Vector3());
return obstacle->get_velocity();
}
COMMAND_2(obstacle_set_position, RID, p_obstacle, Vector3, p_position) {
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
ERR_FAIL_NULL(obstacle);
obstacle->set_position(p_position);
}
Vector3 GodotNavigationServer::obstacle_get_position(RID p_obstacle) const {
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
ERR_FAIL_NULL_V(obstacle, Vector3());
return obstacle->get_position();
}
void GodotNavigationServer::obstacle_set_vertices(RID p_obstacle, const Vector<Vector3> &p_vertices) {
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
ERR_FAIL_NULL(obstacle);
obstacle->set_vertices(p_vertices);
}
Vector<Vector3> GodotNavigationServer::obstacle_get_vertices(RID p_obstacle) const {
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
ERR_FAIL_NULL_V(obstacle, Vector<Vector3>());
return obstacle->get_vertices();
}
COMMAND_2(obstacle_set_avoidance_layers, RID, p_obstacle, uint32_t, p_layers) {
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
ERR_FAIL_NULL(obstacle);
obstacle->set_avoidance_layers(p_layers);
}
uint32_t GodotNavigationServer::obstacle_get_avoidance_layers(RID p_obstacle) const {
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
ERR_FAIL_NULL_V(obstacle, 0);
return obstacle->get_avoidance_layers();
}
void GodotNavigationServer::parse_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, Node *p_root_node, const Callable &p_callback) {
#ifndef _3D_DISABLED
ERR_FAIL_COND_MSG(!Thread::is_main_thread(), "The SceneTree can only be parsed on the main thread. Call this function from the main thread or use call_deferred().");

View file

@ -165,6 +165,7 @@ public:
COMMAND_2(region_set_navigation_layers, RID, p_region, uint32_t, p_navigation_layers);
virtual uint32_t region_get_navigation_layers(RID p_region) const override;
COMMAND_2(region_set_transform, RID, p_region, Transform3D, p_transform);
virtual Transform3D region_get_transform(RID p_region) const override;
COMMAND_2(region_set_navigation_mesh, RID, p_region, Ref<NavigationMesh>, p_navigation_mesh);
#ifndef DISABLE_DEPRECATED
virtual void region_bake_navigation_mesh(Ref<NavigationMesh> p_navigation_mesh, Node *p_root_node) override;
@ -204,20 +205,33 @@ public:
COMMAND_2(agent_set_paused, RID, p_agent, bool, p_paused);
virtual bool agent_get_paused(RID p_agent) const override;
COMMAND_2(agent_set_neighbor_distance, RID, p_agent, real_t, p_distance);
virtual real_t agent_get_neighbor_distance(RID p_agent) const override;
COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count);
virtual int agent_get_max_neighbors(RID p_agent) const override;
COMMAND_2(agent_set_time_horizon_agents, RID, p_agent, real_t, p_time_horizon);
virtual real_t agent_get_time_horizon_agents(RID p_agent) const override;
COMMAND_2(agent_set_time_horizon_obstacles, RID, p_agent, real_t, p_time_horizon);
virtual real_t agent_get_time_horizon_obstacles(RID p_agent) const override;
COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius);
virtual real_t agent_get_radius(RID p_agent) const override;
COMMAND_2(agent_set_height, RID, p_agent, real_t, p_height);
virtual real_t agent_get_height(RID p_agent) const override;
COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed);
virtual real_t agent_get_max_speed(RID p_agent) const override;
COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity);
virtual Vector3 agent_get_velocity(RID p_agent) const override;
COMMAND_2(agent_set_velocity_forced, RID, p_agent, Vector3, p_velocity);
COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position);
virtual Vector3 agent_get_position(RID p_agent) const override;
virtual bool agent_is_map_changed(RID p_agent) const override;
COMMAND_2(agent_set_avoidance_callback, RID, p_agent, Callable, p_callback);
virtual bool agent_has_avoidance_callback(RID p_agent) const override;
COMMAND_2(agent_set_avoidance_layers, RID, p_agent, uint32_t, p_layers);
virtual uint32_t agent_get_avoidance_layers(RID p_agent) const override;
COMMAND_2(agent_set_avoidance_mask, RID, p_agent, uint32_t, p_mask);
virtual uint32_t agent_get_avoidance_mask(RID p_agent) const override;
COMMAND_2(agent_set_avoidance_priority, RID, p_agent, real_t, p_priority);
virtual real_t agent_get_avoidance_priority(RID p_agent) const override;
virtual RID obstacle_create() override;
COMMAND_2(obstacle_set_avoidance_enabled, RID, p_obstacle, bool, p_enabled);
@ -229,11 +243,17 @@ public:
COMMAND_2(obstacle_set_paused, RID, p_obstacle, bool, p_paused);
virtual bool obstacle_get_paused(RID p_obstacle) const override;
COMMAND_2(obstacle_set_radius, RID, p_obstacle, real_t, p_radius);
virtual real_t obstacle_get_radius(RID p_obstacle) const override;
COMMAND_2(obstacle_set_velocity, RID, p_obstacle, Vector3, p_velocity);
virtual Vector3 obstacle_get_velocity(RID p_obstacle) const override;
COMMAND_2(obstacle_set_position, RID, p_obstacle, Vector3, p_position);
virtual Vector3 obstacle_get_position(RID p_obstacle) const override;
COMMAND_2(obstacle_set_height, RID, p_obstacle, real_t, p_height);
virtual real_t obstacle_get_height(RID p_obstacle) const override;
virtual void obstacle_set_vertices(RID p_obstacle, const Vector<Vector3> &p_vertices) override;
virtual Vector<Vector3> obstacle_get_vertices(RID p_obstacle) const override;
COMMAND_2(obstacle_set_avoidance_layers, RID, p_obstacle, uint32_t, p_layers);
virtual uint32_t obstacle_get_avoidance_layers(RID p_obstacle) const override;
virtual void parse_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, Node *p_root_node, const Callable &p_callback = Callable()) override;
virtual void bake_from_source_geometry_data(const Ref<NavigationMesh> &p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data, const Callable &p_callback = Callable()) override;

View file

@ -141,6 +141,13 @@ static Transform3D trf2_to_trf3(const Transform2D &d) {
return Transform3D(b, o);
}
static Transform2D trf3_to_trf2(const Transform3D &d) {
Vector3 o = d.get_origin();
Vector3 nx = d.xform(Vector3(1, 0, 0)) - o;
Vector3 nz = d.xform(Vector3(0, 0, 1)) - o;
return Transform2D(nx.x, nx.z, nz.x, nz.z, o.x, o.z);
}
static ObjectID id_to_id(const ObjectID &id) {
return id;
}
@ -283,6 +290,10 @@ void FORWARD_2(region_set_navigation_layers, RID, p_region, uint32_t, p_navigati
uint32_t FORWARD_1_C(region_get_navigation_layers, RID, p_region, rid_to_rid);
void FORWARD_2(region_set_transform, RID, p_region, Transform2D, p_transform, rid_to_rid, trf2_to_trf3);
Transform2D GodotNavigationServer2D::region_get_transform(RID p_region) const {
return trf3_to_trf2(NavigationServer3D::get_singleton()->region_get_transform(p_region));
}
void GodotNavigationServer2D::region_set_navigation_polygon(RID p_region, Ref<NavigationPolygon> p_navigation_polygon) {
NavigationServer3D::get_singleton()->region_set_navigation_mesh(p_region, poly_to_mesh(p_navigation_polygon));
}
@ -326,25 +337,60 @@ void FORWARD_2(agent_set_avoidance_enabled, RID, p_agent, bool, p_enabled, rid_t
bool FORWARD_1_C(agent_get_avoidance_enabled, RID, p_agent, rid_to_rid);
void FORWARD_2(agent_set_map, RID, p_agent, RID, p_map, rid_to_rid, rid_to_rid);
void FORWARD_2(agent_set_neighbor_distance, RID, p_agent, real_t, p_dist, rid_to_rid, real_to_real);
real_t GodotNavigationServer2D::agent_get_neighbor_distance(RID p_agent) const {
return NavigationServer3D::get_singleton()->agent_get_neighbor_distance(p_agent);
}
void FORWARD_2(agent_set_max_neighbors, RID, p_agent, int, p_count, rid_to_rid, int_to_int);
int GodotNavigationServer2D::agent_get_max_neighbors(RID p_agent) const {
return NavigationServer3D::get_singleton()->agent_get_max_neighbors(p_agent);
}
void FORWARD_2(agent_set_time_horizon_agents, RID, p_agent, real_t, p_time_horizon, rid_to_rid, real_to_real);
real_t GodotNavigationServer2D::agent_get_time_horizon_agents(RID p_agent) const {
return NavigationServer3D::get_singleton()->agent_get_time_horizon_agents(p_agent);
}
void FORWARD_2(agent_set_time_horizon_obstacles, RID, p_agent, real_t, p_time_horizon, rid_to_rid, real_to_real);
real_t GodotNavigationServer2D::agent_get_time_horizon_obstacles(RID p_agent) const {
return NavigationServer3D::get_singleton()->agent_get_time_horizon_obstacles(p_agent);
}
void FORWARD_2(agent_set_radius, RID, p_agent, real_t, p_radius, rid_to_rid, real_to_real);
real_t GodotNavigationServer2D::agent_get_radius(RID p_agent) const {
return NavigationServer3D::get_singleton()->agent_get_radius(p_agent);
}
void FORWARD_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed, rid_to_rid, real_to_real);
real_t GodotNavigationServer2D::agent_get_max_speed(RID p_agent) const {
return NavigationServer3D::get_singleton()->agent_get_max_speed(p_agent);
}
void FORWARD_2(agent_set_velocity_forced, RID, p_agent, Vector2, p_velocity, rid_to_rid, v2_to_v3);
void FORWARD_2(agent_set_velocity, RID, p_agent, Vector2, p_velocity, rid_to_rid, v2_to_v3);
Vector2 GodotNavigationServer2D::agent_get_velocity(RID p_agent) const {
return v3_to_v2(NavigationServer3D::get_singleton()->agent_get_velocity(p_agent));
}
void FORWARD_2(agent_set_position, RID, p_agent, Vector2, p_position, rid_to_rid, v2_to_v3);
Vector2 GodotNavigationServer2D::agent_get_position(RID p_agent) const {
return v3_to_v2(NavigationServer3D::get_singleton()->agent_get_position(p_agent));
}
bool FORWARD_1_C(agent_is_map_changed, RID, p_agent, rid_to_rid);
void FORWARD_2(agent_set_paused, RID, p_agent, bool, p_paused, rid_to_rid, bool_to_bool);
bool FORWARD_1_C(agent_get_paused, RID, p_agent, rid_to_rid);
void FORWARD_1(free, RID, p_object, rid_to_rid);
void FORWARD_2(agent_set_avoidance_callback, RID, p_agent, Callable, p_callback, rid_to_rid, callable_to_callable);
bool GodotNavigationServer2D::agent_has_avoidance_callback(RID p_agent) const {
return NavigationServer3D::get_singleton()->agent_has_avoidance_callback(p_agent);
}
void FORWARD_2(agent_set_avoidance_layers, RID, p_agent, uint32_t, p_layers, rid_to_rid, uint32_to_uint32);
uint32_t GodotNavigationServer2D::agent_get_avoidance_layers(RID p_agent) const {
return NavigationServer3D::get_singleton()->agent_get_avoidance_layers(p_agent);
}
void FORWARD_2(agent_set_avoidance_mask, RID, p_agent, uint32_t, p_mask, rid_to_rid, uint32_to_uint32);
uint32_t GodotNavigationServer2D::agent_get_avoidance_mask(RID p_agent) const {
return NavigationServer3D::get_singleton()->agent_get_avoidance_mask(p_agent);
}
void FORWARD_2(agent_set_avoidance_priority, RID, p_agent, real_t, p_priority, rid_to_rid, real_to_real);
real_t GodotNavigationServer2D::agent_get_avoidance_priority(RID p_agent) const {
return NavigationServer3D::get_singleton()->agent_get_avoidance_priority(p_agent);
}
RID GodotNavigationServer2D::obstacle_create() {
RID obstacle = NavigationServer3D::get_singleton()->obstacle_create();
@ -357,13 +403,28 @@ RID FORWARD_1_C(obstacle_get_map, RID, p_obstacle, rid_to_rid);
void FORWARD_2(obstacle_set_paused, RID, p_obstacle, bool, p_paused, rid_to_rid, bool_to_bool);
bool FORWARD_1_C(obstacle_get_paused, RID, p_obstacle, rid_to_rid);
void FORWARD_2(obstacle_set_radius, RID, p_obstacle, real_t, p_radius, rid_to_rid, real_to_real);
real_t GodotNavigationServer2D::obstacle_get_radius(RID p_obstacle) const {
return NavigationServer3D::get_singleton()->obstacle_get_radius(p_obstacle);
}
void FORWARD_2(obstacle_set_velocity, RID, p_obstacle, Vector2, p_velocity, rid_to_rid, v2_to_v3);
Vector2 GodotNavigationServer2D::obstacle_get_velocity(RID p_obstacle) const {
return v3_to_v2(NavigationServer3D::get_singleton()->obstacle_get_velocity(p_obstacle));
}
void FORWARD_2(obstacle_set_position, RID, p_obstacle, Vector2, p_position, rid_to_rid, v2_to_v3);
Vector2 GodotNavigationServer2D::obstacle_get_position(RID p_obstacle) const {
return v3_to_v2(NavigationServer3D::get_singleton()->obstacle_get_position(p_obstacle));
}
void FORWARD_2(obstacle_set_avoidance_layers, RID, p_obstacle, uint32_t, p_layers, rid_to_rid, uint32_to_uint32);
uint32_t GodotNavigationServer2D::obstacle_get_avoidance_layers(RID p_obstacle) const {
return NavigationServer3D::get_singleton()->obstacle_get_avoidance_layers(p_obstacle);
}
void GodotNavigationServer2D::obstacle_set_vertices(RID p_obstacle, const Vector<Vector2> &p_vertices) {
NavigationServer3D::get_singleton()->obstacle_set_vertices(p_obstacle, vector_v2_to_v3(p_vertices));
}
Vector<Vector2> GodotNavigationServer2D::obstacle_get_vertices(RID p_obstacle) const {
return vector_v3_to_v2(NavigationServer3D::get_singleton()->obstacle_get_vertices(p_obstacle));
}
void GodotNavigationServer2D::query_path(const Ref<NavigationPathQueryParameters2D> &p_query_parameters, Ref<NavigationPathQueryResult2D> p_query_result) const {
ERR_FAIL_COND(!p_query_parameters.is_valid());

View file

@ -95,6 +95,7 @@ public:
virtual void region_set_navigation_layers(RID p_region, uint32_t p_navigation_layers) override;
virtual uint32_t region_get_navigation_layers(RID p_region) const override;
virtual void region_set_transform(RID p_region, Transform2D p_transform) override;
virtual Transform2D region_get_transform(RID p_region) const override;
virtual void region_set_navigation_polygon(RID p_region, Ref<NavigationPolygon> p_navigation_polygon) override;
virtual int region_get_connections_count(RID p_region) const override;
virtual Vector2 region_get_connection_pathway_start(RID p_region, int p_connection_id) const override;
@ -159,6 +160,7 @@ public:
/// low, the simulation will not be safe.
/// Must be non-negative.
virtual void agent_set_neighbor_distance(RID p_agent, real_t p_distance) override;
virtual real_t agent_get_neighbor_distance(RID p_agent) const override;
/// The maximum number of other agents this
/// agent takes into account in the navigation.
@ -167,6 +169,7 @@ public:
/// number is too low, the simulation will not
/// be safe.
virtual void agent_set_max_neighbors(RID p_agent, int p_count) override;
virtual int agent_get_max_neighbors(RID p_agent) const override;
/// The minimal amount of time for which this
/// agent's velocities that are computed by the
@ -176,17 +179,20 @@ public:
/// other agents, but the less freedom this
/// agent has in choosing its velocities.
/// Must be positive.
virtual void agent_set_time_horizon_agents(RID p_agent, real_t p_time_horizon) override;
virtual real_t agent_get_time_horizon_agents(RID p_agent) const override;
virtual void agent_set_time_horizon_obstacles(RID p_agent, real_t p_time_horizon) override;
virtual real_t agent_get_time_horizon_obstacles(RID p_agent) const override;
/// The radius of this agent.
/// Must be non-negative.
virtual void agent_set_radius(RID p_agent, real_t p_radius) override;
virtual real_t agent_get_radius(RID p_agent) const override;
/// The maximum speed of this agent.
/// Must be non-negative.
virtual void agent_set_max_speed(RID p_agent, real_t p_max_speed) override;
virtual real_t agent_get_max_speed(RID p_agent) const override;
/// forces and agent velocity change in the avoidance simulation, adds simulation instability if done recklessly
virtual void agent_set_velocity_forced(RID p_agent, Vector2 p_velocity) override;
@ -194,19 +200,27 @@ public:
/// The wanted velocity for the agent as a "suggestion" to the avoidance simulation.
/// The simulation will try to fulfill this velocity wish if possible but may change the velocity depending on other agent's and obstacles'.
virtual void agent_set_velocity(RID p_agent, Vector2 p_velocity) override;
virtual Vector2 agent_get_velocity(RID p_agent) const override;
/// Position of the agent in world space.
virtual void agent_set_position(RID p_agent, Vector2 p_position) override;
virtual Vector2 agent_get_position(RID p_agent) const override;
/// Returns true if the map got changed the previous frame.
virtual bool agent_is_map_changed(RID p_agent) const override;
/// Callback called at the end of the RVO process
virtual void agent_set_avoidance_callback(RID p_agent, Callable p_callback) override;
virtual bool agent_has_avoidance_callback(RID p_agent) const override;
virtual void agent_set_avoidance_layers(RID p_agent, uint32_t p_layers) override;
virtual uint32_t agent_get_avoidance_layers(RID p_agent) const override;
virtual void agent_set_avoidance_mask(RID p_agent, uint32_t p_mask) override;
virtual uint32_t agent_get_avoidance_mask(RID p_agent) const override;
virtual void agent_set_avoidance_priority(RID p_agent, real_t p_priority) override;
virtual real_t agent_get_avoidance_priority(RID p_agent) const override;
virtual RID obstacle_create() override;
virtual void obstacle_set_avoidance_enabled(RID p_obstacle, bool p_enabled) override;
@ -216,10 +230,15 @@ public:
virtual void obstacle_set_paused(RID p_obstacle, bool p_paused) override;
virtual bool obstacle_get_paused(RID p_obstacle) const override;
virtual void obstacle_set_radius(RID p_obstacle, real_t p_radius) override;
virtual real_t obstacle_get_radius(RID p_obstacle) const override;
virtual void obstacle_set_velocity(RID p_obstacle, Vector2 p_velocity) override;
virtual Vector2 obstacle_get_velocity(RID p_obstacle) const override;
virtual void obstacle_set_position(RID p_obstacle, Vector2 p_position) override;
virtual Vector2 obstacle_get_position(RID p_obstacle) const override;
virtual void obstacle_set_vertices(RID p_obstacle, const Vector<Vector2> &p_vertices) override;
virtual Vector<Vector2> obstacle_get_vertices(RID p_obstacle) const override;
virtual void obstacle_set_avoidance_layers(RID p_obstacle, uint32_t p_layers) override;
virtual uint32_t obstacle_get_avoidance_layers(RID p_obstacle) const override;
virtual void query_path(const Ref<NavigationPathQueryParameters2D> &p_query_parameters, Ref<NavigationPathQueryResult2D> p_query_result) const override;