Move the old comments from the steering ai module to the class doc xmls.

This commit is contained in:
Relintai 2023-01-14 14:31:39 +01:00
parent fc991ede18
commit 013fe0b1a2
59 changed files with 161 additions and 244 deletions

View File

@ -25,7 +25,7 @@ public:
void _physics_process_connect();
void _physics_process_disconnect();
void _apply_steering(Ref<GSAITargetAcceleration> acceleration, float delta);
void _apply_sliding_steering(KinematicBody2D *body, const Vector3 &accel, const float delta);
@ -41,21 +41,9 @@ public:
protected:
static void _bind_methods();
// A specialized steering agent that updates itself every frame so the user does
// not have to using a KinematicBody2D
// @category - Specialized agents
// SLIDE uses `move_and_slide`
// COLLIDE uses `move_and_collide`
// POSITION changes the `global_position` directly
// The KinematicBody2D to keep track of
// setget _set_body
// The type of movement the body executes
int movement_type;
Vector2 _last_position;
ObjectID _body_ref;
// Moves the agent's `body` by target `acceleration`.
// @tags - virtual
};
#endif

View File

@ -41,21 +41,9 @@ public:
protected:
static void _bind_methods();
// A specialized steering agent that updates itself every frame so the user does
// not have to using a KinematicBody
// @category - Specialized agents
// SLIDE uses `move_and_slide`
// COLLIDE uses `move_and_collide`
// POSITION changes the global_position directly
// The KinematicBody to keep track of
// setget _set_body
// The type of movement the body executes
int movement_type;
Vector3 _last_position;
ObjectID _body_ref;
// Moves the agent's `body` by target `acceleration`.
// @tags - virtual
};
#endif

View File

@ -27,15 +27,8 @@ public:
protected:
static void _bind_methods();
// A specialized steering agent that updates itself every frame so the user does
// not have to using a RigidBody2D
// @category - Specialized agents
// The RigidBody2D to keep track of
// setget _set_body
Vector2 _last_position;
ObjectID _body_ref;
// Moves the agent's `body` by target `acceleration`.
// @tags - virtual
};
#endif

View File

@ -27,15 +27,8 @@ public:
protected:
static void _bind_methods();
// A specialized steering agent that updates itself every frame so the user does
// not have to using a RigidBody
// @category - Specialized agents
// The RigidBody to keep track of
// setget _set_body
Vector3 _last_position;
ObjectID _body_ref;
// Moves the agent's `body` by target `acceleration`.
// @tags - virtual
};
#endif

View File

@ -41,33 +41,13 @@ public:
protected:
static void _bind_methods();
// A base class for a specialized steering agent that updates itself every frame
// so the user does not have to. All other specialized agents derive from this.
// @category - Specialized agents
// @tags - abstract
// If `true`, calculates linear and angular velocities based on the previous
// frame. When `false`, the user must keep those values updated.
bool calculate_velocities;
// If `true`, interpolates the current linear velocity towards 0 by the
// `linear_drag_percentage` value.
// Does not apply to `RigidBody` and `RigidBody2D` nodes.
bool apply_linear_drag;
// If `true`, interpolates the current angular velocity towards 0 by the
// `angular_drag_percentage` value.
// Does not apply to `RigidBody` and `RigidBody2D` nodes.
bool apply_angular_drag;
// The percentage between the current linear velocity and 0 to interpolate by if
// `apply_linear_drag` is true.
// Does not apply to `RigidBody` and `RigidBody2D` nodes.
float linear_drag_percentage;
// The percentage between the current angular velocity and 0 to interpolate by if
// `apply_angular_drag` is true.
// Does not apply to `RigidBody` and `RigidBody2D` nodes.
float angular_drag_percentage;
float last_orientation;
bool applied_steering;
// Moves the agent's body by target `acceleration`.
// @tags - virtual
};
#endif

View File

@ -34,17 +34,9 @@ public:
protected:
static void _bind_methods();
// Calculates acceleration to take an agent to its target's location. The
// calculation attempts to arrive with zero remaining velocity.
// @category - Individual behaviors
// Target agent to arrive to.
Ref<GSAIAgentLocation> target;
// Distance from the target for the agent to be considered successfully
// arrived.
float arrival_tolerance;
// Distance from the target for the agent to begin slowing down.
float deceleration_radius;
// Represents the time it takes to change acceleration.
float time_to_reach;
};

View File

@ -21,9 +21,6 @@ public:
protected:
static void _bind_methods();
// Steers the agent to avoid obstacles in its path. Approximates obstacles as
// spheres.
// @category - Group behaviors
Ref<GSAISteeringAgent> _first_neighbor;
float _shortest_time;
float _first_minimum_separation;

View File

@ -67,6 +67,7 @@ GSAIBlend::~GSAIBlend() {
void GSAIBlend::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_behavior", "behavior", "weight"), &GSAIBlend::add_behavior);
ClassDB::bind_method(D_METHOD("get_behavior", "index"), &GSAIBlend::get_behavior);
ClassDB::bind_method(D_METHOD("get_behavior_weight", "index"), &GSAIBlend::get_behavior_weight);
ClassDB::bind_method(D_METHOD("remove_behavior", "index"), &GSAIBlend::remove_behavior);
ClassDB::bind_method(D_METHOD("get_behaviour_count"), &GSAIBlend::get_behaviour_count);
ClassDB::bind_method(D_METHOD("get_accel"), &GSAIBlend::get_accel);

View File

@ -34,14 +34,8 @@ protected:
protected:
static void _bind_methods();
// Blends multiple steering behaviors into one, and returns a weighted
// acceleration from their calculations.
// @category - Combination behaviors
Vector<GSAIBlendBehaviorEntry> _behaviors;
Ref<GSAITargetAcceleration> _accel;
// Appends a behavior to the internal array along with its `weight`.
// Returns the behavior at the specified `index`, or an empty `Dictionary` if
// none was found.
};
#endif

