Cang formatted everything in the new module.

This commit is contained in:
Relintai 2023-01-13 21:35:07 +01:00
parent 0d2aa86bc3
commit 402e8ff689
58 changed files with 2856 additions and 3497 deletions

View File

@ -1,7 +1,6 @@
#include "gsai_kinematic_body_2d_agent.h" #include "gsai_kinematic_body_2d_agent.h"
KinematicBody2D GSAIKinematicBody2DAgent::get_ *body() { KinematicBody2D GSAIKinematicBody2DAgent::get_ *body() {
return *body; return *body;
} }
@ -10,7 +9,6 @@ void GSAIKinematicBody2DAgent::set_*body(const KinematicBody2D &val) {
*body = val; *body = val;
} }
int GSAIKinematicBody2DAgent::get_movement_type() const { int GSAIKinematicBody2DAgent::get_movement_type() const {
return movement_type; return movement_type;
} }
@ -19,7 +17,6 @@ void GSAIKinematicBody2DAgent::set_movement_type(const int val) {
movement_type = val; movement_type = val;
} }
Vector2 GSAIKinematicBody2DAgent::get__last_position() { Vector2 GSAIKinematicBody2DAgent::get__last_position() {
return _last_position; return _last_position;
} }
@ -28,7 +25,6 @@ void GSAIKinematicBody2DAgent::set__last_position(const Vector2 &val) {
_last_position = val; _last_position = val;
} }
Ref<WeakRef> GSAIKinematicBody2DAgent::get__body_ref() { Ref<WeakRef> GSAIKinematicBody2DAgent::get__body_ref() {
return _body_ref; return _body_ref;
} }
@ -37,15 +33,14 @@ void GSAIKinematicBody2DAgent::set__body_ref(const Ref<WeakRef> &val) {
_body_ref = val; _body_ref = val;
} }
// A specialized steering agent that updates itself every frame so the user does; // A specialized steering agent that updates itself every frame so the user does;
// not have to using a KinematicBody2D; // not have to using a KinematicBody2D;
// @category - Specialized agents; // @category - Specialized agents;
// SLIDE uses `move_and_slide`; // SLIDE uses `move_and_slide`;
// COLLIDE uses `move_and_collide`; // COLLIDE uses `move_and_collide`;
// POSITION changes the `global_position` directly; // POSITION changes the `global_position` directly;
}; }
;
// The KinematicBody2D to keep track of; // The KinematicBody2D to keep track of;
// setget _set_body; // setget _set_body;
KinematicBody2D *body; KinematicBody2D *body;
@ -69,12 +64,10 @@ _body_ref = val;
_apply_collide_steering(acceleration.linear, delta); _apply_collide_steering(acceleration.linear, delta);
} }
else if (movement_type == MovementType.SLIDE) { else if (movement_type == MovementType.SLIDE) {
_apply_sliding_steering(acceleration.linear, delta); _apply_sliding_steering(acceleration.linear, delta);
} }
else { else {
_apply_position_steering(acceleration.linear, delta); _apply_position_steering(acceleration.linear, delta);
} }
@ -82,7 +75,6 @@ _body_ref = val;
_apply_orientation_steering(acceleration.angular, delta); _apply_orientation_steering(acceleration.angular, delta);
} }
void GSAIKinematicBody2DAgent::_apply_sliding_steering(const Vector3 &accel, const float delta) { void GSAIKinematicBody2DAgent::_apply_sliding_steering(const Vector3 &accel, const float delta) {
KinematicBody2D *_body = _body_ref.get_ref(); KinematicBody2D *_body = _body_ref.get_ref();
@ -90,7 +82,6 @@ _body_ref = val;
return; return;
} }
if (!_body.is_inside_tree() || _body.get_tree().paused) { if (!_body.is_inside_tree() || _body.get_tree().paused) {
return; return;
} }
@ -106,10 +97,8 @@ _body_ref = val;
if (calculate_velocities) { if (calculate_velocities) {
linear_velocity = GSAIUtils.to_vector3(velocity); linear_velocity = GSAIUtils.to_vector3(velocity);
} }
} }
void GSAIKinematicBody2DAgent::_apply_collide_steering(const Vector3 &accel, const float delta) { void GSAIKinematicBody2DAgent::_apply_collide_steering(const Vector3 &accel, const float delta) {
KinematicBody2D *_body = _body_ref.get_ref(); KinematicBody2D *_body = _body_ref.get_ref();
@ -129,10 +118,8 @@ _body_ref = val;
if (calculate_velocities) { if (calculate_velocities) {
linear_velocity = velocity; linear_velocity = velocity;
} }
} }
void GSAIKinematicBody2DAgent::_apply_position_steering(const Vector3 &accel, const float delta) { void GSAIKinematicBody2DAgent::_apply_position_steering(const Vector3 &accel, const float delta) {
KinematicBody2D *_body = _body_ref.get_ref(); KinematicBody2D *_body = _body_ref.get_ref();
@ -151,10 +138,8 @@ _body_ref = val;
if (calculate_velocities) { if (calculate_velocities) {
linear_velocity = velocity; linear_velocity = velocity;
} }
} }
void GSAIKinematicBody2DAgent::_apply_orientation_steering(const float angular_acceleration, const float delta) { void GSAIKinematicBody2DAgent::_apply_orientation_steering(const float angular_acceleration, const float delta) {
KinematicBody2D *_body = _body_ref.get_ref(); KinematicBody2D *_body = _body_ref.get_ref();
@ -173,10 +158,8 @@ _body_ref = val;
if (calculate_velocities) { if (calculate_velocities) {
angular_velocity = velocity; angular_velocity = velocity;
} }
} }
void GSAIKinematicBody2DAgent::_set_body(const KinematicBody2D &value) { void GSAIKinematicBody2DAgent::_set_body(const KinematicBody2D &value) {
bool had_body = false; bool had_body = false;
@ -192,21 +175,16 @@ _body_ref = val;
orientation = last_orientation; orientation = last_orientation;
if (!had_body) { if (!had_body) {
if (!body.is_inside_tree()) { if (!body.is_inside_tree()) {
body.connect("ready", self, "_body_ready"); body.connect("ready", self, "_body_ready");
} }
else { else {
_body_ready(); _body_ready();
} }
} }
} }
void GSAIKinematicBody2DAgent::_on_SceneTree_physics_frame() { void GSAIKinematicBody2DAgent::_on_SceneTree_physics_frame() {
KinematicBody2D *_body = _body_ref.get_ref(); KinematicBody2D *_body = _body_ref.get_ref();
@ -220,12 +198,10 @@ _body_ref = val;
orientation = current_orientation; orientation = current_orientation;
if (calculate_velocities) { if (calculate_velocities) {
if (applied_steering) { if (applied_steering) {
applied_steering = false; applied_steering = false;
} }
else { else {
linear_velocity = GSAIUtils.clampedv3(GSAIUtils.to_vector3(current_position - _last_position), linear_speed_max); linear_velocity = GSAIUtils.clampedv3(GSAIUtils.to_vector3(current_position - _last_position), linear_speed_max);
@ -242,11 +218,8 @@ _body_ref = val;
_last_position = current_position; _last_position = current_position;
last_orientation = current_orientation; last_orientation = current_orientation;
} }
} }
} }
} }
GSAIKinematicBody2DAgent::GSAIKinematicBody2DAgent() { GSAIKinematicBody2DAgent::GSAIKinematicBody2DAgent() {
@ -259,28 +232,23 @@ _body_ref = val;
GSAIKinematicBody2DAgent::~GSAIKinematicBody2DAgent() { GSAIKinematicBody2DAgent::~GSAIKinematicBody2DAgent() {
} }
static void GSAIKinematicBody2DAgent::_bind_methods() { static void GSAIKinematicBody2DAgent::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_*body"), &GSAIKinematicBody2DAgent::get_ * body); ClassDB::bind_method(D_METHOD("get_*body"), &GSAIKinematicBody2DAgent::get_ * body);
ClassDB::bind_method(D_METHOD("set_*body", "value"), &GSAIKinematicBody2DAgent::set_ * body); ClassDB::bind_method(D_METHOD("set_*body", "value"), &GSAIKinematicBody2DAgent::set_ * body);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*body", PROPERTY_HINT_RESOURCE_TYPE, "KinematicBody2D"), "set_*body", "get_*body"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*body", PROPERTY_HINT_RESOURCE_TYPE, "KinematicBody2D"), "set_*body", "get_*body");
ClassDB::bind_method(D_METHOD("get_movement_type"), &GSAIKinematicBody2DAgent::get_movement_type); ClassDB::bind_method(D_METHOD("get_movement_type"), &GSAIKinematicBody2DAgent::get_movement_type);
ClassDB::bind_method(D_METHOD("set_movement_type", "value"), &GSAIKinematicBody2DAgent::set_movement_type); ClassDB::bind_method(D_METHOD("set_movement_type", "value"), &GSAIKinematicBody2DAgent::set_movement_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "movement_type"), "set_movement_type", "get_movement_type"); ADD_PROPERTY(PropertyInfo(Variant::INT, "movement_type"), "set_movement_type", "get_movement_type");
ClassDB::bind_method(D_METHOD("get__last_position"), &GSAIKinematicBody2DAgent::get__last_position); ClassDB::bind_method(D_METHOD("get__last_position"), &GSAIKinematicBody2DAgent::get__last_position);
ClassDB::bind_method(D_METHOD("set__last_position", "value"), &GSAIKinematicBody2DAgent::set__last_position); ClassDB::bind_method(D_METHOD("set__last_position", "value"), &GSAIKinematicBody2DAgent::set__last_position);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "_last_position"), "set__last_position", "get__last_position"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "_last_position"), "set__last_position", "get__last_position");
ClassDB::bind_method(D_METHOD("get__body_ref"), &GSAIKinematicBody2DAgent::get__body_ref); ClassDB::bind_method(D_METHOD("get__body_ref"), &GSAIKinematicBody2DAgent::get__body_ref);
ClassDB::bind_method(D_METHOD("set__body_ref", "value"), &GSAIKinematicBody2DAgent::set__body_ref); ClassDB::bind_method(D_METHOD("set__body_ref", "value"), &GSAIKinematicBody2DAgent::set__body_ref);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_body_ref", PROPERTY_HINT_RESOURCE_TYPE, "Ref<WeakRef>"), "set__body_ref", "get__body_ref"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_body_ref", PROPERTY_HINT_RESOURCE_TYPE, "Ref<WeakRef>"), "set__body_ref", "get__body_ref");
ClassDB::bind_method(D_METHOD("_body_ready"), &GSAIKinematicBody2DAgent::_body_ready); ClassDB::bind_method(D_METHOD("_body_ready"), &GSAIKinematicBody2DAgent::_body_ready);
ClassDB::bind_method(D_METHOD("_apply_steering", "acceleration", "delta"), &GSAIKinematicBody2DAgent::_apply_steering); ClassDB::bind_method(D_METHOD("_apply_steering", "acceleration", "delta"), &GSAIKinematicBody2DAgent::_apply_steering);
ClassDB::bind_method(D_METHOD("_apply_sliding_steering", "accel", "delta"), &GSAIKinematicBody2DAgent::_apply_sliding_steering); ClassDB::bind_method(D_METHOD("_apply_sliding_steering", "accel", "delta"), &GSAIKinematicBody2DAgent::_apply_sliding_steering);
@ -289,8 +257,4 @@ _body_ref = val;
ClassDB::bind_method(D_METHOD("_apply_orientation_steering", "angular_acceleration", "delta"), &GSAIKinematicBody2DAgent::_apply_orientation_steering); ClassDB::bind_method(D_METHOD("_apply_orientation_steering", "angular_acceleration", "delta"), &GSAIKinematicBody2DAgent::_apply_orientation_steering);
ClassDB::bind_method(D_METHOD("_set_body", "value"), &GSAIKinematicBody2DAgent::_set_body); ClassDB::bind_method(D_METHOD("_set_body", "value"), &GSAIKinematicBody2DAgent::_set_body);
ClassDB::bind_method(D_METHOD("_on_SceneTree_physics_frame"), &GSAIKinematicBody2DAgent::_on_SceneTree_physics_frame); ClassDB::bind_method(D_METHOD("_on_SceneTree_physics_frame"), &GSAIKinematicBody2DAgent::_on_SceneTree_physics_frame);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIKINEMATICBODY2DAGENT_H #ifndef GSAIKINEMATICBODY2DAGENT_H
#define GSAIKINEMATICBODY2DAGENT_H #define GSAIKINEMATICBODY2DAGENT_H
class GSAIKinematicBody2DAgent : public GSAISpecializedAgent { class GSAIKinematicBody2DAgent : public GSAISpecializedAgent {
GDCLASS(GSAIKinematicBody2DAgent, GSAISpecializedAgent); GDCLASS(GSAIKinematicBody2DAgent, GSAISpecializedAgent);
public: public:
KinematicBody2D get_ *body(); KinematicBody2D get_ *body();
void set_ *body(const KinematicBody2D &val); void set_ *body(const KinematicBody2D &val);
@ -57,7 +55,7 @@ class GSAIKinematicBody2DAgent : public GSAISpecializedAgent {
Ref<WeakRef> _body_ref; Ref<WeakRef> _body_ref;
// Moves the agent's `body` by target `acceleration`. // Moves the agent's `body` by target `acceleration`.
// @tags - virtual // @tags - virtual
}; }
;
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_kinematic_body_3d_agent.h" #include "gsai_kinematic_body_3d_agent.h"
KinematicBody GSAIKinematicBody3DAgent::get_ *body() { KinematicBody GSAIKinematicBody3DAgent::get_ *body() {
return *body; return *body;
} }
@ -10,7 +9,6 @@ void GSAIKinematicBody3DAgent::set_*body(const KinematicBody &val) {
*body = val; *body = val;
} }
int GSAIKinematicBody3DAgent::get_movement_type() const { int GSAIKinematicBody3DAgent::get_movement_type() const {
return movement_type; return movement_type;
} }
@ -19,7 +17,6 @@ void GSAIKinematicBody3DAgent::set_movement_type(const int val) {
movement_type = val; movement_type = val;
} }
Vector3 GSAIKinematicBody3DAgent::get__last_position() { Vector3 GSAIKinematicBody3DAgent::get__last_position() {
return _last_position; return _last_position;
} }
@ -28,7 +25,6 @@ void GSAIKinematicBody3DAgent::set__last_position(const Vector3 &val) {
_last_position = val; _last_position = val;
} }
Ref<WeakRef> GSAIKinematicBody3DAgent::get__body_ref() { Ref<WeakRef> GSAIKinematicBody3DAgent::get__body_ref() {
return _body_ref; return _body_ref;
} }
@ -37,15 +33,14 @@ void GSAIKinematicBody3DAgent::set__body_ref(const Ref<WeakRef> &val) {
_body_ref = val; _body_ref = val;
} }
// A specialized steering agent that updates itself every frame so the user does; // A specialized steering agent that updates itself every frame so the user does;
// not have to using a KinematicBody; // not have to using a KinematicBody;
// @category - Specialized agents; // @category - Specialized agents;
// SLIDE uses `move_and_slide`; // SLIDE uses `move_and_slide`;
// COLLIDE uses `move_and_collide`; // COLLIDE uses `move_and_collide`;
// POSITION changes the global_position directly; // POSITION changes the global_position directly;
}; }
;
// The KinematicBody to keep track of; // The KinematicBody to keep track of;
// setget _set_body; // setget _set_body;
KinematicBody *body; KinematicBody *body;
@ -69,12 +64,10 @@ _body_ref = val;
_apply_collide_steering(acceleration.linear, delta); _apply_collide_steering(acceleration.linear, delta);
} }
else if (movement_type == MovementType.SLIDE) { else if (movement_type == MovementType.SLIDE) {
_apply_sliding_steering(acceleration.linear, delta); _apply_sliding_steering(acceleration.linear, delta);
} }
else { else {
_apply_position_steering(acceleration.linear, delta); _apply_position_steering(acceleration.linear, delta);
} }
@ -82,7 +75,6 @@ _body_ref = val;
_apply_orientation_steering(acceleration.angular, delta); _apply_orientation_steering(acceleration.angular, delta);
} }
void GSAIKinematicBody3DAgent::_apply_sliding_steering(const Vector3 &accel, const float delta) { void GSAIKinematicBody3DAgent::_apply_sliding_steering(const Vector3 &accel, const float delta) {
KinematicBody *_body = _body_ref.get_ref(); KinematicBody *_body = _body_ref.get_ref();
@ -101,10 +93,8 @@ _body_ref = val;
if (calculate_velocities) { if (calculate_velocities) {
linear_velocity = velocity; linear_velocity = velocity;
} }
} }
void GSAIKinematicBody3DAgent::_apply_collide_steering(const Vector3 &accel, const float delta) { void GSAIKinematicBody3DAgent::_apply_collide_steering(const Vector3 &accel, const float delta) {
KinematicBody *_body = _body_ref.get_ref(); KinematicBody *_body = _body_ref.get_ref();
@ -124,10 +114,8 @@ _body_ref = val;
if (calculate_velocities) { if (calculate_velocities) {
linear_velocity = velocity; linear_velocity = velocity;
} }
} }
void GSAIKinematicBody3DAgent::_apply_position_steering(const Vector3 &accel, const float delta) { void GSAIKinematicBody3DAgent::_apply_position_steering(const Vector3 &accel, const float delta) {
KinematicBody *_body = _body_ref.get_ref(); KinematicBody *_body = _body_ref.get_ref();
@ -146,10 +134,8 @@ _body_ref = val;
if (calculate_velocities) { if (calculate_velocities) {
linear_velocity = velocity; linear_velocity = velocity;
} }
} }
void GSAIKinematicBody3DAgent::_apply_orientation_steering(const float angular_acceleration, const float delta) { void GSAIKinematicBody3DAgent::_apply_orientation_steering(const float angular_acceleration, const float delta) {
KinematicBody *_body = _body_ref.get_ref(); KinematicBody *_body = _body_ref.get_ref();
@ -168,10 +154,8 @@ _body_ref = val;
if (calculate_velocities) { if (calculate_velocities) {
angular_velocity = velocity; angular_velocity = velocity;
} }
} }
void GSAIKinematicBody3DAgent::_set_body(const KinematicBody &value) { void GSAIKinematicBody3DAgent::_set_body(const KinematicBody &value) {
bool had_body = false; bool had_body = false;
@ -187,21 +171,16 @@ _body_ref = val;
orientation = last_orientation; orientation = last_orientation;
if (!had_body) { if (!had_body) {
if (!body.is_inside_tree()) { if (!body.is_inside_tree()) {
body.connect("ready", self, "_body_ready"); body.connect("ready", self, "_body_ready");
} }
else { else {
_body_ready(); _body_ready();
} }
} }
} }
void GSAIKinematicBody3DAgent::_on_SceneTree_physics_frame() { void GSAIKinematicBody3DAgent::_on_SceneTree_physics_frame() {
KinematicBody *_body = _body_ref.get_ref(); KinematicBody *_body = _body_ref.get_ref();
@ -209,7 +188,6 @@ _body_ref = val;
return; return;
} }
if (!_body.is_inside_tree() || _body.get_tree().paused) { if (!_body.is_inside_tree() || _body.get_tree().paused) {
return; return;
} }
@ -220,12 +198,10 @@ _body_ref = val;
orientation = current_orientation; orientation = current_orientation;
if (calculate_velocities) { if (calculate_velocities) {
if (applied_steering) { if (applied_steering) {
applied_steering = false; applied_steering = false;
} }
else { else {
linear_velocity = GSAIUtils.clampedv3(current_position - _last_position, linear_speed_max); linear_velocity = GSAIUtils.clampedv3(current_position - _last_position, linear_speed_max);
@ -242,11 +218,8 @@ _body_ref = val;
_last_position = current_position; _last_position = current_position;
last_orientation = current_orientation; last_orientation = current_orientation;
} }
} }
} }
} }
GSAIKinematicBody3DAgent::GSAIKinematicBody3DAgent() { GSAIKinematicBody3DAgent::GSAIKinematicBody3DAgent() {
@ -259,28 +232,23 @@ _body_ref = val;
GSAIKinematicBody3DAgent::~GSAIKinematicBody3DAgent() { GSAIKinematicBody3DAgent::~GSAIKinematicBody3DAgent() {
} }
static void GSAIKinematicBody3DAgent::_bind_methods() { static void GSAIKinematicBody3DAgent::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_*body"), &GSAIKinematicBody3DAgent::get_ * body); ClassDB::bind_method(D_METHOD("get_*body"), &GSAIKinematicBody3DAgent::get_ * body);
ClassDB::bind_method(D_METHOD("set_*body", "value"), &GSAIKinematicBody3DAgent::set_ * body); ClassDB::bind_method(D_METHOD("set_*body", "value"), &GSAIKinematicBody3DAgent::set_ * body);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*body", PROPERTY_HINT_RESOURCE_TYPE, "KinematicBody"), "set_*body", "get_*body"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*body", PROPERTY_HINT_RESOURCE_TYPE, "KinematicBody"), "set_*body", "get_*body");
ClassDB::bind_method(D_METHOD("get_movement_type"), &GSAIKinematicBody3DAgent::get_movement_type); ClassDB::bind_method(D_METHOD("get_movement_type"), &GSAIKinematicBody3DAgent::get_movement_type);
ClassDB::bind_method(D_METHOD("set_movement_type", "value"), &GSAIKinematicBody3DAgent::set_movement_type); ClassDB::bind_method(D_METHOD("set_movement_type", "value"), &GSAIKinematicBody3DAgent::set_movement_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "movement_type"), "set_movement_type", "get_movement_type"); ADD_PROPERTY(PropertyInfo(Variant::INT, "movement_type"), "set_movement_type", "get_movement_type");
ClassDB::bind_method(D_METHOD("get__last_position"), &GSAIKinematicBody3DAgent::get__last_position); ClassDB::bind_method(D_METHOD("get__last_position"), &GSAIKinematicBody3DAgent::get__last_position);
ClassDB::bind_method(D_METHOD("set__last_position", "value"), &GSAIKinematicBody3DAgent::set__last_position); ClassDB::bind_method(D_METHOD("set__last_position", "value"), &GSAIKinematicBody3DAgent::set__last_position);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_last_position"), "set__last_position", "get__last_position"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_last_position"), "set__last_position", "get__last_position");
ClassDB::bind_method(D_METHOD("get__body_ref"), &GSAIKinematicBody3DAgent::get__body_ref); ClassDB::bind_method(D_METHOD("get__body_ref"), &GSAIKinematicBody3DAgent::get__body_ref);
ClassDB::bind_method(D_METHOD("set__body_ref", "value"), &GSAIKinematicBody3DAgent::set__body_ref); ClassDB::bind_method(D_METHOD("set__body_ref", "value"), &GSAIKinematicBody3DAgent::set__body_ref);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_body_ref", PROPERTY_HINT_RESOURCE_TYPE, "Ref<WeakRef>"), "set__body_ref", "get__body_ref"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_body_ref", PROPERTY_HINT_RESOURCE_TYPE, "Ref<WeakRef>"), "set__body_ref", "get__body_ref");
ClassDB::bind_method(D_METHOD("_body_ready"), &GSAIKinematicBody3DAgent::_body_ready); ClassDB::bind_method(D_METHOD("_body_ready"), &GSAIKinematicBody3DAgent::_body_ready);
ClassDB::bind_method(D_METHOD("_apply_steering", "acceleration", "delta"), &GSAIKinematicBody3DAgent::_apply_steering); ClassDB::bind_method(D_METHOD("_apply_steering", "acceleration", "delta"), &GSAIKinematicBody3DAgent::_apply_steering);
ClassDB::bind_method(D_METHOD("_apply_sliding_steering", "accel", "delta"), &GSAIKinematicBody3DAgent::_apply_sliding_steering); ClassDB::bind_method(D_METHOD("_apply_sliding_steering", "accel", "delta"), &GSAIKinematicBody3DAgent::_apply_sliding_steering);
@ -289,8 +257,4 @@ _body_ref = val;
ClassDB::bind_method(D_METHOD("_apply_orientation_steering", "angular_acceleration", "delta"), &GSAIKinematicBody3DAgent::_apply_orientation_steering); ClassDB::bind_method(D_METHOD("_apply_orientation_steering", "angular_acceleration", "delta"), &GSAIKinematicBody3DAgent::_apply_orientation_steering);
ClassDB::bind_method(D_METHOD("_set_body", "value"), &GSAIKinematicBody3DAgent::_set_body); ClassDB::bind_method(D_METHOD("_set_body", "value"), &GSAIKinematicBody3DAgent::_set_body);
ClassDB::bind_method(D_METHOD("_on_SceneTree_physics_frame"), &GSAIKinematicBody3DAgent::_on_SceneTree_physics_frame); ClassDB::bind_method(D_METHOD("_on_SceneTree_physics_frame"), &GSAIKinematicBody3DAgent::_on_SceneTree_physics_frame);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIKINEMATICBODY3DAGENT_H #ifndef GSAIKINEMATICBODY3DAGENT_H
#define GSAIKINEMATICBODY3DAGENT_H #define GSAIKINEMATICBODY3DAGENT_H
class GSAIKinematicBody3DAgent : public GSAISpecializedAgent { class GSAIKinematicBody3DAgent : public GSAISpecializedAgent {
GDCLASS(GSAIKinematicBody3DAgent, GSAISpecializedAgent); GDCLASS(GSAIKinematicBody3DAgent, GSAISpecializedAgent);
public: public:
KinematicBody get_ *body(); KinematicBody get_ *body();
void set_ *body(const KinematicBody &val); void set_ *body(const KinematicBody &val);
@ -57,7 +55,7 @@ class GSAIKinematicBody3DAgent : public GSAISpecializedAgent {
Ref<WeakRef> _body_ref; Ref<WeakRef> _body_ref;
// Moves the agent's `body` by target `acceleration`. // Moves the agent's `body` by target `acceleration`.
// @tags - virtual // @tags - virtual
}; }
;
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_rigid_body_2d_agent.h" #include "gsai_rigid_body_2d_agent.h"
RigidBody2D GSAIRigidBody2DAgent::get_ *body() { RigidBody2D GSAIRigidBody2DAgent::get_ *body() {
return *body; return *body;
} }
@ -10,7 +9,6 @@ void GSAIRigidBody2DAgent::set_*body(const RigidBody2D &val) {
*body = val; *body = val;
} }
Vector2 GSAIRigidBody2DAgent::get__last_position() { Vector2 GSAIRigidBody2DAgent::get__last_position() {
return _last_position; return _last_position;
} }
@ -19,7 +17,6 @@ void GSAIRigidBody2DAgent::set__last_position(const Vector2 &val) {
_last_position = val; _last_position = val;
} }
Ref<WeakRef> GSAIRigidBody2DAgent::get__body_ref() { Ref<WeakRef> GSAIRigidBody2DAgent::get__body_ref() {
return _body_ref; return _body_ref;
} }
@ -28,8 +25,6 @@ void GSAIRigidBody2DAgent::set__body_ref(const Ref<WeakRef> &val) {
_body_ref = val; _body_ref = val;
} }
// A specialized steering agent that updates itself every frame so the user does; // A specialized steering agent that updates itself every frame so the user does;
// not have to using a RigidBody2D; // not have to using a RigidBody2D;
// @category - Specialized agents; // @category - Specialized agents;
@ -62,10 +57,8 @@ _body_ref = val;
linear_velocity = GSAIUtils.to_vector3(_body.linear_velocity); linear_velocity = GSAIUtils.to_vector3(_body.linear_velocity);
angular_velocity = _body.angular_velocity; angular_velocity = _body.angular_velocity;
} }
} }
void GSAIRigidBody2DAgent::_set_body(const RigidBody2D &value) { void GSAIRigidBody2DAgent::_set_body(const RigidBody2D &value) {
bool had_body = false; bool had_body = false;
@ -81,21 +74,16 @@ _body_ref = val;
orientation = last_orientation; orientation = last_orientation;
if (!had_body) { if (!had_body) {
if (!body.is_inside_tree()) { if (!body.is_inside_tree()) {
body.connect("ready", self, "_body_ready"); body.connect("ready", self, "_body_ready");
} }
else { else {
_body_ready(); _body_ready();
} }
} }
} }
void GSAIRigidBody2DAgent::_on_SceneTree_frame() { void GSAIRigidBody2DAgent::_on_SceneTree_frame() {
RigidBody2D *_body = _body_ref.get_ref(); RigidBody2D *_body = _body_ref.get_ref();
@ -103,7 +91,6 @@ _body_ref = val;
return; return;
} }
if (!_body.is_inside_tree() || _body.get_tree().paused) { if (!_body.is_inside_tree() || _body.get_tree().paused) {
return; return;
} }
@ -114,21 +101,16 @@ _body_ref = val;
orientation = current_orientation; orientation = current_orientation;
if (calculate_velocities) { if (calculate_velocities) {
if (applied_steering) { if (applied_steering) {
applied_steering = false; applied_steering = false;
} }
else { else {
linear_velocity = GSAIUtils.to_vector3(_body.linear_velocity); linear_velocity = GSAIUtils.to_vector3(_body.linear_velocity);
angular_velocity = _body.angular_velocity; angular_velocity = _body.angular_velocity;
} }
} }
} }
} }
GSAIRigidBody2DAgent::GSAIRigidBody2DAgent() { GSAIRigidBody2DAgent::GSAIRigidBody2DAgent() {
@ -140,29 +122,21 @@ _body_ref = val;
GSAIRigidBody2DAgent::~GSAIRigidBody2DAgent() { GSAIRigidBody2DAgent::~GSAIRigidBody2DAgent() {
} }
static void GSAIRigidBody2DAgent::_bind_methods() { static void GSAIRigidBody2DAgent::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_*body"), &GSAIRigidBody2DAgent::get_ * body); ClassDB::bind_method(D_METHOD("get_*body"), &GSAIRigidBody2DAgent::get_ * body);
ClassDB::bind_method(D_METHOD("set_*body", "value"), &GSAIRigidBody2DAgent::set_ * body); ClassDB::bind_method(D_METHOD("set_*body", "value"), &GSAIRigidBody2DAgent::set_ * body);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*body", PROPERTY_HINT_RESOURCE_TYPE, "RigidBody2D"), "set_*body", "get_*body"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*body", PROPERTY_HINT_RESOURCE_TYPE, "RigidBody2D"), "set_*body", "get_*body");
ClassDB::bind_method(D_METHOD("get__last_position"), &GSAIRigidBody2DAgent::get__last_position); ClassDB::bind_method(D_METHOD("get__last_position"), &GSAIRigidBody2DAgent::get__last_position);
ClassDB::bind_method(D_METHOD("set__last_position", "value"), &GSAIRigidBody2DAgent::set__last_position); ClassDB::bind_method(D_METHOD("set__last_position", "value"), &GSAIRigidBody2DAgent::set__last_position);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "_last_position"), "set__last_position", "get__last_position"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "_last_position"), "set__last_position", "get__last_position");
ClassDB::bind_method(D_METHOD("get__body_ref"), &GSAIRigidBody2DAgent::get__body_ref); ClassDB::bind_method(D_METHOD("get__body_ref"), &GSAIRigidBody2DAgent::get__body_ref);
ClassDB::bind_method(D_METHOD("set__body_ref", "value"), &GSAIRigidBody2DAgent::set__body_ref); ClassDB::bind_method(D_METHOD("set__body_ref", "value"), &GSAIRigidBody2DAgent::set__body_ref);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_body_ref", PROPERTY_HINT_RESOURCE_TYPE, "Ref<WeakRef>"), "set__body_ref", "get__body_ref"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_body_ref", PROPERTY_HINT_RESOURCE_TYPE, "Ref<WeakRef>"), "set__body_ref", "get__body_ref");
ClassDB::bind_method(D_METHOD("_body_ready"), &GSAIRigidBody2DAgent::_body_ready); ClassDB::bind_method(D_METHOD("_body_ready"), &GSAIRigidBody2DAgent::_body_ready);
ClassDB::bind_method(D_METHOD("_apply_steering", "acceleration", "_delta"), &GSAIRigidBody2DAgent::_apply_steering); ClassDB::bind_method(D_METHOD("_apply_steering", "acceleration", "_delta"), &GSAIRigidBody2DAgent::_apply_steering);
ClassDB::bind_method(D_METHOD("_set_body", "value"), &GSAIRigidBody2DAgent::_set_body); ClassDB::bind_method(D_METHOD("_set_body", "value"), &GSAIRigidBody2DAgent::_set_body);
ClassDB::bind_method(D_METHOD("_on_SceneTree_frame"), &GSAIRigidBody2DAgent::_on_SceneTree_frame); ClassDB::bind_method(D_METHOD("_on_SceneTree_frame"), &GSAIRigidBody2DAgent::_on_SceneTree_frame);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIRIGIDBODY2DAGENT_H #ifndef GSAIRIGIDBODY2DAGENT_H
#define GSAIRIGIDBODY2DAGENT_H #define GSAIRIGIDBODY2DAGENT_H
class GSAIRigidBody2DAgent : public GSAISpecializedAgent { class GSAIRigidBody2DAgent : public GSAISpecializedAgent {
GDCLASS(GSAIRigidBody2DAgent, GSAISpecializedAgent); GDCLASS(GSAIRigidBody2DAgent, GSAISpecializedAgent);
public: public:
RigidBody2D get_ *body(); RigidBody2D get_ *body();
void set_ *body(const RigidBody2D &val); void set_ *body(const RigidBody2D &val);
@ -39,5 +37,4 @@ class GSAIRigidBody2DAgent : public GSAISpecializedAgent {
// @tags - virtual // @tags - virtual
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_rigid_body_3d_agent.h" #include "gsai_rigid_body_3d_agent.h"
RigidBody GSAIRigidBody3DAgent::get_ *body() { RigidBody GSAIRigidBody3DAgent::get_ *body() {
return *body; return *body;
} }
@ -10,7 +9,6 @@ void GSAIRigidBody3DAgent::set_*body(const RigidBody &val) {
*body = val; *body = val;
} }
Vector3 GSAIRigidBody3DAgent::get__last_position() { Vector3 GSAIRigidBody3DAgent::get__last_position() {
return _last_position; return _last_position;
} }
@ -19,7 +17,6 @@ void GSAIRigidBody3DAgent::set__last_position(const Vector3 &val) {
_last_position = val; _last_position = val;
} }
Ref<WeakRef> GSAIRigidBody3DAgent::get__body_ref() { Ref<WeakRef> GSAIRigidBody3DAgent::get__body_ref() {
return _body_ref; return _body_ref;
} }
@ -28,8 +25,6 @@ void GSAIRigidBody3DAgent::set__body_ref(const Ref<WeakRef> &val) {
_body_ref = val; _body_ref = val;
} }
// A specialized steering agent that updates itself every frame so the user does; // A specialized steering agent that updates itself every frame so the user does;
// not have to using a RigidBody; // not have to using a RigidBody;
// @category - Specialized agents; // @category - Specialized agents;
@ -62,10 +57,8 @@ _body_ref = val;
linear_velocity = _body.linear_velocity; linear_velocity = _body.linear_velocity;
angular_velocity = _body.angular_velocity.y; angular_velocity = _body.angular_velocity.y;
} }
} }
void GSAIRigidBody3DAgent::_set_body(const RigidBody &value) { void GSAIRigidBody3DAgent::_set_body(const RigidBody &value) {
bool had_body = false; bool had_body = false;
@ -81,21 +74,16 @@ _body_ref = val;
orientation = last_orientation; orientation = last_orientation;
if (!had_body) { if (!had_body) {
if (!body.is_inside_tree()) { if (!body.is_inside_tree()) {
body.connect("ready", self, "_body_ready"); body.connect("ready", self, "_body_ready");
} }
else { else {
_body_ready(); _body_ready();
} }
} }
} }
void GSAIRigidBody3DAgent::_on_SceneTree_frame() { void GSAIRigidBody3DAgent::_on_SceneTree_frame() {
RigidBody *_body = _body_ref.get_ref(); RigidBody *_body = _body_ref.get_ref();
@ -103,7 +91,6 @@ _body_ref = val;
return; return;
} }
if (not _body.is_inside_tree() || _body.get_tree().paused) { if (not _body.is_inside_tree() || _body.get_tree().paused) {
return; return;
} }
@ -114,21 +101,16 @@ _body_ref = val;
orientation = current_orientation; orientation = current_orientation;
if (calculate_velocities) { if (calculate_velocities) {
if (applied_steering) { if (applied_steering) {
applied_steering = false; applied_steering = false;
} }
else { else {
linear_velocity = _body.linear_velocity; linear_velocity = _body.linear_velocity;
angular_velocity = _body.angular_velocity.y; angular_velocity = _body.angular_velocity.y;
} }
} }
} }
} }
GSAIRigidBody3DAgent::GSAIRigidBody3DAgent() { GSAIRigidBody3DAgent::GSAIRigidBody3DAgent() {
@ -140,29 +122,21 @@ _body_ref = val;
GSAIRigidBody3DAgent::~GSAIRigidBody3DAgent() { GSAIRigidBody3DAgent::~GSAIRigidBody3DAgent() {
} }
static void GSAIRigidBody3DAgent::_bind_methods() { static void GSAIRigidBody3DAgent::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_*body"), &GSAIRigidBody3DAgent::get_ * body); ClassDB::bind_method(D_METHOD("get_*body"), &GSAIRigidBody3DAgent::get_ * body);
ClassDB::bind_method(D_METHOD("set_*body", "value"), &GSAIRigidBody3DAgent::set_ * body); ClassDB::bind_method(D_METHOD("set_*body", "value"), &GSAIRigidBody3DAgent::set_ * body);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*body", PROPERTY_HINT_RESOURCE_TYPE, "RigidBody"), "set_*body", "get_*body"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*body", PROPERTY_HINT_RESOURCE_TYPE, "RigidBody"), "set_*body", "get_*body");
ClassDB::bind_method(D_METHOD("get__last_position"), &GSAIRigidBody3DAgent::get__last_position); ClassDB::bind_method(D_METHOD("get__last_position"), &GSAIRigidBody3DAgent::get__last_position);
ClassDB::bind_method(D_METHOD("set__last_position", "value"), &GSAIRigidBody3DAgent::set__last_position); ClassDB::bind_method(D_METHOD("set__last_position", "value"), &GSAIRigidBody3DAgent::set__last_position);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_last_position"), "set__last_position", "get__last_position"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_last_position"), "set__last_position", "get__last_position");
ClassDB::bind_method(D_METHOD("get__body_ref"), &GSAIRigidBody3DAgent::get__body_ref); ClassDB::bind_method(D_METHOD("get__body_ref"), &GSAIRigidBody3DAgent::get__body_ref);
ClassDB::bind_method(D_METHOD("set__body_ref", "value"), &GSAIRigidBody3DAgent::set__body_ref); ClassDB::bind_method(D_METHOD("set__body_ref", "value"), &GSAIRigidBody3DAgent::set__body_ref);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_body_ref", PROPERTY_HINT_RESOURCE_TYPE, "Ref<WeakRef>"), "set__body_ref", "get__body_ref"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_body_ref", PROPERTY_HINT_RESOURCE_TYPE, "Ref<WeakRef>"), "set__body_ref", "get__body_ref");
ClassDB::bind_method(D_METHOD("_body_ready"), &GSAIRigidBody3DAgent::_body_ready); ClassDB::bind_method(D_METHOD("_body_ready"), &GSAIRigidBody3DAgent::_body_ready);
ClassDB::bind_method(D_METHOD("_apply_steering", "acceleration", "_delta"), &GSAIRigidBody3DAgent::_apply_steering); ClassDB::bind_method(D_METHOD("_apply_steering", "acceleration", "_delta"), &GSAIRigidBody3DAgent::_apply_steering);
ClassDB::bind_method(D_METHOD("_set_body", "value"), &GSAIRigidBody3DAgent::_set_body); ClassDB::bind_method(D_METHOD("_set_body", "value"), &GSAIRigidBody3DAgent::_set_body);
ClassDB::bind_method(D_METHOD("_on_SceneTree_frame"), &GSAIRigidBody3DAgent::_on_SceneTree_frame); ClassDB::bind_method(D_METHOD("_on_SceneTree_frame"), &GSAIRigidBody3DAgent::_on_SceneTree_frame);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIRIGIDBODY3DAGENT_H #ifndef GSAIRIGIDBODY3DAGENT_H
#define GSAIRIGIDBODY3DAGENT_H #define GSAIRIGIDBODY3DAGENT_H
class GSAIRigidBody3DAgent : public GSAISpecializedAgent { class GSAIRigidBody3DAgent : public GSAISpecializedAgent {
GDCLASS(GSAIRigidBody3DAgent, GSAISpecializedAgent); GDCLASS(GSAIRigidBody3DAgent, GSAISpecializedAgent);
public: public:
RigidBody get_ *body(); RigidBody get_ *body();
void set_ *body(const RigidBody &val); void set_ *body(const RigidBody &val);
@ -39,5 +37,4 @@ class GSAIRigidBody3DAgent : public GSAISpecializedAgent {
// @tags - virtual // @tags - virtual
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_specialize_dagent.h" #include "gsai_specialize_dagent.h"
bool GSAISpecializedAgent::get_calculate_velocities() const { bool GSAISpecializedAgent::get_calculate_velocities() const {
return calculate_velocities; return calculate_velocities;
} }
@ -10,7 +9,6 @@ void GSAISpecializedAgent::set_calculate_velocities(const bool val) {
calculate_velocities = val; calculate_velocities = val;
} }
bool GSAISpecializedAgent::get_apply_linear_drag() const { bool GSAISpecializedAgent::get_apply_linear_drag() const {
return apply_linear_drag; return apply_linear_drag;
} }
@ -19,7 +17,6 @@ void GSAISpecializedAgent::set_apply_linear_drag(const bool val) {
apply_linear_drag = val; apply_linear_drag = val;
} }
bool GSAISpecializedAgent::get_apply_angular_drag() const { bool GSAISpecializedAgent::get_apply_angular_drag() const {
return apply_angular_drag; return apply_angular_drag;
} }
@ -28,7 +25,6 @@ void GSAISpecializedAgent::set_apply_angular_drag(const bool val) {
apply_angular_drag = val; apply_angular_drag = val;
} }
float GSAISpecializedAgent::get_linear_drag_percentage() const { float GSAISpecializedAgent::get_linear_drag_percentage() const {
return linear_drag_percentage; return linear_drag_percentage;
} }
@ -37,7 +33,6 @@ void GSAISpecializedAgent::set_linear_drag_percentage(const float val) {
linear_drag_percentage = val; linear_drag_percentage = val;
} }
float GSAISpecializedAgent::get_angular_drag_percentage() const { float GSAISpecializedAgent::get_angular_drag_percentage() const {
return angular_drag_percentage; return angular_drag_percentage;
} }
@ -46,7 +41,6 @@ void GSAISpecializedAgent::set_angular_drag_percentage(const float val) {
angular_drag_percentage = val; angular_drag_percentage = val;
} }
float GSAISpecializedAgent::get_last_orientation() const { float GSAISpecializedAgent::get_last_orientation() const {
return last_orientation; return last_orientation;
} }
@ -55,7 +49,6 @@ void GSAISpecializedAgent::set_last_orientation(const float val) {
last_orientation = val; last_orientation = val;
} }
bool GSAISpecializedAgent::get_applied_steering() const { bool GSAISpecializedAgent::get_applied_steering() const {
return applied_steering; return applied_steering;
} }
@ -64,8 +57,6 @@ void GSAISpecializedAgent::set_applied_steering(const bool val) {
applied_steering = val; applied_steering = val;
} }
// A base class for a specialized steering agent that updates itself every frame; // 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.; // so the user does not have to. All other specialized agents derive from this.;
// @category - Specialized agents; // @category - Specialized agents;
@ -102,7 +93,6 @@ applied_steering = val;
void GSAISpecializedAgent::_apply_steering(const GSAITargetAcceleration &_acceleration, const float _delta) { void GSAISpecializedAgent::_apply_steering(const GSAITargetAcceleration &_acceleration, const float _delta) {
pass; pass;
} }
} }
GSAISpecializedAgent::GSAISpecializedAgent() { GSAISpecializedAgent::GSAISpecializedAgent() {
@ -118,47 +108,35 @@ applied_steering = val;
GSAISpecializedAgent::~GSAISpecializedAgent() { GSAISpecializedAgent::~GSAISpecializedAgent() {
} }
static void GSAISpecializedAgent::_bind_methods() { static void GSAISpecializedAgent::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_calculate_velocities"), &GSAISpecializedAgent::get_calculate_velocities); ClassDB::bind_method(D_METHOD("get_calculate_velocities"), &GSAISpecializedAgent::get_calculate_velocities);
ClassDB::bind_method(D_METHOD("set_calculate_velocities", "value"), &GSAISpecializedAgent::set_calculate_velocities); ClassDB::bind_method(D_METHOD("set_calculate_velocities", "value"), &GSAISpecializedAgent::set_calculate_velocities);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "calculate_velocities"), "set_calculate_velocities", "get_calculate_velocities"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "calculate_velocities"), "set_calculate_velocities", "get_calculate_velocities");
ClassDB::bind_method(D_METHOD("get_apply_linear_drag"), &GSAISpecializedAgent::get_apply_linear_drag); ClassDB::bind_method(D_METHOD("get_apply_linear_drag"), &GSAISpecializedAgent::get_apply_linear_drag);
ClassDB::bind_method(D_METHOD("set_apply_linear_drag", "value"), &GSAISpecializedAgent::set_apply_linear_drag); ClassDB::bind_method(D_METHOD("set_apply_linear_drag", "value"), &GSAISpecializedAgent::set_apply_linear_drag);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "apply_linear_drag"), "set_apply_linear_drag", "get_apply_linear_drag"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "apply_linear_drag"), "set_apply_linear_drag", "get_apply_linear_drag");
ClassDB::bind_method(D_METHOD("get_apply_angular_drag"), &GSAISpecializedAgent::get_apply_angular_drag); ClassDB::bind_method(D_METHOD("get_apply_angular_drag"), &GSAISpecializedAgent::get_apply_angular_drag);
ClassDB::bind_method(D_METHOD("set_apply_angular_drag", "value"), &GSAISpecializedAgent::set_apply_angular_drag); ClassDB::bind_method(D_METHOD("set_apply_angular_drag", "value"), &GSAISpecializedAgent::set_apply_angular_drag);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "apply_angular_drag"), "set_apply_angular_drag", "get_apply_angular_drag"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "apply_angular_drag"), "set_apply_angular_drag", "get_apply_angular_drag");
ClassDB::bind_method(D_METHOD("get_linear_drag_percentage"), &GSAISpecializedAgent::get_linear_drag_percentage); ClassDB::bind_method(D_METHOD("get_linear_drag_percentage"), &GSAISpecializedAgent::get_linear_drag_percentage);
ClassDB::bind_method(D_METHOD("set_linear_drag_percentage", "value"), &GSAISpecializedAgent::set_linear_drag_percentage); ClassDB::bind_method(D_METHOD("set_linear_drag_percentage", "value"), &GSAISpecializedAgent::set_linear_drag_percentage);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_drag_percentage"), "set_linear_drag_percentage", "get_linear_drag_percentage"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_drag_percentage"), "set_linear_drag_percentage", "get_linear_drag_percentage");
ClassDB::bind_method(D_METHOD("get_angular_drag_percentage"), &GSAISpecializedAgent::get_angular_drag_percentage); ClassDB::bind_method(D_METHOD("get_angular_drag_percentage"), &GSAISpecializedAgent::get_angular_drag_percentage);
ClassDB::bind_method(D_METHOD("set_angular_drag_percentage", "value"), &GSAISpecializedAgent::set_angular_drag_percentage); ClassDB::bind_method(D_METHOD("set_angular_drag_percentage", "value"), &GSAISpecializedAgent::set_angular_drag_percentage);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_drag_percentage"), "set_angular_drag_percentage", "get_angular_drag_percentage"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_drag_percentage"), "set_angular_drag_percentage", "get_angular_drag_percentage");
ClassDB::bind_method(D_METHOD("get_last_orientation"), &GSAISpecializedAgent::get_last_orientation); ClassDB::bind_method(D_METHOD("get_last_orientation"), &GSAISpecializedAgent::get_last_orientation);
ClassDB::bind_method(D_METHOD("set_last_orientation", "value"), &GSAISpecializedAgent::set_last_orientation); ClassDB::bind_method(D_METHOD("set_last_orientation", "value"), &GSAISpecializedAgent::set_last_orientation);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "last_orientation"), "set_last_orientation", "get_last_orientation"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "last_orientation"), "set_last_orientation", "get_last_orientation");
ClassDB::bind_method(D_METHOD("get_applied_steering"), &GSAISpecializedAgent::get_applied_steering); ClassDB::bind_method(D_METHOD("get_applied_steering"), &GSAISpecializedAgent::get_applied_steering);
ClassDB::bind_method(D_METHOD("set_applied_steering", "value"), &GSAISpecializedAgent::set_applied_steering); ClassDB::bind_method(D_METHOD("set_applied_steering", "value"), &GSAISpecializedAgent::set_applied_steering);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "applied_steering"), "set_applied_steering", "get_applied_steering"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "applied_steering"), "set_applied_steering", "get_applied_steering");
ClassDB::bind_method(D_METHOD("apply_steering", "_acceleration", "_delta"), &GSAISpecializedAgent::apply_steering); ClassDB::bind_method(D_METHOD("apply_steering", "_acceleration", "_delta"), &GSAISpecializedAgent::apply_steering);
ClassDB::bind_method(D_METHOD("_apply_steering", "_acceleration", "_delta"), &GSAISpecializedAgent::_apply_steering); ClassDB::bind_method(D_METHOD("_apply_steering", "_acceleration", "_delta"), &GSAISpecializedAgent::_apply_steering);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAISPECIALIZEDAGENT_H #ifndef GSAISPECIALIZEDAGENT_H
#define GSAISPECIALIZEDAGENT_H #define GSAISPECIALIZEDAGENT_H
class GSAISpecializedAgent : public GSAISteeringAgent { class GSAISpecializedAgent : public GSAISteeringAgent {
GDCLASS(GSAISpecializedAgent, GSAISteeringAgent); GDCLASS(GSAISpecializedAgent, GSAISteeringAgent);
public: public:
bool get_calculate_velocities() const; bool get_calculate_velocities() const;
void set_calculate_velocities(const bool val); void set_calculate_velocities(const bool val);
@ -66,5 +64,4 @@ class GSAISpecializedAgent : public GSAISteeringAgent {
// @tags - virtual // @tags - virtual
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_arrive.h" #include "gsai_arrive.h"
GSAIAgentLocation GSAIArrive::get_ *target() { GSAIAgentLocation GSAIArrive::get_ *target() {
return *target; return *target;
} }
@ -10,7 +9,6 @@ void GSAIArrive::set_*target(const GSAIAgentLocation &val) {
*target = val; *target = val;
} }
float GSAIArrive::get_arrival_tolerance() const { float GSAIArrive::get_arrival_tolerance() const {
return arrival_tolerance; return arrival_tolerance;
} }
@ -19,7 +17,6 @@ void GSAIArrive::set_arrival_tolerance(const float val) {
arrival_tolerance = val; arrival_tolerance = val;
} }
float GSAIArrive::get_deceleration_radius() const { float GSAIArrive::get_deceleration_radius() const {
return deceleration_radius; return deceleration_radius;
} }
@ -28,7 +25,6 @@ void GSAIArrive::set_deceleration_radius(const float val) {
deceleration_radius = val; deceleration_radius = val;
} }
float GSAIArrive::get_time_to_reach() const { float GSAIArrive::get_time_to_reach() const {
return time_to_reach; return time_to_reach;
} }
@ -37,8 +33,6 @@ void GSAIArrive::set_time_to_reach(const float val) {
time_to_reach = val; time_to_reach = val;
} }
// Calculates acceleration to take an agent to its target's location. The; // Calculates acceleration to take an agent to its target's location. The;
// calculation attempts to arrive with zero remaining velocity.; // calculation attempts to arrive with zero remaining velocity.;
// @category - Individual behaviors; // @category - Individual behaviors;
@ -56,7 +50,6 @@ time_to_reach = val;
call("_arrive", acceleration, target_position); call("_arrive", acceleration, target_position);
} }
void GSAIArrive::_arrive(const GSAITargetAcceleration &acceleration, const Vector3 &target_position) { void GSAIArrive::_arrive(const GSAITargetAcceleration &acceleration, const Vector3 &target_position) {
Vector3 to_target = target_position - agent.position; Vector3 to_target = target_position - agent.position;
float distance = to_target.length(); float distance = to_target.length();
@ -65,7 +58,6 @@ time_to_reach = val;
acceleration.set_zero(); acceleration.set_zero();
} }
else { else {
float desired_speed = agent.linear_speed_max; float desired_speed = agent.linear_speed_max;
@ -78,14 +70,11 @@ time_to_reach = val;
acceleration.linear = GSAIUtils.clampedv3(desired_velocity, agent.linear_acceleration_max); acceleration.linear = GSAIUtils.clampedv3(desired_velocity, agent.linear_acceleration_max);
acceleration.angular = 0; acceleration.angular = 0;
} }
} }
void GSAIArrive::_calculate_steering(const GSAITargetAcceleration &acceleration) { void GSAIArrive::_calculate_steering(const GSAITargetAcceleration &acceleration) {
arrive(acceleration, target.position); arrive(acceleration, target.position);
} }
} }
GSAIArrive::GSAIArrive() { GSAIArrive::GSAIArrive() {
@ -98,33 +87,24 @@ time_to_reach = val;
GSAIArrive::~GSAIArrive() { GSAIArrive::~GSAIArrive() {
} }
static void GSAIArrive::_bind_methods() { static void GSAIArrive::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_*target"), &GSAIArrive::get_ * target); ClassDB::bind_method(D_METHOD("get_*target"), &GSAIArrive::get_ * target);
ClassDB::bind_method(D_METHOD("set_*target", "value"), &GSAIArrive::set_ * target); ClassDB::bind_method(D_METHOD("set_*target", "value"), &GSAIArrive::set_ * target);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*target", PROPERTY_HINT_RESOURCE_TYPE, "GSAIAgentLocation"), "set_*target", "get_*target"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*target", PROPERTY_HINT_RESOURCE_TYPE, "GSAIAgentLocation"), "set_*target", "get_*target");
ClassDB::bind_method(D_METHOD("get_arrival_tolerance"), &GSAIArrive::get_arrival_tolerance); ClassDB::bind_method(D_METHOD("get_arrival_tolerance"), &GSAIArrive::get_arrival_tolerance);
ClassDB::bind_method(D_METHOD("set_arrival_tolerance", "value"), &GSAIArrive::set_arrival_tolerance); ClassDB::bind_method(D_METHOD("set_arrival_tolerance", "value"), &GSAIArrive::set_arrival_tolerance);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "arrival_tolerance"), "set_arrival_tolerance", "get_arrival_tolerance"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "arrival_tolerance"), "set_arrival_tolerance", "get_arrival_tolerance");
ClassDB::bind_method(D_METHOD("get_deceleration_radius"), &GSAIArrive::get_deceleration_radius); ClassDB::bind_method(D_METHOD("get_deceleration_radius"), &GSAIArrive::get_deceleration_radius);
ClassDB::bind_method(D_METHOD("set_deceleration_radius", "value"), &GSAIArrive::set_deceleration_radius); ClassDB::bind_method(D_METHOD("set_deceleration_radius", "value"), &GSAIArrive::set_deceleration_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "deceleration_radius"), "set_deceleration_radius", "get_deceleration_radius"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "deceleration_radius"), "set_deceleration_radius", "get_deceleration_radius");
ClassDB::bind_method(D_METHOD("get_time_to_reach"), &GSAIArrive::get_time_to_reach); ClassDB::bind_method(D_METHOD("get_time_to_reach"), &GSAIArrive::get_time_to_reach);
ClassDB::bind_method(D_METHOD("set_time_to_reach", "value"), &GSAIArrive::set_time_to_reach); ClassDB::bind_method(D_METHOD("set_time_to_reach", "value"), &GSAIArrive::set_time_to_reach);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_to_reach"), "set_time_to_reach", "get_time_to_reach"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_to_reach"), "set_time_to_reach", "get_time_to_reach");
ClassDB::bind_method(D_METHOD("arrive", "acceleration", "target_position"), &GSAIArrive::arrive); ClassDB::bind_method(D_METHOD("arrive", "acceleration", "target_position"), &GSAIArrive::arrive);
ClassDB::bind_method(D_METHOD("_arrive", "acceleration", "target_position"), &GSAIArrive::_arrive); ClassDB::bind_method(D_METHOD("_arrive", "acceleration", "target_position"), &GSAIArrive::_arrive);
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIArrive::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIArrive::_calculate_steering);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIARRIVE_H #ifndef GSAIARRIVE_H
#define GSAIARRIVE_H #define GSAIARRIVE_H
class GSAIArrive : public GSAISteeringBehavior { class GSAIArrive : public GSAISteeringBehavior {
GDCLASS(GSAIArrive, GSAISteeringBehavior); GDCLASS(GSAIArrive, GSAISteeringBehavior);
public: public:
GSAIAgentLocation get_ *target(); GSAIAgentLocation get_ *target();
void set_ *target(const GSAIAgentLocation &val); void set_ *target(const GSAIAgentLocation &val);
@ -43,5 +41,4 @@ class GSAIArrive : public GSAISteeringBehavior {
float time_to_reach = 0.1; float time_to_reach = 0.1;
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_avoid_collisions.h" #include "gsai_avoid_collisions.h"
GSAISteeringAgent GSAIAvoidCollisions::get_ *_first_neighbor() { GSAISteeringAgent GSAIAvoidCollisions::get_ *_first_neighbor() {
return *_first_neighbor; return *_first_neighbor;
} }
@ -10,7 +9,6 @@ void GSAIAvoidCollisions::set_*_first_neighbor(const GSAISteeringAgent &val) {
*_first_neighbor = val; *_first_neighbor = val;
} }
float GSAIAvoidCollisions::get__shortest_time() const { float GSAIAvoidCollisions::get__shortest_time() const {
return _shortest_time; return _shortest_time;
} }
@ -19,7 +17,6 @@ void GSAIAvoidCollisions::set__shortest_time(const float val) {
_shortest_time = val; _shortest_time = val;
} }
float GSAIAvoidCollisions::get__first_minimum_separation() const { float GSAIAvoidCollisions::get__first_minimum_separation() const {
return _first_minimum_separation; return _first_minimum_separation;
} }
@ -28,7 +25,6 @@ void GSAIAvoidCollisions::set__first_minimum_separation(const float val) {
_first_minimum_separation = val; _first_minimum_separation = val;
} }
float GSAIAvoidCollisions::get__first_distance() const { float GSAIAvoidCollisions::get__first_distance() const {
return _first_distance; return _first_distance;
} }
@ -37,7 +33,6 @@ void GSAIAvoidCollisions::set__first_distance(const float val) {
_first_distance = val; _first_distance = val;
} }
Vector3 GSAIAvoidCollisions::get__first_relative_position() { Vector3 GSAIAvoidCollisions::get__first_relative_position() {
return _first_relative_position; return _first_relative_position;
} }
@ -46,7 +41,6 @@ void GSAIAvoidCollisions::set__first_relative_position(const Vector3 &val) {
_first_relative_position = val; _first_relative_position = val;
} }
Vector3 GSAIAvoidCollisions::get__first_relative_velocity() { Vector3 GSAIAvoidCollisions::get__first_relative_velocity() {
return _first_relative_velocity; return _first_relative_velocity;
} }
@ -55,8 +49,6 @@ void GSAIAvoidCollisions::set__first_relative_velocity(const Vector3 &val) {
_first_relative_velocity = val; _first_relative_velocity = val;
} }
// Steers the agent to avoid obstacles in its path. Approximates obstacles as; // Steers the agent to avoid obstacles in its path. Approximates obstacles as;
// spheres.; // spheres.;
// @category - Group behaviors; // @category - Group behaviors;
@ -78,18 +70,14 @@ _first_relative_velocity = val;
acceleration.set_zero(); acceleration.set_zero();
} }
else { else {
if ((_first_minimum_separation <= 0 || _first_distance < agent.bounding_radius + _first_neighbor.bounding_radius)) { if ((_first_minimum_separation <= 0 || _first_distance < agent.bounding_radius + _first_neighbor.bounding_radius)) {
acceleration.linear = _first_neighbor.position - agent.position; acceleration.linear = _first_neighbor.position - agent.position;
} }
else { else {
acceleration.linear = (_first_relative_position + (_first_relative_velocity * _shortest_time)); acceleration.linear = (_first_relative_position + (_first_relative_velocity * _shortest_time));
} }
} }
acceleration.linear = (acceleration.linear.normalized() * -agent.linear_acceleration_max); acceleration.linear = (acceleration.linear.normalized() * -agent.linear_acceleration_max);
@ -109,7 +97,6 @@ _first_relative_velocity = val;
return false; return false;
} }
else { else {
float time_to_collision = -relative_position.dot(relative_velocity) / relative_speed_squared; float time_to_collision = -relative_position.dot(relative_velocity) / relative_speed_squared;
@ -117,7 +104,6 @@ _first_relative_velocity = val;
return false; return false;
} }
else { else {
Variant = relative_position.length(); Variant = relative_position.length();
float minimum_separation = (distance - sqrt(relative_speed_squared) * time_to_collision); float minimum_separation = (distance - sqrt(relative_speed_squared) * time_to_collision);
@ -126,7 +112,6 @@ _first_relative_velocity = val;
return false; return false;
} }
else { else {
_shortest_time = time_to_collision; _shortest_time = time_to_collision;
_first_neighbor = neighbor; _first_neighbor = neighbor;
@ -136,13 +121,9 @@ _first_relative_velocity = val;
_first_relative_velocity = relative_velocity; _first_relative_velocity = relative_velocity;
return true; return true;
} }
} }
} }
} }
} }
GSAIAvoidCollisions::GSAIAvoidCollisions() { GSAIAvoidCollisions::GSAIAvoidCollisions() {
@ -157,42 +138,31 @@ _first_relative_velocity = val;
GSAIAvoidCollisions::~GSAIAvoidCollisions() { GSAIAvoidCollisions::~GSAIAvoidCollisions() {
} }
static void GSAIAvoidCollisions::_bind_methods() { static void GSAIAvoidCollisions::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_*_first_neighbor"), &GSAIAvoidCollisions::get_ * _first_neighbor); ClassDB::bind_method(D_METHOD("get_*_first_neighbor"), &GSAIAvoidCollisions::get_ * _first_neighbor);
ClassDB::bind_method(D_METHOD("set_*_first_neighbor", "value"), &GSAIAvoidCollisions::set_ * _first_neighbor); ClassDB::bind_method(D_METHOD("set_*_first_neighbor", "value"), &GSAIAvoidCollisions::set_ * _first_neighbor);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_first_neighbor", PROPERTY_HINT_RESOURCE_TYPE, "GSAISteeringAgent"), "set_*_first_neighbor", "get_*_first_neighbor"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_first_neighbor", PROPERTY_HINT_RESOURCE_TYPE, "GSAISteeringAgent"), "set_*_first_neighbor", "get_*_first_neighbor");
ClassDB::bind_method(D_METHOD("get__shortest_time"), &GSAIAvoidCollisions::get__shortest_time); ClassDB::bind_method(D_METHOD("get__shortest_time"), &GSAIAvoidCollisions::get__shortest_time);
ClassDB::bind_method(D_METHOD("set__shortest_time", "value"), &GSAIAvoidCollisions::set__shortest_time); ClassDB::bind_method(D_METHOD("set__shortest_time", "value"), &GSAIAvoidCollisions::set__shortest_time);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "_shortest_time"), "set__shortest_time", "get__shortest_time"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "_shortest_time"), "set__shortest_time", "get__shortest_time");
ClassDB::bind_method(D_METHOD("get__first_minimum_separation"), &GSAIAvoidCollisions::get__first_minimum_separation); ClassDB::bind_method(D_METHOD("get__first_minimum_separation"), &GSAIAvoidCollisions::get__first_minimum_separation);
ClassDB::bind_method(D_METHOD("set__first_minimum_separation", "value"), &GSAIAvoidCollisions::set__first_minimum_separation); ClassDB::bind_method(D_METHOD("set__first_minimum_separation", "value"), &GSAIAvoidCollisions::set__first_minimum_separation);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "_first_minimum_separation"), "set__first_minimum_separation", "get__first_minimum_separation"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "_first_minimum_separation"), "set__first_minimum_separation", "get__first_minimum_separation");
ClassDB::bind_method(D_METHOD("get__first_distance"), &GSAIAvoidCollisions::get__first_distance); ClassDB::bind_method(D_METHOD("get__first_distance"), &GSAIAvoidCollisions::get__first_distance);
ClassDB::bind_method(D_METHOD("set__first_distance", "value"), &GSAIAvoidCollisions::set__first_distance); ClassDB::bind_method(D_METHOD("set__first_distance", "value"), &GSAIAvoidCollisions::set__first_distance);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "_first_distance"), "set__first_distance", "get__first_distance"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "_first_distance"), "set__first_distance", "get__first_distance");
ClassDB::bind_method(D_METHOD("get__first_relative_position"), &GSAIAvoidCollisions::get__first_relative_position); ClassDB::bind_method(D_METHOD("get__first_relative_position"), &GSAIAvoidCollisions::get__first_relative_position);
ClassDB::bind_method(D_METHOD("set__first_relative_position", "value"), &GSAIAvoidCollisions::set__first_relative_position); ClassDB::bind_method(D_METHOD("set__first_relative_position", "value"), &GSAIAvoidCollisions::set__first_relative_position);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_first_relative_position"), "set__first_relative_position", "get__first_relative_position"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_first_relative_position"), "set__first_relative_position", "get__first_relative_position");
ClassDB::bind_method(D_METHOD("get__first_relative_velocity"), &GSAIAvoidCollisions::get__first_relative_velocity); ClassDB::bind_method(D_METHOD("get__first_relative_velocity"), &GSAIAvoidCollisions::get__first_relative_velocity);
ClassDB::bind_method(D_METHOD("set__first_relative_velocity", "value"), &GSAIAvoidCollisions::set__first_relative_velocity); ClassDB::bind_method(D_METHOD("set__first_relative_velocity", "value"), &GSAIAvoidCollisions::set__first_relative_velocity);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_first_relative_velocity"), "set__first_relative_velocity", "get__first_relative_velocity"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_first_relative_velocity"), "set__first_relative_velocity", "get__first_relative_velocity");
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIAvoidCollisions::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIAvoidCollisions::_calculate_steering);
ClassDB::bind_method(D_METHOD("_report_neighbor", "neighbor"), &GSAIAvoidCollisions::_report_neighbor); ClassDB::bind_method(D_METHOD("_report_neighbor", "neighbor"), &GSAIAvoidCollisions::_report_neighbor);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIAVOIDCOLLISIONS_H #ifndef GSAIAVOIDCOLLISIONS_H
#define GSAIAVOIDCOLLISIONS_H #define GSAIAVOIDCOLLISIONS_H
class GSAIAvoidCollisions : public GSAIGroupBehavior { class GSAIAvoidCollisions : public GSAIGroupBehavior {
GDCLASS(GSAIAvoidCollisions, GSAIGroupBehavior); GDCLASS(GSAIAvoidCollisions, GSAIGroupBehavior);
public: public:
GSAISteeringAgent get_ *_first_neighbor(); GSAISteeringAgent get_ *_first_neighbor();
void set_ *_first_neighbor(const GSAISteeringAgent &val); void set_ *_first_neighbor(const GSAISteeringAgent &val);
@ -48,5 +46,4 @@ class GSAIAvoidCollisions : public GSAIGroupBehavior {
// @tags - virtual // @tags - virtual
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_blend.h" #include "gsai_blend.h"
Array GSAIBlend::get__behaviors() { Array GSAIBlend::get__behaviors() {
return _behaviors; return _behaviors;
} }
@ -10,7 +9,6 @@ void GSAIBlend::set__behaviors(const Array &val) {
_behaviors = val; _behaviors = val;
} }
GSAITargetAcceleration GSAIBlend::get_ *_accel() { GSAITargetAcceleration GSAIBlend::get_ *_accel() {
return *_accel; return *_accel;
} }
@ -19,8 +17,6 @@ void GSAIBlend::set_*_accel(const GSAITargetAcceleration &val) {
*_accel = val; *_accel = val;
} }
// Blends multiple steering behaviors into one, and returns a weighted; // Blends multiple steering behaviors into one, and returns a weighted;
// acceleration from their calculations.; // acceleration from their calculations.;
//; //;
@ -46,7 +42,6 @@ void GSAIBlend::set_*_accel(const GSAITargetAcceleration &val) {
// none was found.; // none was found.;
Dictionary GSAIBlend::get_behavior(const int index) { Dictionary GSAIBlend::get_behavior(const int index) {
if (_behaviors.size() > index) { if (_behaviors.size() > index) {
return _behaviors[index]; return _behaviors[index];
} }
@ -55,9 +50,7 @@ void GSAIBlend::set_*_accel(const GSAITargetAcceleration &val) {
return Dictionary(); return Dictionary();
} }
void GSAIBlend::remove_behavior(const int index) { void GSAIBlend::remove_behavior(const int index) {
if (_behaviors.size() > index) { if (_behaviors.size() > index) {
_behaviors.remove(index); _behaviors.remove(index);
return; return;
@ -67,17 +60,14 @@ void GSAIBlend::set_*_accel(const GSAITargetAcceleration &val) {
return; return;
} }
int GSAIBlend::get_behaviour_count() { int GSAIBlend::get_behaviour_count() {
return _behaviors.size(); return _behaviors.size();
} }
GSAITargetAcceleration GSAIBlend::get_accel() { GSAITargetAcceleration GSAIBlend::get_accel() {
return _accel; return _accel;
} }
void GSAIBlend::_calculate_steering(const GSAITargetAcceleration &blended_accel) { void GSAIBlend::_calculate_steering(const GSAITargetAcceleration &blended_accel) {
blended_accel.set_zero(); blended_accel.set_zero();
@ -90,7 +80,6 @@ void GSAIBlend::set_*_accel(const GSAITargetAcceleration &val) {
blended_accel.linear = GSAIUtils.clampedv3(blended_accel.linear, agent.linear_acceleration_max); blended_accel.linear = GSAIUtils.clampedv3(blended_accel.linear, agent.linear_acceleration_max);
blended_accel.angular = clamp(blended_accel.angular, -agent.angular_acceleration_max, agent.angular_acceleration_max); blended_accel.angular = clamp(blended_accel.angular, -agent.angular_acceleration_max, agent.angular_acceleration_max);
} }
} }
GSAIBlend::GSAIBlend() { GSAIBlend::GSAIBlend() {
@ -101,26 +90,19 @@ void GSAIBlend::set_*_accel(const GSAITargetAcceleration &val) {
GSAIBlend::~GSAIBlend() { GSAIBlend::~GSAIBlend() {
} }
static void GSAIBlend::_bind_methods() { static void GSAIBlend::_bind_methods() {
ClassDB::bind_method(D_METHOD("get__behaviors"), &GSAIBlend::get__behaviors); ClassDB::bind_method(D_METHOD("get__behaviors"), &GSAIBlend::get__behaviors);
ClassDB::bind_method(D_METHOD("set__behaviors", "value"), &GSAIBlend::set__behaviors); ClassDB::bind_method(D_METHOD("set__behaviors", "value"), &GSAIBlend::set__behaviors);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_behaviors"), "set__behaviors", "get__behaviors"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_behaviors"), "set__behaviors", "get__behaviors");
ClassDB::bind_method(D_METHOD("get_*_accel"), &GSAIBlend::get_ * _accel); ClassDB::bind_method(D_METHOD("get_*_accel"), &GSAIBlend::get_ * _accel);
ClassDB::bind_method(D_METHOD("set_*_accel", "value"), &GSAIBlend::set_ * _accel); ClassDB::bind_method(D_METHOD("set_*_accel", "value"), &GSAIBlend::set_ * _accel);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_accel", PROPERTY_HINT_RESOURCE_TYPE, "GSAITargetAcceleration"), "set_*_accel", "get_*_accel"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_accel", PROPERTY_HINT_RESOURCE_TYPE, "GSAITargetAcceleration"), "set_*_accel", "get_*_accel");
ClassDB::bind_method(D_METHOD("add_behavior", "behavior", "weight"), &GSAIBlend::add_behavior); 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", "index"), &GSAIBlend::get_behavior);
ClassDB::bind_method(D_METHOD("remove_behavior", "index"), &GSAIBlend::remove_behavior); 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_behaviour_count"), &GSAIBlend::get_behaviour_count);
ClassDB::bind_method(D_METHOD("get_accel"), &GSAIBlend::get_accel); ClassDB::bind_method(D_METHOD("get_accel"), &GSAIBlend::get_accel);
ClassDB::bind_method(D_METHOD("_calculate_steering", "blended_accel"), &GSAIBlend::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "blended_accel"), &GSAIBlend::_calculate_steering);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIBLEND_H #ifndef GSAIBLEND_H
#define GSAIBLEND_H #define GSAIBLEND_H
class GSAIBlend : public GSAISteeringBehavior { class GSAIBlend : public GSAISteeringBehavior {
GDCLASS(GSAIBlend, GSAISteeringBehavior); GDCLASS(GSAIBlend, GSAISteeringBehavior);
public: public:
Array get__behaviors(); Array get__behaviors();
void set__behaviors(const Array &val); void set__behaviors(const Array &val);
@ -42,5 +40,4 @@ class GSAIBlend : public GSAISteeringBehavior {
// none was found. // none was found.
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_cohesion.h" #include "gsai_cohesion.h"
Vector3 GSAICohesion::get__center_of_mass() { Vector3 GSAICohesion::get__center_of_mass() {
return _center_of_mass; return _center_of_mass;
} }
@ -10,8 +9,6 @@ void GSAICohesion::set__center_of_mass(const Vector3 &val) {
_center_of_mass = val; _center_of_mass = val;
} }
// Calculates an acceleration that attempts to move the agent towards the center; // Calculates an acceleration that attempts to move the agent towards the center;
// of mass of the agents in the area defined by the `GSAIProximity`.; // of mass of the agents in the area defined by the `GSAIProximity`.;
// @category - Group behaviors; // @category - Group behaviors;
@ -32,12 +29,10 @@ _center_of_mass = val;
// @tags - virtual; // @tags - virtual;
} }
bool GSAICohesion::_report_neighbor(const GSAISteeringAgent &neighbor) { bool GSAICohesion::_report_neighbor(const GSAISteeringAgent &neighbor) {
_center_of_mass += neighbor.position; _center_of_mass += neighbor.position;
return true; return true;
} }
} }
GSAICohesion::GSAICohesion() { GSAICohesion::GSAICohesion() {
@ -47,17 +42,11 @@ _center_of_mass = val;
GSAICohesion::~GSAICohesion() { GSAICohesion::~GSAICohesion() {
} }
static void GSAICohesion::_bind_methods() { static void GSAICohesion::_bind_methods() {
ClassDB::bind_method(D_METHOD("get__center_of_mass"), &GSAICohesion::get__center_of_mass); ClassDB::bind_method(D_METHOD("get__center_of_mass"), &GSAICohesion::get__center_of_mass);
ClassDB::bind_method(D_METHOD("set__center_of_mass", "value"), &GSAICohesion::set__center_of_mass); ClassDB::bind_method(D_METHOD("set__center_of_mass", "value"), &GSAICohesion::set__center_of_mass);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_center_of_mass"), "set__center_of_mass", "get__center_of_mass"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_center_of_mass"), "set__center_of_mass", "get__center_of_mass");
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAICohesion::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAICohesion::_calculate_steering);
ClassDB::bind_method(D_METHOD("_report_neighbor", "neighbor"), &GSAICohesion::_report_neighbor); ClassDB::bind_method(D_METHOD("_report_neighbor", "neighbor"), &GSAICohesion::_report_neighbor);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAICOHESION_H #ifndef GSAICOHESION_H
#define GSAICOHESION_H #define GSAICOHESION_H
class GSAICohesion : public GSAIGroupBehavior { class GSAICohesion : public GSAIGroupBehavior {
GDCLASS(GSAICohesion, GSAIGroupBehavior); GDCLASS(GSAICohesion, GSAIGroupBehavior);
public: public:
Vector3 get__center_of_mass(); Vector3 get__center_of_mass();
void set__center_of_mass(const Vector3 &val); void set__center_of_mass(const Vector3 &val);
@ -25,5 +23,4 @@ class GSAICohesion : public GSAIGroupBehavior {
Vector3 _center_of_mass = ; Vector3 _center_of_mass = ;
}; };
#endif #endif

View File

@ -1,8 +1,6 @@
#include "gsai_evade.h" #include "gsai_evade.h"
// Calculates acceleration to take an agent away from where a target agent is; // Calculates acceleration to take an agent away from where a target agent is;
// moving.; // moving.;
// @category - Individual behaviors; // @category - Individual behaviors;
@ -10,7 +8,6 @@
float GSAIEvade::_get_modified_acceleration() { float GSAIEvade::_get_modified_acceleration() {
return -agent.linear_acceleration_max; return -agent.linear_acceleration_max;
} }
} }
GSAIEvade::GSAIEvade() { GSAIEvade::GSAIEvade() {
@ -19,11 +16,6 @@
GSAIEvade::~GSAIEvade() { GSAIEvade::~GSAIEvade() {
} }
static void GSAIEvade::_bind_methods() { static void GSAIEvade::_bind_methods() {
ClassDB::bind_method(D_METHOD("_get_modified_acceleration"), &GSAIEvade::_get_modified_acceleration); ClassDB::bind_method(D_METHOD("_get_modified_acceleration"), &GSAIEvade::_get_modified_acceleration);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIEVADE_H #ifndef GSAIEVADE_H
#define GSAIEVADE_H #define GSAIEVADE_H
class GSAIEvade : public GSAIPursue { class GSAIEvade : public GSAIPursue {
GDCLASS(GSAIEvade, GSAIPursue); GDCLASS(GSAIEvade, GSAIPursue);
public: public:
float _get_modified_acceleration(); float _get_modified_acceleration();
GSAIEvade(); GSAIEvade();
@ -20,5 +18,4 @@ class GSAIEvade : public GSAIPursue {
// @category - Individual behaviors // @category - Individual behaviors
}; };
#endif #endif

View File

@ -1,8 +1,6 @@
#include "gsai_face.h" #include "gsai_face.h"
// Calculates angular acceleration to rotate a target to face its target's; // Calculates angular acceleration to rotate a target to face its target's;
// position. The behavior attemps to arrive with zero remaining angular velocity.; // position. The behavior attemps to arrive with zero remaining angular velocity.;
// @category - Individual behaviors; // @category - Individual behaviors;
@ -11,7 +9,6 @@
call("_face", acceleration, target_position); call("_face", acceleration, target_position);
} }
void GSAIFace::_face(const GSAITargetAcceleration &acceleration, const Vector3 &target_position) { void GSAIFace::_face(const GSAITargetAcceleration &acceleration, const Vector3 &target_position) {
Vector3 to_target = target_position - agent.position; Vector3 to_target = target_position - agent.position;
float distance_squared = to_target.length_squared(); float distance_squared = to_target.length_squared();
@ -20,7 +17,6 @@
acceleration.set_zero(); acceleration.set_zero();
} }
else { else {
float orientation = ; float orientation = ;
@ -28,21 +24,17 @@
orientation = GSAIUtils.vector3_to_angle(to_target); orientation = GSAIUtils.vector3_to_angle(to_target);
} }
else { else {
orientation = GSAIUtils.vector2_to_angle(GSAIUtils.to_vector2(to_target)); orientation = GSAIUtils.vector2_to_angle(GSAIUtils.to_vector2(to_target));
} }
match_orientation(acceleration, orientation); match_orientation(acceleration, orientation);
} }
} }
void GSAIFace::_calculate_steering(const GSAITargetAcceleration &acceleration) { void GSAIFace::_calculate_steering(const GSAITargetAcceleration &acceleration) {
face(acceleration, target.position); face(acceleration, target.position);
} }
} }
GSAIFace::GSAIFace() { GSAIFace::GSAIFace() {
@ -51,13 +43,8 @@
GSAIFace::~GSAIFace() { GSAIFace::~GSAIFace() {
} }
static void GSAIFace::_bind_methods() { static void GSAIFace::_bind_methods() {
ClassDB::bind_method(D_METHOD("face", "acceleration", "target_position"), &GSAIFace::face); ClassDB::bind_method(D_METHOD("face", "acceleration", "target_position"), &GSAIFace::face);
ClassDB::bind_method(D_METHOD("_face", "acceleration", "target_position"), &GSAIFace::_face); ClassDB::bind_method(D_METHOD("_face", "acceleration", "target_position"), &GSAIFace::_face);
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIFace::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIFace::_calculate_steering);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIFACE_H #ifndef GSAIFACE_H
#define GSAIFACE_H #define GSAIFACE_H
class GSAIFace : public GSAIMatchOrientation { class GSAIFace : public GSAIMatchOrientation {
GDCLASS(GSAIFace, GSAIMatchOrientation); GDCLASS(GSAIFace, GSAIMatchOrientation);
public: public:
void face(const GSAITargetAcceleration &acceleration, const Vector3 &target_position); void face(const GSAITargetAcceleration &acceleration, const Vector3 &target_position);
void _face(const GSAITargetAcceleration &acceleration, const Vector3 &target_position); void _face(const GSAITargetAcceleration &acceleration, const Vector3 &target_position);
void _calculate_steering(const GSAITargetAcceleration &acceleration); void _calculate_steering(const GSAITargetAcceleration &acceleration);
@ -22,5 +20,4 @@ class GSAIFace : public GSAIMatchOrientation {
// @category - Individual behaviors // @category - Individual behaviors
}; };
#endif #endif

View File

@ -1,8 +1,6 @@
#include "gsai_flee.h" #include "gsai_flee.h"
// Calculates acceleration to take an agent directly away from a target agent.; // Calculates acceleration to take an agent directly away from a target agent.;
// @category - Individual behaviors; // @category - Individual behaviors;
@ -10,7 +8,6 @@
acceleration.linear = ((agent.position - target.position).normalized() * agent.linear_acceleration_max); acceleration.linear = ((agent.position - target.position).normalized() * agent.linear_acceleration_max);
acceleration.angular = 0; acceleration.angular = 0;
} }
} }
GSAIFlee::GSAIFlee() { GSAIFlee::GSAIFlee() {
@ -19,11 +16,6 @@
GSAIFlee::~GSAIFlee() { GSAIFlee::~GSAIFlee() {
} }
static void GSAIFlee::_bind_methods() { static void GSAIFlee::_bind_methods() {
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIFlee::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIFlee::_calculate_steering);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIFLEE_H #ifndef GSAIFLEE_H
#define GSAIFLEE_H #define GSAIFLEE_H
class GSAIFlee : public GSAISeek { class GSAIFlee : public GSAISeek {
GDCLASS(GSAIFlee, GSAISeek); GDCLASS(GSAIFlee, GSAISeek);
public: public:
void _calculate_steering(const GSAITargetAcceleration &acceleration); void _calculate_steering(const GSAITargetAcceleration &acceleration);
GSAIFlee(); GSAIFlee();
@ -19,5 +17,4 @@ class GSAIFlee : public GSAISeek {
// @category - Individual behaviors // @category - Individual behaviors
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_follow_path.h" #include "gsai_follow_path.h"
GSAIPath GSAIFollowPath::get_ *path() { GSAIPath GSAIFollowPath::get_ *path() {
return *path; return *path;
} }
@ -10,7 +9,6 @@ void GSAIFollowPath::set_*path(const GSAIPath &val) {
*path = val; *path = val;
} }
float GSAIFollowPath::get_path_offset() const { float GSAIFollowPath::get_path_offset() const {
return path_offset; return path_offset;
} }
@ -19,7 +17,6 @@ void GSAIFollowPath::set_path_offset(const float val) {
path_offset = val; path_offset = val;
} }
bool GSAIFollowPath::get_is_arrive_enabled() const { bool GSAIFollowPath::get_is_arrive_enabled() const {
return is_arrive_enabled; return is_arrive_enabled;
} }
@ -28,7 +25,6 @@ void GSAIFollowPath::set_is_arrive_enabled(const bool val) {
is_arrive_enabled = val; is_arrive_enabled = val;
} }
float GSAIFollowPath::get_prediction_time() const { float GSAIFollowPath::get_prediction_time() const {
return prediction_time; return prediction_time;
} }
@ -37,8 +33,6 @@ void GSAIFollowPath::set_prediction_time(const float val) {
prediction_time = val; prediction_time = val;
} }
// Produces a linear acceleration that moves the agent along the specified path.; // Produces a linear acceleration that moves the agent along the specified path.;
// @category - Individual behaviors; // @category - Individual behaviors;
// The path to follow and travel along.; // The path to follow and travel along.;
@ -58,7 +52,6 @@ prediction_time = val;
location = agent.position; location = agent.position;
} }
else { else {
location = agent.position + (agent.linear_velocity * prediction_time); location = agent.position + (agent.linear_velocity * prediction_time);
} }
@ -67,19 +60,15 @@ prediction_time = val;
float target_distance = distance + path_offset; float target_distance = distance + path_offset;
if (prediction_time > 0 && path.is_open) { if (prediction_time > 0 && path.is_open) {
if (target_distance < path.calculate_distance(agent.position)) { if (target_distance < path.calculate_distance(agent.position)) {
target_distance = path.length; target_distance = path.length;
} }
} }
Vector3 target_position = path.calculate_target_position(target_distance); Vector3 target_position = path.calculate_target_position(target_distance);
if (is_arrive_enabled && path.is_open) { if (is_arrive_enabled && path.is_open) {
if (path_offset >= 0) { if (path_offset >= 0) {
if (target_distance > path.length - deceleration_radius) { if (target_distance > path.length - deceleration_radius) {
arrive(acceleration, target_position); arrive(acceleration, target_position);
return; return;
@ -87,23 +76,18 @@ prediction_time = val;
} }
else { else {
if (target_distance < deceleration_radius) { if (target_distance < deceleration_radius) {
arrive(acceleration, target_position); arrive(acceleration, target_position);
return; return;
} }
} }
} }
acceleration.linear = (target_position - agent.position).normalized(); acceleration.linear = (target_position - agent.position).normalized();
acceleration.linear *= agent.linear_acceleration_max; acceleration.linear *= agent.linear_acceleration_max;
acceleration.angular = 0; acceleration.angular = 0;
} }
} }
GSAIFollowPath::GSAIFollowPath() { GSAIFollowPath::GSAIFollowPath() {
@ -116,31 +100,22 @@ prediction_time = val;
GSAIFollowPath::~GSAIFollowPath() { GSAIFollowPath::~GSAIFollowPath() {
} }
static void GSAIFollowPath::_bind_methods() { static void GSAIFollowPath::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_*path"), &GSAIFollowPath::get_ * path); ClassDB::bind_method(D_METHOD("get_*path"), &GSAIFollowPath::get_ * path);
ClassDB::bind_method(D_METHOD("set_*path", "value"), &GSAIFollowPath::set_ * path); ClassDB::bind_method(D_METHOD("set_*path", "value"), &GSAIFollowPath::set_ * path);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*path", PROPERTY_HINT_RESOURCE_TYPE, "GSAIPath"), "set_*path", "get_*path"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*path", PROPERTY_HINT_RESOURCE_TYPE, "GSAIPath"), "set_*path", "get_*path");
ClassDB::bind_method(D_METHOD("get_path_offset"), &GSAIFollowPath::get_path_offset); ClassDB::bind_method(D_METHOD("get_path_offset"), &GSAIFollowPath::get_path_offset);
ClassDB::bind_method(D_METHOD("set_path_offset", "value"), &GSAIFollowPath::set_path_offset); ClassDB::bind_method(D_METHOD("set_path_offset", "value"), &GSAIFollowPath::set_path_offset);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "path_offset"), "set_path_offset", "get_path_offset"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "path_offset"), "set_path_offset", "get_path_offset");
ClassDB::bind_method(D_METHOD("get_is_arrive_enabled"), &GSAIFollowPath::get_is_arrive_enabled); ClassDB::bind_method(D_METHOD("get_is_arrive_enabled"), &GSAIFollowPath::get_is_arrive_enabled);
ClassDB::bind_method(D_METHOD("set_is_arrive_enabled", "value"), &GSAIFollowPath::set_is_arrive_enabled); ClassDB::bind_method(D_METHOD("set_is_arrive_enabled", "value"), &GSAIFollowPath::set_is_arrive_enabled);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_arrive_enabled"), "set_is_arrive_enabled", "get_is_arrive_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_arrive_enabled"), "set_is_arrive_enabled", "get_is_arrive_enabled");
ClassDB::bind_method(D_METHOD("get_prediction_time"), &GSAIFollowPath::get_prediction_time); ClassDB::bind_method(D_METHOD("get_prediction_time"), &GSAIFollowPath::get_prediction_time);
ClassDB::bind_method(D_METHOD("set_prediction_time", "value"), &GSAIFollowPath::set_prediction_time); ClassDB::bind_method(D_METHOD("set_prediction_time", "value"), &GSAIFollowPath::set_prediction_time);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "prediction_time"), "set_prediction_time", "get_prediction_time"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "prediction_time"), "set_prediction_time", "get_prediction_time");
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIFollowPath::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIFollowPath::_calculate_steering);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIFOLLOWPATH_H #ifndef GSAIFOLLOWPATH_H
#define GSAIFOLLOWPATH_H #define GSAIFOLLOWPATH_H
class GSAIFollowPath : public GSAIArrive { class GSAIFollowPath : public GSAIArrive {
GDCLASS(GSAIFollowPath, GSAIArrive); GDCLASS(GSAIFollowPath, GSAIArrive);
public: public:
GSAIPath get_ *path(); GSAIPath get_ *path();
void set_ *path(const GSAIPath &val); void set_ *path(const GSAIPath &val);
@ -40,5 +38,4 @@ class GSAIFollowPath : public GSAIArrive {
float prediction_time = 0.0; float prediction_time = 0.0;
}; };
#endif #endif

View File

@ -1,19 +1,15 @@
#include "gsai_look_where_you_go.h" #include "gsai_look_where_you_go.h"
// Calculates an angular acceleration to match an agent's orientation to its; // Calculates an angular acceleration to match an agent's orientation to its;
// direction of travel.; // direction of travel.;
// @category - Individual behaviors; // @category - Individual behaviors;
void GSAILookWhereYouGo::_calculate_steering(const GSAITargetAcceleration &accel) { void GSAILookWhereYouGo::_calculate_steering(const GSAITargetAcceleration &accel) {
if (agent.linear_velocity.length_squared() < agent.zero_linear_speed_threshold) { if (agent.linear_velocity.length_squared() < agent.zero_linear_speed_threshold) {
accel.set_zero(); accel.set_zero();
} }
else { else {
float orientation = ; float orientation = ;
@ -21,16 +17,13 @@
orientation = GSAIUtils.vector3_to_angle(agent.linear_velocity); orientation = GSAIUtils.vector3_to_angle(agent.linear_velocity);
} }
else { else {
orientation = GSAIUtils.vector2_to_angle(GSAIUtils.to_vector2(agent.linear_velocity)); orientation = GSAIUtils.vector2_to_angle(GSAIUtils.to_vector2(agent.linear_velocity));
} }
match_orientation(accel, orientation); match_orientation(accel, orientation);
} }
} }
} }
GSAILookWhereYouGo::GSAILookWhereYouGo() { GSAILookWhereYouGo::GSAILookWhereYouGo() {
@ -39,11 +32,6 @@
GSAILookWhereYouGo::~GSAILookWhereYouGo() { GSAILookWhereYouGo::~GSAILookWhereYouGo() {
} }
static void GSAILookWhereYouGo::_bind_methods() { static void GSAILookWhereYouGo::_bind_methods() {
ClassDB::bind_method(D_METHOD("_calculate_steering", "accel"), &GSAILookWhereYouGo::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "accel"), &GSAILookWhereYouGo::_calculate_steering);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAILOOKWHEREYOUGO_H #ifndef GSAILOOKWHEREYOUGO_H
#define GSAILOOKWHEREYOUGO_H #define GSAILOOKWHEREYOUGO_H
class GSAILookWhereYouGo : public GSAIMatchOrientation { class GSAILookWhereYouGo : public GSAIMatchOrientation {
GDCLASS(GSAILookWhereYouGo, GSAIMatchOrientation); GDCLASS(GSAILookWhereYouGo, GSAIMatchOrientation);
public: public:
void _calculate_steering(const GSAITargetAcceleration &accel); void _calculate_steering(const GSAITargetAcceleration &accel);
GSAILookWhereYouGo(); GSAILookWhereYouGo();
@ -20,5 +18,4 @@ class GSAILookWhereYouGo : public GSAIMatchOrientation {
// @category - Individual behaviors // @category - Individual behaviors
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_match_orientation.h" #include "gsai_match_orientation.h"
GSAIAgentLocation GSAIMatchOrientation::get_ *target() { GSAIAgentLocation GSAIMatchOrientation::get_ *target() {
return *target; return *target;
} }
@ -10,7 +9,6 @@ void GSAIMatchOrientation::set_*target(const GSAIAgentLocation &val) {
*target = val; *target = val;
} }
float GSAIMatchOrientation::get_alignment_tolerance() const { float GSAIMatchOrientation::get_alignment_tolerance() const {
return alignment_tolerance; return alignment_tolerance;
} }
@ -19,7 +17,6 @@ void GSAIMatchOrientation::set_alignment_tolerance(const float val) {
alignment_tolerance = val; alignment_tolerance = val;
} }
float GSAIMatchOrientation::get_deceleration_radius() const { float GSAIMatchOrientation::get_deceleration_radius() const {
return deceleration_radius; return deceleration_radius;
} }
@ -28,7 +25,6 @@ void GSAIMatchOrientation::set_deceleration_radius(const float val) {
deceleration_radius = val; deceleration_radius = val;
} }
float GSAIMatchOrientation::get_time_to_reach() const { float GSAIMatchOrientation::get_time_to_reach() const {
return time_to_reach; return time_to_reach;
} }
@ -37,7 +33,6 @@ void GSAIMatchOrientation::set_time_to_reach(const float val) {
time_to_reach = val; time_to_reach = val;
} }
bool GSAIMatchOrientation::get_use_z() const { bool GSAIMatchOrientation::get_use_z() const {
return use_z; return use_z;
} }
@ -46,8 +41,6 @@ void GSAIMatchOrientation::set_use_z(const bool val) {
use_z = val; use_z = val;
} }
// Calculates an angular acceleration to match an agent's orientation to that of; // 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; // its target. Attempts to make the agent arrive with zero remaining angular;
// velocity.; // velocity.;
@ -69,7 +62,6 @@ use_z = val;
call("_match_orientation", acceleration, desired_orientation); call("_match_orientation", acceleration, desired_orientation);
} }
void GSAIMatchOrientation::_match_orientation(const GSAITargetAcceleration &acceleration, const float desired_orientation) { void GSAIMatchOrientation::_match_orientation(const GSAITargetAcceleration &acceleration, const float desired_orientation) {
float rotation = wrapf(desired_orientation - agent.orientation, -PI, PI); float rotation = wrapf(desired_orientation - agent.orientation, -PI, PI);
float rotation_size = abs(rotation); float rotation_size = abs(rotation);
@ -78,7 +70,6 @@ use_z = val;
acceleration.set_zero(); acceleration.set_zero();
} }
else { else {
float desired_rotation = agent.angular_speed_max; float desired_rotation = agent.angular_speed_max;
@ -93,17 +84,14 @@ use_z = val;
if (limited_acceleration > agent.angular_acceleration_max) { if (limited_acceleration > agent.angular_acceleration_max) {
acceleration.angular *= (agent.angular_acceleration_max / limited_acceleration); acceleration.angular *= (agent.angular_acceleration_max / limited_acceleration);
} }
} }
acceleration.linear = Vector3.ZERO; acceleration.linear = Vector3.ZERO;
} }
void GSAIMatchOrientation::_calculate_steering(const GSAITargetAcceleration &acceleration) { void GSAIMatchOrientation::_calculate_steering(const GSAITargetAcceleration &acceleration) {
match_orientation(acceleration, target.orientation); match_orientation(acceleration, target.orientation);
} }
} }
GSAIMatchOrientation::GSAIMatchOrientation() { GSAIMatchOrientation::GSAIMatchOrientation() {
@ -117,38 +105,28 @@ use_z = val;
GSAIMatchOrientation::~GSAIMatchOrientation() { GSAIMatchOrientation::~GSAIMatchOrientation() {
} }
static void GSAIMatchOrientation::_bind_methods() { static void GSAIMatchOrientation::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_*target"), &GSAIMatchOrientation::get_ * target); ClassDB::bind_method(D_METHOD("get_*target"), &GSAIMatchOrientation::get_ * target);
ClassDB::bind_method(D_METHOD("set_*target", "value"), &GSAIMatchOrientation::set_ * target); ClassDB::bind_method(D_METHOD("set_*target", "value"), &GSAIMatchOrientation::set_ * target);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*target", PROPERTY_HINT_RESOURCE_TYPE, "GSAIAgentLocation"), "set_*target", "get_*target"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*target", PROPERTY_HINT_RESOURCE_TYPE, "GSAIAgentLocation"), "set_*target", "get_*target");
ClassDB::bind_method(D_METHOD("get_alignment_tolerance"), &GSAIMatchOrientation::get_alignment_tolerance); ClassDB::bind_method(D_METHOD("get_alignment_tolerance"), &GSAIMatchOrientation::get_alignment_tolerance);
ClassDB::bind_method(D_METHOD("set_alignment_tolerance", "value"), &GSAIMatchOrientation::set_alignment_tolerance); ClassDB::bind_method(D_METHOD("set_alignment_tolerance", "value"), &GSAIMatchOrientation::set_alignment_tolerance);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "alignment_tolerance"), "set_alignment_tolerance", "get_alignment_tolerance"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "alignment_tolerance"), "set_alignment_tolerance", "get_alignment_tolerance");
ClassDB::bind_method(D_METHOD("get_deceleration_radius"), &GSAIMatchOrientation::get_deceleration_radius); ClassDB::bind_method(D_METHOD("get_deceleration_radius"), &GSAIMatchOrientation::get_deceleration_radius);
ClassDB::bind_method(D_METHOD("set_deceleration_radius", "value"), &GSAIMatchOrientation::set_deceleration_radius); ClassDB::bind_method(D_METHOD("set_deceleration_radius", "value"), &GSAIMatchOrientation::set_deceleration_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "deceleration_radius"), "set_deceleration_radius", "get_deceleration_radius"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "deceleration_radius"), "set_deceleration_radius", "get_deceleration_radius");
ClassDB::bind_method(D_METHOD("get_time_to_reach"), &GSAIMatchOrientation::get_time_to_reach); ClassDB::bind_method(D_METHOD("get_time_to_reach"), &GSAIMatchOrientation::get_time_to_reach);
ClassDB::bind_method(D_METHOD("set_time_to_reach", "value"), &GSAIMatchOrientation::set_time_to_reach); ClassDB::bind_method(D_METHOD("set_time_to_reach", "value"), &GSAIMatchOrientation::set_time_to_reach);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_to_reach"), "set_time_to_reach", "get_time_to_reach"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_to_reach"), "set_time_to_reach", "get_time_to_reach");
ClassDB::bind_method(D_METHOD("get_use_z"), &GSAIMatchOrientation::get_use_z); ClassDB::bind_method(D_METHOD("get_use_z"), &GSAIMatchOrientation::get_use_z);
ClassDB::bind_method(D_METHOD("set_use_z", "value"), &GSAIMatchOrientation::set_use_z); ClassDB::bind_method(D_METHOD("set_use_z", "value"), &GSAIMatchOrientation::set_use_z);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_z"), "set_use_z", "get_use_z"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_z"), "set_use_z", "get_use_z");
ClassDB::bind_method(D_METHOD("match_orientation", "acceleration", "desired_orientation"), &GSAIMatchOrientation::match_orientation); ClassDB::bind_method(D_METHOD("match_orientation", "acceleration", "desired_orientation"), &GSAIMatchOrientation::match_orientation);
ClassDB::bind_method(D_METHOD("_match_orientation", "acceleration", "desired_orientation"), &GSAIMatchOrientation::_match_orientation); ClassDB::bind_method(D_METHOD("_match_orientation", "acceleration", "desired_orientation"), &GSAIMatchOrientation::_match_orientation);
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIMatchOrientation::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIMatchOrientation::_calculate_steering);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIMATCHORIENTATION_H #ifndef GSAIMATCHORIENTATION_H
#define GSAIMATCHORIENTATION_H #define GSAIMATCHORIENTATION_H
class GSAIMatchOrientation : public GSAISteeringBehavior { class GSAIMatchOrientation : public GSAISteeringBehavior {
GDCLASS(GSAIMatchOrientation, GSAISteeringBehavior); GDCLASS(GSAIMatchOrientation, GSAISteeringBehavior);
public: public:
GSAIAgentLocation get_ *target(); GSAIAgentLocation get_ *target();
void set_ *target(const GSAIAgentLocation &val); void set_ *target(const GSAIAgentLocation &val);
@ -50,5 +48,4 @@ class GSAIMatchOrientation : public GSAISteeringBehavior {
bool use_z = false; bool use_z = false;
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_priority.h" #include "gsai_priority.h"
float GSAIPriority::get_zero_threshold() const { float GSAIPriority::get_zero_threshold() const {
return zero_threshold; return zero_threshold;
} }
@ -10,7 +9,6 @@ void GSAIPriority::set_zero_threshold(const float val) {
zero_threshold = val; zero_threshold = val;
} }
int GSAIPriority::get__last_selected_index() const { int GSAIPriority::get__last_selected_index() const {
return _last_selected_index; return _last_selected_index;
} }
@ -19,7 +17,6 @@ void GSAIPriority::set__last_selected_index(const int val) {
_last_selected_index = val; _last_selected_index = val;
} }
Array GSAIPriority::get__behaviors() { Array GSAIPriority::get__behaviors() {
return _behaviors; return _behaviors;
} }
@ -28,8 +25,6 @@ void GSAIPriority::set__behaviors(const Array &val) {
_behaviors = val; _behaviors = val;
} }
// Container for multiple behaviors that returns the result of the first child; // Container for multiple behaviors that returns the result of the first child;
// behavior with non-zero acceleration.; // behavior with non-zero acceleration.;
// @category - Combination behaviors; // @category - Combination behaviors;
@ -49,7 +44,6 @@ _behaviors = val;
// `null` if no behavior was found.; // `null` if no behavior was found.;
GSAISteeringBehavior GSAIPriority::get_behavior(const int index) { GSAISteeringBehavior GSAIPriority::get_behavior(const int index) {
if (_behaviors.size() > index) { if (_behaviors.size() > index) {
return _behaviors[index]; return _behaviors[index];
} }
@ -58,9 +52,7 @@ _behaviors = val;
return null; return null;
} }
void GSAIPriority::remove_behavior(const int index) { void GSAIPriority::remove_behavior(const int index) {
if (_behaviors.size() > index) { if (_behaviors.size() > index) {
_behaviors.remove(index); _behaviors.remove(index);
return; return;
@ -70,19 +62,16 @@ _behaviors = val;
return; return;
} }
int GSAIPriority::get_behaviour_count() { int GSAIPriority::get_behaviour_count() {
return _behaviors.size(); return _behaviors.size();
} }
void GSAIPriority::_calculate_steering(const GSAITargetAcceleration &accel) { void GSAIPriority::_calculate_steering(const GSAITargetAcceleration &accel) {
float threshold_squared = zero_threshold * zero_threshold; float threshold_squared = zero_threshold * zero_threshold;
_last_selected_index = -1; _last_selected_index = -1;
int size = _behaviors.size(); int size = _behaviors.size();
if (size > 0) { if (size > 0) {
for (int i = 0; i < size; ++i) { //i in range(size) for (int i = 0; i < size; ++i) { //i in range(size)
_last_selected_index = i; _last_selected_index = i;
GSAISteeringBehavior *behavior = _behaviors[i]; GSAISteeringBehavior *behavior = _behaviors[i];
@ -91,18 +80,14 @@ _behaviors = val;
if (accel.get_magnitude_squared() > threshold_squared) { if (accel.get_magnitude_squared() > threshold_squared) {
break; break;
} }
} }
} }
else { else {
accel.set_zero(); accel.set_zero();
} }
} }
} }
GSAIPriority::GSAIPriority() { GSAIPriority::GSAIPriority() {
@ -114,30 +99,22 @@ _behaviors = val;
GSAIPriority::~GSAIPriority() { GSAIPriority::~GSAIPriority() {
} }
static void GSAIPriority::_bind_methods() { static void GSAIPriority::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_zero_threshold"), &GSAIPriority::get_zero_threshold); ClassDB::bind_method(D_METHOD("get_zero_threshold"), &GSAIPriority::get_zero_threshold);
ClassDB::bind_method(D_METHOD("set_zero_threshold", "value"), &GSAIPriority::set_zero_threshold); ClassDB::bind_method(D_METHOD("set_zero_threshold", "value"), &GSAIPriority::set_zero_threshold);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "zero_threshold"), "set_zero_threshold", "get_zero_threshold"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "zero_threshold"), "set_zero_threshold", "get_zero_threshold");
ClassDB::bind_method(D_METHOD("get__last_selected_index"), &GSAIPriority::get__last_selected_index); ClassDB::bind_method(D_METHOD("get__last_selected_index"), &GSAIPriority::get__last_selected_index);
ClassDB::bind_method(D_METHOD("set__last_selected_index", "value"), &GSAIPriority::set__last_selected_index); ClassDB::bind_method(D_METHOD("set__last_selected_index", "value"), &GSAIPriority::set__last_selected_index);
ADD_PROPERTY(PropertyInfo(Variant::INT, "_last_selected_index"), "set__last_selected_index", "get__last_selected_index"); ADD_PROPERTY(PropertyInfo(Variant::INT, "_last_selected_index"), "set__last_selected_index", "get__last_selected_index");
ClassDB::bind_method(D_METHOD("get__behaviors"), &GSAIPriority::get__behaviors); ClassDB::bind_method(D_METHOD("get__behaviors"), &GSAIPriority::get__behaviors);
ClassDB::bind_method(D_METHOD("set__behaviors", "value"), &GSAIPriority::set__behaviors); ClassDB::bind_method(D_METHOD("set__behaviors", "value"), &GSAIPriority::set__behaviors);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_behaviors"), "set__behaviors", "get__behaviors"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_behaviors"), "set__behaviors", "get__behaviors");
ClassDB::bind_method(D_METHOD("add_behavior", "behavior"), &GSAIPriority::add_behavior); ClassDB::bind_method(D_METHOD("add_behavior", "behavior"), &GSAIPriority::add_behavior);
ClassDB::bind_method(D_METHOD("get_behavior", "index"), &GSAIPriority::get_behavior); ClassDB::bind_method(D_METHOD("get_behavior", "index"), &GSAIPriority::get_behavior);
ClassDB::bind_method(D_METHOD("remove_behavior", "index"), &GSAIPriority::remove_behavior); ClassDB::bind_method(D_METHOD("remove_behavior", "index"), &GSAIPriority::remove_behavior);
ClassDB::bind_method(D_METHOD("get_behaviour_count"), &GSAIPriority::get_behaviour_count); ClassDB::bind_method(D_METHOD("get_behaviour_count"), &GSAIPriority::get_behaviour_count);
ClassDB::bind_method(D_METHOD("_calculate_steering", "accel"), &GSAIPriority::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "accel"), &GSAIPriority::_calculate_steering);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIPRIORITY_H #ifndef GSAIPRIORITY_H
#define GSAIPRIORITY_H #define GSAIPRIORITY_H
class GSAIPriority : public GSAISteeringBehavior { class GSAIPriority : public GSAISteeringBehavior {
GDCLASS(GSAIPriority, GSAISteeringBehavior); GDCLASS(GSAIPriority, GSAISteeringBehavior);
public: public:
float get_zero_threshold() const; float get_zero_threshold() const;
void set_zero_threshold(const float val); void set_zero_threshold(const float val);
@ -42,5 +40,4 @@ class GSAIPriority : public GSAISteeringBehavior {
// `null` if no behavior was found. // `null` if no behavior was found.
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_pursue.h" #include "gsai_pursue.h"
GSAISteeringAgent GSAIPursue::get_ *target() { GSAISteeringAgent GSAIPursue::get_ *target() {
return *target; return *target;
} }
@ -10,7 +9,6 @@ void GSAIPursue::set_*target(const GSAISteeringAgent &val) {
*target = val; *target = val;
} }
float GSAIPursue::get_predict_time_max() const { float GSAIPursue::get_predict_time_max() const {
return predict_time_max; return predict_time_max;
} }
@ -19,8 +17,6 @@ void GSAIPursue::set_predict_time_max(const float val) {
predict_time_max = val; predict_time_max = val;
} }
// Calculates an acceleration to make an agent intercept another based on the; // Calculates an acceleration to make an agent intercept another based on the;
// target agent's movement.; // target agent's movement.;
// @category - Individual behaviors; // @category - Individual behaviors;
@ -42,7 +38,6 @@ predict_time_max = val;
if (predict_time_squared < predict_time_max * predict_time_max) { if (predict_time_squared < predict_time_max * predict_time_max) {
predict_time = sqrt(predict_time_squared); predict_time = sqrt(predict_time_squared);
} }
} }
acceleration.linear = ((target_position + (target.linear_velocity * predict_time)) - agent.position).normalized(); acceleration.linear = ((target_position + (target.linear_velocity * predict_time)) - agent.position).normalized();
@ -50,16 +45,13 @@ predict_time_max = val;
acceleration.angular = 0; acceleration.angular = 0;
} }
float GSAIPursue::get_modified_acceleration() { float GSAIPursue::get_modified_acceleration() {
return call("_get_modified_acceleration"); return call("_get_modified_acceleration");
} }
float GSAIPursue::_get_modified_acceleration() { float GSAIPursue::_get_modified_acceleration() {
return agent.linear_acceleration_max; return agent.linear_acceleration_max;
} }
} }
GSAIPursue::GSAIPursue() { GSAIPursue::GSAIPursue() {
@ -70,23 +62,16 @@ predict_time_max = val;
GSAIPursue::~GSAIPursue() { GSAIPursue::~GSAIPursue() {
} }
static void GSAIPursue::_bind_methods() { static void GSAIPursue::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_*target"), &GSAIPursue::get_ * target); ClassDB::bind_method(D_METHOD("get_*target"), &GSAIPursue::get_ * target);
ClassDB::bind_method(D_METHOD("set_*target", "value"), &GSAIPursue::set_ * target); ClassDB::bind_method(D_METHOD("set_*target", "value"), &GSAIPursue::set_ * target);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*target", PROPERTY_HINT_RESOURCE_TYPE, "GSAISteeringAgent"), "set_*target", "get_*target"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*target", PROPERTY_HINT_RESOURCE_TYPE, "GSAISteeringAgent"), "set_*target", "get_*target");
ClassDB::bind_method(D_METHOD("get_predict_time_max"), &GSAIPursue::get_predict_time_max); ClassDB::bind_method(D_METHOD("get_predict_time_max"), &GSAIPursue::get_predict_time_max);
ClassDB::bind_method(D_METHOD("set_predict_time_max", "value"), &GSAIPursue::set_predict_time_max); ClassDB::bind_method(D_METHOD("set_predict_time_max", "value"), &GSAIPursue::set_predict_time_max);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "predict_time_max"), "set_predict_time_max", "get_predict_time_max"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "predict_time_max"), "set_predict_time_max", "get_predict_time_max");
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIPursue::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIPursue::_calculate_steering);
ClassDB::bind_method(D_METHOD("get_modified_acceleration"), &GSAIPursue::get_modified_acceleration); ClassDB::bind_method(D_METHOD("get_modified_acceleration"), &GSAIPursue::get_modified_acceleration);
ClassDB::bind_method(D_METHOD("_get_modified_acceleration"), &GSAIPursue::_get_modified_acceleration); ClassDB::bind_method(D_METHOD("_get_modified_acceleration"), &GSAIPursue::_get_modified_acceleration);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIPURSUE_H #ifndef GSAIPURSUE_H
#define GSAIPURSUE_H #define GSAIPURSUE_H
class GSAIPursue : public GSAISteeringBehavior { class GSAIPursue : public GSAISteeringBehavior {
GDCLASS(GSAIPursue, GSAISteeringBehavior); GDCLASS(GSAIPursue, GSAISteeringBehavior);
public: public:
GSAISteeringAgent get_ *target(); GSAISteeringAgent get_ *target();
void set_ *target(const GSAISteeringAgent &val); void set_ *target(const GSAISteeringAgent &val);
@ -33,5 +31,4 @@ class GSAIPursue : public GSAISteeringBehavior {
float predict_time_max = 1.0; float predict_time_max = 1.0;
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_seek.h" #include "gsai_seek.h"
GSAIAgentLocation GSAISeek::get_ *target() { GSAIAgentLocation GSAISeek::get_ *target() {
return *target; return *target;
} }
@ -10,8 +9,6 @@ void GSAISeek::set_*target(const GSAIAgentLocation &val) {
*target = val; *target = val;
} }
// Calculates an acceleration to take an agent to a target agent's position; // Calculates an acceleration to take an agent to a target agent's position;
// directly.; // directly.;
// @category - Individual behaviors; // @category - Individual behaviors;
@ -22,7 +19,6 @@ void GSAISeek::set_*target(const GSAIAgentLocation &val) {
acceleration.linear = ((target.position - agent.position).normalized() * agent.linear_acceleration_max); acceleration.linear = ((target.position - agent.position).normalized() * agent.linear_acceleration_max);
acceleration.angular = 0; acceleration.angular = 0;
} }
} }
GSAISeek::GSAISeek() { GSAISeek::GSAISeek() {
@ -32,16 +28,10 @@ void GSAISeek::set_*target(const GSAIAgentLocation &val) {
GSAISeek::~GSAISeek() { GSAISeek::~GSAISeek() {
} }
static void GSAISeek::_bind_methods() { static void GSAISeek::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_*target"), &GSAISeek::get_ * target); ClassDB::bind_method(D_METHOD("get_*target"), &GSAISeek::get_ * target);
ClassDB::bind_method(D_METHOD("set_*target", "value"), &GSAISeek::set_ * target); ClassDB::bind_method(D_METHOD("set_*target", "value"), &GSAISeek::set_ * target);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*target", PROPERTY_HINT_RESOURCE_TYPE, "GSAIAgentLocation"), "set_*target", "get_*target"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*target", PROPERTY_HINT_RESOURCE_TYPE, "GSAIAgentLocation"), "set_*target", "get_*target");
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAISeek::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAISeek::_calculate_steering);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAISEEK_H #ifndef GSAISEEK_H
#define GSAISEEK_H #define GSAISEEK_H
class GSAISeek : public GSAISteeringBehavior { class GSAISeek : public GSAISteeringBehavior {
GDCLASS(GSAISeek, GSAISteeringBehavior); GDCLASS(GSAISeek, GSAISteeringBehavior);
public: public:
GSAIAgentLocation get_ *target(); GSAIAgentLocation get_ *target();
void set_ *target(const GSAIAgentLocation &val); void set_ *target(const GSAIAgentLocation &val);
@ -25,5 +23,4 @@ class GSAISeek : public GSAISteeringBehavior {
GSAIAgentLocation *target; GSAIAgentLocation *target;
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_separation.h" #include "gsai_separation.h"
float GSAISeparation::get_decay_coefficient() const { float GSAISeparation::get_decay_coefficient() const {
return decay_coefficient; return decay_coefficient;
} }
@ -10,7 +9,6 @@ void GSAISeparation::set_decay_coefficient(const float val) {
decay_coefficient = val; decay_coefficient = val;
} }
GSAITargetAcceleration GSAISeparation::get_ *acceleration() { GSAITargetAcceleration GSAISeparation::get_ *acceleration() {
return *acceleration; return *acceleration;
} }
@ -19,8 +17,6 @@ void GSAISeparation::set_*acceleration(const GSAITargetAcceleration &val) {
*acceleration = val; *acceleration = val;
} }
// Calculates an acceleration that repels the agent from its neighbors in the; // Calculates an acceleration that repels the agent from its neighbors in the;
// given `GSAIProximity`.; // given `GSAIProximity`.;
//; //;
@ -56,7 +52,6 @@ void GSAISeparation::set_*acceleration(const GSAITargetAcceleration &val) {
acceleration.linear += to_agent * (strength / sqrt(distance_squared)); acceleration.linear += to_agent * (strength / sqrt(distance_squared));
return true; return true;
} }
} }
GSAISeparation::GSAISeparation() { GSAISeparation::GSAISeparation() {
@ -67,22 +62,15 @@ void GSAISeparation::set_*acceleration(const GSAITargetAcceleration &val) {
GSAISeparation::~GSAISeparation() { GSAISeparation::~GSAISeparation() {
} }
static void GSAISeparation::_bind_methods() { static void GSAISeparation::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_decay_coefficient"), &GSAISeparation::get_decay_coefficient); ClassDB::bind_method(D_METHOD("get_decay_coefficient"), &GSAISeparation::get_decay_coefficient);
ClassDB::bind_method(D_METHOD("set_decay_coefficient", "value"), &GSAISeparation::set_decay_coefficient); ClassDB::bind_method(D_METHOD("set_decay_coefficient", "value"), &GSAISeparation::set_decay_coefficient);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "decay_coefficient"), "set_decay_coefficient", "get_decay_coefficient"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "decay_coefficient"), "set_decay_coefficient", "get_decay_coefficient");
ClassDB::bind_method(D_METHOD("get_*acceleration"), &GSAISeparation::get_ * acceleration); ClassDB::bind_method(D_METHOD("get_*acceleration"), &GSAISeparation::get_ * acceleration);
ClassDB::bind_method(D_METHOD("set_*acceleration", "value"), &GSAISeparation::set_ * acceleration); ClassDB::bind_method(D_METHOD("set_*acceleration", "value"), &GSAISeparation::set_ * acceleration);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*acceleration", PROPERTY_HINT_RESOURCE_TYPE, "GSAITargetAcceleration"), "set_*acceleration", "get_*acceleration"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*acceleration", PROPERTY_HINT_RESOURCE_TYPE, "GSAITargetAcceleration"), "set_*acceleration", "get_*acceleration");
ClassDB::bind_method(D_METHOD("_calculate_steering", "_acceleration"), &GSAISeparation::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "_acceleration"), &GSAISeparation::_calculate_steering);
ClassDB::bind_method(D_METHOD("_report_neighbor", "neighbor"), &GSAISeparation::_report_neighbor); ClassDB::bind_method(D_METHOD("_report_neighbor", "neighbor"), &GSAISeparation::_report_neighbor);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAISEPARATION_H #ifndef GSAISEPARATION_H
#define GSAISEPARATION_H #define GSAISEPARATION_H
class GSAISeparation : public GSAIGroupBehavior { class GSAISeparation : public GSAIGroupBehavior {
GDCLASS(GSAISeparation, GSAIGroupBehavior); GDCLASS(GSAISeparation, GSAIGroupBehavior);
public: public:
float get_decay_coefficient() const; float get_decay_coefficient() const;
void set_decay_coefficient(const float val); void set_decay_coefficient(const float val);
@ -37,5 +35,4 @@ class GSAISeparation : public GSAIGroupBehavior {
// @tags - virtual // @tags - virtual
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_agent_location.h" #include "gsai_agent_location.h"
Vector3 GSAIAgentLocation::get_position() { Vector3 GSAIAgentLocation::get_position() {
return position; return position;
} }
@ -10,7 +9,6 @@ void GSAIAgentLocation::set_position(const Vector3 &val) {
position = val; position = val;
} }
float GSAIAgentLocation::get_orientation() const { float GSAIAgentLocation::get_orientation() const {
return orientation; return orientation;
} }
@ -19,8 +17,6 @@ void GSAIAgentLocation::set_orientation(const float val) {
orientation = val; orientation = val;
} }
// Represents an agent with only a location and an orientation.; // Represents an agent with only a location and an orientation.;
// @category - Base types; // @category - Base types;
// The agent's position in space.; // The agent's position in space.;
@ -37,20 +33,12 @@ orientation = val;
GSAIAgentLocation::~GSAIAgentLocation() { GSAIAgentLocation::~GSAIAgentLocation() {
} }
static void GSAIAgentLocation::_bind_methods() { static void GSAIAgentLocation::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_position"), &GSAIAgentLocation::get_position); ClassDB::bind_method(D_METHOD("get_position"), &GSAIAgentLocation::get_position);
ClassDB::bind_method(D_METHOD("set_position", "value"), &GSAIAgentLocation::set_position); ClassDB::bind_method(D_METHOD("set_position", "value"), &GSAIAgentLocation::set_position);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "set_position", "get_position"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "set_position", "get_position");
ClassDB::bind_method(D_METHOD("get_orientation"), &GSAIAgentLocation::get_orientation); ClassDB::bind_method(D_METHOD("get_orientation"), &GSAIAgentLocation::get_orientation);
ClassDB::bind_method(D_METHOD("set_orientation", "value"), &GSAIAgentLocation::set_orientation); ClassDB::bind_method(D_METHOD("set_orientation", "value"), &GSAIAgentLocation::set_orientation);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "orientation"), "set_orientation", "get_orientation"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "orientation"), "set_orientation", "get_orientation");
} }

