gdnative/include/gdn/aabb.h
2023-05-26 20:19:57 +02:00

137 lines
7.3 KiB
C

/**************************************************************************/
/* aabb.h */
/**************************************************************************/
/* This file is part of: */
/* PANDEMONIUM ENGINE */
/* https://pandemoniumengine.org */
/**************************************************************************/
/* 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>
#define PANDEMONIUM_AABB_SIZE 24
#ifndef PANDEMONIUM_CORE_API_PANDEMONIUM_AABB_TYPE_DEFINED
#define PANDEMONIUM_CORE_API_PANDEMONIUM_AABB_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[PANDEMONIUM_AABB_SIZE];
} pandemonium_aabb;
#endif
// reduce extern "C" nesting for VS2013
#ifdef __cplusplus
}
#endif
#include <gdn/gdnative.h>
#include <gdn/plane.h>
#include <gdn/vector3.h>
#ifdef __cplusplus
extern "C" {
#endif
//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);
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);
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);
pandemonium_bool GDAPI pandemonium_aabb_operator_equal(const pandemonium_aabb *p_self, const pandemonium_aabb *p_b);
//bool is_equal_approx(const AABB &p_aabb) const;
pandemonium_bool GDAPI pandemonium_aabb_intersects(const pandemonium_aabb *p_self, const pandemonium_aabb *p_with);
//_FORCE_INLINE_ bool intersects_inclusive(const AABB &p_aabb) const; /// Both AABBs (or their faces) overlap
pandemonium_bool GDAPI pandemonium_aabb_encloses(const pandemonium_aabb *p_self, const pandemonium_aabb *p_with);
pandemonium_aabb GDAPI pandemonium_aabb_merge(const pandemonium_aabb *p_self, const pandemonium_aabb *p_with);
//void merge_with(const AABB &p_aabb); ///merge with another AABB
pandemonium_aabb GDAPI pandemonium_aabb_intersection(const pandemonium_aabb *p_self, const pandemonium_aabb *p_with);
//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);
//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;
//_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);
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);
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);
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);
pandemonium_aabb GDAPI pandemonium_aabb_grow(const pandemonium_aabb *p_self, const pandemonium_real p_by);
//_FORCE_INLINE_ void grow_by(real_t p_amount);
//void get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const;
pandemonium_vector3 GDAPI pandemonium_aabb_get_endpoint(const pandemonium_aabb *p_self, const pandemonium_int p_idx);
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);
#ifdef __cplusplus
}
#endif
#endif // GDNATIVE_AABB_H