View File

@ -21,9 +21,6 @@ public:
protected:
static void _bind_methods();
// Calculates an acceleration that attempts to move the agent towards the center
// of mass of the agents in the area defined by the `GSAIProximity`.
// @category - Group behaviors
Vector3 _center_of_mass;
};

View File

@ -16,10 +16,6 @@ public:
protected:
static void _bind_methods();
// Calculates acceleration to take an agent away from where a target agent is
// moving.
// @category - Individual behaviors
};
#endif

View File

@ -21,10 +21,6 @@ public:
protected:
static void _bind_methods();
// Calculates angular acceleration to rotate a target to face its target's
// position. The behavior attemps to arrive with zero remaining angular velocity.
// @category - Individual behaviors
};
#endif

View File

@ -18,9 +18,6 @@ public:
protected:
static void _bind_methods();
// Calculates acceleration to take an agent directly away from a target agent.
// @category - Individual behaviors
};
#endif

View File

@ -31,16 +31,9 @@ public:
protected:
static void _bind_methods();
// Produces a linear acceleration that moves the agent along the specified path.
// @category - Individual behaviors
// The path to follow and travel along.
Ref<GSAIPath> path;
// The distance along the path to generate the next target position.
float path_offset;
// Whether to use `GSAIArrive` behavior on an open path.
bool is_arrive_enabled;
// The amount of time in the future to predict the owning agent's position along
// the path. Setting it to 0.0 will force non-predictive path following.
float prediction_time;
};

View File

@ -18,10 +18,6 @@ public:
protected:
static void _bind_methods();
// Calculates an angular acceleration to match an agent's orientation to its
// direction of travel.
// @category - Individual behaviors
};
#endif

View File

@ -29,7 +29,7 @@ public:
void match_orientation(const Ref<GSAITargetAcceleration> &acceleration, const float desired_orientation);
virtual void _match_orientation(Ref<GSAITargetAcceleration> acceleration, float desired_orientation);
void _calculate_steering(Ref<GSAITargetAcceleration> acceleration);
GSAIMatchOrientation();
@ -38,21 +38,10 @@ public:
protected:
static void _bind_methods();
// Calculates an angular acceleration to match an agent's orientation to that of
// its target. Attempts to make the agent arrive with zero remaining angular
// velocity.
// @category - Individual behaviors
// The target orientation for the behavior to try and match rotations to.
Ref<GSAIAgentLocation> target;
// The amount of distance in radians for the behavior to consider itself close
// enough to be matching the target agent's rotation.
float alignment_tolerance;
// The amount of distance in radians from the goal to start slowing down.
float deceleration_radius;
// The amount of time to reach the target velocity
float time_to_reach;
// Whether to use the X and Z components instead of X and Y components when
// determining angles. X and Z should be used in 3D.
bool use_z;
};

View File

@ -28,18 +28,9 @@ public:
protected:
static void _bind_methods();
// Container for multiple behaviors that returns the result of the first child
// behavior with non-zero acceleration.
// @category - Combination behaviors
// If a behavior's acceleration is lower than this threshold, the container
// considers it has an acceleration of zero.
float zero_threshold;
// The index of the last behavior the container prioritized.
int _last_selected_index;
Vector<Ref<GSAISteeringBehavior>> _behaviors;
// Appends a steering behavior as a child of this container.
// Returns the behavior at the position in the pool referred to by `index`, or
// `null` if no behavior was found.
};
#endif

View File

@ -19,7 +19,7 @@ public:
void set_predict_time_max(const float val);
void _calculate_steering(Ref<GSAITargetAcceleration> acceleration);
float get_modified_acceleration();
virtual float _get_modified_acceleration();
@ -29,13 +29,7 @@ public:
protected:
static void _bind_methods();
// Calculates an acceleration to make an agent intercept another based on the
// target agent's movement.
// @category - Individual behaviors
// The target agent that the behavior is trying to intercept.
Ref<GSAISteeringAgent> target;
// The maximum amount of time in the future the behavior predicts the target's
// location.
float predict_time_max;
};

View File

@ -23,10 +23,6 @@ public:
protected:
static void _bind_methods();
// Calculates an acceleration to take an agent to a target agent's position
// directly.
// @category - Individual behaviors
// The target that the behavior aims to move the agent to.
Ref<GSAIAgentLocation> target;
};

View File

