summaryrefslogtreecommitdiff
path: root/modules/bullet
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2020-02-17 18:06:54 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-18 10:10:36 +0100
commit3205a92ad872f918c8322cdcd1434c231a1fd251 (patch)
treedb44242ca27432eb8ea849679752d0835d2ae41a /modules/bullet
parentfb8c93c10b4b73d5f18f1ed287497728800e22b5 (diff)
PoolVector is gone, replaced by Vector
Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector<Type>`.
Diffstat (limited to 'modules/bullet')
-rw-r--r--modules/bullet/shape_bullet.cpp30
-rw-r--r--modules/bullet/shape_bullet.h10
-rw-r--r--modules/bullet/soft_body_bullet.cpp14
-rw-r--r--modules/bullet/soft_body_bullet.h2
4 files changed, 28 insertions, 28 deletions
diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp
index f46db09e4a..1690950049 100644
--- a/modules/bullet/shape_bullet.cpp
+++ b/modules/bullet/shape_bullet.cpp
@@ -142,11 +142,11 @@ btScaledBvhTriangleMeshShape *ShapeBullet::create_shape_concave(btBvhTriangleMes
}
}
-btHeightfieldTerrainShape *ShapeBullet::create_shape_height_field(PoolVector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {
+btHeightfieldTerrainShape *ShapeBullet::create_shape_height_field(Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {
const btScalar ignoredHeightScale(1);
const int YAxis = 1; // 0=X, 1=Y, 2=Z
const bool flipQuadEdges = false;
- const void *heightsPtr = p_heights.read().ptr();
+ const void *heightsPtr = p_heights.ptr();
btHeightfieldTerrainShape *heightfield = bulletnew(btHeightfieldTerrainShape(p_width, p_depth, heightsPtr, ignoredHeightScale, p_min_height, p_max_height, YAxis, PHY_FLOAT, flipQuadEdges));
@@ -370,7 +370,7 @@ ConcavePolygonShapeBullet::~ConcavePolygonShapeBullet() {
delete meshShape->getTriangleInfoMap();
bulletdelete(meshShape);
}
- faces = PoolVector<Vector3>();
+ faces = Vector<Vector3>();
}
void ConcavePolygonShapeBullet::set_data(const Variant &p_data) {
@@ -385,7 +385,7 @@ PhysicsServer::ShapeType ConcavePolygonShapeBullet::get_type() const {
return PhysicsServer::SHAPE_CONCAVE_POLYGON;
}
-void ConcavePolygonShapeBullet::setup(PoolVector<Vector3> p_faces) {
+void ConcavePolygonShapeBullet::setup(Vector<Vector3> p_faces) {
faces = p_faces;
if (meshShape) {
/// Clear previous created shape
@@ -401,8 +401,8 @@ void ConcavePolygonShapeBullet::setup(PoolVector<Vector3> p_faces) {
btTriangleMesh *shapeInterface = bulletnew(btTriangleMesh);
src_face_count /= 3;
- PoolVector<Vector3>::Read r = p_faces.read();
- const Vector3 *facesr = r.ptr();
+ const Vector3 *r = p_faces.ptr();
+ const Vector3 *facesr = r;
btVector3 supVec_0;
btVector3 supVec_1;
@@ -471,10 +471,10 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
// TODO This code will need adjustments if real_t is set to `double`,
// because that precision is unnecessary for a heightmap and Bullet doesn't support it...
- PoolVector<real_t> l_heights;
+ Vector<real_t> l_heights;
Variant l_heights_v = d["heights"];
- if (l_heights_v.get_type() == Variant::POOL_REAL_ARRAY) {
+ if (l_heights_v.get_type() == Variant::PACKED_REAL_ARRAY) {
// Ready-to-use heights can be passed
l_heights = l_heights_v;
@@ -491,13 +491,13 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
// We could convert here automatically but it's better to not be intrusive and let the caller do it if necessary.
ERR_FAIL_COND(l_image->get_format() != Image::FORMAT_RF);
- PoolByteArray im_data = l_image->get_data();
+ PackedByteArray im_data = l_image->get_data();
l_heights.resize(l_image->get_width() * l_image->get_height());
- PoolRealArray::Write w = l_heights.write();
- PoolByteArray::Read r = im_data.read();
- float *rp = (float *)r.ptr();
+ real_t *w = l_heights.ptrw();
+ const uint8_t *r = im_data.ptr();
+ float *rp = (float *)r;
// At this point, `rp` could be used directly for Bullet, but I don't know how safe it would be.
for (int i = 0; i < l_heights.size(); ++i) {
@@ -505,7 +505,7 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
}
} else {
- ERR_FAIL_MSG("Expected PoolRealArray or float Image.");
+ ERR_FAIL_MSG("Expected PackedRealArray or float Image.");
}
ERR_FAIL_COND(l_width <= 0);
@@ -515,7 +515,7 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
// Compute min and max heights if not specified.
if (!d.has("min_height") && !d.has("max_height")) {
- PoolVector<real_t>::Read r = l_heights.read();
+ const real_t *r = l_heights.ptr();
int heights_size = l_heights.size();
for (int i = 0; i < heights_size; ++i) {
@@ -540,7 +540,7 @@ PhysicsServer::ShapeType HeightMapShapeBullet::get_type() const {
return PhysicsServer::SHAPE_HEIGHTMAP;
}
-void HeightMapShapeBullet::setup(PoolVector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {
+void HeightMapShapeBullet::setup(Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {
// TODO cell size must be tweaked using localScaling, which is a shared property for all Bullet shapes
// If this array is resized outside of here, it should be preserved due to CoW
diff --git a/modules/bullet/shape_bullet.h b/modules/bullet/shape_bullet.h
index 8d3512cab4..27bf011ca1 100644
--- a/modules/bullet/shape_bullet.h
+++ b/modules/bullet/shape_bullet.h
@@ -90,7 +90,7 @@ public:
/// IMPORTANT: Remember to delete the shape interface by calling: delete my_shape->getMeshInterface();
static class btConvexPointCloudShape *create_shape_convex(btAlignedObjectArray<btVector3> &p_vertices, const btVector3 &p_local_scaling = btVector3(1, 1, 1));
static class btScaledBvhTriangleMeshShape *create_shape_concave(btBvhTriangleMeshShape *p_mesh_shape, const btVector3 &p_local_scaling = btVector3(1, 1, 1));
- static class btHeightfieldTerrainShape *create_shape_height_field(PoolVector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height);
+ static class btHeightfieldTerrainShape *create_shape_height_field(Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height);
static class btRayShape *create_shape_ray(real_t p_length, bool p_slips_on_slope);
};
@@ -203,7 +203,7 @@ class ConcavePolygonShapeBullet : public ShapeBullet {
class btBvhTriangleMeshShape *meshShape;
public:
- PoolVector<Vector3> faces;
+ Vector<Vector3> faces;
ConcavePolygonShapeBullet();
virtual ~ConcavePolygonShapeBullet();
@@ -214,13 +214,13 @@ public:
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
- void setup(PoolVector<Vector3> p_faces);
+ void setup(Vector<Vector3> p_faces);
};
class HeightMapShapeBullet : public ShapeBullet {
public:
- PoolVector<real_t> heights;
+ Vector<real_t> heights;
int width;
int depth;
real_t min_height;
@@ -234,7 +234,7 @@ public:
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
- void setup(PoolVector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height);
+ void setup(Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height);
};
class RayShapeBullet : public ShapeBullet {
diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp
index a7988279c0..f21206dd0d 100644
--- a/modules/bullet/soft_body_bullet.cpp
+++ b/modules/bullet/soft_body_bullet.cpp
@@ -184,7 +184,7 @@ void SoftBodyBullet::get_node_offset(int p_node_index, Vector3 &r_offset) const
return;
Array arrays = soft_mesh->surface_get_arrays(0);
- PoolVector<Vector3> vertices(arrays[VS::ARRAY_VERTEX]);
+ Vector<Vector3> vertices(arrays[VS::ARRAY_VERTEX]);
if (0 <= p_node_index && vertices.size() > p_node_index) {
r_offset = vertices[p_node_index];
@@ -230,8 +230,8 @@ void SoftBodyBullet::reset_all_node_positions() {
return;
Array arrays = soft_mesh->surface_get_arrays(0);
- PoolVector<Vector3> vs_vertices(arrays[VS::ARRAY_VERTEX]);
- PoolVector<Vector3>::Read vs_vertices_read = vs_vertices.read();
+ Vector<Vector3> vs_vertices(arrays[VS::ARRAY_VERTEX]);
+ const Vector3 *vs_vertices_read = vs_vertices.ptr();
for (int vertex_index = bt_soft_body->m_nodes.size() - 1; 0 <= vertex_index; --vertex_index) {
@@ -320,7 +320,7 @@ void SoftBodyBullet::set_drag_coefficient(real_t p_val) {
}
}
-void SoftBodyBullet::set_trimesh_body_shape(PoolVector<int> p_indices, PoolVector<Vector3> p_vertices) {
+void SoftBodyBullet::set_trimesh_body_shape(Vector<int> p_indices, Vector<Vector3> p_vertices) {
/// Assert the current soft body is destroyed
destroy_soft_body();
@@ -339,7 +339,7 @@ void SoftBodyBullet::set_trimesh_body_shape(PoolVector<int> p_indices, PoolVecto
const int vs_vertices_size(p_vertices.size());
- PoolVector<Vector3>::Read p_vertices_read = p_vertices.read();
+ const Vector3 *p_vertices_read = p_vertices.ptr();
for (int vs_vertex_index = 0; vs_vertex_index < vs_vertices_size; ++vs_vertex_index) {
@@ -366,7 +366,7 @@ void SoftBodyBullet::set_trimesh_body_shape(PoolVector<int> p_indices, PoolVecto
{ // Parse vertices to bullet
bt_vertices.resize(indices_map_size * 3);
- PoolVector<Vector3>::Read p_vertices_read = p_vertices.read();
+ const Vector3 *p_vertices_read = p_vertices.ptr();
for (int i = 0; i < indices_map_size; ++i) {
bt_vertices.write[3 * i + 0] = p_vertices_read[indices_table[i][0]].x;
@@ -382,7 +382,7 @@ void SoftBodyBullet::set_trimesh_body_shape(PoolVector<int> p_indices, PoolVecto
bt_triangles.resize(triangles_size * 3);
- PoolVector<int>::Read p_indices_read = p_indices.read();
+ const int *p_indices_read = p_indices.ptr();
for (int i = 0; i < triangles_size; ++i) {
bt_triangles.write[3 * i + 0] = vs_indices_to_physics_table[p_indices_read[3 * i + 2]];
diff --git a/modules/bullet/soft_body_bullet.h b/modules/bullet/soft_body_bullet.h
index b98116b073..2df8ce074f 100644
--- a/modules/bullet/soft_body_bullet.h
+++ b/modules/bullet/soft_body_bullet.h
@@ -152,7 +152,7 @@ public:
_FORCE_INLINE_ real_t get_drag_coefficient() const { return drag_coefficient; }
private:
- void set_trimesh_body_shape(PoolVector<int> p_indices, PoolVector<Vector3> p_vertices);
+ void set_trimesh_body_shape(Vector<int> p_indices, Vector<Vector3> p_vertices);
void setup_soft_body();
void pin_node(int p_node_index);