summaryrefslogtreecommitdiff
path: root/core/bind
diff options
context:
space:
mode:
authorMichael Alexsander Silva Dias <michaelalexsander@protonmail.com>2019-08-25 18:02:16 -0300
committerMichael Alexsander Silva Dias <michaelalexsander@protonmail.com>2019-08-27 18:01:05 -0300
commit6cc54a58647454850c5475f6759c1bbbb76d68d3 (patch)
tree6da646bd34aca7633140b9f308bc4726c6cdfb79 /core/bind
parentc59da91aad4c73c68e5e2884674f5fb3c3340751 (diff)
Add 'is_point_in_circle()' to Geometry class, and general file cleanup
Diffstat (limited to 'core/bind')
-rw-r--r--core/bind/core_bind.cpp6
-rw-r--r--core/bind/core_bind.h107
2 files changed, 51 insertions, 62 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index b5e84d49a0..ce0f47de9c 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -1432,6 +1432,11 @@ PoolVector<Plane> _Geometry::build_capsule_planes(float p_radius, float p_height
return Geometry::build_capsule_planes(p_radius, p_height, p_sides, p_lats, p_axis);
}
+bool _Geometry::is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius) {
+
+ return Geometry::is_point_in_circle(p_point, p_circle_pos, p_circle_radius);
+}
+
real_t _Geometry::segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius) {
return Geometry::segment_intersects_circle(p_from, p_to, p_circle_pos, p_circle_radius);
@@ -1727,6 +1732,7 @@ void _Geometry::_bind_methods() {
ClassDB::bind_method(D_METHOD("build_box_planes", "extents"), &_Geometry::build_box_planes);
ClassDB::bind_method(D_METHOD("build_cylinder_planes", "radius", "height", "sides", "axis"), &_Geometry::build_cylinder_planes, DEFVAL(Vector3::AXIS_Z));
ClassDB::bind_method(D_METHOD("build_capsule_planes", "radius", "height", "sides", "lats", "axis"), &_Geometry::build_capsule_planes, DEFVAL(Vector3::AXIS_Z));
+ ClassDB::bind_method(D_METHOD("is_point_in_circle", "point", "circle_position", "circle_radius"), &_Geometry::is_point_in_circle);
ClassDB::bind_method(D_METHOD("segment_intersects_circle", "segment_from", "segment_to", "circle_position", "circle_radius"), &_Geometry::segment_intersects_circle);
ClassDB::bind_method(D_METHOD("segment_intersects_segment_2d", "from_a", "to_a", "from_b", "to_b"), &_Geometry::segment_intersects_segment_2d);
ClassDB::bind_method(D_METHOD("line_intersects_line_2d", "from_a", "dir_a", "from_b", "dir_b"), &_Geometry::line_intersects_line_2d);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 76ba2dc0a5..561bba53c9 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -109,11 +109,11 @@ public:
};
enum PowerState {
- POWERSTATE_UNKNOWN, /**< cannot determine power status */
- POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */
- POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */
- POWERSTATE_CHARGING, /**< Plugged in, charging battery */
- POWERSTATE_CHARGED /**< Plugged in, battery charged */
+ POWERSTATE_UNKNOWN, // Cannot determine power status.
+ POWERSTATE_ON_BATTERY, // Not plugged in, running on the battery.
+ POWERSTATE_NO_BATTERY, // Plugged in, no battery available.
+ POWERSTATE_CHARGING, // Plugged in, charging battery.
+ POWERSTATE_CHARGED // Plugged in, battery charged.
};
enum Weekday {
@@ -127,8 +127,8 @@ public:
};
enum Month {
- /// Start at 1 to follow Windows SYSTEMTIME structure
- /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
+ // Start at 1 to follow Windows SYSTEMTIME structure
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
MONTH_JANUARY = 1,
MONTH_FEBRUARY,
MONTH_MARCH,
@@ -264,24 +264,6 @@ public:
bool is_scancode_unicode(uint32_t p_unicode) const;
int find_scancode_from_string(const String &p_code) const;
- /*
- struct Date {
-
- int year;
- Month month;
- int day;
- Weekday weekday;
- bool dst;
- };
-
- struct Time {
-
- int hour;
- int min;
- int sec;
- };
-*/
-
void set_use_file_access_save_and_swap(bool p_enable);
void set_native_icon(const String &p_filename);
@@ -409,6 +391,7 @@ public:
PoolVector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
PoolVector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
PoolVector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes);
+ bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
int get_uv84_normal_bit(const Vector3 &p_vector);
@@ -425,17 +408,17 @@ public:
OPERATION_INTERSECTION,
OPERATION_XOR
};
- // 2D polygon boolean operations
- Array merge_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // union (add)
- Array clip_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // difference (subtract)
- Array intersect_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // common area (multiply)
- Array exclude_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // all but common area (xor)
+ // 2D polygon boolean operations.
+ Array merge_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
+ Array clip_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
+ Array intersect_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
+ Array exclude_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
- // 2D polyline vs polygon operations
- Array clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // cut
- Array intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // chop
+ // 2D polyline vs polygon operations.
+ Array clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
+ Array intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
- // 2D offset polygons/polylines
+ // 2D offset polygons/polylines.
enum PolyJoinType {
JOIN_SQUARE,
JOIN_ROUND,
@@ -491,24 +474,24 @@ public:
Error open_encrypted_pass(const String &p_path, ModeFlags p_mode_flags, const String &p_pass);
Error open_compressed(const String &p_path, ModeFlags p_mode_flags, CompressionMode p_compress_mode = COMPRESSION_FASTLZ);
- Error open(const String &p_path, ModeFlags p_mode_flags); ///< open a file
- void close(); ///< close a file
- bool is_open() const; ///< true when file is open
+ Error open(const String &p_path, ModeFlags p_mode_flags); // open a file.
+ void close(); // Close a file.
+ bool is_open() const; // True when file is open.
- String get_path() const; /// returns the path for the current open file
- String get_path_absolute() const; /// returns the absolute path for the current open file
+ String get_path() const; // Returns the path for the current open file.
+ String get_path_absolute() const; // Returns the absolute path for the current open file.
- void seek(int64_t p_position); ///< seek to a given position
- void seek_end(int64_t p_position = 0); ///< seek from the end of file
- int64_t get_position() const; ///< get position in the file
- int64_t get_len() const; ///< get size of the file
+ void seek(int64_t p_position); // Seek to a given position.
+ void seek_end(int64_t p_position = 0); // Seek from the end of file.
+ int64_t get_position() const; // Get position in the file.
+ int64_t get_len() const; // Get size of the file.
- bool eof_reached() const; ///< reading passed EOF
+ bool eof_reached() const; // Reading passed EOF.
- uint8_t get_8() const; ///< get a byte
- uint16_t get_16() const; ///< get 16 bits uint
- uint32_t get_32() const; ///< get 32 bits uint
- uint64_t get_64() const; ///< get 64 bits uint
+ uint8_t get_8() const; // Get a byte.
+ uint16_t get_16() const; // Get 16 bits uint.
+ uint32_t get_32() const; // Get 32 bits uint.
+ uint64_t get_64() const; // Get 64 bits uint.
float get_float() const;
double get_double() const;
@@ -516,27 +499,27 @@ public:
Variant get_var(bool p_allow_objects = false) const;
- PoolVector<uint8_t> get_buffer(int p_length) const; ///< get an array of bytes
+ PoolVector<uint8_t> get_buffer(int p_length) const; // Get an array of bytes.
String get_line() const;
Vector<String> get_csv_line(const String &p_delim = ",") const;
String get_as_text() const;
String get_md5(const String &p_path) const;
String get_sha256(const String &p_path) const;
- /**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac)
+ /* Use this for files WRITTEN in _big_ endian machines (ie, amiga/mac).
* It's not about the current CPU type but file formats.
- * this flags get reset to false (little endian) on each open
+ * This flags get reset to false (little endian) on each open.
*/
void set_endian_swap(bool p_swap);
bool get_endian_swap();
- Error get_error() const; ///< get last error
+ Error get_error() const; // Get last error.
- void store_8(uint8_t p_dest); ///< store a byte
- void store_16(uint16_t p_dest); ///< store 16 bits uint
- void store_32(uint32_t p_dest); ///< store 32 bits uint
- void store_64(uint64_t p_dest); ///< store 64 bits uint
+ void store_8(uint8_t p_dest); // Store a byte.
+ void store_16(uint16_t p_dest); // Store 16 bits uint.
+ void store_32(uint32_t p_dest); // Store 32 bits uint.
+ void store_64(uint64_t p_dest); // Store 64 bits uint.
void store_float(float p_dest);
void store_double(double p_dest);
@@ -549,11 +532,11 @@ public:
virtual void store_pascal_string(const String &p_string);
virtual String get_pascal_string();
- void store_buffer(const PoolVector<uint8_t> &p_buffer); ///< store an array of bytes
+ void store_buffer(const PoolVector<uint8_t> &p_buffer); // Store an array of bytes.
void store_var(const Variant &p_var, bool p_full_objects = false);
- bool file_exists(const String &p_name) const; ///< return true if a file exists
+ bool file_exists(const String &p_name) const; // Return true if a file exists.
uint64_t get_modified_time(const String &p_file) const;
@@ -575,18 +558,18 @@ protected:
public:
Error open(const String &p_path);
- Error list_dir_begin(bool p_skip_navigational = false, bool p_skip_hidden = false); ///< This starts dir listing
+ Error list_dir_begin(bool p_skip_navigational = false, bool p_skip_hidden = false); // This starts dir listing.
String get_next();
bool current_is_dir() const;
- void list_dir_end(); ///<
+ void list_dir_end();
int get_drive_count();
String get_drive(int p_drive);
int get_current_drive();
- Error change_dir(String p_dir); ///< can be relative or absolute, return false on success
- String get_current_dir(); ///< return current dir location
+ Error change_dir(String p_dir); // Can be relative or absolute, return false on success.
+ String get_current_dir(); // Return current dir location.
Error make_dir(String p_dir);
Error make_dir_recursive(String p_dir);