2023-05-23 18:02:01 +02:00
|
|
|
/**************************************************************************/
|
|
|
|
/* aabb.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
2023-05-26 10:58:14 +02:00
|
|
|
/* PANDEMONIUM ENGINE */
|
|
|
|
/* https://pandemoniumengine.org */
|
2023-05-23 18:02:01 +02:00
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
#ifndef GDNATIVE_AABB_H
|
|
|
|
#define GDNATIVE_AABB_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
#define PANDEMONIUM_AABB_SIZE 24
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
#ifndef PANDEMONIUM_CORE_API_PANDEMONIUM_AABB_TYPE_DEFINED
|
|
|
|
#define PANDEMONIUM_CORE_API_PANDEMONIUM_AABB_TYPE_DEFINED
|
2023-05-23 18:02:01 +02:00
|
|
|
typedef struct {
|
2023-05-26 10:58:14 +02:00
|
|
|
uint8_t _dont_touch_that[PANDEMONIUM_AABB_SIZE];
|
|
|
|
} pandemonium_aabb;
|
2023-05-23 18:02:01 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// reduce extern "C" nesting for VS2013
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-05-25 21:54:24 +02:00
|
|
|
#include <gdn/gdnative.h>
|
|
|
|
#include <gdn/plane.h>
|
|
|
|
#include <gdn/vector3.h>
|
2023-05-23 18:02:01 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2023-05-26 20:19:57 +02:00
|
|
|
//real_t get_volume() const; /// get area
|
|
|
|
//_FORCE_INLINE_ bool has_no_volume() const { fix names
|
|
|
|
pandemonium_real GDAPI pandemonium_aabb_get_area(const pandemonium_aabb *p_self);
|
|
|
|
pandemonium_bool GDAPI pandemonium_aabb_has_no_area(const pandemonium_aabb *p_self);
|
|
|
|
pandemonium_bool GDAPI pandemonium_aabb_has_no_surface(const pandemonium_aabb *p_self);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_vector3 GDAPI pandemonium_aabb_get_position(const pandemonium_aabb *p_self);
|
|
|
|
void GDAPI pandemonium_aabb_set_position(const pandemonium_aabb *p_self, const pandemonium_vector3 *p_v);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_vector3 GDAPI pandemonium_aabb_get_size(const pandemonium_aabb *p_self);
|
|
|
|
void GDAPI pandemonium_aabb_set_size(const pandemonium_aabb *p_self, const pandemonium_vector3 *p_v);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:19:57 +02:00
|
|
|
pandemonium_bool GDAPI pandemonium_aabb_operator_equal(const pandemonium_aabb *p_self, const pandemonium_aabb *p_b);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:19:57 +02:00
|
|
|
//bool is_equal_approx(const AABB &p_aabb) const;
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_bool GDAPI pandemonium_aabb_intersects(const pandemonium_aabb *p_self, const pandemonium_aabb *p_with);
|
2023-05-26 20:19:57 +02:00
|
|
|
//_FORCE_INLINE_ bool intersects_inclusive(const AABB &p_aabb) const; /// Both AABBs (or their faces) overlap
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_bool GDAPI pandemonium_aabb_encloses(const pandemonium_aabb *p_self, const pandemonium_aabb *p_with);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_aabb GDAPI pandemonium_aabb_merge(const pandemonium_aabb *p_self, const pandemonium_aabb *p_with);
|
2023-05-26 20:19:57 +02:00
|
|
|
//void merge_with(const AABB &p_aabb); ///merge with another AABB
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_aabb GDAPI pandemonium_aabb_intersection(const pandemonium_aabb *p_self, const pandemonium_aabb *p_with);
|
2023-05-26 20:19:57 +02:00
|
|
|
//bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip = nullptr, Vector3 *r_normal = nullptr) const; //add variants
|
|
|
|
pandemonium_bool GDAPI pandemonium_aabb_intersects_segment(const pandemonium_aabb *p_self, const pandemonium_vector3 *p_from, const pandemonium_vector3 *p_to);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:19:57 +02:00
|
|
|
//bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip = nullptr, Vector3 *r_normal = nullptr) const;
|
|
|
|
//_FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const;
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:19:57 +02:00
|
|
|
//_FORCE_INLINE_ bool intersects_convex_shape(const Plane *p_planes, int p_plane_count, const Vector3 *p_points, int p_point_count) const;
|
|
|
|
//_FORCE_INLINE_ bool inside_convex_shape(const Plane *p_planes, int p_plane_count) const;
|
|
|
|
pandemonium_bool GDAPI pandemonium_aabb_intersects_plane(const pandemonium_aabb *p_self, const pandemonium_plane *p_plane);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_bool GDAPI pandemonium_aabb_has_point(const pandemonium_aabb *p_self, const pandemonium_vector3 *p_point);
|
|
|
|
pandemonium_vector3 GDAPI pandemonium_aabb_get_support(const pandemonium_aabb *p_self, const pandemonium_vector3 *p_dir);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_vector3 GDAPI pandemonium_aabb_get_longest_axis(const pandemonium_aabb *p_self);
|
|
|
|
pandemonium_int GDAPI pandemonium_aabb_get_longest_axis_index(const pandemonium_aabb *p_self);
|
|
|
|
pandemonium_real GDAPI pandemonium_aabb_get_longest_axis_size(const pandemonium_aabb *p_self);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_vector3 GDAPI pandemonium_aabb_get_shortest_axis(const pandemonium_aabb *p_self);
|
|
|
|
pandemonium_int GDAPI pandemonium_aabb_get_shortest_axis_index(const pandemonium_aabb *p_self);
|
|
|
|
pandemonium_real GDAPI pandemonium_aabb_get_shortest_axis_size(const pandemonium_aabb *p_self);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_aabb GDAPI pandemonium_aabb_grow(const pandemonium_aabb *p_self, const pandemonium_real p_by);
|
2023-05-26 20:19:57 +02:00
|
|
|
//_FORCE_INLINE_ void grow_by(real_t p_amount);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:19:57 +02:00
|
|
|
//void get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const;
|
2023-05-26 10:58:14 +02:00
|
|
|
pandemonium_vector3 GDAPI pandemonium_aabb_get_endpoint(const pandemonium_aabb *p_self, const pandemonium_int p_idx);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
2023-05-26 20:19:57 +02:00
|
|
|
pandemonium_aabb GDAPI pandemonium_aabb_expand(const pandemonium_aabb *p_self, const pandemonium_vector3 *p_to_point);
|
|
|
|
//_FORCE_INLINE_ void project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const;
|
|
|
|
//_FORCE_INLINE_ void expand_to(const Vector3 &p_vector); /** expand to contain a point if necessary */
|
|
|
|
//bool create_from_points(const Vector<Vector3> &p_points);
|
|
|
|
|
|
|
|
//_FORCE_INLINE_ AABB abs() const {
|
|
|
|
|
|
|
|
//Variant intersects_segmentv(const Vector3 &p_from, const Vector3 &p_to) const;
|
|
|
|
//Variant intersects_rayv(const Vector3 &p_from, const Vector3 &p_dir) const;
|
|
|
|
|
|
|
|
//_FORCE_INLINE_ void quantize(real_t p_unit);
|
|
|
|
//_FORCE_INLINE_ AABB quantized(real_t p_unit) const;
|
|
|
|
|
|
|
|
//_FORCE_INLINE_ void set_end(const Vector3 &p_end) {
|
|
|
|
//_FORCE_INLINE_ Vector3 get_end() const {
|
|
|
|
//_FORCE_INLINE_ Vector3 get_center() const {
|
|
|
|
|
|
|
|
pandemonium_string GDAPI pandemonium_aabb_as_string(const pandemonium_aabb *p_self);
|
|
|
|
|
|
|
|
void GDAPI pandemonium_aabb_new(pandemonium_aabb *r_dest, const pandemonium_vector3 *p_pos, const pandemonium_vector3 *p_size);
|
2023-05-23 18:02:01 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // GDNATIVE_AABB_H
|