@ -26,19 +26,8 @@ public:
protected:
static void _bind_methods();
// Calculates an acceleration that repels the agent from its neighbors in the
// given `GSAIProximity`.
//
// The acceleration is an average based on all neighbors, multiplied by a
// strength decreasing by the inverse square law in relation to distance, and it
// accumulates.
// @category - Group behaviors
// The coefficient to calculate how fast the separation strength decays with distance.
float decay_coefficient;
Ref<GSAITargetAcceleration> acceleration;
// Callback for the proximity to call when finding neighbors. Determines the amount of
// acceleration that `neighbor` imposes based on its distance from the owner agent.
// @tags - virtual
};
#endif

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIAgentLocation" inherits="Reference" version="3.11">
<brief_description>
Represents an agent with only a location and an orientation.
</brief_description>
<description>
Represents an agent with only a location and an orientation.
</description>
<tutorials>
</tutorials>
@ -10,8 +12,10 @@
</methods>
<members>
<member name="orientation" type="float" setter="set_orientation" getter="get_orientation" default="0.0">
The agent's orientation on its Y axis rotation.
</member>
<member name="position" type="Vector3" setter="set_position" getter="get_position" default="Vector3( 0, 0, 0 )">
The agent's position in space.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIArrive" inherits="GSAISteeringBehavior" version="3.11">
<brief_description>
Calculates acceleration to take an agent to its target's location. The calculation attempts to arrive with zero remaining velocity.
</brief_description>
<description>
Calculates acceleration to take an agent to its target's location. The calculation attempts to arrive with zero remaining velocity.
</description>
<tutorials>
</tutorials>
@ -24,12 +26,16 @@
</methods>
<members>
<member name="arrival_tolerance" type="float" setter="set_arrival_tolerance" getter="get_arrival_tolerance" default="0.0">
Distance from the target for the agent to be considered successfully arrived.
</member>
<member name="deceleration_radius" type="float" setter="set_deceleration_radius" getter="get_deceleration_radius" default="0.0">
Distance from the target for the agent to begin slowing down.
</member>
<member name="target" type="GSAIAgentLocation" setter="set_target" getter="get_target">
Target agent to arrive to.
</member>
<member name="time_to_reach" type="float" setter="set_time_to_reach" getter="get_time_to_reach" default="0.1">
Represents the time it takes to change acceleration.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIAvoidCollisions" inherits="GSAIGroupBehavior" version="3.11">
<brief_description>
Steers the agent to avoid obstacles in its path. Approximates obstacles as spheres.
</brief_description>
<description>
Steers the agent to avoid obstacles in its path. Approximates obstacles as spheres.
</description>
<tutorials>
</tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIBlend" inherits="GSAISteeringBehavior" version="3.11">
<brief_description>
Blends multiple steering behaviors into one, and returns a weighted acceleration from their calculations.
</brief_description>
<description>
Blends multiple steering behaviors into one, and returns a weighted acceleration from their calculations.
</description>
<tutorials>
</tutorials>
@ -12,28 +14,40 @@
<argument index="0" name="behavior" type="GSAISteeringBehavior" />
<argument index="1" name="weight" type="float" />
<description>
Appends a behavior to the internal array along with its weight.
</description>
</method>
<method name="get_accel">
<return type="GSAITargetAcceleration" />
<description>
Returns the internal GSAITargetAcceleration.
</description>
</method>
<method name="get_behavior">
<return type="GSAISteeringBehavior" />
<argument index="0" name="index" type="int" />
<description>
Returns the behavior at the specified index, or null if none was found.
</description>
</method>
<method name="get_behavior_weight">
<return type="float" />
<argument index="0" name="index" type="int" />
<description>
Returns the behavior's weight at the specified index, or null if none was found.
</description>
</method>
<method name="get_behaviour_count">
<return type="int" />
<description>
Returns how many behaviors are added.
</description>
</method>
<method name="remove_behavior">
<return type="void" />
<argument index="0" name="index" type="int" />
<description>
Removed the behavior at the specified index.
</description>
</method>
</methods>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAICohesion" inherits="GSAIGroupBehavior" version="3.11">
<brief_description>
Calculates an acceleration that attempts to move the agent towards the center of mass of the agents in the area defined by the GSAIProximity.
</brief_description>
<description>
Calculates an acceleration that attempts to move the agent towards the center of mass of the agents in the area defined by the GSAIProximity.
</description>
<tutorials>
</tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIEvade" inherits="GSAIPursue" version="3.11">
<brief_description>
Calculates acceleration to take an agent away from where a target agent is moving.
</brief_description>
<description>
Calculates acceleration to take an agent away from where a target agent is moving.
</description>
<tutorials>
</tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIFace" inherits="GSAIMatchOrientation" version="3.11">
<brief_description>
Calculates angular acceleration to rotate a target to face its target's position. The behavior attemps to arrive with zero remaining angular velocity.
</brief_description>
<description>
Calculates angular acceleration to rotate a target to face its target's position. The behavior attemps to arrive with zero remaining angular velocity.
</description>
<tutorials>
</tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIFlee" inherits="GSAISeek" version="3.11">
<brief_description>
Calculates acceleration to take an agent directly away from a target agent.
</brief_description>
<description>
Calculates acceleration to take an agent directly away from a target agent.
</description>
<tutorials>
</tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIFollowPath" inherits="GSAIArrive" version="3.11">
<brief_description>
Produces a linear acceleration that moves the agent along the specified path.
</brief_description>
<description>
Produces a linear acceleration that moves the agent along the specified path.
</description>
<tutorials>
</tutorials>
@ -10,12 +12,16 @@
</methods>
<members>
<member name="is_arrive_enabled" type="bool" setter="set_is_arrive_enabled" getter="get_is_arrive_enabled" default="true">
Whether to use GSAIArrive behavior on an open path.
</member>
<member name="path" type="GSAIPath" setter="set_path" getter="get_path">
The path to follow and travel along.
</member>
<member name="path_offset" type="float" setter="set_path_offset" getter="get_path_offset" default="0.0">
The distance along the path to generate the next target position.
</member>
<member name="prediction_time" type="float" setter="set_prediction_time" getter="get_prediction_time" default="0.0">
The amount of time in the future to predict the owning agent's position along the path. Setting it to 0.0 will force non-predictive path following.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIGroupBehavior" inherits="GSAISteeringBehavior" version="3.11">
<brief_description>
Base type for group-based steering behaviors.
</brief_description>
<description>
Base type for group-based steering behaviors.
</description>
<tutorials>
</tutorials>
@ -16,8 +18,10 @@
</methods>
<members>
<member name="_callback" type="FuncRef" setter="set_callback" getter="get_callback">
Internal callback for the behavior to define whether or not a member is relevant
</member>
<member name="proximity" type="GSAIProximity" setter="set_proximity" getter="get_proximity">
Container to find neighbors of the agent and calculate group behavior.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIInfiniteProximity" inherits="GSAIProximity" version="3.11">
<brief_description>
Determines any agent that is in the specified list as being neighbors with the owner agent, regardless of distance.
</brief_description>
<description>
Determines any agent that is in the specified list as being neighbors with the owner agent, regardless of distance.
</description>
<tutorials>
</tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIKinematicBody2DAgent" inherits="GSAISpecializedAgent" version="3.11">
<brief_description>
A specialized steering agent that updates itself every frame so the user does not have to using a KinematicBody2D.
</brief_description>
<description>
A specialized steering agent that updates itself every frame so the user does not have to using a KinematicBody2D.
</description>
<tutorials>
</tutorials>
@ -10,8 +12,12 @@
</methods>
<members>
<member name="body" type="KinematicBody2D" setter="set_body" getter="get_body">
The KinematicBody2D to keep track of.
</member>
<member name="movement_type" type="int" setter="set_movement_type" getter="get_movement_type" default="0">
SLIDE uses move_and_slide.
COLLIDE uses move_and_collide.
POSITION changes the global_position directly.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIKinematicBody3DAgent" inherits="GSAISpecializedAgent" version="3.11">
<brief_description>
A specialized steering agent that updates itself every frame so the user does not have to using a KinematicBody.
</brief_description>
<description>
A specialized steering agent that updates itself every frame so the user does not have to using a KinematicBody.
</description>
<tutorials>
</tutorials>
@ -10,8 +12,12 @@
</methods>
<members>
<member name="body" type="KinematicBody" setter="set_body" getter="get_body">
The KinematicBody to keep track of.
</member>
<member name="movement_type" type="int" setter="set_movement_type" getter="get_movement_type" default="0">
SLIDE uses move_and_slide.
COLLIDE uses move_and_collide.
POSITION changes the global_position directly.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAILookWhereYouGo" inherits="GSAIMatchOrientation" version="3.11">
<brief_description>
Calculates an angular acceleration to match an agent's orientation to its direction of travel.
</brief_description>
<description>
Calculates an angular acceleration to match an agent's orientation to its direction of travel.
</description>
<tutorials>
</tutorials>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIMatchOrientation" inherits="GSAISteeringBehavior" version="3.11">
<brief_description>
Calculates an angular acceleration to match an agent's orientation to that of its target. Attempts to make the agent arrive with zero remaining angular velocity.
</brief_description>
<description>
Calculates an angular acceleration to match an agent's orientation to that of its target. Attempts to make the agent arrive with zero remaining angular velocity.
</description>
<tutorials>
</tutorials>
@ -24,14 +26,19 @@
</methods>
<members>
<member name="alignment_tolerance" type="float" setter="set_alignment_tolerance" getter="get_alignment_tolerance" default="0.0">
The amount of distance in radians for the behavior to consider itself close enough to be matching the target agent's rotation.
</member>
<member name="deceleration_radius" type="float" setter="set_deceleration_radius" getter="get_deceleration_radius" default="0.0">
The amount of distance in radians from the goal to start slowing down.
</member>
<member name="target" type="GSAIAgentLocation" setter="set_target" getter="get_target">
The target orientation for the behavior to try and match rotations to.
</member>
<member name="time_to_reach" type="float" setter="set_time_to_reach" getter="get_time_to_reach" default="0.1">
The amount of time to reach the target velocity
</member>
<member name="use_z" type="bool" setter="set_use_z" getter="get_use_z" default="false">
Whether to use the X and Z components instead of X and Y components when determining angles. X and Z should be used in 3D.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIPath" inherits="Reference" version="3.11">
<brief_description>
Represents a path made up of Vector3 waypoints, split into segments path follow behaviors can use.
</brief_description>
<description>
Represents a path made up of Vector3 waypoints, split into segments path follow behaviors can use.
</description>
<tutorials>
</tutorials>
@ -17,22 +19,26 @@
<return type="Vector3" />
<argument index="0" name="target_distance" type="float" />
<description>
Calculates a target position from the path's starting point based on the target_distance.
</description>
</method>
<method name="create_path">
<return type="void" />
<argument index="0" name="waypoints" type="PoolVector3Array" />
<description>
Creates a path from a list of waypoints.
</description>
</method>
<method name="get_end_point">
<return type="Vector3" />
<description>
Returns the position of the last point on the path.
</description>
</method>
<method name="get_start_point">
<return type="Vector3" />
<description>
Returns the position of the first point on the path.
</description>
</method>
<method name="initialize">
@ -45,8 +51,10 @@
</methods>
<members>
<member name="is_open" type="bool" setter="set_is_open" getter="get_is_open" default="false">
If false, the path loops.
</member>
<member name="length" type="float" setter="set_length" getter="get_length" default="0.0">
Total length of the path.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIPriority" inherits="GSAISteeringBehavior" version="3.11">
<brief_description>
Container for multiple behaviors that returns the result of the first child behavior with non-zero acceleration.
</brief_description>
<description>
Container for multiple behaviors that returns the result of the first child behavior with non-zero acceleration.
</description>
<tutorials>
</tutorials>
@ -11,28 +13,33 @@
<return type="void" />
<argument index="0" name="behavior" type="GSAISteeringBehavior" />
<description>
Appends a steering behavior as a child of this container.
</description>
</method>
<method name="get_behavior">
<return type="GSAISteeringBehavior" />
<argument index="0" name="index" type="int" />
<description>
Returns the behavior at the position in the pool referred to by index, or null if no behavior was found.
</description>
</method>
<method name="get_behaviour_count">
<return type="int" />
<description>
Returns how many behaviors are added.
</description>
</method>
<method name="remove_behavior">
<return type="void" />
<argument index="0" name="index" type="int" />
<description>
Removed the behavior at the position in the pool referred to by index.
</description>
</method>
</methods>
<members>
<member name="zero_threshold" type="float" setter="set_zero_threshold" getter="get_zero_threshold" default="0.0">
If a behavior's acceleration is lower than this threshold, the container considers it has an acceleration of zero.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIProximity" inherits="Reference" version="3.11">
<brief_description>
Base container type that stores data to find the neighbors of an agent.
</brief_description>
<description>
Base container type that stores data to find the neighbors of an agent.
</description>
<tutorials>
</tutorials>
@ -11,19 +13,25 @@
<return type="int" />
<argument index="0" name="callback" type="FuncRef" />
<description>
Returns a number of neighbors based on a `callback` function.
_find_neighbors calls callback for each agent in the agents array and adds one to the count if its callback returns true.
</description>
</method>
<method name="find_neighbors">
<return type="int" />
<argument index="0" name="callback" type="FuncRef" />
<description>
Returns a number of neighbors based on a `callback` function.
_find_neighbors calls callback for each agent in the agents array and adds one to the count if its callback returns true.
</description>
</method>
</methods>
<members>
<member name="agent" type="GSAISteeringAgent" setter="set_agent" getter="get_agent">
The owning agent whose neighbors are found in the group
</member>
<member name="agents" type="Array" setter="set_agents" getter="get_agents" default="[ ]">
The agents who are part of this group and could be potential neighbors
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIPursue" inherits="GSAISteeringBehavior" version="3.11">
<brief_description>
Calculates an acceleration to make an agent intercept another based on the target agent's movement.
</brief_description>
<description>
Calculates an acceleration to make an agent intercept another based on the target agent's movement.
</description>
<tutorials>
</tutorials>
@ -20,8 +22,10 @@
</methods>
<members>
<member name="predict_time_max" type="float" setter="set_predict_time_max" getter="get_predict_time_max" default="1.0">
The maximum amount of time in the future the behavior predicts the target's location.
</member>
<member name="target" type="GSAISteeringAgent" setter="set_target" getter="get_target">
The target agent that the behavior is trying to intercept.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIRadiusProximity" inherits="GSAIProximity" version="3.11">
<brief_description>
Determines any agent that is in the specified list as being neighbors with the owner agent if they lie within the specified radius.
</brief_description>
<description>
Determines any agent that is in the specified list as being neighbors with the owner agent if they lie within the specified radius.
</description>
<tutorials>
</tutorials>
@ -10,6 +12,7 @@
</methods>
<members>
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="0.0">
The radius around the owning agent to find neighbors in
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIRigidBody2DAgent" inherits="GSAISpecializedAgent" version="3.11">
<brief_description>
A specialized steering agent that updates itself every frame so the user does not have to using a RigidBody2D.
</brief_description>
<description>
A specialized steering agent that updates itself every frame so the user does not have to using a RigidBody2D.
</description>
<tutorials>
</tutorials>
@ -10,6 +12,7 @@
</methods>
<members>
<member name="body" type="RigidBody2D" setter="set_body" getter="get_body">
The RigidBody2D to keep track of.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIRigidBody3DAgent" inherits="GSAISpecializedAgent" version="3.11">
<brief_description>
A specialized steering agent that updates itself every frame so the user does not have to using a RigidBody
</brief_description>
<description>
A specialized steering agent that updates itself every frame so the user does not have to using a RigidBody
</description>
<tutorials>
</tutorials>
@ -10,6 +12,7 @@
</methods>
<members>
<member name="body" type="RigidBody" setter="set_body" getter="get_body">
The RigidBody to keep track of.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAISeek" inherits="GSAISteeringBehavior" version="3.11">
<brief_description>
Calculates an acceleration to take an agent to a target agent's position directly.
</brief_description>
<description>
Calculates an acceleration to take an agent to a target agent's position directly.
</description>
<tutorials>
</tutorials>
@ -10,6 +12,7 @@
</methods>
<members>
<member name="target" type="GSAIAgentLocation" setter="set_target" getter="get_target">
The target that the behavior aims to move the agent to.
</member>
</members>
<constants>

