summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
Diffstat (limited to 'core/math')
-rw-r--r--core/math/a_star.cpp28
-rw-r--r--core/math/a_star.h4
-rw-r--r--core/math/bsp_tree.cpp14
-rw-r--r--core/math/bsp_tree.h2
-rw-r--r--core/math/geometry.cpp44
-rw-r--r--core/math/geometry.h14
-rw-r--r--core/math/matrix3.cpp66
-rw-r--r--core/math/matrix3.h8
-rw-r--r--core/math/transform.cpp9
-rw-r--r--core/math/transform.h2
-rw-r--r--core/math/triangle_mesh.cpp48
-rw-r--r--core/math/triangle_mesh.h10
12 files changed, 140 insertions, 109 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 29f61834b4..0d6997183f 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -295,10 +295,10 @@ bool AStar::_solve(Point* begin_point, Point* end_point) {
}
-DVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
+PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
- ERR_FAIL_COND_V(!points.has(p_from_id),DVector<Vector3>());
- ERR_FAIL_COND_V(!points.has(p_to_id),DVector<Vector3>());
+ ERR_FAIL_COND_V(!points.has(p_from_id),PoolVector<Vector3>());
+ ERR_FAIL_COND_V(!points.has(p_to_id),PoolVector<Vector3>());
pass++;
@@ -307,7 +307,7 @@ DVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
Point* b = points[p_to_id];
if (a==b) {
- DVector<Vector3> ret;
+ PoolVector<Vector3> ret;
ret.push_back(a->pos);
return ret;
}
@@ -319,7 +319,7 @@ DVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
bool found_route=_solve(begin_point,end_point);
if (!found_route)
- return DVector<Vector3>();
+ return PoolVector<Vector3>();
//midpoints
Point *p=end_point;
@@ -329,11 +329,11 @@ DVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
p=p->prev_point;
}
- DVector<Vector3> path;
+ PoolVector<Vector3> path;
path.resize(pc);
{
- DVector<Vector3>::Write w = path.write();
+ PoolVector<Vector3>::Write w = path.write();
Point *p=end_point;
int idx=pc-1;
@@ -351,10 +351,10 @@ DVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
}
-DVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
+PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
- ERR_FAIL_COND_V(!points.has(p_from_id),DVector<int>());
- ERR_FAIL_COND_V(!points.has(p_to_id),DVector<int>());
+ ERR_FAIL_COND_V(!points.has(p_from_id),PoolVector<int>());
+ ERR_FAIL_COND_V(!points.has(p_to_id),PoolVector<int>());
pass++;
@@ -363,7 +363,7 @@ DVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
Point* b = points[p_to_id];
if (a==b) {
- DVector<int> ret;
+ PoolVector<int> ret;
ret.push_back(a->id);
return ret;
}
@@ -375,7 +375,7 @@ DVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
bool found_route=_solve(begin_point,end_point);
if (!found_route)
- return DVector<int>();
+ return PoolVector<int>();
//midpoints
Point *p=end_point;
@@ -385,11 +385,11 @@ DVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
p=p->prev_point;
}
- DVector<int> path;
+ PoolVector<int> path;
path.resize(pc);
{
- DVector<int>::Write w = path.write();
+ PoolVector<int>::Write w = path.write();
p=end_point;
int idx=pc-1;
diff --git a/core/math/a_star.h b/core/math/a_star.h
index 66a983a6ce..35e6ead226 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -113,8 +113,8 @@ public:
int get_closest_point(const Vector3& p_point) const;
Vector3 get_closest_pos_in_segment(const Vector3& p_point) const;
- DVector<Vector3> get_point_path(int p_from_id, int p_to_id);
- DVector<int> get_id_path(int p_from_id, int p_to_id);
+ PoolVector<Vector3> get_point_path(int p_from_id, int p_to_id);
+ PoolVector<int> get_id_path(int p_from_id, int p_to_id);
AStar();
~AStar();
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index 5242abfa3b..b7194d7ffb 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -484,7 +484,7 @@ BSP_Tree::operator Variant() const {
d["planes"]=plane_values;
- DVector<int> dst_nodes;
+ PoolVector<int> dst_nodes;
dst_nodes.resize(nodes.size()*3);
for(int i=0;i<nodes.size();i++) {
@@ -514,19 +514,19 @@ BSP_Tree::BSP_Tree(const Variant& p_variant) {
ERR_FAIL_COND(!d.has("aabb"));
ERR_FAIL_COND(!d.has("error_radius"));
- DVector<int> src_nodes = d["nodes"];
+ PoolVector<int> src_nodes = d["nodes"];
ERR_FAIL_COND(src_nodes.size()%3);
if (d["planes"].get_type()==Variant::REAL_ARRAY) {
- DVector<float> src_planes=d["planes"];
+ PoolVector<float> src_planes=d["planes"];
int plane_count=src_planes.size();
ERR_FAIL_COND(plane_count%4);
planes.resize(plane_count/4);
if (plane_count) {
- DVector<float>::Read r = src_planes.read();
+ PoolVector<float>::Read r = src_planes.read();
for(int i=0;i<plane_count/4;i++) {
planes[i].normal.x=r[i*4+0];
@@ -549,7 +549,7 @@ BSP_Tree::BSP_Tree(const Variant& p_variant) {
// int node_count = src_nodes.size();
nodes.resize(src_nodes.size()/3);
- DVector<int>::Read r = src_nodes.read();
+ PoolVector<int>::Read r = src_nodes.read();
for(int i=0;i<nodes.size();i++) {
@@ -560,12 +560,12 @@ BSP_Tree::BSP_Tree(const Variant& p_variant) {
}
-BSP_Tree::BSP_Tree(const DVector<Face3>& p_faces,float p_error_radius) {
+BSP_Tree::BSP_Tree(const PoolVector<Face3>& p_faces,float p_error_radius) {
// compute aabb
int face_count=p_faces.size();
- DVector<Face3>::Read faces_r=p_faces.read();
+ PoolVector<Face3>::Read faces_r=p_faces.read();
const Face3 *facesptr = faces_r.ptr();
diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h
index 3913e3d34a..236b6e5ac2 100644
--- a/core/math/bsp_tree.h
+++ b/core/math/bsp_tree.h
@@ -91,7 +91,7 @@ public:
BSP_Tree();
BSP_Tree(const Variant& p_variant);
- BSP_Tree(const DVector<Face3>& p_faces,float p_error_radius=0);
+ BSP_Tree(const PoolVector<Face3>& p_faces,float p_error_radius=0);
BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB& p_aabb,float p_error_radius=0);
~BSP_Tree();
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index 91f7cf179a..3232d36262 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -204,21 +204,21 @@ static bool _group_face(_FaceClassify *p_faces, int len, int p_index,int p_group
}
-DVector< DVector< Face3 > > Geometry::separate_objects( DVector< Face3 > p_array ) {
+PoolVector< PoolVector< Face3 > > Geometry::separate_objects( PoolVector< Face3 > p_array ) {
- DVector< DVector< Face3 > > objects;
+ PoolVector< PoolVector< Face3 > > objects;
int len = p_array.size();
- DVector<Face3>::Read r=p_array.read();
+ PoolVector<Face3>::Read r=p_array.read();
const Face3* arrayptr = r.ptr();
- DVector< _FaceClassify> fc;
+ PoolVector< _FaceClassify> fc;
fc.resize( len );
- DVector< _FaceClassify >::Write fcw=fc.write();
+ PoolVector< _FaceClassify >::Write fcw=fc.write();
_FaceClassify * _fcptr = fcw.ptr();
@@ -231,7 +231,7 @@ DVector< DVector< Face3 > > Geometry::separate_objects( DVector< Face3 > p_array
if (error) {
- ERR_FAIL_COND_V(error, DVector< DVector< Face3 > >() ); // invalid geometry
+ ERR_FAIL_COND_V(error, PoolVector< PoolVector< Face3 > >() ); // invalid geometry
}
/* group connected faces in separate objects */
@@ -257,8 +257,8 @@ DVector< DVector< Face3 > > Geometry::separate_objects( DVector< Face3 > p_array
if (group>=0) {
objects.resize(group);
- DVector< DVector<Face3> >::Write obw=objects.write();
- DVector< Face3 > *group_faces = obw.ptr();
+ PoolVector< PoolVector<Face3> >::Write obw=objects.write();
+ PoolVector< Face3 > *group_faces = obw.ptr();
for (int i=0;i<len;i++) {
if (!_fcptr[i].valid)
@@ -487,7 +487,7 @@ static inline void _mark_outside(uint8_t*** p_cell_status,int x,int y,int z,int
}
}
-static inline void _build_faces(uint8_t*** p_cell_status,int x,int y,int z,int len_x,int len_y,int len_z,DVector<Face3>& p_faces) {
+static inline void _build_faces(uint8_t*** p_cell_status,int x,int y,int z,int len_x,int len_y,int len_z,PoolVector<Face3>& p_faces) {
ERR_FAIL_INDEX(x,len_x);
ERR_FAIL_INDEX(y,len_y);
@@ -580,13 +580,13 @@ static inline void _build_faces(uint8_t*** p_cell_status,int x,int y,int z,int l
}
-DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_error ) {
+PoolVector< Face3 > Geometry::wrap_geometry( PoolVector< Face3 > p_array,float *p_error ) {
#define _MIN_SIZE 1.0
#define _MAX_LENGTH 20
int face_count=p_array.size();
- DVector<Face3>::Read facesr=p_array.read();
+ PoolVector<Face3>::Read facesr=p_array.read();
const Face3 *faces = facesr.ptr();
AABB global_aabb;
@@ -696,7 +696,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
//print_line("Wrapper (3/6): Building Faces");
- DVector<Face3> wrapped_faces;
+ PoolVector<Face3> wrapped_faces;
for (int i=0;i<div_x;i++) {
@@ -714,7 +714,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
// transform face vertices to global coords
int wrapped_faces_count=wrapped_faces.size();
- DVector<Face3>::Write wrapped_facesw=wrapped_faces.write();
+ PoolVector<Face3>::Write wrapped_facesw=wrapped_faces.write();
Face3* wrapped_faces_ptr=wrapped_facesw.ptr();
for(int i=0;i<wrapped_faces_count;i++) {
@@ -748,7 +748,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
return wrapped_faces;
}
-Geometry::MeshData Geometry::build_convex_mesh(const DVector<Plane> &p_planes) {
+Geometry::MeshData Geometry::build_convex_mesh(const PoolVector<Plane> &p_planes) {
MeshData mesh;
@@ -896,9 +896,9 @@ Geometry::MeshData Geometry::build_convex_mesh(const DVector<Plane> &p_planes) {
}
-DVector<Plane> Geometry::build_box_planes(const Vector3& p_extents) {
+PoolVector<Plane> Geometry::build_box_planes(const Vector3& p_extents) {
- DVector<Plane> planes;
+ PoolVector<Plane> planes;
planes.push_back( Plane( Vector3(1,0,0), p_extents.x ) );
planes.push_back( Plane( Vector3(-1,0,0), p_extents.x ) );
@@ -910,9 +910,9 @@ DVector<Plane> Geometry::build_box_planes(const Vector3& p_extents) {
return planes;
}
-DVector<Plane> Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
+PoolVector<Plane> Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
- DVector<Plane> planes;
+ PoolVector<Plane> planes;
for (int i=0;i<p_sides;i++) {
@@ -933,10 +933,10 @@ DVector<Plane> Geometry::build_cylinder_planes(float p_radius, float p_height, i
}
-DVector<Plane> Geometry::build_sphere_planes(float p_radius, int p_lats,int p_lons, Vector3::Axis p_axis) {
+PoolVector<Plane> Geometry::build_sphere_planes(float p_radius, int p_lats,int p_lons, Vector3::Axis p_axis) {
- DVector<Plane> planes;
+ PoolVector<Plane> planes;
Vector3 axis;
axis[p_axis]=1.0;
@@ -969,9 +969,9 @@ DVector<Plane> Geometry::build_sphere_planes(float p_radius, int p_lats,int p_lo
}
-DVector<Plane> Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
+PoolVector<Plane> Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
- DVector<Plane> planes;
+ PoolVector<Plane> planes;
Vector3 axis;
axis[p_axis]=1.0;
diff --git a/core/math/geometry.h b/core/math/geometry.h
index dae556cd09..9800e5513c 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -808,9 +808,9 @@ public:
}
- static DVector< DVector< Face3 > > separate_objects( DVector< Face3 > p_array );
+ static PoolVector< PoolVector< Face3 > > separate_objects( PoolVector< Face3 > p_array );
- static DVector< Face3 > wrap_geometry( DVector< Face3 > p_array, float *p_error=NULL ); ///< create a "wrap" that encloses the given geometry
+ static PoolVector< Face3 > wrap_geometry( PoolVector< Face3 > p_array, float *p_error=NULL ); ///< create a "wrap" that encloses the given geometry
struct MeshData {
@@ -919,11 +919,11 @@ public:
return H;
}
- static MeshData build_convex_mesh(const DVector<Plane> &p_planes);
- static DVector<Plane> build_sphere_planes(float p_radius, int p_lats, int p_lons, Vector3::Axis p_axis=Vector3::AXIS_Z);
- static DVector<Plane> build_box_planes(const Vector3& p_extents);
- static DVector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z);
- static DVector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis=Vector3::AXIS_Z);
+ static MeshData build_convex_mesh(const PoolVector<Plane> &p_planes);
+ static PoolVector<Plane> build_sphere_planes(float p_radius, int p_lats, int p_lons, Vector3::Axis p_axis=Vector3::AXIS_Z);
+ static PoolVector<Plane> build_box_planes(const Vector3& p_extents);
+ static PoolVector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z);
+ static PoolVector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis=Vector3::AXIS_Z);
static void make_atlas(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, Size2i& r_size);
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index a985e29abb..a928b4d0e5 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -133,16 +133,18 @@ Matrix3 Matrix3::transposed() const {
return tr;
}
+// Multiplies the matrix from left by the scaling matrix: M -> S.M
+// See the comment for Matrix3::rotated for further explanation.
void Matrix3::scale(const Vector3& p_scale) {
elements[0][0]*=p_scale.x;
- elements[1][0]*=p_scale.x;
- elements[2][0]*=p_scale.x;
- elements[0][1]*=p_scale.y;
+ elements[0][1]*=p_scale.x;
+ elements[0][2]*=p_scale.x;
+ elements[1][0]*=p_scale.y;
elements[1][1]*=p_scale.y;
- elements[2][1]*=p_scale.y;
- elements[0][2]*=p_scale.z;
- elements[1][2]*=p_scale.z;
+ elements[1][2]*=p_scale.y;
+ elements[2][0]*=p_scale.z;
+ elements[2][1]*=p_scale.z;
elements[2][2]*=p_scale.z;
}
@@ -154,8 +156,13 @@ Matrix3 Matrix3::scaled( const Vector3& p_scale ) const {
}
Vector3 Matrix3::get_scale() const {
-
- return Vector3(
+ // We are assuming M = R.S, and performing a polar decomposition to extract R and S.
+ // FIXME: We eventually need a proper polar decomposition.
+ // As a cheap workaround until then, to ensure that R is a proper rotation matrix with determinant +1
+ // (such that it can be represented by a Quat or Euler angles), we absorb the sign flip into the scaling matrix.
+ // As such, it works in conjuction with get_rotation().
+ real_t det_sign = determinant() > 0 ? 1 : -1;
+ return det_sign*Vector3(
Vector3(elements[0][0],elements[1][0],elements[2][0]).length(),
Vector3(elements[0][1],elements[1][1],elements[2][1]).length(),
Vector3(elements[0][2],elements[1][2],elements[2][2]).length()
@@ -163,18 +170,40 @@ Vector3 Matrix3::get_scale() const {
}
-// Matrix3::rotate and Matrix3::rotated return M * R(axis,phi), and is a convenience function. They do *not* perform proper matrix rotation.
+// Multiplies the matrix from left by the rotation matrix: M -> R.M
+// Note that this does *not* rotate the matrix itself.
+//
+// The main use of Matrix3 is as Transform.basis, which is used a the transformation matrix
+// of 3D object. Rotate here refers to rotation of the object (which is R * (*this)),
+// not the matrix itself (which is R * (*this) * R.transposed()).
+Matrix3 Matrix3::rotated(const Vector3& p_axis, real_t p_phi) const {
+ return Matrix3(p_axis, p_phi) * (*this);
+}
+
void Matrix3::rotate(const Vector3& p_axis, real_t p_phi) {
- // TODO: This function should also be renamed as the current name is misleading: rotate does *not* perform matrix rotation.
- // Same problem affects Matrix3::rotated.
- // A similar problem exists in 2D math, which will be handled separately.
- // After Matrix3 is renamed to Basis, this comments needs to be revised.
- *this = *this * Matrix3(p_axis, p_phi);
+ *this = rotated(p_axis, p_phi);
}
-Matrix3 Matrix3::rotated(const Vector3& p_axis, real_t p_phi) const {
- return *this * Matrix3(p_axis, p_phi);
+Matrix3 Matrix3::rotated(const Vector3& p_euler) const {
+ return Matrix3(p_euler) * (*this);
+}
+
+void Matrix3::rotate(const Vector3& p_euler) {
+ *this = rotated(p_euler);
+}
+
+Vector3 Matrix3::get_rotation() const {
+ // Assumes that the matrix can be decomposed into a proper rotation and scaling matrix as M = R.S,
+ // and returns the Euler angles corresponding to the rotation part, complementing get_scale().
+ // See the comment in get_scale() for further information.
+ Matrix3 m = orthonormalized();
+ real_t det = m.determinant();
+ if (det < 0) {
+ // Ensure that the determinant is 1, such that result is a proper rotation matrix which can be represented by Euler angles.
+ m.scale(Vector3(-1,-1,-1));
+ }
+ return m.get_euler();
}
// get_euler returns a vector containing the Euler angles in the format
@@ -363,7 +392,7 @@ int Matrix3::get_orthogonal_index() const {
for(int i=0;i<3;i++) {
for(int j=0;j<3;j++) {
- float v = orth[i][j];
+ real_t v = orth[i][j];
if (v>0.5)
v=1.0;
else if (v<-0.5)
@@ -398,9 +427,6 @@ void Matrix3::set_orthogonal_index(int p_index){
void Matrix3::get_axis_and_angle(Vector3 &r_axis,real_t& r_angle) const {
- // TODO: We can handle improper matrices here too, in which case axis will also correspond to the axis of reflection.
- // See Eq. (52) in http://scipp.ucsc.edu/~haber/ph251/rotreflect_13.pdf for example
- // After that change, we should fail on is_orthogonal() == false.
ERR_FAIL_COND(is_rotation() == false);
diff --git a/core/math/matrix3.h b/core/math/matrix3.h
index 1d967c03b8..33a5ce8687 100644
--- a/core/math/matrix3.h
+++ b/core/math/matrix3.h
@@ -55,7 +55,7 @@ public:
Matrix3 inverse() const;
Matrix3 transposed() const;
- _FORCE_INLINE_ float determinant() const;
+ _FORCE_INLINE_ real_t determinant() const;
void from_z(const Vector3& p_z);
@@ -73,6 +73,10 @@ public:
void rotate(const Vector3& p_axis, real_t p_phi);
Matrix3 rotated(const Vector3& p_axis, real_t p_phi) const;
+ void rotate(const Vector3& p_euler);
+ Matrix3 rotated(const Vector3& p_euler) const;
+ Vector3 get_rotation() const;
+
void scale( const Vector3& p_scale );
Matrix3 scaled( const Vector3& p_scale ) const;
Vector3 get_scale() const;
@@ -226,7 +230,7 @@ Vector3 Matrix3::xform_inv(const Vector3& p_vector) const {
);
}
-float Matrix3::determinant() const {
+real_t Matrix3::determinant() const {
return elements[0][0]*(elements[1][1]*elements[2][2] - elements[2][1]*elements[1][2]) -
elements[1][0]*(elements[0][1]*elements[2][2] - elements[2][1]*elements[0][2]) +
diff --git a/core/math/transform.cpp b/core/math/transform.cpp
index 8516e4afcf..0dba121013 100644
--- a/core/math/transform.cpp
+++ b/core/math/transform.cpp
@@ -54,7 +54,8 @@ void Transform::invert() {
}
Transform Transform::inverse() const {
-
+ // FIXME: this function assumes the basis is a rotation matrix, with no scaling.
+ // Transform::affine_inverse can handle matrices with scaling, so GDScript should eventually use that.
Transform ret=*this;
ret.invert();
return ret;
@@ -63,12 +64,12 @@ Transform Transform::inverse() const {
void Transform::rotate(const Vector3& p_axis,real_t p_phi) {
- *this = *this * Transform( Matrix3( p_axis, p_phi ), Vector3() );
+ *this = rotated(p_axis, p_phi);
}
Transform Transform::rotated(const Vector3& p_axis,real_t p_phi) const{
- return *this * Transform( Matrix3( p_axis, p_phi ), Vector3() );
+ return Transform(Matrix3( p_axis, p_phi ), Vector3()) * (*this);
}
void Transform::rotate_basis(const Vector3& p_axis,real_t p_phi) {
@@ -113,7 +114,7 @@ void Transform::set_look_at( const Vector3& p_eye, const Vector3& p_target, cons
}
-Transform Transform::interpolate_with(const Transform& p_transform, float p_c) const {
+Transform Transform::interpolate_with(const Transform& p_transform, real_t p_c) const {
/* not sure if very "efficient" but good enough? */
diff --git a/core/math/transform.h b/core/math/transform.h
index 7999f0b347..5f069ab586 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -86,7 +86,7 @@ public:
void operator*=(const Transform& p_transform);
Transform operator*(const Transform& p_transform) const;
- Transform interpolate_with(const Transform& p_transform, float p_c) const;
+ Transform interpolate_with(const Transform& p_transform, real_t p_c) const;
_FORCE_INLINE_ Transform inverse_xform(const Transform& t) const {
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index b3daee0c7e..101e164eae 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -94,7 +94,7 @@ int TriangleMesh::_create_bvh(BVH*p_bvh,BVH** p_bb,int p_from,int p_size,int p_d
}
-void TriangleMesh::create(const DVector<Vector3>& p_faces) {
+void TriangleMesh::create(const PoolVector<Vector3>& p_faces) {
valid=false;
@@ -104,7 +104,7 @@ void TriangleMesh::create(const DVector<Vector3>& p_faces) {
triangles.resize(fc);
bvh.resize(fc*3); //will never be larger than this (todo make better)
- DVector<BVH>::Write bw = bvh.write();
+ PoolVector<BVH>::Write bw = bvh.write();
{
@@ -112,8 +112,8 @@ void TriangleMesh::create(const DVector<Vector3>& p_faces) {
//except for the Set for repeated triangles, everything
//goes in-place.
- DVector<Vector3>::Read r = p_faces.read();
- DVector<Triangle>::Write w = triangles.write();
+ PoolVector<Vector3>::Read r = p_faces.read();
+ PoolVector<Triangle>::Write w = triangles.write();
Map<Vector3,int> db;
for(int i=0;i<fc;i++) {
@@ -149,16 +149,16 @@ void TriangleMesh::create(const DVector<Vector3>& p_faces) {
}
vertices.resize(db.size());
- DVector<Vector3>::Write vw = vertices.write();
+ PoolVector<Vector3>::Write vw = vertices.write();
for (Map<Vector3,int>::Element *E=db.front();E;E=E->next()) {
vw[E->get()]=E->key();
}
}
- DVector<BVH*> bwptrs;
+ PoolVector<BVH*> bwptrs;
bwptrs.resize(fc);
- DVector<BVH*>::Write bwp = bwptrs.write();
+ PoolVector<BVH*>::Write bwp = bwptrs.write();
for(int i=0;i<fc;i++) {
bwp[i]=&bw[i];
@@ -168,7 +168,7 @@ void TriangleMesh::create(const DVector<Vector3>& p_faces) {
int max_alloc=fc;
int max=_create_bvh(bw.ptr(),bwp.ptr(),0,fc,1,max_depth,max_alloc);
- bw=DVector<BVH>::Write(); //clearup
+ bw=PoolVector<BVH>::Write(); //clearup
bvh.resize(max_alloc); //resize back
valid=true;
@@ -197,9 +197,9 @@ Vector3 TriangleMesh::get_area_normal(const AABB& p_aabb) const {
int level=0;
- DVector<Triangle>::Read trianglesr = triangles.read();
- DVector<Vector3>::Read verticesr=vertices.read();
- DVector<BVH>::Read bvhr=bvh.read();
+ PoolVector<Triangle>::Read trianglesr = triangles.read();
+ PoolVector<Vector3>::Read verticesr=vertices.read();
+ PoolVector<BVH>::Read bvhr=bvh.read();
const Triangle *triangleptr=trianglesr.ptr();
int pos=bvh.size()-1;
@@ -299,9 +299,9 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end
int level=0;
- DVector<Triangle>::Read trianglesr = triangles.read();
- DVector<Vector3>::Read verticesr=vertices.read();
- DVector<BVH>::Read bvhr=bvh.read();
+ PoolVector<Triangle>::Read trianglesr = triangles.read();
+ PoolVector<Vector3>::Read verticesr=vertices.read();
+ PoolVector<BVH>::Read bvhr=bvh.read();
const Triangle *triangleptr=trianglesr.ptr();
const Vector3 *vertexptr=verticesr.ptr();
@@ -422,9 +422,9 @@ bool TriangleMesh::intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vec
int level=0;
- DVector<Triangle>::Read trianglesr = triangles.read();
- DVector<Vector3>::Read verticesr=vertices.read();
- DVector<BVH>::Read bvhr=bvh.read();
+ PoolVector<Triangle>::Read trianglesr = triangles.read();
+ PoolVector<Vector3>::Read verticesr=vertices.read();
+ PoolVector<BVH>::Read bvhr=bvh.read();
const Triangle *triangleptr=trianglesr.ptr();
const Vector3 *vertexptr=verticesr.ptr();
@@ -524,18 +524,18 @@ bool TriangleMesh::is_valid() const {
return valid;
}
-DVector<Face3> TriangleMesh::get_faces() const {
+PoolVector<Face3> TriangleMesh::get_faces() const {
if (!valid)
- return DVector<Face3>();
+ return PoolVector<Face3>();
- DVector<Face3> faces;
+ PoolVector<Face3> faces;
int ts = triangles.size();
faces.resize(triangles.size());
- DVector<Face3>::Write w=faces.write();
- DVector<Triangle>::Read r = triangles.read();
- DVector<Vector3>::Read rv = vertices.read();
+ PoolVector<Face3>::Write w=faces.write();
+ PoolVector<Triangle>::Read r = triangles.read();
+ PoolVector<Vector3>::Read rv = vertices.read();
for(int i=0;i<ts;i++) {
for(int j=0;j<3;j++) {
@@ -543,7 +543,7 @@ DVector<Face3> TriangleMesh::get_faces() const {
}
}
- w = DVector<Face3>::Write();
+ w = PoolVector<Face3>::Write();
return faces;
}
diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h
index d42f9c8dde..37d32bd7ec 100644
--- a/core/math/triangle_mesh.h
+++ b/core/math/triangle_mesh.h
@@ -41,8 +41,8 @@ class TriangleMesh : public Reference {
int indices[3];
};
- DVector<Triangle> triangles;
- DVector<Vector3> vertices;
+ PoolVector<Triangle> triangles;
+ PoolVector<Vector3> vertices;
struct BVH {
@@ -79,7 +79,7 @@ class TriangleMesh : public Reference {
int _create_bvh(BVH*p_bvh,BVH** p_bb,int p_from,int p_size,int p_depth,int&max_depth,int&max_alloc);
- DVector<BVH> bvh;
+ PoolVector<BVH> bvh;
int max_depth;
bool valid;
@@ -89,10 +89,10 @@ public:
bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_point, Vector3 &r_normal) const;
bool intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vector3 &r_point, Vector3 &r_normal) const;
Vector3 get_area_normal(const AABB& p_aabb) const;
- DVector<Face3> get_faces() const;
+ PoolVector<Face3> get_faces() const;
- void create(const DVector<Vector3>& p_faces);
+ void create(const PoolVector<Vector3>& p_faces);
TriangleMesh();
};