Add 'is_point_in_circle()' to Geometry class, and general file cleanup

This commit is contained in:
Michael Alexsander Silva Dias 2019-08-25 18:02:16 -03:00
parent c59da91aad
commit 6cc54a5864
5 changed files with 213 additions and 266 deletions

View file

@ -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);