View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAISeparation" inherits="GSAIGroupBehavior" version="3.11">
<brief_description>
Calculates an acceleration that repels the agent from its neighbors in the given GSAIProximity.
</brief_description>
<description>
Calculates an acceleration that repels the agent from its neighbors in the given GSAIProximity.
_callback is the callback for the proximity to call when finding neighbors. Determines the amount of acceleration that neighbor imposes based on its distance from the owner agent.
</description>
<tutorials>
</tutorials>
@ -11,8 +14,10 @@
<members>
<member name="_callback" type="FuncRef" setter="set_callback" getter="get_callback" overrides="GSAIGroupBehavior" />
<member name="acceleration" type="GSAITargetAcceleration" setter="set_acceleration" getter="get_acceleration">
The acceleration is an average based on all neighbors, multiplied by a strength decreasing by the inverse square law in relation to distance, and it accumulates.
</member>
<member name="decay_coefficient" type="float" setter="set_decay_coefficient" getter="get_decay_coefficient" default="1.0">
The coefficient to calculate how fast the separation strength decays with distance.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAISpecializedAgent" inherits="GSAISteeringAgent" version="3.11">
<brief_description>
A base class for a specialized steering agent that updates itself every frame so the user does not have to. All other specialized agents derive from this.
</brief_description>
<description>
A base class for a specialized steering agent that updates itself every frame so the user does not have to. All other specialized agents derive from this.
</description>
<tutorials>
</tutorials>
@ -12,6 +14,7 @@
<argument index="0" name="acceleration" type="GSAITargetAcceleration" />
<argument index="1" name="delta" type="float" />
<description>
Moves the agent's body by target acceleration.
</description>
</method>
<method name="apply_steering">
@ -19,23 +22,29 @@
<argument index="0" name="acceleration" type="GSAITargetAcceleration" />
<argument index="1" name="delta" type="float" />
<description>
Moves the agent's body by target acceleration.
</description>
</method>
</methods>
<members>
<member name="angular_drag_percentage" type="float" setter="set_angular_drag_percentage" getter="get_angular_drag_percentage" default="0.0">
The percentage between the current angular velocity and 0 to interpolate by if apply_angular_drag is true. Does not apply to RigidBody and RigidBody2D nodes.
</member>
<member name="applied_steering" type="bool" setter="set_applied_steering" getter="get_applied_steering" default="false">
</member>
<member name="apply_angular_drag" type="bool" setter="set_apply_angular_drag" getter="get_apply_angular_drag" default="true">
If true, interpolates the current angular velocity towards 0 by the angular_drag_percentage value. Does not apply to RigidBody and RigidBody2D nodes.
</member>
<member name="apply_linear_drag" type="bool" setter="set_apply_linear_drag" getter="get_apply_linear_drag" default="true">
If true, interpolates the current linear velocity towards 0 by the linear_drag_percentage value. Does not apply to RigidBody and RigidBody2D nodes.
</member>
<member name="calculate_velocities" type="bool" setter="set_calculate_velocities" getter="get_calculate_velocities" default="true">
If true, calculates linear and angular velocities based on the previous frame. When false, the user must keep those values updated.
</member>
<member name="last_orientation" type="float" setter="set_last_orientation" getter="get_last_orientation" default="0.0">
</member>
<member name="linear_drag_percentage" type="float" setter="set_linear_drag_percentage" getter="get_linear_drag_percentage" default="0.0">
The percentage between the current linear velocity and 0 to interpolate by if apply_linear_drag is true. Does not apply to RigidBody and RigidBody2D nodes.
</member>
</members>
<constants>

