summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authoralexholly <alexander.holland@live.de>2017-06-06 20:33:51 +0200
committerRĂ©mi Verschelde <rverschelde@gmail.com>2017-06-09 15:54:02 +0200
commit935f730170d75955f708b5014da3e11c95fcdac4 (patch)
tree693c281eb4ed706ba4be9867e7f1276450e63e99 /core/math
parent63fd693c1ebd2d3d2c23f3969ca8f6f3e18ff3e4 (diff)
renamed all Rect3.pos to Rect3.position
Diffstat (limited to 'core/math')
-rw-r--r--core/math/bsp_tree.cpp6
-rw-r--r--core/math/camera_matrix.cpp4
-rw-r--r--core/math/face3.cpp28
-rw-r--r--core/math/face3.h54
-rw-r--r--core/math/geometry.cpp6
-rw-r--r--core/math/octree.h26
-rw-r--r--core/math/quick_hull.cpp2
-rw-r--r--core/math/rect3.cpp92
-rw-r--r--core/math/rect3.h118
-rw-r--r--core/math/transform.h38
-rw-r--r--core/math/triangle_mesh.cpp6
11 files changed, 190 insertions, 190 deletions
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index 9bbce752c0..327a6017c3 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -39,8 +39,8 @@ void BSP_Tree::from_aabb(const Rect3 &p_aabb) {
Vector3 n;
n[i] = 1;
- planes.push_back(Plane(n, p_aabb.pos[i] + p_aabb.size[i]));
- planes.push_back(Plane(-n, -p_aabb.pos[i]));
+ planes.push_back(Plane(n, p_aabb.position[i] + p_aabb.size[i]));
+ planes.push_back(Plane(-n, -p_aabb.position[i]));
}
nodes.clear();
@@ -552,7 +552,7 @@ BSP_Tree::BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius) {
if (first) {
- aabb.pos = f.vertex[0];
+ aabb.position = f.vertex[0];
first = false;
} else {
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index c26b12b0f0..33ad522315 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -559,8 +559,8 @@ void CameraMatrix::make_scale(const Vector3 &p_scale) {
void CameraMatrix::scale_translate_to_fit(const Rect3 &p_aabb) {
- Vector3 min = p_aabb.pos;
- Vector3 max = p_aabb.pos + p_aabb.size;
+ Vector3 min = p_aabb.position;
+ Vector3 max = p_aabb.position + p_aabb.size;
matrix[0][0] = 2 / (max.x - min.x);
matrix[1][0] = 0;
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index 6d772cf08c..5b66e1999a 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -197,20 +197,20 @@ bool Face3::intersects_aabb(const Rect3 &p_aabb) const {
/** TEST FACE AXIS */
-#define TEST_AXIS(m_ax) \
- { \
- real_t aabb_min = p_aabb.pos.m_ax; \
- real_t aabb_max = p_aabb.pos.m_ax + p_aabb.size.m_ax; \
- real_t tri_min, tri_max; \
- for (int i = 0; i < 3; i++) { \
- if (i == 0 || vertex[i].m_ax > tri_max) \
- tri_max = vertex[i].m_ax; \
- if (i == 0 || vertex[i].m_ax < tri_min) \
- tri_min = vertex[i].m_ax; \
- } \
- \
- if (tri_max < aabb_min || aabb_max < tri_min) \
- return false; \
+#define TEST_AXIS(m_ax) \
+ { \
+ real_t aabb_min = p_aabb.position.m_ax; \
+ real_t aabb_max = p_aabb.position.m_ax + p_aabb.size.m_ax; \
+ real_t tri_min, tri_max; \
+ for (int i = 0; i < 3; i++) { \
+ if (i == 0 || vertex[i].m_ax > tri_max) \
+ tri_max = vertex[i].m_ax; \
+ if (i == 0 || vertex[i].m_ax < tri_min) \
+ tri_min = vertex[i].m_ax; \
+ } \
+ \
+ if (tri_max < aabb_min || aabb_max < tri_min) \
+ return false; \
}
TEST_AXIS(x);
diff --git a/core/math/face3.h b/core/math/face3.h
index 31ab72b925..1cc94321c3 100644
--- a/core/math/face3.h
+++ b/core/math/face3.h
@@ -101,7 +101,7 @@ bool Face3::intersects_aabb2(const Rect3 &p_aabb) const {
Vector3 perp = (vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]);
Vector3 half_extents = p_aabb.size * 0.5;
- Vector3 ofs = p_aabb.pos + half_extents;
+ Vector3 ofs = p_aabb.position + half_extents;
Vector3 sup = Vector3(
(perp.x > 0) ? -half_extents.x : half_extents.x,
@@ -117,8 +117,8 @@ bool Face3::intersects_aabb2(const Rect3 &p_aabb) const {
#define TEST_AXIS(m_ax) \
{ \
- real_t aabb_min = p_aabb.pos.m_ax; \
- real_t aabb_max = p_aabb.pos.m_ax + p_aabb.size.m_ax; \
+ real_t aabb_min = p_aabb.position.m_ax; \
+ real_t aabb_max = p_aabb.position.m_ax + p_aabb.size.m_ax; \
real_t tri_min, tri_max; \
for (int i = 0; i < 3; i++) { \
if (i == 0 || vertex[i].m_ax > tri_max) \
@@ -150,68 +150,68 @@ bool Face3::intersects_aabb2(const Rect3 &p_aabb) const {
case 0: {
- from = Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y, p_aabb.pos.z);
- to = Vector3(p_aabb.pos.x, p_aabb.pos.y, p_aabb.pos.z);
+ from = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z);
+ to = Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z);
} break;
case 1: {
- from = Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y, p_aabb.pos.z + p_aabb.size.z);
- to = Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y, p_aabb.pos.z);
+ from = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z);
+ to = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z);
} break;
case 2: {
- from = Vector3(p_aabb.pos.x, p_aabb.pos.y, p_aabb.pos.z + p_aabb.size.z);
- to = Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y, p_aabb.pos.z + p_aabb.size.z);
+ from = Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z);
+ to = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z);
} break;
case 3: {
- from = Vector3(p_aabb.pos.x, p_aabb.pos.y, p_aabb.pos.z);
- to = Vector3(p_aabb.pos.x, p_aabb.pos.y, p_aabb.pos.z + p_aabb.size.z);
+ from = Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z);
+ to = Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z);
} break;
case 4: {
- from = Vector3(p_aabb.pos.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z);
- to = Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z);
+ from = Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z);
+ to = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z);
} break;
case 5: {
- from = Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z);
- to = Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z + p_aabb.size.z);
+ from = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z);
+ to = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z);
} break;
case 6: {
- from = Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z + p_aabb.size.z);
- to = Vector3(p_aabb.pos.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z + p_aabb.size.z);
+ from = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z);
+ to = Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z);
} break;
case 7: {
- from = Vector3(p_aabb.pos.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z + p_aabb.size.z);
- to = Vector3(p_aabb.pos.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z);
+ from = Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z);
+ to = Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z);
} break;
case 8: {
- from = Vector3(p_aabb.pos.x, p_aabb.pos.y, p_aabb.pos.z + p_aabb.size.z);
- to = Vector3(p_aabb.pos.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z + p_aabb.size.z);
+ from = Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z);
+ to = Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z);
} break;
case 9: {
- from = Vector3(p_aabb.pos.x, p_aabb.pos.y, p_aabb.pos.z);
- to = Vector3(p_aabb.pos.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z);
+ from = Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z);
+ to = Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z);
} break;
case 10: {
- from = Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y, p_aabb.pos.z);
- to = Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z);
+ from = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z);
+ to = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z);
} break;
case 11: {
- from = Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y, p_aabb.pos.z + p_aabb.size.z);
- to = Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z + p_aabb.size.z);
+ from = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z);
+ to = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z);
} break;
}
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index 618017f8b3..2bea514d37 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -301,7 +301,7 @@ enum _CellFlags {
static inline void _plot_face(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z, const Vector3 &voxelsize, const Face3 &p_face) {
Rect3 aabb(Vector3(x, y, z), Vector3(len_x, len_y, len_z));
- aabb.pos = aabb.pos * voxelsize;
+ aabb.position = aabb.position * voxelsize;
aabb.size = aabb.size * voxelsize;
if (!p_face.intersects_aabb(aabb))
@@ -640,7 +640,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
Face3 f = faces[i];
for (int j = 0; j < 3; j++) {
- f.vertex[j] -= global_aabb.pos;
+ f.vertex[j] -= global_aabb.position;
}
_plot_face(cell_status, 0, 0, 0, div_x, div_y, div_z, voxelsize, f);
}
@@ -707,7 +707,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
Vector3 &v = wrapped_faces_ptr[i].vertex[j];
v = v * voxelsize;
- v += global_aabb.pos;
+ v += global_aabb.position;
}
}
diff --git a/core/math/octree.h b/core/math/octree.h
index 4cc046ddf4..010c1b18f7 100644
--- a/core/math/octree.h
+++ b/core/math/octree.h
@@ -483,11 +483,11 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
aabb.size *= 0.5;
if (i & 1)
- aabb.pos.x += aabb.size.x;
+ aabb.position.x += aabb.size.x;
if (i & 2)
- aabb.pos.y += aabb.size.y;
+ aabb.position.y += aabb.size.y;
if (i & 4)
- aabb.pos.z += aabb.size.z;
+ aabb.position.z += aabb.size.z;
if (aabb.intersects_inclusive(p_element->aabb)) {
/* if actually intersects, create the child */
@@ -544,11 +544,11 @@ void Octree<T, use_pairs, AL>::_ensure_valid_root(const Rect3 &p_aabb) {
while (!base.encloses(p_aabb)) {
- if (ABS(base.pos.x + base.size.x) <= ABS(base.pos.x)) {
+ if (ABS(base.position.x + base.size.x) <= ABS(base.position.x)) {
/* grow towards positive */
base.size *= 2.0;
} else {
- base.pos -= base.size;
+ base.position -= base.size;
base.size *= 2.0;
}
}
@@ -576,14 +576,14 @@ void Octree<T, use_pairs, AL>::_ensure_valid_root(const Rect3 &p_aabb) {
octant_count++;
root->parent = gp;
- if (ABS(base.pos.x + base.size.x) <= ABS(base.pos.x)) {
+ if (ABS(base.position.x + base.size.x) <= ABS(base.position.x)) {
/* grow towards positive */
base.size *= 2.0;
gp->aabb = base;
gp->children[0] = root;
root->parent_index = 0;
} else {
- base.pos -= base.size;
+ base.position -= base.size;
base.size *= 2.0;
gp->aabb = base;
gp->children[(1 << 0) | (1 << 1) | (1 << 2)] = root; // add at all-positive
@@ -797,9 +797,9 @@ OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const Rect3 &p_a
// check for AABB validity
#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V(p_aabb.pos.x > 1e15 || p_aabb.pos.x < -1e15, 0);
- ERR_FAIL_COND_V(p_aabb.pos.y > 1e15 || p_aabb.pos.y < -1e15, 0);
- ERR_FAIL_COND_V(p_aabb.pos.z > 1e15 || p_aabb.pos.z < -1e15, 0);
+ ERR_FAIL_COND_V(p_aabb.position.x > 1e15 || p_aabb.position.x < -1e15, 0);
+ ERR_FAIL_COND_V(p_aabb.position.y > 1e15 || p_aabb.position.y < -1e15, 0);
+ ERR_FAIL_COND_V(p_aabb.position.z > 1e15 || p_aabb.position.z < -1e15, 0);
ERR_FAIL_COND_V(p_aabb.size.x > 1e15 || p_aabb.size.x < 0.0, 0);
ERR_FAIL_COND_V(p_aabb.size.y > 1e15 || p_aabb.size.y < 0.0, 0);
ERR_FAIL_COND_V(p_aabb.size.z > 1e15 || p_aabb.size.z < 0.0, 0);
@@ -837,9 +837,9 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) {
#ifdef DEBUG_ENABLED
// check for AABB validity
- ERR_FAIL_COND(p_aabb.pos.x > 1e15 || p_aabb.pos.x < -1e15);
- ERR_FAIL_COND(p_aabb.pos.y > 1e15 || p_aabb.pos.y < -1e15);
- ERR_FAIL_COND(p_aabb.pos.z > 1e15 || p_aabb.pos.z < -1e15);
+ ERR_FAIL_COND(p_aabb.position.x > 1e15 || p_aabb.position.x < -1e15);
+ ERR_FAIL_COND(p_aabb.position.y > 1e15 || p_aabb.position.y < -1e15);
+ ERR_FAIL_COND(p_aabb.position.z > 1e15 || p_aabb.position.z < -1e15);
ERR_FAIL_COND(p_aabb.size.x > 1e15 || p_aabb.size.x < 0.0);
ERR_FAIL_COND(p_aabb.size.y > 1e15 || p_aabb.size.y < 0.0);
ERR_FAIL_COND(p_aabb.size.z > 1e15 || p_aabb.size.z < 0.0);
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index ce93720067..9f594ba4fa 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -42,7 +42,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
for (int i = 0; i < p_points.size(); i++) {
if (i == 0) {
- aabb.pos = p_points[i];
+ aabb.position = p_points[i];
} else {
aabb.expand_to(p_points[i]);
}
diff --git a/core/math/rect3.cpp b/core/math/rect3.cpp
index 39b0beb071..973607f565 100644
--- a/core/math/rect3.cpp
+++ b/core/math/rect3.cpp
@@ -38,11 +38,11 @@ real_t Rect3::get_area() const {
bool Rect3::operator==(const Rect3 &p_rval) const {
- return ((pos == p_rval.pos) && (size == p_rval.size));
+ return ((position == p_rval.position) && (size == p_rval.size));
}
bool Rect3::operator!=(const Rect3 &p_rval) const {
- return ((pos != p_rval.pos) || (size != p_rval.size));
+ return ((position != p_rval.position) || (size != p_rval.size));
}
void Rect3::merge_with(const Rect3 &p_aabb) {
@@ -51,8 +51,8 @@ void Rect3::merge_with(const Rect3 &p_aabb) {
Vector3 end_1, end_2;
Vector3 min, max;
- beg_1 = pos;
- beg_2 = p_aabb.pos;
+ beg_1 = position;
+ beg_2 = p_aabb.position;
end_1 = Vector3(size.x, size.y, size.z) + beg_1;
end_2 = Vector3(p_aabb.size.x, p_aabb.size.y, p_aabb.size.z) + beg_2;
@@ -64,16 +64,16 @@ void Rect3::merge_with(const Rect3 &p_aabb) {
max.y = (end_1.y > end_2.y) ? end_1.y : end_2.y;
max.z = (end_1.z > end_2.z) ? end_1.z : end_2.z;
- pos = min;
+ position = min;
size = max - min;
}
Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
- Vector3 src_min = pos;
- Vector3 src_max = pos + size;
- Vector3 dst_min = p_aabb.pos;
- Vector3 dst_max = p_aabb.pos + p_aabb.size;
+ Vector3 src_min = position;
+ Vector3 src_max = position + size;
+ Vector3 dst_min = p_aabb.position;
+ Vector3 dst_max = p_aabb.position + p_aabb.size;
Vector3 min, max;
@@ -107,18 +107,18 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
bool Rect3::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const {
Vector3 c1, c2;
- Vector3 end = pos + size;
+ Vector3 end = position + size;
real_t near = -1e20;
real_t far = 1e20;
int axis = 0;
for (int i = 0; i < 3; i++) {
if (p_dir[i] == 0) {
- if ((p_from[i] < pos[i]) || (p_from[i] > end[i])) {
+ if ((p_from[i] < position[i]) || (p_from[i] > end[i])) {
return false;
}
} else { // ray not parallel to planes in this direction
- c1[i] = (pos[i] - p_from[i]) / p_dir[i];
+ c1[i] = (position[i] - p_from[i]) / p_dir[i];
c2[i] = (end[i] - p_from[i]) / p_dir[i];
if (c1[i] > c2[i]) {
@@ -156,7 +156,7 @@ bool Rect3::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vecto
for (int i = 0; i < 3; i++) {
real_t seg_from = p_from[i];
real_t seg_to = p_to[i];
- real_t box_begin = pos[i];
+ real_t box_begin = position[i];
real_t box_end = box_begin + size[i];
real_t cmin, cmax;
real_t csign;
@@ -208,14 +208,14 @@ bool Rect3::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vecto
bool Rect3::intersects_plane(const Plane &p_plane) const {
Vector3 points[8] = {
- Vector3(pos.x, pos.y, pos.z),
- Vector3(pos.x, pos.y, pos.z + size.z),
- Vector3(pos.x, pos.y + size.y, pos.z),
- Vector3(pos.x, pos.y + size.y, pos.z + size.z),
- Vector3(pos.x + size.x, pos.y, pos.z),
- Vector3(pos.x + size.x, pos.y, pos.z + size.z),
- Vector3(pos.x + size.x, pos.y + size.y, pos.z),
- Vector3(pos.x + size.x, pos.y + size.y, pos.z + size.z),
+ Vector3(position.x, position.y, position.z),
+ Vector3(position.x, position.y, position.z + size.z),
+ Vector3(position.x, position.y + size.y, position.z),
+ Vector3(position.x, position.y + size.y, position.z + size.z),
+ Vector3(position.x + size.x, position.y, position.z),
+ Vector3(position.x + size.x, position.y, position.z + size.z),
+ Vector3(position.x + size.x, position.y + size.y, position.z),
+ Vector3(position.x + size.x, position.y + size.y, position.z + size.z),
};
bool over = false;
@@ -327,68 +327,68 @@ void Rect3::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
case 0: {
- r_from = Vector3(pos.x + size.x, pos.y, pos.z);
- r_to = Vector3(pos.x, pos.y, pos.z);
+ r_from = Vector3(position.x + size.x, position.y, position.z);
+ r_to = Vector3(position.x, position.y, position.z);
} break;
case 1: {
- r_from = Vector3(pos.x + size.x, pos.y, pos.z + size.z);
- r_to = Vector3(pos.x + size.x, pos.y, pos.z);
+ r_from = Vector3(position.x + size.x, position.y, position.z + size.z);
+ r_to = Vector3(position.x + size.x, position.y, position.z);
} break;
case 2: {
- r_from = Vector3(pos.x, pos.y, pos.z + size.z);
- r_to = Vector3(pos.x + size.x, pos.y, pos.z + size.z);
+ r_from = Vector3(position.x, position.y, position.z + size.z);
+ r_to = Vector3(position.x + size.x, position.y, position.z + size.z);
} break;
case 3: {
- r_from = Vector3(pos.x, pos.y, pos.z);
- r_to = Vector3(pos.x, pos.y, pos.z + size.z);
+ r_from = Vector3(position.x, position.y, position.z);
+ r_to = Vector3(position.x, position.y, position.z + size.z);
} break;
case 4: {
- r_from = Vector3(pos.x, pos.y + size.y, pos.z);
- r_to = Vector3(pos.x + size.x, pos.y + size.y, pos.z);
+ r_from = Vector3(position.x, position.y + size.y, position.z);
+ r_to = Vector3(position.x + size.x, position.y + size.y, position.z);
} break;
case 5: {
- r_from = Vector3(pos.x + size.x, pos.y + size.y, pos.z);
- r_to = Vector3(pos.x + size.x, pos.y + size.y, pos.z + size.z);
+ r_from = Vector3(position.x + size.x, position.y + size.y, position.z);
+ r_to = Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
} break;
case 6: {
- r_from = Vector3(pos.x + size.x, pos.y + size.y, pos.z + size.z);
- r_to = Vector3(pos.x, pos.y + size.y, pos.z + size.z);
+ r_from = Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
+ r_to = Vector3(position.x, position.y + size.y, position.z + size.z);
} break;
case 7: {
- r_from = Vector3(pos.x, pos.y + size.y, pos.z + size.z);
- r_to = Vector3(pos.x, pos.y + size.y, pos.z);
+ r_from = Vector3(position.x, position.y + size.y, position.z + size.z);
+ r_to = Vector3(position.x, position.y + size.y, position.z);
} break;
case 8: {
- r_from = Vector3(pos.x, pos.y, pos.z + size.z);
- r_to = Vector3(pos.x, pos.y + size.y, pos.z + size.z);
+ r_from = Vector3(position.x, position.y, position.z + size.z);
+ r_to = Vector3(position.x, position.y + size.y, position.z + size.z);
} break;
case 9: {
- r_from = Vector3(pos.x, pos.y, pos.z);
- r_to = Vector3(pos.x, pos.y + size.y, pos.z);
+ r_from = Vector3(position.x, position.y, position.z);
+ r_to = Vector3(position.x, position.y + size.y, position.z);
} break;
case 10: {
- r_from = Vector3(pos.x + size.x, pos.y, pos.z);
- r_to = Vector3(pos.x + size.x, pos.y + size.y, pos.z);
+ r_from = Vector3(position.x + size.x, position.y, position.z);
+ r_to = Vector3(position.x + size.x, position.y + size.y, position.z);
} break;
case 11: {
- r_from = Vector3(pos.x + size.x, pos.y, pos.z + size.z);
- r_to = Vector3(pos.x + size.x, pos.y + size.y, pos.z + size.z);
+ r_from = Vector3(position.x + size.x, position.y, position.z + size.z);
+ r_to = Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
} break;
}
@@ -396,5 +396,5 @@ void Rect3::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
Rect3::operator String() const {
- return String() + pos + " - " + size;
+ return String() + position + " - " + size;
}
diff --git a/core/math/rect3.h b/core/math/rect3.h
index 136a156151..b7c94ad9f7 100644
--- a/core/math/rect3.h
+++ b/core/math/rect3.h
@@ -36,12 +36,12 @@
/**
* AABB / AABB (Axis Aligned Bounding Box)
- * This is implemented by a point (pos) and the box size
+ * This is implemented by a point (position) and the box size
*/
class Rect3 {
public:
- Vector3 pos;
+ Vector3 position;
Vector3 size;
real_t get_area() const; /// get area
@@ -55,8 +55,8 @@ public:
return (size.x <= CMP_EPSILON && size.y <= CMP_EPSILON && size.z <= CMP_EPSILON);
}
- const Vector3 &get_pos() const { return pos; }
- void set_pos(const Vector3 &p_pos) { pos = p_pos; }
+ const Vector3 &get_position() const { return position; }
+ void set_position(const Vector3 &p_pos) { position = p_pos; }
const Vector3 &get_size() const { return size; }
void set_size(const Vector3 &p_size) { size = p_size; }
@@ -102,24 +102,24 @@ public:
_FORCE_INLINE_ Rect3() {}
inline Rect3(const Vector3 &p_pos, const Vector3 &p_size) {
- pos = p_pos;
+ position = p_pos;
size = p_size;
}
};
inline bool Rect3::intersects(const Rect3 &p_aabb) const {
- if (pos.x >= (p_aabb.pos.x + p_aabb.size.x))
+ if (position.x >= (p_aabb.position.x + p_aabb.size.x))
return false;
- if ((pos.x + size.x) <= p_aabb.pos.x)
+ if ((position.x + size.x) <= p_aabb.position.x)
return false;
- if (pos.y >= (p_aabb.pos.y + p_aabb.size.y))
+ if (position.y >= (p_aabb.position.y + p_aabb.size.y))
return false;
- if ((pos.y + size.y) <= p_aabb.pos.y)
+ if ((position.y + size.y) <= p_aabb.position.y)
return false;
- if (pos.z >= (p_aabb.pos.z + p_aabb.size.z))
+ if (position.z >= (p_aabb.position.z + p_aabb.size.z))
return false;
- if ((pos.z + size.z) <= p_aabb.pos.z)
+ if ((position.z + size.z) <= p_aabb.position.z)
return false;
return true;
@@ -127,17 +127,17 @@ inline bool Rect3::intersects(const Rect3 &p_aabb) const {
inline bool Rect3::intersects_inclusive(const Rect3 &p_aabb) const {
- if (pos.x > (p_aabb.pos.x + p_aabb.size.x))
+ if (position.x > (p_aabb.position.x + p_aabb.size.x))
return false;
- if ((pos.x + size.x) < p_aabb.pos.x)
+ if ((position.x + size.x) < p_aabb.position.x)
return false;
- if (pos.y > (p_aabb.pos.y + p_aabb.size.y))
+ if (position.y > (p_aabb.position.y + p_aabb.size.y))
return false;
- if ((pos.y + size.y) < p_aabb.pos.y)
+ if ((position.y + size.y) < p_aabb.position.y)
return false;
- if (pos.z > (p_aabb.pos.z + p_aabb.size.z))
+ if (position.z > (p_aabb.position.z + p_aabb.size.z))
return false;
- if ((pos.z + size.z) < p_aabb.pos.z)
+ if ((position.z + size.z) < p_aabb.position.z)
return false;
return true;
@@ -145,10 +145,10 @@ inline bool Rect3::intersects_inclusive(const Rect3 &p_aabb) const {
inline bool Rect3::encloses(const Rect3 &p_aabb) const {
- Vector3 src_min = pos;
- Vector3 src_max = pos + size;
- Vector3 dst_min = p_aabb.pos;
- Vector3 dst_max = p_aabb.pos + p_aabb.size;
+ Vector3 src_min = position;
+ Vector3 src_max = position + size;
+ Vector3 dst_min = p_aabb.position;
+ Vector3 dst_max = p_aabb.position + p_aabb.size;
return (
(src_min.x <= dst_min.x) &&
@@ -162,7 +162,7 @@ inline bool Rect3::encloses(const Rect3 &p_aabb) const {
Vector3 Rect3::get_support(const Vector3 &p_normal) const {
Vector3 half_extents = size * 0.5;
- Vector3 ofs = pos + half_extents;
+ Vector3 ofs = position + half_extents;
return Vector3(
(p_normal.x > 0) ? -half_extents.x : half_extents.x,
@@ -174,14 +174,14 @@ Vector3 Rect3::get_support(const Vector3 &p_normal) const {
Vector3 Rect3::get_endpoint(int p_point) const {
switch (p_point) {
- case 0: return Vector3(pos.x, pos.y, pos.z);
- case 1: return Vector3(pos.x, pos.y, pos.z + size.z);
- case 2: return Vector3(pos.x, pos.y + size.y, pos.z);
- case 3: return Vector3(pos.x, pos.y + size.y, pos.z + size.z);
- case 4: return Vector3(pos.x + size.x, pos.y, pos.z);
- case 5: return Vector3(pos.x + size.x, pos.y, pos.z + size.z);
- case 6: return Vector3(pos.x + size.x, pos.y + size.y, pos.z);
- case 7: return Vector3(pos.x + size.x, pos.y + size.y, pos.z + size.z);
+ case 0: return Vector3(position.x, position.y, position.z);
+ case 1: return Vector3(position.x, position.y, position.z + size.z);
+ case 2: return Vector3(position.x, position.y + size.y, position.z);
+ case 3: return Vector3(position.x, position.y + size.y, position.z + size.z);
+ case 4: return Vector3(position.x + size.x, position.y, position.z);
+ case 5: return Vector3(position.x + size.x, position.y, position.z + size.z);
+ case 6: return Vector3(position.x + size.x, position.y + size.y, position.z);
+ case 7: return Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
};
ERR_FAIL_V(Vector3());
@@ -192,7 +192,7 @@ bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) co
#if 1
Vector3 half_extents = size * 0.5;
- Vector3 ofs = pos + half_extents;
+ Vector3 ofs = position + half_extents;
for (int i = 0; i < p_plane_count; i++) {
const Plane &p = p_planes[i];
@@ -210,14 +210,14 @@ bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) co
//cache all points to check against!
// #warning should be easy to optimize, just use the same as when taking the support and use only that point
Vector3 points[8] = {
- Vector3(pos.x, pos.y, pos.z),
- Vector3(pos.x, pos.y, pos.z + size.z),
- Vector3(pos.x, pos.y + size.y, pos.z),
- Vector3(pos.x, pos.y + size.y, pos.z + size.z),
- Vector3(pos.x + size.x, pos.y, pos.z),
- Vector3(pos.x + size.x, pos.y, pos.z + size.z),
- Vector3(pos.x + size.x, pos.y + size.y, pos.z),
- Vector3(pos.x + size.x, pos.y + size.y, pos.z + size.z),
+ Vector3(position.x, position.y, position.z),
+ Vector3(position.x, position.y, position.z + size.z),
+ Vector3(position.x, position.y + size.y, position.z),
+ Vector3(position.x, position.y + size.y, position.z + size.z),
+ Vector3(position.x + size.x, position.y, position.z),
+ Vector3(position.x + size.x, position.y, position.z + size.z),
+ Vector3(position.x + size.x, position.y + size.y, position.z),
+ Vector3(position.x + size.x, position.y + size.y, position.z + size.z),
};
for (int i = 0; i < p_plane_count; i++) { //for each plane
@@ -246,17 +246,17 @@ bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) co
bool Rect3::has_point(const Vector3 &p_point) const {
- if (p_point.x < pos.x)
+ if (p_point.x < position.x)
return false;
- if (p_point.y < pos.y)
+ if (p_point.y < position.y)
return false;
- if (p_point.z < pos.z)
+ if (p_point.z < position.z)
return false;
- if (p_point.x > pos.x + size.x)
+ if (p_point.x > position.x + size.x)
return false;
- if (p_point.y > pos.y + size.y)
+ if (p_point.y > position.y + size.y)
return false;
- if (p_point.z > pos.z + size.z)
+ if (p_point.z > position.z + size.z)
return false;
return true;
@@ -264,8 +264,8 @@ bool Rect3::has_point(const Vector3 &p_point) const {
inline void Rect3::expand_to(const Vector3 &p_vector) {
- Vector3 begin = pos;
- Vector3 end = pos + size;
+ Vector3 begin = position;
+ Vector3 end = position + size;
if (p_vector.x < begin.x)
begin.x = p_vector.x;
@@ -281,14 +281,14 @@ inline void Rect3::expand_to(const Vector3 &p_vector) {
if (p_vector.z > end.z)
end.z = p_vector.z;
- pos = begin;
+ position = begin;
size = end - begin;
}
void Rect3::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const {
Vector3 half_extents(size.x * 0.5, size.y * 0.5, size.z * 0.5);
- Vector3 center(pos.x + half_extents.x, pos.y + half_extents.y, pos.z + half_extents.z);
+ Vector3 center(position.x + half_extents.x, position.y + half_extents.y, position.z + half_extents.z);
real_t length = p_plane.normal.abs().dot(half_extents);
real_t distance = p_plane.distance_to(center);
@@ -332,21 +332,21 @@ bool Rect3::smits_intersect_ray(const Vector3 &from, const Vector3 &dir, real_t
real_t divy = 1.0 / dir.y;
real_t divz = 1.0 / dir.z;
- Vector3 upbound = pos + size;
+ Vector3 upbound = position + size;
real_t tmin, tmax, tymin, tymax, tzmin, tzmax;
if (dir.x >= 0) {
- tmin = (pos.x - from.x) * divx;
+ tmin = (position.x - from.x) * divx;
tmax = (upbound.x - from.x) * divx;
} else {
tmin = (upbound.x - from.x) * divx;
- tmax = (pos.x - from.x) * divx;
+ tmax = (position.x - from.x) * divx;
}
if (dir.y >= 0) {
- tymin = (pos.y - from.y) * divy;
+ tymin = (position.y - from.y) * divy;
tymax = (upbound.y - from.y) * divy;
} else {
tymin = (upbound.y - from.y) * divy;
- tymax = (pos.y - from.y) * divy;
+ tymax = (position.y - from.y) * divy;
}
if ((tmin > tymax) || (tymin > tmax))
return false;
@@ -355,11 +355,11 @@ bool Rect3::smits_intersect_ray(const Vector3 &from, const Vector3 &dir, real_t
if (tymax < tmax)
tmax = tymax;
if (dir.z >= 0) {
- tzmin = (pos.z - from.z) * divz;
+ tzmin = (position.z - from.z) * divz;
tzmax = (upbound.z - from.z) * divz;
} else {
tzmin = (upbound.z - from.z) * divz;
- tzmax = (pos.z - from.z) * divz;
+ tzmax = (position.z - from.z) * divz;
}
if ((tmin > tzmax) || (tzmin > tmax))
return false;
@@ -372,9 +372,9 @@ bool Rect3::smits_intersect_ray(const Vector3 &from, const Vector3 &dir, real_t
void Rect3::grow_by(real_t p_amount) {
- pos.x -= p_amount;
- pos.y -= p_amount;
- pos.z -= p_amount;
+ position.x -= p_amount;
+ position.y -= p_amount;
+ position.z -= p_amount;
size.x += 2.0 * p_amount;
size.y += 2.0 * p_amount;
size.z += 2.0 * p_amount;
diff --git a/core/math/transform.h b/core/math/transform.h
index 4731496bf3..c39ea7826f 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -167,10 +167,10 @@ _FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const {
Vector3 x = basis.get_axis(0) * p_aabb.size.x;
Vector3 y = basis.get_axis(1) * p_aabb.size.y;
Vector3 z = basis.get_axis(2) * p_aabb.size.z;
- Vector3 pos = xform(p_aabb.pos);
+ Vector3 pos = xform(p_aabb.position);
//could be even further optimized
Rect3 new_aabb;
- new_aabb.pos = pos;
+ new_aabb.position = pos;
new_aabb.expand_to(pos + x);
new_aabb.expand_to(pos + y);
new_aabb.expand_to(pos + z);
@@ -182,14 +182,14 @@ _FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const {
#else
Vector3 vertices[8] = {
- Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z + p_aabb.size.z),
- Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z),
- Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y, p_aabb.pos.z + p_aabb.size.z),
- Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y, p_aabb.pos.z),
- Vector3(p_aabb.pos.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z + p_aabb.size.z),
- Vector3(p_aabb.pos.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z),
- Vector3(p_aabb.pos.x, p_aabb.pos.y, p_aabb.pos.z + p_aabb.size.z),
- Vector3(p_aabb.pos.x, p_aabb.pos.y, p_aabb.pos.z)
+ Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z),
+ Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z),
+ Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z),
+ Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z),
+ Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z),
+ Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z),
+ Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z),
+ Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z)
};
AABB ret;
@@ -208,19 +208,19 @@ _FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const {
/* define vertices */
Vector3 vertices[8] = {
- Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z + p_aabb.size.z),
- Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z),
- Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y, p_aabb.pos.z + p_aabb.size.z),
- Vector3(p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y, p_aabb.pos.z),
- Vector3(p_aabb.pos.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z + p_aabb.size.z),
- Vector3(p_aabb.pos.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z),
- Vector3(p_aabb.pos.x, p_aabb.pos.y, p_aabb.pos.z + p_aabb.size.z),
- Vector3(p_aabb.pos.x, p_aabb.pos.y, p_aabb.pos.z)
+ Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z),
+ Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z),
+ Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z),
+ Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z),
+ Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z),
+ Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z),
+ Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z),
+ Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z)
};
Rect3 ret;
- ret.pos = xform_inv(vertices[0]);
+ ret.position = xform_inv(vertices[0]);
for (int i = 1; i < 8; i++) {
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index 1cf1351646..08ac08d776 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -79,7 +79,7 @@ int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, in
int index = max_alloc++;
BVH *_new = &p_bvh[index];
_new->aabb = aabb;
- _new->center = aabb.pos + aabb.size * 0.5;
+ _new->center = aabb.position + aabb.size * 0.5;
_new->face_index = -1;
_new->left = left;
_new->right = right;
@@ -128,7 +128,7 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
f.indices[j] = vidx;
if (j == 0)
- bw[i].aabb.pos = vs;
+ bw[i].aabb.position = vs;
else
bw[i].aabb.expand_to(vs);
}
@@ -138,7 +138,7 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
bw[i].left = -1;
bw[i].right = -1;
bw[i].face_index = i;
- bw[i].center = bw[i].aabb.pos + bw[i].aabb.size * 0.5;
+ bw[i].center = bw[i].aabb.position + bw[i].aabb.size * 0.5;
}
vertices.resize(db.size());