View File

@ -1,19 +1,16 @@
#ifndef GSAIAGENTLOCATION_H #ifndef GSAIAGENTLOCATION_H
#define GSAIAGENTLOCATION_H #define GSAIAGENTLOCATION_H
class GSAIAgentLocation : public Reference { class GSAIAgentLocation : public Reference {
GDCLASS(GSAIAgentLocation, Reference); GDCLASS(GSAIAgentLocation, Reference);
public: public:
Vector3 get_position(); Vector3 get_position();
void set_position(const Vector3 &val); void set_position(const Vector3 &val);
float get_orientation() const; float get_orientation() const;
void set_orientation(const float val); void set_orientation(const float val);
GSAIAgentLocation(); GSAIAgentLocation();
~GSAIAgentLocation(); ~GSAIAgentLocation();
@ -28,5 +25,4 @@ class GSAIAgentLocation : public Reference {
float orientation = 0.0; float orientation = 0.0;
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_group_behavior.h" #include "gsai_group_behavior.h"
GSAIProximity GSAIGroupBehavior::get_ *proximity() { GSAIProximity GSAIGroupBehavior::get_ *proximity() {
return *proximity; return *proximity;
} }
@ -10,7 +9,6 @@ void GSAIGroupBehavior::set_*proximity(const GSAIProximity &val) {
*proximity = val; *proximity = val;
} }
Ref<FuncRef> GSAIGroupBehavior::get__callback() { Ref<FuncRef> GSAIGroupBehavior::get__callback() {
return _callback; return _callback;
} }
@ -19,8 +17,6 @@ void GSAIGroupBehavior::set__callback(const Ref<FuncRef> &val) {
_callback = val; _callback = val;
} }
// Base type for group-based steering behaviors.; // Base type for group-based steering behaviors.;
// @category - Base types; // @category - Base types;
// Container to find neighbors of the agent and calculate group behavior.; // Container to find neighbors of the agent and calculate group behavior.;
@ -38,7 +34,6 @@ _callback = val;
bool GSAIGroupBehavior::_report_neighbor(const GSAISteeringAgent &_neighbor) { bool GSAIGroupBehavior::_report_neighbor(const GSAISteeringAgent &_neighbor) {
return false; return false;
} }
} }
GSAIGroupBehavior::GSAIGroupBehavior() { GSAIGroupBehavior::GSAIGroupBehavior() {
@ -49,22 +44,15 @@ _callback = val;
GSAIGroupBehavior::~GSAIGroupBehavior() { GSAIGroupBehavior::~GSAIGroupBehavior() {
} }
static void GSAIGroupBehavior::_bind_methods() { static void GSAIGroupBehavior::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_*proximity"), &GSAIGroupBehavior::get_ * proximity); ClassDB::bind_method(D_METHOD("get_*proximity"), &GSAIGroupBehavior::get_ * proximity);
ClassDB::bind_method(D_METHOD("set_*proximity", "value"), &GSAIGroupBehavior::set_ * proximity); ClassDB::bind_method(D_METHOD("set_*proximity", "value"), &GSAIGroupBehavior::set_ * proximity);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*proximity", PROPERTY_HINT_RESOURCE_TYPE, "GSAIProximity"), "set_*proximity", "get_*proximity"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*proximity", PROPERTY_HINT_RESOURCE_TYPE, "GSAIProximity"), "set_*proximity", "get_*proximity");
ClassDB::bind_method(D_METHOD("get__callback"), &GSAIGroupBehavior::get__callback); ClassDB::bind_method(D_METHOD("get__callback"), &GSAIGroupBehavior::get__callback);
ClassDB::bind_method(D_METHOD("set__callback", "value"), &GSAIGroupBehavior::set__callback); ClassDB::bind_method(D_METHOD("set__callback", "value"), &GSAIGroupBehavior::set__callback);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_callback", PROPERTY_HINT_RESOURCE_TYPE, "Ref<FuncRef>"), "set__callback", "get__callback"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_callback", PROPERTY_HINT_RESOURCE_TYPE, "Ref<FuncRef>"), "set__callback", "get__callback");
ClassDB::bind_method(D_METHOD("get_callback"), &GSAIGroupBehavior::get_callback); ClassDB::bind_method(D_METHOD("get_callback"), &GSAIGroupBehavior::get_callback);
ClassDB::bind_method(D_METHOD("_report_neighbor", "_neighbor"), &GSAIGroupBehavior::_report_neighbor); ClassDB::bind_method(D_METHOD("_report_neighbor", "_neighbor"), &GSAIGroupBehavior::_report_neighbor);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIGROUPBEHAVIOR_H #ifndef GSAIGROUPBEHAVIOR_H
#define GSAIGROUPBEHAVIOR_H #define GSAIGROUPBEHAVIOR_H
class GSAIGroupBehavior : public GSAISteeringBehavior { class GSAIGroupBehavior : public GSAISteeringBehavior {
GDCLASS(GSAIGroupBehavior, GSAISteeringBehavior); GDCLASS(GSAIGroupBehavior, GSAISteeringBehavior);
public: public:
GSAIProximity get_ *proximity(); GSAIProximity get_ *proximity();
void set_ *proximity(const GSAIProximity &val); void set_ *proximity(const GSAIProximity &val);
@ -32,5 +30,4 @@ class GSAIGroupBehavior : public GSAISteeringBehavior {
// @tags - virtual // @tags - virtual
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_path.h" #include "gsai_path.h"
bool GSAIPath::get_is_open() const { bool GSAIPath::get_is_open() const {
return is_open; return is_open;
} }
@ -10,7 +9,6 @@ void GSAIPath::set_is_open(const bool val) {
is_open = val; is_open = val;
} }
float GSAIPath::get_length() const { float GSAIPath::get_length() const {
return length; return length;
} }
@ -19,7 +17,6 @@ void GSAIPath::set_length(const float val) {
length = val; length = val;
} }
Array GSAIPath::get__segments() { Array GSAIPath::get__segments() {
return _segments; return _segments;
} }
@ -28,7 +25,6 @@ void GSAIPath::set__segments(const Array &val) {
_segments = val; _segments = val;
} }
Vector3 GSAIPath::get__nearest_point_on_segment() { Vector3 GSAIPath::get__nearest_point_on_segment() {
return _nearest_point_on_segment; return _nearest_point_on_segment;
} }
@ -37,7 +33,6 @@ void GSAIPath::set__nearest_point_on_segment(const Vector3 &val) {
_nearest_point_on_segment = val; _nearest_point_on_segment = val;
} }
Vector3 GSAIPath::get__nearest_point_on_path() { Vector3 GSAIPath::get__nearest_point_on_path() {
return _nearest_point_on_path; return _nearest_point_on_path;
} }
@ -46,8 +41,6 @@ void GSAIPath::set__nearest_point_on_path(const Vector3 &val) {
_nearest_point_on_path = val; _nearest_point_on_path = val;
} }
// Represents a path made up of Vector3 waypoints, split into segments path; // Represents a path made up of Vector3 waypoints, split into segments path;
// follow behaviors can use.; // follow behaviors can use.;
// @category - Base types; // @category - Base types;
@ -69,7 +62,6 @@ _nearest_point_on_path = val;
// Creates a path from a list of waypoints.; // Creates a path from a list of waypoints.;
void GSAIPath::create_path(const Array &waypoints) { void GSAIPath::create_path(const Array &waypoints) {
if (not waypoints || waypoints.size() < 2) { if (not waypoints || waypoints.size() < 2) {
printerr("Waypoints cannot be null and must contain at least two (2) waypoints."); printerr("Waypoints cannot be null and must contain at least two (2) waypoints.");
return; return;
@ -87,12 +79,10 @@ _nearest_point_on_path = val;
current = waypoints[i]; current = waypoints[i];
} }
else if (is_open) { else if (is_open) {
break; break;
} }
else { else {
current = waypoints[0]; current = waypoints[0];
} }
@ -106,9 +96,7 @@ _nearest_point_on_path = val;
// Returns the distance from `agent_current_position` to the next waypoint.; // Returns the distance from `agent_current_position` to the next waypoint.;
} }
float GSAIPath::calculate_distance(const Vector3 &agent_current_position) { float GSAIPath::calculate_distance(const Vector3 &agent_current_position) {
if (_segments.size() == 0) { if (_segments.size() == 0) {
return 0.0; return 0.0;
} }
@ -125,7 +113,6 @@ _nearest_point_on_path = val;
smallest_distance_squared = distance_squared; smallest_distance_squared = distance_squared;
nearest_segment = segment; nearest_segment = segment;
} }
} }
float length_on_path = nearest_segment.cumulative_length - _nearest_point_on_path.distance_to(nearest_segment.end); float length_on_path = nearest_segment.cumulative_length - _nearest_point_on_path.distance_to(nearest_segment.end);
@ -135,23 +122,18 @@ _nearest_point_on_path = val;
// Calculates a target position from the path's starting point based on the `target_distance`.; // Calculates a target position from the path's starting point based on the `target_distance`.;
Vector3 GSAIPath::calculate_target_position(const float target_distance) { Vector3 GSAIPath::calculate_target_position(const float target_distance) {
if (is_open) { if (is_open) {
target_distance = clamp(target_distance, 0, length); target_distance = clamp(target_distance, 0, length);
} }
else { else {
if (target_distance < 0) { if (target_distance < 0) {
target_distance = length + fmod(target_distance, length); target_distance = length + fmod(target_distance, length);
} }
else if (target_distance > length) { else if (target_distance > length) {
target_distance = fmod(target_distance, length); target_distance = fmod(target_distance, length);
} }
} }
GSAISegment *desired_segment; GSAISegment *desired_segment;
@ -163,10 +145,8 @@ _nearest_point_on_path = val;
desired_segment = segment; desired_segment = segment;
break; break;
} }
} }
if (not desired_segment) { if (not desired_segment) {
desired_segment = _segments.back(); desired_segment = _segments.back();
} }
@ -187,7 +167,6 @@ _nearest_point_on_path = val;
return _segments.back().end; return _segments.back().end;
} }
float GSAIPath::_calculate_point_segment_distance_squared(const Vector3 &start, const Vector3 &end, const Vector3 &position) { float GSAIPath::_calculate_point_segment_distance_squared(const Vector3 &start, const Vector3 &end, const Vector3 &position) {
_nearest_point_on_segment = start; _nearest_point_on_segment = start;
Vector3 start_end = end - start; Vector3 start_end = end - start;
@ -211,7 +190,6 @@ _nearest_point_on_path = val;
begin = val; begin = val;
} }
Vector3 GSAISegment::get_end() { Vector3 GSAISegment::get_end() {
return end; return end;
} }
@ -220,7 +198,6 @@ _nearest_point_on_path = val;
end = val; end = val;
} }
float GSAISegment::get_length() const { float GSAISegment::get_length() const {
return length; return length;
} }
@ -229,7 +206,6 @@ _nearest_point_on_path = val;
length = val; length = val;
} }
float GSAISegment::get_cumulative_length() const { float GSAISegment::get_cumulative_length() const {
return cumulative_length; return cumulative_length;
} }
@ -238,8 +214,6 @@ _nearest_point_on_path = val;
cumulative_length = val; cumulative_length = val;
} }
Vector3 begin = ; Vector3 begin = ;
Vector3 end = ; Vector3 end = ;
float length = ; float length = ;
@ -250,7 +224,6 @@ _nearest_point_on_path = val;
self.end = _end; self.end = _end;
length = _begin.distance_to(_end); length = _begin.distance_to(_end);
} }
} }
GSAISegment::GSAISegment() { GSAISegment::GSAISegment() {
@ -263,33 +236,25 @@ _nearest_point_on_path = val;
GSAISegment::~GSAISegment() { GSAISegment::~GSAISegment() {
} }
static void GSAISegment::_bind_methods() { static void GSAISegment::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_begin"), &GSAISegment::get_begin); ClassDB::bind_method(D_METHOD("get_begin"), &GSAISegment::get_begin);
ClassDB::bind_method(D_METHOD("set_begin", "value"), &GSAISegment::set_begin); ClassDB::bind_method(D_METHOD("set_begin", "value"), &GSAISegment::set_begin);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "begin"), "set_begin", "get_begin"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "begin"), "set_begin", "get_begin");
ClassDB::bind_method(D_METHOD("get_end"), &GSAISegment::get_end); ClassDB::bind_method(D_METHOD("get_end"), &GSAISegment::get_end);
ClassDB::bind_method(D_METHOD("set_end", "value"), &GSAISegment::set_end); ClassDB::bind_method(D_METHOD("set_end", "value"), &GSAISegment::set_end);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "end"), "set_end", "get_end"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "end"), "set_end", "get_end");
ClassDB::bind_method(D_METHOD("get_length"), &GSAISegment::get_length); ClassDB::bind_method(D_METHOD("get_length"), &GSAISegment::get_length);
ClassDB::bind_method(D_METHOD("set_length", "value"), &GSAISegment::set_length); ClassDB::bind_method(D_METHOD("set_length", "value"), &GSAISegment::set_length);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length");
ClassDB::bind_method(D_METHOD("get_cumulative_length"), &GSAISegment::get_cumulative_length); ClassDB::bind_method(D_METHOD("get_cumulative_length"), &GSAISegment::get_cumulative_length);
ClassDB::bind_method(D_METHOD("set_cumulative_length", "value"), &GSAISegment::set_cumulative_length); ClassDB::bind_method(D_METHOD("set_cumulative_length", "value"), &GSAISegment::set_cumulative_length);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "cumulative_length"), "set_cumulative_length", "get_cumulative_length"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "cumulative_length"), "set_cumulative_length", "get_cumulative_length");
ClassDB::bind_method(D_METHOD("_init", "_begin", "_end"), &GSAISegment::_init); ClassDB::bind_method(D_METHOD("_init", "_begin", "_end"), &GSAISegment::_init);
} }
} }
GSAIPath::GSAIPath() { GSAIPath::GSAIPath() {
@ -303,33 +268,27 @@ _nearest_point_on_path = val;
GSAIPath::~GSAIPath() { GSAIPath::~GSAIPath() {
} }
static void GSAIPath::_bind_methods() { static void GSAIPath::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_is_open"), &GSAIPath::get_is_open); ClassDB::bind_method(D_METHOD("get_is_open"), &GSAIPath::get_is_open);
ClassDB::bind_method(D_METHOD("set_is_open", "value"), &GSAIPath::set_is_open); ClassDB::bind_method(D_METHOD("set_is_open", "value"), &GSAIPath::set_is_open);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_open"), "set_is_open", "get_is_open"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_open"), "set_is_open", "get_is_open");
ClassDB::bind_method(D_METHOD("get_length"), &GSAIPath::get_length); ClassDB::bind_method(D_METHOD("get_length"), &GSAIPath::get_length);
ClassDB::bind_method(D_METHOD("set_length", "value"), &GSAIPath::set_length); ClassDB::bind_method(D_METHOD("set_length", "value"), &GSAIPath::set_length);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length");
ClassDB::bind_method(D_METHOD("get__segments"), &GSAIPath::get__segments); ClassDB::bind_method(D_METHOD("get__segments"), &GSAIPath::get__segments);
ClassDB::bind_method(D_METHOD("set__segments", "value"), &GSAIPath::set__segments); ClassDB::bind_method(D_METHOD("set__segments", "value"), &GSAIPath::set__segments);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_segments"), "set__segments", "get__segments"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_segments"), "set__segments", "get__segments");
ClassDB::bind_method(D_METHOD("get__nearest_point_on_segment"), &GSAIPath::get__nearest_point_on_segment); ClassDB::bind_method(D_METHOD("get__nearest_point_on_segment"), &GSAIPath::get__nearest_point_on_segment);
ClassDB::bind_method(D_METHOD("set__nearest_point_on_segment", "value"), &GSAIPath::set__nearest_point_on_segment); ClassDB::bind_method(D_METHOD("set__nearest_point_on_segment", "value"), &GSAIPath::set__nearest_point_on_segment);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_nearest_point_on_segment"), "set__nearest_point_on_segment", "get__nearest_point_on_segment"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_nearest_point_on_segment"), "set__nearest_point_on_segment", "get__nearest_point_on_segment");
ClassDB::bind_method(D_METHOD("get__nearest_point_on_path"), &GSAIPath::get__nearest_point_on_path); ClassDB::bind_method(D_METHOD("get__nearest_point_on_path"), &GSAIPath::get__nearest_point_on_path);
ClassDB::bind_method(D_METHOD("set__nearest_point_on_path", "value"), &GSAIPath::set__nearest_point_on_path); ClassDB::bind_method(D_METHOD("set__nearest_point_on_path", "value"), &GSAIPath::set__nearest_point_on_path);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_nearest_point_on_path"), "set__nearest_point_on_path", "get__nearest_point_on_path"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_nearest_point_on_path"), "set__nearest_point_on_path", "get__nearest_point_on_path");
ClassDB::bind_method(D_METHOD("initialize", "waypoints", "_is_open"), &GSAIPath::initialize, false); ClassDB::bind_method(D_METHOD("initialize", "waypoints", "_is_open"), &GSAIPath::initialize, false);
ClassDB::bind_method(D_METHOD("create_path", "waypoints"), &GSAIPath::create_path); ClassDB::bind_method(D_METHOD("create_path", "waypoints"), &GSAIPath::create_path);
ClassDB::bind_method(D_METHOD("calculate_distance", "agent_current_position"), &GSAIPath::calculate_distance); ClassDB::bind_method(D_METHOD("calculate_distance", "agent_current_position"), &GSAIPath::calculate_distance);
@ -337,8 +296,4 @@ _nearest_point_on_path = val;
ClassDB::bind_method(D_METHOD("get_start_point"), &GSAIPath::get_start_point); ClassDB::bind_method(D_METHOD("get_start_point"), &GSAIPath::get_start_point);
ClassDB::bind_method(D_METHOD("get_end_point"), &GSAIPath::get_end_point); ClassDB::bind_method(D_METHOD("get_end_point"), &GSAIPath::get_end_point);
ClassDB::bind_method(D_METHOD("_calculate_point_segment_distance_squared", "start", "end", "position"), &GSAIPath::_calculate_point_segment_distance_squared); ClassDB::bind_method(D_METHOD("_calculate_point_segment_distance_squared", "start", "end", "position"), &GSAIPath::_calculate_point_segment_distance_squared);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIPATH_H #ifndef GSAIPATH_H
#define GSAIPATH_H #define GSAIPATH_H
class GSAIPath : public Reference { class GSAIPath : public Reference {
GDCLASS(GSAIPath, Reference); GDCLASS(GSAIPath, Reference);
public: public:
bool get_is_open() const; bool get_is_open() const;
void set_is_open(const bool val); void set_is_open(const bool val);
@ -31,7 +29,6 @@ class GSAIPath : public Reference {
float _calculate_point_segment_distance_squared(const Vector3 &start, const Vector3 &end, const Vector3 &position); float _calculate_point_segment_distance_squared(const Vector3 &start, const Vector3 &end, const Vector3 &position);
class GSAISegment { class GSAISegment {
public: public:
Vector3 get_begin(); Vector3 get_begin();
void set_begin(const Vector3 &val); void set_begin(const Vector3 &val);
@ -58,7 +55,6 @@ class GSAIPath : public Reference {
float cumulative_length = ; float cumulative_length = ;
}; };
GSAIPath(); GSAIPath();
~GSAIPath(); ~GSAIPath();
@ -82,5 +78,4 @@ class GSAIPath : public Reference {
// not exposed helper struct // not exposed helper struct
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_steering_agent.h" #include "gsai_steering_agent.h"
float GSAISteeringAgent::get_zero_linear_speed_threshold() const { float GSAISteeringAgent::get_zero_linear_speed_threshold() const {
return zero_linear_speed_threshold; return zero_linear_speed_threshold;
} }
@ -10,7 +9,6 @@ void GSAISteeringAgent::set_zero_linear_speed_threshold(const float val) {
zero_linear_speed_threshold = val; zero_linear_speed_threshold = val;
} }
float GSAISteeringAgent::get_linear_speed_max() const { float GSAISteeringAgent::get_linear_speed_max() const {
return linear_speed_max; return linear_speed_max;
} }
@ -19,7 +17,6 @@ void GSAISteeringAgent::set_linear_speed_max(const float val) {
linear_speed_max = val; linear_speed_max = val;
} }
float GSAISteeringAgent::get_linear_acceleration_max() const { float GSAISteeringAgent::get_linear_acceleration_max() const {
return linear_acceleration_max; return linear_acceleration_max;
} }
@ -28,7 +25,6 @@ void GSAISteeringAgent::set_linear_acceleration_max(const float val) {
linear_acceleration_max = val; linear_acceleration_max = val;
} }
float GSAISteeringAgent::get_angular_speed_max() const { float GSAISteeringAgent::get_angular_speed_max() const {
return angular_speed_max; return angular_speed_max;
} }
@ -37,7 +33,6 @@ void GSAISteeringAgent::set_angular_speed_max(const float val) {
angular_speed_max = val; angular_speed_max = val;
} }
float GSAISteeringAgent::get_angular_acceleration_max() const { float GSAISteeringAgent::get_angular_acceleration_max() const {
return angular_acceleration_max; return angular_acceleration_max;
} }
@ -46,7 +41,6 @@ void GSAISteeringAgent::set_angular_acceleration_max(const float val) {
angular_acceleration_max = val; angular_acceleration_max = val;
} }
Vector3 GSAISteeringAgent::get_linear_velocity() { Vector3 GSAISteeringAgent::get_linear_velocity() {
return linear_velocity; return linear_velocity;
} }
@ -55,7 +49,6 @@ void GSAISteeringAgent::set_linear_velocity(const Vector3 &val) {
linear_velocity = val; linear_velocity = val;
} }
float GSAISteeringAgent::get_angular_velocity() const { float GSAISteeringAgent::get_angular_velocity() const {
return angular_velocity; return angular_velocity;
} }
@ -64,7 +57,6 @@ void GSAISteeringAgent::set_angular_velocity(const float val) {
angular_velocity = val; angular_velocity = val;
} }
float GSAISteeringAgent::get_bounding_radius() const { float GSAISteeringAgent::get_bounding_radius() const {
return bounding_radius; return bounding_radius;
} }
@ -73,7 +65,6 @@ void GSAISteeringAgent::set_bounding_radius(const float val) {
bounding_radius = val; bounding_radius = val;
} }
bool GSAISteeringAgent::get_is_tagged() const { bool GSAISteeringAgent::get_is_tagged() const {
return is_tagged; return is_tagged;
} }
@ -82,8 +73,6 @@ void GSAISteeringAgent::set_is_tagged(const bool val) {
is_tagged = val; is_tagged = val;
} }
// Adds velocity, speed, and size data to `GSAIAgentLocation`.; // Adds velocity, speed, and size data to `GSAIAgentLocation`.;
//; //;
// It is the character's responsibility to keep this information up to date for; // It is the character's responsibility to keep this information up to date for;
@ -126,55 +115,40 @@ is_tagged = val;
GSAISteeringAgent::~GSAISteeringAgent() { GSAISteeringAgent::~GSAISteeringAgent() {
} }
static void GSAISteeringAgent::_bind_methods() { static void GSAISteeringAgent::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_zero_linear_speed_threshold"), &GSAISteeringAgent::get_zero_linear_speed_threshold); ClassDB::bind_method(D_METHOD("get_zero_linear_speed_threshold"), &GSAISteeringAgent::get_zero_linear_speed_threshold);
ClassDB::bind_method(D_METHOD("set_zero_linear_speed_threshold", "value"), &GSAISteeringAgent::set_zero_linear_speed_threshold); ClassDB::bind_method(D_METHOD("set_zero_linear_speed_threshold", "value"), &GSAISteeringAgent::set_zero_linear_speed_threshold);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "zero_linear_speed_threshold"), "set_zero_linear_speed_threshold", "get_zero_linear_speed_threshold"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "zero_linear_speed_threshold"), "set_zero_linear_speed_threshold", "get_zero_linear_speed_threshold");
ClassDB::bind_method(D_METHOD("get_linear_speed_max"), &GSAISteeringAgent::get_linear_speed_max); ClassDB::bind_method(D_METHOD("get_linear_speed_max"), &GSAISteeringAgent::get_linear_speed_max);
ClassDB::bind_method(D_METHOD("set_linear_speed_max", "value"), &GSAISteeringAgent::set_linear_speed_max); ClassDB::bind_method(D_METHOD("set_linear_speed_max", "value"), &GSAISteeringAgent::set_linear_speed_max);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_speed_max"), "set_linear_speed_max", "get_linear_speed_max"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_speed_max"), "set_linear_speed_max", "get_linear_speed_max");
ClassDB::bind_method(D_METHOD("get_linear_acceleration_max"), &GSAISteeringAgent::get_linear_acceleration_max); ClassDB::bind_method(D_METHOD("get_linear_acceleration_max"), &GSAISteeringAgent::get_linear_acceleration_max);
ClassDB::bind_method(D_METHOD("set_linear_acceleration_max", "value"), &GSAISteeringAgent::set_linear_acceleration_max); ClassDB::bind_method(D_METHOD("set_linear_acceleration_max", "value"), &GSAISteeringAgent::set_linear_acceleration_max);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_acceleration_max"), "set_linear_acceleration_max", "get_linear_acceleration_max"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_acceleration_max"), "set_linear_acceleration_max", "get_linear_acceleration_max");
ClassDB::bind_method(D_METHOD("get_angular_speed_max"), &GSAISteeringAgent::get_angular_speed_max); ClassDB::bind_method(D_METHOD("get_angular_speed_max"), &GSAISteeringAgent::get_angular_speed_max);
ClassDB::bind_method(D_METHOD("set_angular_speed_max", "value"), &GSAISteeringAgent::set_angular_speed_max); ClassDB::bind_method(D_METHOD("set_angular_speed_max", "value"), &GSAISteeringAgent::set_angular_speed_max);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_speed_max"), "set_angular_speed_max", "get_angular_speed_max"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_speed_max"), "set_angular_speed_max", "get_angular_speed_max");
ClassDB::bind_method(D_METHOD("get_angular_acceleration_max"), &GSAISteeringAgent::get_angular_acceleration_max); ClassDB::bind_method(D_METHOD("get_angular_acceleration_max"), &GSAISteeringAgent::get_angular_acceleration_max);
ClassDB::bind_method(D_METHOD("set_angular_acceleration_max", "value"), &GSAISteeringAgent::set_angular_acceleration_max); ClassDB::bind_method(D_METHOD("set_angular_acceleration_max", "value"), &GSAISteeringAgent::set_angular_acceleration_max);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_acceleration_max"), "set_angular_acceleration_max", "get_angular_acceleration_max"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_acceleration_max"), "set_angular_acceleration_max", "get_angular_acceleration_max");
ClassDB::bind_method(D_METHOD("get_linear_velocity"), &GSAISteeringAgent::get_linear_velocity); ClassDB::bind_method(D_METHOD("get_linear_velocity"), &GSAISteeringAgent::get_linear_velocity);
ClassDB::bind_method(D_METHOD("set_linear_velocity", "value"), &GSAISteeringAgent::set_linear_velocity); ClassDB::bind_method(D_METHOD("set_linear_velocity", "value"), &GSAISteeringAgent::set_linear_velocity);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity"), "set_linear_velocity", "get_linear_velocity"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity"), "set_linear_velocity", "get_linear_velocity");
ClassDB::bind_method(D_METHOD("get_angular_velocity"), &GSAISteeringAgent::get_angular_velocity); ClassDB::bind_method(D_METHOD("get_angular_velocity"), &GSAISteeringAgent::get_angular_velocity);
ClassDB::bind_method(D_METHOD("set_angular_velocity", "value"), &GSAISteeringAgent::set_angular_velocity); ClassDB::bind_method(D_METHOD("set_angular_velocity", "value"), &GSAISteeringAgent::set_angular_velocity);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_velocity"), "set_angular_velocity", "get_angular_velocity"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
ClassDB::bind_method(D_METHOD("get_bounding_radius"), &GSAISteeringAgent::get_bounding_radius); ClassDB::bind_method(D_METHOD("get_bounding_radius"), &GSAISteeringAgent::get_bounding_radius);
ClassDB::bind_method(D_METHOD("set_bounding_radius", "value"), &GSAISteeringAgent::set_bounding_radius); ClassDB::bind_method(D_METHOD("set_bounding_radius", "value"), &GSAISteeringAgent::set_bounding_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bounding_radius"), "set_bounding_radius", "get_bounding_radius"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "bounding_radius"), "set_bounding_radius", "get_bounding_radius");
ClassDB::bind_method(D_METHOD("get_is_tagged"), &GSAISteeringAgent::get_is_tagged); ClassDB::bind_method(D_METHOD("get_is_tagged"), &GSAISteeringAgent::get_is_tagged);
ClassDB::bind_method(D_METHOD("set_is_tagged", "value"), &GSAISteeringAgent::set_is_tagged); ClassDB::bind_method(D_METHOD("set_is_tagged", "value"), &GSAISteeringAgent::set_is_tagged);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_tagged"), "set_is_tagged", "get_is_tagged"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_tagged"), "set_is_tagged", "get_is_tagged");
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAISTEERINGAGENT_H #ifndef GSAISTEERINGAGENT_H
#define GSAISTEERINGAGENT_H #define GSAISTEERINGAGENT_H
class GSAISteeringAgent : public GSAIAgentLocation { class GSAISteeringAgent : public GSAIAgentLocation {
GDCLASS(GSAISteeringAgent, GSAIAgentLocation); GDCLASS(GSAISteeringAgent, GSAIAgentLocation);
public: public:
float get_zero_linear_speed_threshold() const; float get_zero_linear_speed_threshold() const;
void set_zero_linear_speed_threshold(const float val); void set_zero_linear_speed_threshold(const float val);
@ -34,7 +32,6 @@ class GSAISteeringAgent : public GSAIAgentLocation {
bool get_is_tagged() const; bool get_is_tagged() const;
void set_is_tagged(const bool val); void set_is_tagged(const bool val);
GSAISteeringAgent(); GSAISteeringAgent();
~GSAISteeringAgent(); ~GSAISteeringAgent();
@ -68,5 +65,4 @@ class GSAISteeringAgent : public GSAIAgentLocation {
bool is_tagged = false; bool is_tagged = false;
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_steering_behavior.h" #include "gsai_steering_behavior.h"
bool GSAISteeringBehavior::get_is_enabled() const { bool GSAISteeringBehavior::get_is_enabled() const {
return is_enabled; return is_enabled;
} }
@ -10,7 +9,6 @@ void GSAISteeringBehavior::set_is_enabled(const bool val) {
is_enabled = val; is_enabled = val;
} }
GSAISteeringAgent GSAISteeringBehavior::get_ *agent() { GSAISteeringAgent GSAISteeringBehavior::get_ *agent() {
return *agent; return *agent;
} }
@ -19,8 +17,6 @@ void GSAISteeringBehavior::set_*agent(const GSAISteeringAgent &val) {
*agent = val; *agent = val;
} }
// Base class for all steering behaviors.; // Base class for all steering behaviors.;
//; //;
// Steering behaviors calculate the linear and the angular acceleration to be; // Steering behaviors calculate the linear and the angular acceleration to be;
@ -36,23 +32,18 @@ void GSAISteeringBehavior::set_*agent(const GSAISteeringAgent &val) {
// Sets the `acceleration` with the behavior's desired amount of acceleration.; // Sets the `acceleration` with the behavior's desired amount of acceleration.;
void GSAISteeringBehavior::calculate_steering(const GSAITargetAcceleration &acceleration) { void GSAISteeringBehavior::calculate_steering(const GSAITargetAcceleration &acceleration) {
if (is_enabled) { if (is_enabled) {
call("_calculate_steering", acceleration); call("_calculate_steering", acceleration);
} }
else { else {
acceleration.set_zero(); acceleration.set_zero();
} }
} }
void GSAISteeringBehavior::_calculate_steering(const GSAITargetAcceleration &acceleration) { void GSAISteeringBehavior::_calculate_steering(const GSAITargetAcceleration &acceleration) {
acceleration.set_zero(); acceleration.set_zero();
} }
} }
GSAISteeringBehavior::GSAISteeringBehavior() { GSAISteeringBehavior::GSAISteeringBehavior() {
@ -63,22 +54,15 @@ void GSAISteeringBehavior::set_*agent(const GSAISteeringAgent &val) {
GSAISteeringBehavior::~GSAISteeringBehavior() { GSAISteeringBehavior::~GSAISteeringBehavior() {
} }
static void GSAISteeringBehavior::_bind_methods() { static void GSAISteeringBehavior::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_is_enabled"), &GSAISteeringBehavior::get_is_enabled); ClassDB::bind_method(D_METHOD("get_is_enabled"), &GSAISteeringBehavior::get_is_enabled);
ClassDB::bind_method(D_METHOD("set_is_enabled", "value"), &GSAISteeringBehavior::set_is_enabled); ClassDB::bind_method(D_METHOD("set_is_enabled", "value"), &GSAISteeringBehavior::set_is_enabled);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_enabled"), "set_is_enabled", "get_is_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_enabled"), "set_is_enabled", "get_is_enabled");
ClassDB::bind_method(D_METHOD("get_*agent"), &GSAISteeringBehavior::get_ * agent); ClassDB::bind_method(D_METHOD("get_*agent"), &GSAISteeringBehavior::get_ * agent);
ClassDB::bind_method(D_METHOD("set_*agent", "value"), &GSAISteeringBehavior::set_ * agent); ClassDB::bind_method(D_METHOD("set_*agent", "value"), &GSAISteeringBehavior::set_ * agent);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*agent", PROPERTY_HINT_RESOURCE_TYPE, "GSAISteeringAgent"), "set_*agent", "get_*agent"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*agent", PROPERTY_HINT_RESOURCE_TYPE, "GSAISteeringAgent"), "set_*agent", "get_*agent");
ClassDB::bind_method(D_METHOD("calculate_steering", "acceleration"), &GSAISteeringBehavior::calculate_steering); ClassDB::bind_method(D_METHOD("calculate_steering", "acceleration"), &GSAISteeringBehavior::calculate_steering);
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAISteeringBehavior::_calculate_steering); ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAISteeringBehavior::_calculate_steering);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAISTEERINGBEHAVIOR_H #ifndef GSAISTEERINGBEHAVIOR_H
#define GSAISTEERINGBEHAVIOR_H #define GSAISTEERINGBEHAVIOR_H
class GSAISteeringBehavior : public Reference { class GSAISteeringBehavior : public Reference {
GDCLASS(GSAISteeringBehavior, Reference); GDCLASS(GSAISteeringBehavior, Reference);
public: public:
bool get_is_enabled() const; bool get_is_enabled() const;
void set_is_enabled(const bool val); void set_is_enabled(const bool val);
@ -37,5 +35,4 @@ class GSAISteeringBehavior : public Reference {
// Sets the `acceleration` with the behavior's desired amount of acceleration. // Sets the `acceleration` with the behavior's desired amount of acceleration.
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_target_acceleration.h" #include "gsai_target_acceleration.h"
Vector3 GSAITargetAcceleration::get_linear() { Vector3 GSAITargetAcceleration::get_linear() {
return linear; return linear;
} }
@ -10,7 +9,6 @@ void GSAITargetAcceleration::set_linear(const Vector3 &val) {
linear = val; linear = val;
} }
float GSAITargetAcceleration::get_angular() const { float GSAITargetAcceleration::get_angular() const {
return angular; return angular;
} }
@ -19,8 +17,6 @@ void GSAITargetAcceleration::set_angular(const float val) {
angular = val; angular = val;
} }
// A desired linear and angular amount of acceleration requested by the steering; // A desired linear and angular amount of acceleration requested by the steering;
// system.; // system.;
// @category - Base types; // @category - Base types;
@ -55,7 +51,6 @@ angular = val;
float GSAITargetAcceleration::get_magnitude() { float GSAITargetAcceleration::get_magnitude() {
return sqrt(get_magnitude_squared()); return sqrt(get_magnitude_squared());
} }
} }
GSAITargetAcceleration::GSAITargetAcceleration() { GSAITargetAcceleration::GSAITargetAcceleration() {
@ -66,24 +61,17 @@ angular = val;
GSAITargetAcceleration::~GSAITargetAcceleration() { GSAITargetAcceleration::~GSAITargetAcceleration() {
} }
static void GSAITargetAcceleration::_bind_methods() { static void GSAITargetAcceleration::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_linear"), &GSAITargetAcceleration::get_linear); ClassDB::bind_method(D_METHOD("get_linear"), &GSAITargetAcceleration::get_linear);
ClassDB::bind_method(D_METHOD("set_linear", "value"), &GSAITargetAcceleration::set_linear); ClassDB::bind_method(D_METHOD("set_linear", "value"), &GSAITargetAcceleration::set_linear);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear"), "set_linear", "get_linear"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear"), "set_linear", "get_linear");
ClassDB::bind_method(D_METHOD("get_angular"), &GSAITargetAcceleration::get_angular); ClassDB::bind_method(D_METHOD("get_angular"), &GSAITargetAcceleration::get_angular);
ClassDB::bind_method(D_METHOD("set_angular", "value"), &GSAITargetAcceleration::set_angular); ClassDB::bind_method(D_METHOD("set_angular", "value"), &GSAITargetAcceleration::set_angular);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular"), "set_angular", "get_angular"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular"), "set_angular", "get_angular");
ClassDB::bind_method(D_METHOD("set_zero"), &GSAITargetAcceleration::set_zero); ClassDB::bind_method(D_METHOD("set_zero"), &GSAITargetAcceleration::set_zero);
ClassDB::bind_method(D_METHOD("add_scaled_accel", "accel", "scalar"), &GSAITargetAcceleration::add_scaled_accel); ClassDB::bind_method(D_METHOD("add_scaled_accel", "accel", "scalar"), &GSAITargetAcceleration::add_scaled_accel);
ClassDB::bind_method(D_METHOD("get_magnitude_squared"), &GSAITargetAcceleration::get_magnitude_squared); ClassDB::bind_method(D_METHOD("get_magnitude_squared"), &GSAITargetAcceleration::get_magnitude_squared);
ClassDB::bind_method(D_METHOD("get_magnitude"), &GSAITargetAcceleration::get_magnitude); ClassDB::bind_method(D_METHOD("get_magnitude"), &GSAITargetAcceleration::get_magnitude);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAITARGETACCELERATION_H #ifndef GSAITARGETACCELERATION_H
#define GSAITARGETACCELERATION_H #define GSAITARGETACCELERATION_H
class GSAITargetAcceleration : public Reference { class GSAITargetAcceleration : public Reference {
GDCLASS(GSAITargetAcceleration, Reference); GDCLASS(GSAITargetAcceleration, Reference);
public: public:
Vector3 get_linear(); Vector3 get_linear();
void set_linear(const Vector3 &val); void set_linear(const Vector3 &val);
@ -37,5 +35,4 @@ class GSAITargetAcceleration : public Reference {
// Returns the magnitude of the linear and angular components. // Returns the magnitude of the linear and angular components.
}; };
#endif #endif

View File

@ -1,8 +1,6 @@
#include "gsai_utils.h" #include "gsai_utils.h"
// Math and vector utility functions.; // Math and vector utility functions.;
// @Category - Utilities; // @Category - Utilities;
// Returns the `vector` with its length capped to `limit`.; // Returns the `vector` with its length capped to `limit`.;
@ -53,7 +51,6 @@
Vector3 GSAIUtils::to_vector3(const Vector2 &vector) { Vector3 GSAIUtils::to_vector3(const Vector2 &vector) {
return Vector3(vector.x, vector.y, 0); return Vector3(vector.x, vector.y, 0);
} }
} }
GSAIUtils::GSAIUtils() { GSAIUtils::GSAIUtils() {
@ -62,10 +59,5 @@
GSAIUtils::~GSAIUtils() { GSAIUtils::~GSAIUtils() {
} }
static void GSAIUtils::_bind_methods() { static void GSAIUtils::_bind_methods() {
} }

View File

@ -1,10 +1,8 @@
#ifndef GSAIUTILS_H #ifndef GSAIUTILS_H
#define GSAIUTILS_H #define GSAIUTILS_H
class GSAIUtils { class GSAIUtils {
public: public:
static Vector3 clampedv3(const Vector3 &vector, const float limit); static Vector3 clampedv3(const Vector3 &vector, const float limit);
static float vector3_to_angle(const Vector3 &vector); static float vector3_to_angle(const Vector3 &vector);
static float vector2_to_angle(const Vector2 &vector); static float vector2_to_angle(const Vector2 &vector);
@ -34,5 +32,4 @@ class GSAIUtils {
// Returns a vector3 with `vector`'s x and y components and 0 in z. // Returns a vector3 with `vector`'s x and y components and 0 in z.
}; };
#endif #endif

View File

@ -1,8 +1,6 @@
#include "gsai_infinite_proximity.h" #include "gsai_infinite_proximity.h"
// Determines any agent that is in the specified list as being neighbors with the; // Determines any agent that is in the specified list as being neighbors with the;
// owner agent, regardless of distance.; // owner agent, regardless of distance.;
// @category - Proximities; // @category - Proximities;
@ -20,18 +18,14 @@
GSAISteeringAgent *current_agent = agents[i] as GSAISteeringAgent; GSAISteeringAgent *current_agent = agents[i] as GSAISteeringAgent;
if (current_agent != agent) { if (current_agent != agent) {
if (callback.call_func(current_agent)) { if (callback.call_func(current_agent)) {
neighbor_count += 1; neighbor_count += 1;
} }
} }
} }
return neighbor_count; return neighbor_count;
} }
} }
GSAIInfiniteProximity::GSAIInfiniteProximity() { GSAIInfiniteProximity::GSAIInfiniteProximity() {
@ -40,11 +34,6 @@
GSAIInfiniteProximity::~GSAIInfiniteProximity() { GSAIInfiniteProximity::~GSAIInfiniteProximity() {
} }
static void GSAIInfiniteProximity::_bind_methods() { static void GSAIInfiniteProximity::_bind_methods() {
ClassDB::bind_method(D_METHOD("_find_neighbors", "callback"), &GSAIInfiniteProximity::_find_neighbors); ClassDB::bind_method(D_METHOD("_find_neighbors", "callback"), &GSAIInfiniteProximity::_find_neighbors);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIINFINITEPROXIMITY_H #ifndef GSAIINFINITEPROXIMITY_H
#define GSAIINFINITEPROXIMITY_H #define GSAIINFINITEPROXIMITY_H
class GSAIInfiniteProximity : public GSAIProximity { class GSAIInfiniteProximity : public GSAIProximity {
GDCLASS(GSAIInfiniteProximity, GSAIProximity); GDCLASS(GSAIInfiniteProximity, GSAIProximity);
public: public:
int _find_neighbors(const FuncRef &callback); int _find_neighbors(const FuncRef &callback);
GSAIInfiniteProximity(); GSAIInfiniteProximity();
@ -25,5 +23,4 @@ class GSAIInfiniteProximity : public GSAIProximity {
// @tags - virtual // @tags - virtual
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_proximity.h" #include "gsai_proximity.h"
GSAISteeringAgent GSAIProximity::get_ *agent() { GSAISteeringAgent GSAIProximity::get_ *agent() {
return *agent; return *agent;
} }
@ -10,7 +9,6 @@ void GSAIProximity::set_*agent(const GSAISteeringAgent &val) {
*agent = val; *agent = val;
} }
Array GSAIProximity::get_agents() { Array GSAIProximity::get_agents() {
return agents; return agents;
} }
@ -19,8 +17,6 @@ void GSAIProximity::set_agents(const Array &val) {
agents = val; agents = val;
} }
// Base container type that stores data to find the neighbors of an agent.; // Base container type that stores data to find the neighbors of an agent.;
// @category - Proximities; // @category - Proximities;
// @tags - abstract; // @tags - abstract;
@ -42,7 +38,6 @@ agents = val;
int GSAIProximity::_find_neighbors(const FuncRef &_callback) { int GSAIProximity::_find_neighbors(const FuncRef &_callback) {
return 0; return 0;
} }
} }
GSAIProximity::GSAIProximity() { GSAIProximity::GSAIProximity() {
@ -53,22 +48,15 @@ agents = val;
GSAIProximity::~GSAIProximity() { GSAIProximity::~GSAIProximity() {
} }
static void GSAIProximity::_bind_methods() { static void GSAIProximity::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_*agent"), &GSAIProximity::get_ * agent); ClassDB::bind_method(D_METHOD("get_*agent"), &GSAIProximity::get_ * agent);
ClassDB::bind_method(D_METHOD("set_*agent", "value"), &GSAIProximity::set_ * agent); ClassDB::bind_method(D_METHOD("set_*agent", "value"), &GSAIProximity::set_ * agent);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*agent", PROPERTY_HINT_RESOURCE_TYPE, "GSAISteeringAgent"), "set_*agent", "get_*agent"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*agent", PROPERTY_HINT_RESOURCE_TYPE, "GSAISteeringAgent"), "set_*agent", "get_*agent");
ClassDB::bind_method(D_METHOD("get_agents"), &GSAIProximity::get_agents); ClassDB::bind_method(D_METHOD("get_agents"), &GSAIProximity::get_agents);
ClassDB::bind_method(D_METHOD("set_agents", "value"), &GSAIProximity::set_agents); ClassDB::bind_method(D_METHOD("set_agents", "value"), &GSAIProximity::set_agents);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "agents"), "set_agents", "get_agents"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "agents"), "set_agents", "get_agents");
ClassDB::bind_method(D_METHOD("find_neighbors", "_callback"), &GSAIProximity::find_neighbors); ClassDB::bind_method(D_METHOD("find_neighbors", "_callback"), &GSAIProximity::find_neighbors);
ClassDB::bind_method(D_METHOD("_find_neighbors", "_callback"), &GSAIProximity::_find_neighbors); ClassDB::bind_method(D_METHOD("_find_neighbors", "_callback"), &GSAIProximity::_find_neighbors);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIPROXIMITY_H #ifndef GSAIPROXIMITY_H
#define GSAIPROXIMITY_H #define GSAIPROXIMITY_H
class GSAIProximity : public Reference { class GSAIProximity : public Reference {
GDCLASS(GSAIProximity, Reference); GDCLASS(GSAIProximity, Reference);
public: public:
GSAISteeringAgent get_ *agent(); GSAISteeringAgent get_ *agent();
void set_ *agent(const GSAISteeringAgent &val); void set_ *agent(const GSAISteeringAgent &val);
@ -36,5 +34,4 @@ class GSAIProximity : public Reference {
// @tags - virtual // @tags - virtual
}; };
#endif #endif

View File

@ -1,7 +1,6 @@
#include "gsai_radius_proximity.h" #include "gsai_radius_proximity.h"
float GSAIRadiusProximity::get_radius() const { float GSAIRadiusProximity::get_radius() const {
return radius; return radius;
} }
@ -10,7 +9,6 @@ void GSAIRadiusProximity::set_radius(const float val) {
radius = val; radius = val;
} }
int GSAIRadiusProximity::get__last_frame() const { int GSAIRadiusProximity::get__last_frame() const {
return _last_frame; return _last_frame;
} }
@ -19,7 +17,6 @@ void GSAIRadiusProximity::set__last_frame(const int val) {
_last_frame = val; _last_frame = val;
} }
SceneTree GSAIRadiusProximity::get_ *_scene_tree() { SceneTree GSAIRadiusProximity::get_ *_scene_tree() {
return *_scene_tree; return *_scene_tree;
} }
@ -28,8 +25,6 @@ void GSAIRadiusProximity::set_*_scene_tree(const SceneTree &val) {
*_scene_tree = val; *_scene_tree = val;
} }
// Determines any agent that is in the specified list as being neighbors with the owner agent if; // Determines any agent that is in the specified list as being neighbors with the owner agent if;
// they lie within the specified radius.; // they lie within the specified radius.;
// @category - Proximities; // @category - Proximities;
@ -57,12 +52,10 @@ void GSAIRadiusProximity::set_*_scene_tree(const SceneTree &val) {
current_frame = _scene_tree.get_frame(); current_frame = _scene_tree.get_frame();
} }
else { else {
current_frame = -_last_frame; current_frame = -_last_frame;
} }
if (current_frame != _last_frame) { if (current_frame != _last_frame) {
_last_frame = current_frame; _last_frame = current_frame;
Vector3 owner_position = agent.position; Vector3 owner_position = agent.position;
@ -75,15 +68,12 @@ void GSAIRadiusProximity::set_*_scene_tree(const SceneTree &val) {
float range_to = radius + current_agent.bounding_radius; float range_to = radius + current_agent.bounding_radius;
if (distance_squared < range_to * range_to) { if (distance_squared < range_to * range_to) {
if (callback.call_func(current_agent)) { if (callback.call_func(current_agent)) {
current_agent.is_tagged = true; current_agent.is_tagged = true;
neighbor_count += 1; neighbor_count += 1;
continue; continue;
} }
} }
} }
current_agent.is_tagged = false; current_agent.is_tagged = false;
@ -91,27 +81,20 @@ void GSAIRadiusProximity::set_*_scene_tree(const SceneTree &val) {
} }
else { else {
for (int i = 0; i < agent_count; ++i) { //i in range(agent_count) for (int i = 0; i < agent_count; ++i) { //i in range(agent_count)
GSAISteeringAgent *current_agent = agents[i] as GSAISteeringAgent; GSAISteeringAgent *current_agent = agents[i] as GSAISteeringAgent;
if (current_agent != agent && current_agent.is_tagged) { if (current_agent != agent && current_agent.is_tagged) {
if (callback.call_func(current_agent)) { if (callback.call_func(current_agent)) {
neighbor_count += 1; neighbor_count += 1;
} }
} }
} }
} }
return neighbor_count; return neighbor_count;
} }
} }
GSAIRadiusProximity::GSAIRadiusProximity() { GSAIRadiusProximity::GSAIRadiusProximity() {
@ -123,27 +106,19 @@ void GSAIRadiusProximity::set_*_scene_tree(const SceneTree &val) {
GSAIRadiusProximity::~GSAIRadiusProximity() { GSAIRadiusProximity::~GSAIRadiusProximity() {
} }
static void GSAIRadiusProximity::_bind_methods() { static void GSAIRadiusProximity::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_radius"), &GSAIRadiusProximity::get_radius); ClassDB::bind_method(D_METHOD("get_radius"), &GSAIRadiusProximity::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &GSAIRadiusProximity::set_radius); ClassDB::bind_method(D_METHOD("set_radius", "value"), &GSAIRadiusProximity::set_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
ClassDB::bind_method(D_METHOD("get__last_frame"), &GSAIRadiusProximity::get__last_frame); ClassDB::bind_method(D_METHOD("get__last_frame"), &GSAIRadiusProximity::get__last_frame);
ClassDB::bind_method(D_METHOD("set__last_frame", "value"), &GSAIRadiusProximity::set__last_frame); ClassDB::bind_method(D_METHOD("set__last_frame", "value"), &GSAIRadiusProximity::set__last_frame);
ADD_PROPERTY(PropertyInfo(Variant::INT, "_last_frame"), "set__last_frame", "get__last_frame"); ADD_PROPERTY(PropertyInfo(Variant::INT, "_last_frame"), "set__last_frame", "get__last_frame");
ClassDB::bind_method(D_METHOD("get_*_scene_tree"), &GSAIRadiusProximity::get_ * _scene_tree); ClassDB::bind_method(D_METHOD("get_*_scene_tree"), &GSAIRadiusProximity::get_ * _scene_tree);
ClassDB::bind_method(D_METHOD("set_*_scene_tree", "value"), &GSAIRadiusProximity::set_ * _scene_tree); ClassDB::bind_method(D_METHOD("set_*_scene_tree", "value"), &GSAIRadiusProximity::set_ * _scene_tree);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_scene_tree", PROPERTY_HINT_RESOURCE_TYPE, "SceneTree"), "set_*_scene_tree", "get_*_scene_tree"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_scene_tree", PROPERTY_HINT_RESOURCE_TYPE, "SceneTree"), "set_*_scene_tree", "get_*_scene_tree");
ClassDB::bind_method(D_METHOD("_init"), &GSAIRadiusProximity::_init); ClassDB::bind_method(D_METHOD("_init"), &GSAIRadiusProximity::_init);
ClassDB::bind_method(D_METHOD("_find_neighbors", "callback"), &GSAIRadiusProximity::_find_neighbors); ClassDB::bind_method(D_METHOD("_find_neighbors", "callback"), &GSAIRadiusProximity::_find_neighbors);
} }

View File

@ -1,12 +1,10 @@
#ifndef GSAIRADIUSPROXIMITY_H #ifndef GSAIRADIUSPROXIMITY_H
#define GSAIRADIUSPROXIMITY_H #define GSAIRADIUSPROXIMITY_H
class GSAIRadiusProximity : public GSAIProximity { class GSAIRadiusProximity : public GSAIProximity {
GDCLASS(GSAIRadiusProximity, GSAIProximity); GDCLASS(GSAIRadiusProximity, GSAIProximity);
public: public:
float get_radius() const; float get_radius() const;
void set_radius(const float val); void set_radius(const float val);
@ -39,5 +37,4 @@ class GSAIRadiusProximity : public GSAIProximity {
// @tags - virtual // @tags - virtual
}; };
#endif #endif