View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAISteeringAgent" inherits="GSAIAgentLocation" version="3.11">
<brief_description>
Adds velocity, speed, and size data to GSAIAgentLocation.
</brief_description>
<description>
Adds velocity, speed, and size data to GSAIAgentLocation.
It is the character's responsibility to keep this information up to date for the steering toolkit to work correctly.
</description>
<tutorials>
</tutorials>
@ -10,22 +13,31 @@
</methods>
<members>
<member name="angular_acceleration_max" type="float" setter="set_angular_acceleration_max" getter="get_angular_acceleration_max" default="0.0">
The maximum amount of angular acceleration that any behavior can apply to an agent.
</member>
<member name="angular_speed_max" type="float" setter="set_angular_speed_max" getter="get_angular_speed_max" default="0.0">
The maximum amount of angular speed at which the agent can rotate.
</member>
<member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity" default="0.0">
Current angular velocity of the agent.
</member>
<member name="bounding_radius" type="float" setter="set_bounding_radius" getter="get_bounding_radius" default="0.0">
The radius of the sphere that approximates the agent's size in space.
</member>
<member name="is_tagged" type="bool" setter="set_is_tagged" getter="get_is_tagged" default="false">
Used internally by group behaviors and proximities to mark the agent as already considered.
</member>
<member name="linear_acceleration_max" type="float" setter="set_linear_acceleration_max" getter="get_linear_acceleration_max" default="0.0">
The maximum amount of acceleration that any behavior can apply to the agent.
</member>
<member name="linear_speed_max" type="float" setter="set_linear_speed_max" getter="get_linear_speed_max" default="0.0">
The maximum speed at which the agent can move.
</member>
<member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3( 0, 0, 0 )">
Current velocity of the agent.
</member>
<member name="zero_linear_speed_threshold" type="float" setter="set_zero_linear_speed_threshold" getter="get_zero_linear_speed_threshold" default="0.01">
The amount of velocity to be considered effectively not moving.
</member>
</members>
<constants>

View File

@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAISteeringBehavior" inherits="Reference" version="3.11">
<brief_description>
Base class for all steering behaviors.
</brief_description>
<description>
Base class for all steering behaviors.
Steering behaviors calculate the linear and the angular acceleration to be to the agent that owns them.
Individual steering behaviors encapsulate the steering logic.
</description>
<tutorials>
</tutorials>
@ -11,19 +15,23 @@
<return type="void" />
<argument index="0" name="acceleration" type="GSAITargetAcceleration" />
<description>
The calculate_steering function is the entry point for all behaviors. Sets the acceleration with the behavior's desired amount of acceleration.
</description>
</method>
<method name="calculate_steering">
<return type="void" />
<argument index="0" name="acceleration" type="GSAITargetAcceleration" />
The calculate_steering function is the entry point for all behaviors. Sets the acceleration with the behavior's desired amount of acceleration.
<description>
</description>
</method>
</methods>
<members>
<member name="agent" type="GSAISteeringAgent" setter="set_agent" getter="get_agent">
The AI agent on which the steering behavior bases its calculations.
</member>
<member name="is_enabled" type="bool" setter="set_is_enabled" getter="get_is_enabled" default="true">
If false, all calculations return zero amounts of acceleration.
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAITargetAcceleration" inherits="Reference" version="3.11">
<brief_description>
A desired linear and angular amount of acceleration requested by the steering system.
</brief_description>
<description>
A desired linear and angular amount of acceleration requested by the steering system.
</description>
<tutorials>
</tutorials>
@ -12,28 +14,34 @@
<argument index="0" name="accel" type="GSAITargetAcceleration" />
<argument index="1" name="scalar" type="float" />
<description>
Adds accel's components, multiplied by scalar, to this one.
</description>
</method>
<method name="get_magnitude">
<return type="float" />
<description>
Returns the squared magnitude of the linear and angular components.
</description>
</method>
<method name="get_magnitude_squared">
<return type="float" />
<description>
Returns the squared magnitude of the linear and angular components.
</description>
</method>
<method name="set_zero">
<return type="void" />
<description>
Sets the linear and angular components to 0.
</description>
</method>
</methods>
<members>
<member name="angular" type="float" setter="set_angular" getter="get_angular" default="0.0">
Angular acceleration
</member>
<member name="linear" type="Vector3" setter="set_linear" getter="get_linear" default="Vector3( 0, 0, 0 )">
Linear acceleration
</member>
</members>
<constants>

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GSAIUtils" inherits="Object" version="3.11">
<brief_description>
Math and vector utility functions.
</brief_description>
<description>
Math and vector utility functions.
</description>
<tutorials>
</tutorials>
@ -11,6 +13,7 @@
<return type="Vector2" />
<argument index="0" name="angle" type="float" />
<description>
Returns a directional vector from the given orientation angle. This assumes orientation for 2D agents or 3D agents that are upright and rotate around the Y axis.
</description>
</method>
<method name="clampedv3">
@ -18,30 +21,35 @@
<argument index="0" name="vector" type="Vector3" />
<argument index="1" name="limit" type="float" />
<description>
Returns the vector with its length capped to limit.
</description>
</method>
<method name="to_vector2">
<return type="Vector2" />
<argument index="0" name="vector" type="Vector3" />
<description>
Returns a vector2 with vector's x and y components.
</description>
</method>
<method name="to_vector3">
<return type="Vector3" />
<argument index="0" name="vector" type="Vector2" />
<description>
Returns a vector3 with vector's x and y components and 0 in z.
</description>
</method>
<method name="vector2_to_angle">
<return type="float" />
<argument index="0" name="vector" type="Vector2" />
<description>
Returns an angle in radians between the positive X axis and the vector.
</description>
</method>
<method name="vector3_to_angle">
<return type="float" />
<argument index="0" name="vector" type="Vector3" />
<description>
Returns an angle in radians between the positive X axis and the vector. This assumes orientation for 3D agents that are upright and rotate around the Y axis.
</description>
</method>
</methods>

View File

@ -21,11 +21,7 @@ public:
protected:
static void _bind_methods();
// Represents an agent with only a location and an orientation.
// @category - Base types
// The agent's position in space.
Vector3 position;
// The agent's orientation on its Y axis rotation.
float orientation;
};

View File

@ -29,14 +29,8 @@ public:
protected:
static void _bind_methods();
// Base type for group-based steering behaviors.
// @category - Base types
// Container to find neighbors of the agent and calculate group behavior.
Ref<GSAIProximity> proximity;
Ref<FuncRef> _callback;
// Internal callback for the behavior to define whether or not a member is
// relevant
// @tags - virtual
};
#endif

View File

@ -54,23 +54,13 @@ protected:
protected:
static void _bind_methods();
// Represents a path made up of Vector3 waypoints, split into segments path
// follow behaviors can use.
// @category - Base types
// If `false`, the path loops.
bool is_open;
// Total length of the path.
float length;
Vector<GSAISegment> _segments;
Vector3 _nearest_point_on_segment;
Vector3 _nearest_point_on_path;
// Creates a path from a list of waypoints.
// Calculates a target position from the path's starting point based on the `target_distance`.
// Returns the position of the first point on the path.
// Returns the position of the last point on the path.
// not exposed helper struct
};
#endif

View File

@ -45,30 +45,14 @@ public:
protected:
static void _bind_methods();
// Adds velocity, speed, and size data to `GSAIAgentLocation`.
//
// It is the character's responsibility to keep this information up to date for
// the steering toolkit to work correctly.
// @category - Base types
// The amount of velocity to be considered effectively not moving.
float zero_linear_speed_threshold;
// The maximum speed at which the agent can move.
float linear_speed_max;
// The maximum amount of acceleration that any behavior can apply to the agent.
float linear_acceleration_max;
// The maximum amount of angular speed at which the agent can rotate.
float angular_speed_max;
// The maximum amount of angular acceleration that any behavior can apply to an
// agent.
float angular_acceleration_max;
// Current velocity of the agent.
Vector3 linear_velocity;
// Current angular velocity of the agent.
float angular_velocity;
// The radius of the sphere that approximates the agent's size in space.
float bounding_radius;
// Used internally by group behaviors and proximities to mark the agent as already
// considered.
bool is_tagged;
};

View File

@ -9,25 +9,16 @@
class GSAISteeringAgent;
class GSAITargetAcceleration;
// Base class for all steering behaviors.
// Steering behaviors calculate the linear and the angular acceleration to be
// to the agent that owns them.
// Individual steering behaviors encapsulate the steering logic.
class GSAISteeringBehavior : public Reference {
GDCLASS(GSAISteeringBehavior, Reference);
public:
// If `false`, all calculations return zero amounts of acceleration.
bool get_is_enabled() const;
void set_is_enabled(const bool val);
// The AI agent on which the steering behavior bases its calculations.
Ref<GSAISteeringAgent> get_agent();
void set_agent(const Ref<GSAISteeringAgent> &val);
// The `calculate_steering` function is the entry point for all behaviors.
// Sets the `acceleration` with the behavior's desired amount of acceleration.
void calculate_steering(Ref<GSAITargetAcceleration> acceleration);
virtual void _calculate_steering(Ref<GSAITargetAcceleration> acceleration);

View File

@ -5,8 +5,6 @@
#include "core/math/vector3.h"
#include "core/object/reference.h"
// A desired linear and angular amount of acceleration requested by the steering system.
class GSAITargetAcceleration : public Reference {
GDCLASS(GSAITargetAcceleration, Reference);
@ -17,13 +15,10 @@ public:
float get_angular() const;
void set_angular(const float val);
// Sets the linear and angular components to 0.
void set_zero();
// Adds `accel`'s components, multiplied by `scalar`, to this one.
void add_scaled_accel(const Ref<GSAITargetAcceleration> &accel, const float scalar);
// Returns the squared magnitude of the linear and angular components.
float get_magnitude_squared();
// Returns the magnitude of the linear and angular components.
float get_magnitude();
GSAITargetAcceleration();
@ -32,10 +27,7 @@ public:
protected:
static void _bind_methods();
// Linear acceleration
Vector3 linear;
// Angular acceleration
float angular;
};

View File

@ -8,14 +8,10 @@
#include "core/object/object.h"
// Math and vector utility functions.
class GSAIUtils : public Object {
GDCLASS(GSAIUtils, Object);
public:
// Returns the `vector` with its length capped to `limit`.
static _ALWAYS_INLINE_ Vector3 clampedv3(Vector3 vector, const float limit) {
float length_squared = vector.length_squared();
float limit_squared = limit * limit;
@ -27,36 +23,22 @@ public:
return vector;
}
// Returns an angle in radians between the positive X axis and the `vector`.
// This assumes orientation for 3D agents that are upright and rotate
// around the Y axis.
static _ALWAYS_INLINE_ float vector3_to_angle(const Vector3 &vector) {
return atan2(vector.x, vector.z);
}
// Returns an angle in radians between the positive X axis and the `vector`.
static _ALWAYS_INLINE_ float vector2_to_angle(const Vector2 &vector) {
return atan2(vector.x, -vector.y);
}
// Returns a directional vector from the given orientation angle.
// This assumes orientation for 2D agents or 3D agents that are upright and
// rotate around the Y axis.
static _ALWAYS_INLINE_ Vector2 angle_to_vector2(const float angle) {
return Vector2(sin(-angle), cos(angle));
}
// Returns a vector2 with `vector`'s x and y components.
static _ALWAYS_INLINE_ Vector2 to_vector2(const Vector3 &vector) {
return Vector2(vector.x, vector.y);
}
// Returns a vector3 with `vector`'s x and y components and 0 in z.
static _ALWAYS_INLINE_ Vector3 to_vector3(const Vector2 &vector) {
return Vector3(vector.x, vector.y, 0);
}

View File

@ -17,15 +17,6 @@ public:
protected:
static void _bind_methods();
// Determines any agent that is in the specified list as being neighbors with the
// owner agent, regardless of distance.
// @category - Proximities
// Returns a number of neighbors based on a `callback` function.
//
// `_find_neighbors` calls `callback` for each agent in the `agents` array and
// adds one to the count if its `callback` returns true.
// @tags - virtual
};
#endif

View File

@ -31,18 +31,8 @@ public:
protected:
static void _bind_methods();
// Base container type that stores data to find the neighbors of an agent.
// @category - Proximities
// @tags - abstract
// The owning agent whose neighbors are found in the group
Ref<GSAISteeringAgent> agent;
// The agents who are part of this group and could be potential neighbors
Vector<Ref<GSAISteeringAgent>> agents;
// Returns a number of neighbors based on a `callback` function.
//
// `_find_neighbors` calls `callback` for each agent in the `agents` array and
// adds one to the count if its `callback` returns true.
// @tags - virtual
};
#endif

View File

@ -23,17 +23,8 @@ public:
protected:
static void _bind_methods();
// Determines any agent that is in the specified list as being neighbors with the owner agent if
// they lie within the specified radius.
// @category - Proximities
// The radius around the owning agent to find neighbors in
float radius;
int _last_frame;
// Returns a number of neighbors based on a `callback` function.
//
// `_find_neighbors` calls `callback` for each agent in the `agents` array that lie within
// the radius around the owning agent and adds one to the count if its `callback` returns true.
// @tags - virtual
};
#endif