SoftBody support in GodotPhysics 3D
- Fixed SoftBody surface update with new rendering system - Added GodotPhysics implementation for SoftBody - Added support to get SoftBody rid to interact with the physics server - Added support to get SoftBody bounds from the physics server - Removed support for unused get_vertex_position and get_point_offset from the physics server - Removed SoftBody properties that are unused in both Bullet and GodotPhysics (angular and volume stiffness, pose matching) - Added RenderingServerHandler interface to PhysicsServer3D so the physics servers don't need to reference the class from SoftBody node directly
This commit is contained in:
parent
01851defb5
commit
d5ea4acd2d
26 changed files with 2489 additions and 359 deletions
|
|
@ -433,12 +433,6 @@ void BulletPhysicsServer3D::area_set_ray_pickable(RID p_area, bool p_enable) {
|
|||
area->set_ray_pickable(p_enable);
|
||||
}
|
||||
|
||||
bool BulletPhysicsServer3D::area_is_ray_pickable(RID p_area) const {
|
||||
AreaBullet *area = area_owner.getornull(p_area);
|
||||
ERR_FAIL_COND_V(!area, false);
|
||||
return area->is_ray_pickable();
|
||||
}
|
||||
|
||||
RID BulletPhysicsServer3D::body_create(BodyMode p_mode, bool p_init_sleeping) {
|
||||
RigidBodyBullet *body = bulletnew(RigidBodyBullet);
|
||||
body->set_mode(p_mode);
|
||||
|
|
@ -842,12 +836,6 @@ void BulletPhysicsServer3D::body_set_ray_pickable(RID p_body, bool p_enable) {
|
|||
body->set_ray_pickable(p_enable);
|
||||
}
|
||||
|
||||
bool BulletPhysicsServer3D::body_is_ray_pickable(RID p_body) const {
|
||||
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, false);
|
||||
return body->is_ray_pickable();
|
||||
}
|
||||
|
||||
PhysicsDirectBodyState3D *BulletPhysicsServer3D::body_get_direct_state(RID p_body) {
|
||||
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, nullptr);
|
||||
|
|
@ -880,7 +868,7 @@ RID BulletPhysicsServer3D::soft_body_create(bool p_init_sleeping) {
|
|||
CreateThenReturnRID(soft_body_owner, body);
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::soft_body_update_rendering_server(RID p_body, class SoftBodyRenderingServerHandler *p_rendering_server_handler) {
|
||||
void BulletPhysicsServer3D::soft_body_update_rendering_server(RID p_body, RenderingServerHandler *p_rendering_server_handler) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
|
||||
|
|
@ -922,6 +910,13 @@ void BulletPhysicsServer3D::soft_body_set_mesh(RID p_body, const REF &p_mesh) {
|
|||
body->set_soft_mesh(p_mesh);
|
||||
}
|
||||
|
||||
AABB BulletPhysicsServer::soft_body_get_bounds(RID p_body) const {
|
||||
SoftBodyBullet *body = soft_body_owner.get(p_body);
|
||||
ERR_FAIL_COND_V(!body, AABB());
|
||||
|
||||
return body->get_bounds();
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
|
|
@ -1002,34 +997,19 @@ void BulletPhysicsServer3D::soft_body_set_transform(RID p_body, const Transform
|
|||
body->set_soft_transform(p_transform);
|
||||
}
|
||||
|
||||
Vector3 BulletPhysicsServer3D::soft_body_get_vertex_position(RID p_body, int vertex_index) const {
|
||||
const SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
Vector3 pos;
|
||||
ERR_FAIL_COND_V(!body, pos);
|
||||
|
||||
body->get_node_position(vertex_index, pos);
|
||||
return pos;
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::soft_body_set_ray_pickable(RID p_body, bool p_enable) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
body->set_ray_pickable(p_enable);
|
||||
}
|
||||
|
||||
bool BulletPhysicsServer3D::soft_body_is_ray_pickable(RID p_body) const {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, false);
|
||||
return body->is_ray_pickable();
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
body->set_simulation_precision(p_simulation_precision);
|
||||
}
|
||||
|
||||
int BulletPhysicsServer3D::soft_body_get_simulation_precision(RID p_body) {
|
||||
int BulletPhysicsServer3D::soft_body_get_simulation_precision(RID p_body) const {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0.f);
|
||||
return body->get_simulation_precision();
|
||||
|
|
@ -1041,13 +1021,13 @@ void BulletPhysicsServer3D::soft_body_set_total_mass(RID p_body, real_t p_total_
|
|||
body->set_total_mass(p_total_mass);
|
||||
}
|
||||
|
||||
real_t BulletPhysicsServer3D::soft_body_get_total_mass(RID p_body) {
|
||||
real_t BulletPhysicsServer3D::soft_body_get_total_mass(RID p_body) const {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0.f);
|
||||
return body->get_total_mass();
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) {
|
||||
void BulletPhysicsServer3D::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) const {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
body->set_linear_stiffness(p_stiffness);
|
||||
|
|
@ -1059,61 +1039,25 @@ real_t BulletPhysicsServer3D::soft_body_get_linear_stiffness(RID p_body) {
|
|||
return body->get_linear_stiffness();
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::soft_body_set_angular_stiffness(RID p_body, real_t p_stiffness) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
body->set_angular_stiffness(p_stiffness);
|
||||
}
|
||||
|
||||
real_t BulletPhysicsServer3D::soft_body_get_angular_stiffness(RID p_body) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0.f);
|
||||
return body->get_angular_stiffness();
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
body->set_volume_stiffness(p_stiffness);
|
||||
}
|
||||
|
||||
real_t BulletPhysicsServer3D::soft_body_get_volume_stiffness(RID p_body) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0.f);
|
||||
return body->get_volume_stiffness();
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
body->set_pressure_coefficient(p_pressure_coefficient);
|
||||
}
|
||||
|
||||
real_t BulletPhysicsServer3D::soft_body_get_pressure_coefficient(RID p_body) {
|
||||
real_t BulletPhysicsServer3D::soft_body_get_pressure_coefficient(RID p_body) const {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0.f);
|
||||
return body->get_pressure_coefficient();
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::soft_body_set_pose_matching_coefficient(RID p_body, real_t p_pose_matching_coefficient) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
return body->set_pose_matching_coefficient(p_pose_matching_coefficient);
|
||||
}
|
||||
|
||||
real_t BulletPhysicsServer3D::soft_body_get_pose_matching_coefficient(RID p_body) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0.f);
|
||||
return body->get_pose_matching_coefficient();
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
body->set_damping_coefficient(p_damping_coefficient);
|
||||
}
|
||||
|
||||
real_t BulletPhysicsServer3D::soft_body_get_damping_coefficient(RID p_body) {
|
||||
real_t BulletPhysicsServer3D::soft_body_get_damping_coefficient(RID p_body) const {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0.f);
|
||||
return body->get_damping_coefficient();
|
||||
|
|
@ -1125,7 +1069,7 @@ void BulletPhysicsServer3D::soft_body_set_drag_coefficient(RID p_body, real_t p_
|
|||
body->set_drag_coefficient(p_drag_coefficient);
|
||||
}
|
||||
|
||||
real_t BulletPhysicsServer3D::soft_body_get_drag_coefficient(RID p_body) {
|
||||
real_t BulletPhysicsServer3D::soft_body_get_drag_coefficient(RID p_body) const {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0.f);
|
||||
return body->get_drag_coefficient();
|
||||
|
|
@ -1137,7 +1081,7 @@ void BulletPhysicsServer3D::soft_body_move_point(RID p_body, int p_point_index,
|
|||
body->set_node_position(p_point_index, p_global_position);
|
||||
}
|
||||
|
||||
Vector3 BulletPhysicsServer3D::soft_body_get_point_global_position(RID p_body, int p_point_index) {
|
||||
Vector3 BulletPhysicsServer3D::soft_body_get_point_global_position(RID p_body, int p_point_index) const {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, Vector3(0., 0., 0.));
|
||||
Vector3 pos;
|
||||
|
|
@ -1145,14 +1089,6 @@ Vector3 BulletPhysicsServer3D::soft_body_get_point_global_position(RID p_body, i
|
|||
return pos;
|
||||
}
|
||||
|
||||
Vector3 BulletPhysicsServer3D::soft_body_get_point_offset(RID p_body, int p_point_index) const {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, Vector3());
|
||||
Vector3 res;
|
||||
body->get_node_offset(p_point_index, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
void BulletPhysicsServer3D::soft_body_remove_all_pinned_points(RID p_body) {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
|
|
@ -1165,7 +1101,7 @@ void BulletPhysicsServer3D::soft_body_pin_point(RID p_body, int p_point_index, b
|
|||
body->set_node_mass(p_point_index, p_pin ? 0 : 1);
|
||||
}
|
||||
|
||||
bool BulletPhysicsServer3D::soft_body_is_point_pinned(RID p_body, int p_point_index) {
|
||||
bool BulletPhysicsServer3D::soft_body_is_point_pinned(RID p_body, int p_point_index) const {
|
||||
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
|
||||
ERR_FAIL_COND_V(!body, 0.f);
|
||||
return body->get_node_mass(p_point_index);
|
||||
|
|
|
|||
|
|
@ -163,7 +163,6 @@ public:
|
|||
virtual void area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) override;
|
||||
virtual void area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) override;
|
||||
virtual void area_set_ray_pickable(RID p_area, bool p_enable) override;
|
||||
virtual bool area_is_ray_pickable(RID p_area) const override;
|
||||
|
||||
/* RIGID BODY API */
|
||||
|
||||
|
|
@ -250,7 +249,6 @@ public:
|
|||
virtual void body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata = Variant()) override;
|
||||
|
||||
virtual void body_set_ray_pickable(RID p_body, bool p_enable) override;
|
||||
virtual bool body_is_ray_pickable(RID p_body) const override;
|
||||
|
||||
// this function only works on physics process, errors and returns null otherwise
|
||||
virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) override;
|
||||
|
|
@ -262,13 +260,15 @@ public:
|
|||
|
||||
virtual RID soft_body_create(bool p_init_sleeping = false) override;
|
||||
|
||||
virtual void soft_body_update_rendering_server(RID p_body, class SoftBodyRenderingServerHandler *p_rendering_server_handler) override;
|
||||
virtual void soft_body_update_rendering_server(RID p_body, RenderingServerHandler *p_rendering_server_handler) override;
|
||||
|
||||
virtual void soft_body_set_space(RID p_body, RID p_space) override;
|
||||
virtual RID soft_body_get_space(RID p_body) const override;
|
||||
|
||||
virtual void soft_body_set_mesh(RID p_body, const REF &p_mesh) override;
|
||||
|
||||
virtual AABB soft_body_get_bounds(RID p_body) const override;
|
||||
|
||||
virtual void soft_body_set_collision_layer(RID p_body, uint32_t p_layer) override;
|
||||
virtual uint32_t soft_body_get_collision_layer(RID p_body) const override;
|
||||
|
||||
|
|
@ -284,46 +284,33 @@ public:
|
|||
|
||||
/// Special function. This function has bad performance
|
||||
virtual void soft_body_set_transform(RID p_body, const Transform &p_transform) override;
|
||||
virtual Vector3 soft_body_get_vertex_position(RID p_body, int vertex_index) const override;
|
||||
|
||||
virtual void soft_body_set_ray_pickable(RID p_body, bool p_enable) override;
|
||||
virtual bool soft_body_is_ray_pickable(RID p_body) const override;
|
||||
|
||||
virtual void soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) override;
|
||||
virtual int soft_body_get_simulation_precision(RID p_body) override;
|
||||
virtual int soft_body_get_simulation_precision(RID p_body) const override;
|
||||
|
||||
virtual void soft_body_set_total_mass(RID p_body, real_t p_total_mass) override;
|
||||
virtual real_t soft_body_get_total_mass(RID p_body) override;
|
||||
virtual real_t soft_body_get_total_mass(RID p_body) const override;
|
||||
|
||||
virtual void soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) override;
|
||||
virtual real_t soft_body_get_linear_stiffness(RID p_body) override;
|
||||
|
||||
virtual void soft_body_set_angular_stiffness(RID p_body, real_t p_stiffness) override;
|
||||
virtual real_t soft_body_get_angular_stiffness(RID p_body) override;
|
||||
|
||||
virtual void soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) override;
|
||||
virtual real_t soft_body_get_volume_stiffness(RID p_body) override;
|
||||
virtual real_t soft_body_get_linear_stiffness(RID p_body) const override;
|
||||
|
||||
virtual void soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) override;
|
||||
virtual real_t soft_body_get_pressure_coefficient(RID p_body) override;
|
||||
|
||||
virtual void soft_body_set_pose_matching_coefficient(RID p_body, real_t p_pose_matching_coefficient) override;
|
||||
virtual real_t soft_body_get_pose_matching_coefficient(RID p_body) override;
|
||||
virtual real_t soft_body_get_pressure_coefficient(RID p_body) const override;
|
||||
|
||||
virtual void soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) override;
|
||||
virtual real_t soft_body_get_damping_coefficient(RID p_body) override;
|
||||
virtual real_t soft_body_get_damping_coefficient(RID p_body) const override;
|
||||
|
||||
virtual void soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) override;
|
||||
virtual real_t soft_body_get_drag_coefficient(RID p_body) override;
|
||||
virtual real_t soft_body_get_drag_coefficient(RID p_body) const override;
|
||||
|
||||
virtual void soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) override;
|
||||
virtual Vector3 soft_body_get_point_global_position(RID p_body, int p_point_index) override;
|
||||
|
||||
virtual Vector3 soft_body_get_point_offset(RID p_body, int p_point_index) const override;
|
||||
virtual Vector3 soft_body_get_point_global_position(RID p_body, int p_point_index) const override;
|
||||
|
||||
virtual void soft_body_remove_all_pinned_points(RID p_body) override;
|
||||
virtual void soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) override;
|
||||
virtual bool soft_body_is_point_pinned(RID p_body, int p_point_index) override;
|
||||
virtual bool soft_body_is_point_pinned(RID p_body, int p_point_index) const override;
|
||||
|
||||
/* JOINT API */
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ void SoftBodyBullet::on_enter_area(AreaBullet *p_area) {}
|
|||
|
||||
void SoftBodyBullet::on_exit_area(AreaBullet *p_area) {}
|
||||
|
||||
void SoftBodyBullet::update_rendering_server(SoftBodyRenderingServerHandler *p_rendering_server_handler) {
|
||||
void SoftBodyBullet::update_rendering_server(RenderingServerHandler *p_rendering_server_handler) {
|
||||
if (!bt_soft_body) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -141,6 +141,24 @@ void SoftBodyBullet::set_soft_transform(const Transform &p_transform) {
|
|||
move_all_nodes(p_transform);
|
||||
}
|
||||
|
||||
AABB SoftBodyBullet::get_bounds() const {
|
||||
if (!bt_soft_body) {
|
||||
return AABB();
|
||||
}
|
||||
|
||||
btVector3 aabb_min;
|
||||
btVector3 aabb_max;
|
||||
bt_soft_body->getAabb(aabb_min, aabb_max);
|
||||
|
||||
btVector3 size(aabb_max - aabb_min);
|
||||
|
||||
AABB aabb;
|
||||
B_TO_G(aabb_min, aabb.position);
|
||||
B_TO_G(size, aabb.size);
|
||||
|
||||
return aabb;
|
||||
}
|
||||
|
||||
void SoftBodyBullet::move_all_nodes(const Transform &p_transform) {
|
||||
if (!bt_soft_body) {
|
||||
return;
|
||||
|
|
@ -169,25 +187,6 @@ void SoftBodyBullet::get_node_position(int p_node_index, Vector3 &r_position) co
|
|||
}
|
||||
}
|
||||
|
||||
void SoftBodyBullet::get_node_offset(int p_node_index, Vector3 &r_offset) const {
|
||||
if (soft_mesh.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Array arrays = soft_mesh->surface_get_arrays(0);
|
||||
Vector<Vector3> vertices(arrays[RS::ARRAY_VERTEX]);
|
||||
|
||||
if (0 <= p_node_index && vertices.size() > p_node_index) {
|
||||
r_offset = vertices[p_node_index];
|
||||
}
|
||||
}
|
||||
|
||||
void SoftBodyBullet::get_node_offset(int p_node_index, btVector3 &r_offset) const {
|
||||
Vector3 off;
|
||||
get_node_offset(p_node_index, off);
|
||||
G_TO_B(off, r_offset);
|
||||
}
|
||||
|
||||
void SoftBodyBullet::set_node_mass(int node_index, btScalar p_mass) {
|
||||
if (0 >= p_mass) {
|
||||
pin_node(node_index);
|
||||
|
|
@ -259,20 +258,6 @@ void SoftBodyBullet::set_linear_stiffness(real_t p_val) {
|
|||
}
|
||||
}
|
||||
|
||||
void SoftBodyBullet::set_angular_stiffness(real_t p_val) {
|
||||
angular_stiffness = p_val;
|
||||
if (bt_soft_body) {
|
||||
mat0->m_kAST = angular_stiffness;
|
||||
}
|
||||
}
|
||||
|
||||
void SoftBodyBullet::set_volume_stiffness(real_t p_val) {
|
||||
volume_stiffness = p_val;
|
||||
if (bt_soft_body) {
|
||||
mat0->m_kVST = volume_stiffness;
|
||||
}
|
||||
}
|
||||
|
||||
void SoftBodyBullet::set_simulation_precision(int p_val) {
|
||||
simulation_precision = p_val;
|
||||
if (bt_soft_body) {
|
||||
|
|
@ -290,13 +275,6 @@ void SoftBodyBullet::set_pressure_coefficient(real_t p_val) {
|
|||
}
|
||||
}
|
||||
|
||||
void SoftBodyBullet::set_pose_matching_coefficient(real_t p_val) {
|
||||
pose_matching_coefficient = p_val;
|
||||
if (bt_soft_body) {
|
||||
bt_soft_body->m_cfg.kMT = pose_matching_coefficient;
|
||||
}
|
||||
}
|
||||
|
||||
void SoftBodyBullet::set_damping_coefficient(real_t p_val) {
|
||||
damping_coefficient = p_val;
|
||||
if (bt_soft_body) {
|
||||
|
|
@ -409,8 +387,6 @@ void SoftBodyBullet::setup_soft_body() {
|
|||
bt_soft_body->generateBendingConstraints(2, mat0);
|
||||
|
||||
mat0->m_kLST = linear_stiffness;
|
||||
mat0->m_kAST = angular_stiffness;
|
||||
mat0->m_kVST = volume_stiffness;
|
||||
|
||||
// Clusters allow to have Soft vs Soft collision but doesn't work well right now
|
||||
|
||||
|
|
@ -430,7 +406,6 @@ void SoftBodyBullet::setup_soft_body() {
|
|||
bt_soft_body->m_cfg.kDP = damping_coefficient;
|
||||
bt_soft_body->m_cfg.kDG = drag_coefficient;
|
||||
bt_soft_body->m_cfg.kPR = pressure_coefficient;
|
||||
bt_soft_body->m_cfg.kMT = pose_matching_coefficient;
|
||||
bt_soft_body->setTotalMass(total_mass);
|
||||
|
||||
btSoftBodyHelpers::ReoptimizeLinkOrder(bt_soft_body);
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@
|
|||
@author AndreaCatania
|
||||
*/
|
||||
|
||||
class RenderingServerHandler;
|
||||
|
||||
class SoftBodyBullet : public CollisionObjectBullet {
|
||||
private:
|
||||
btSoftBody *bt_soft_body = nullptr;
|
||||
|
|
@ -67,10 +69,7 @@ private:
|
|||
int simulation_precision = 5;
|
||||
real_t total_mass = 1.;
|
||||
real_t linear_stiffness = 0.5; // [0,1]
|
||||
real_t angular_stiffness = 0.5; // [0,1]
|
||||
real_t volume_stiffness = 0.5; // [0,1]
|
||||
real_t pressure_coefficient = 0.; // [-inf,+inf]
|
||||
real_t pose_matching_coefficient = 0.; // [0,1]
|
||||
real_t damping_coefficient = 0.01; // [0,1]
|
||||
real_t drag_coefficient = 0.; // [0,1]
|
||||
Vector<int> pinned_nodes;
|
||||
|
|
@ -99,7 +98,7 @@ public:
|
|||
|
||||
_FORCE_INLINE_ btSoftBody *get_bt_soft_body() const { return bt_soft_body; }
|
||||
|
||||
void update_rendering_server(class SoftBodyRenderingServerHandler *p_rendering_server_handler);
|
||||
void update_rendering_server(RenderingServerHandler *p_rendering_server_handler);
|
||||
|
||||
void set_soft_mesh(const Ref<Mesh> &p_mesh);
|
||||
void destroy_soft_body();
|
||||
|
|
@ -107,14 +106,12 @@ public:
|
|||
// Special function. This function has bad performance
|
||||
void set_soft_transform(const Transform &p_transform);
|
||||
|
||||
AABB get_bounds() const;
|
||||
|
||||
void move_all_nodes(const Transform &p_transform);
|
||||
void set_node_position(int node_index, const Vector3 &p_global_position);
|
||||
void set_node_position(int node_index, const btVector3 &p_global_position);
|
||||
void get_node_position(int node_index, Vector3 &r_position) const;
|
||||
// Heavy function, Please cache this info
|
||||
void get_node_offset(int node_index, Vector3 &r_offset) const;
|
||||
// Heavy function, Please cache this info
|
||||
void get_node_offset(int node_index, btVector3 &r_offset) const;
|
||||
|
||||
void set_node_mass(int node_index, btScalar p_mass);
|
||||
btScalar get_node_mass(int node_index) const;
|
||||
|
|
@ -129,21 +126,12 @@ public:
|
|||
void set_linear_stiffness(real_t p_val);
|
||||
_FORCE_INLINE_ real_t get_linear_stiffness() const { return linear_stiffness; }
|
||||
|
||||
void set_angular_stiffness(real_t p_val);
|
||||
_FORCE_INLINE_ real_t get_angular_stiffness() const { return angular_stiffness; }
|
||||
|
||||
void set_volume_stiffness(real_t p_val);
|
||||
_FORCE_INLINE_ real_t get_volume_stiffness() const { return volume_stiffness; }
|
||||
|
||||
void set_simulation_precision(int p_val);
|
||||
_FORCE_INLINE_ int get_simulation_precision() const { return simulation_precision; }
|
||||
|
||||
void set_pressure_coefficient(real_t p_val);
|
||||
_FORCE_INLINE_ real_t get_pressure_coefficient() const { return pressure_coefficient; }
|
||||
|
||||
void set_pose_matching_coefficient(real_t p_val);
|
||||
_FORCE_INLINE_ real_t get_pose_matching_coefficient() const { return pose_matching_coefficient; }
|
||||
|
||||
void set_damping_coefficient(real_t p_val);
|
||||
_FORCE_INLINE_ real_t get_damping_coefficient() const { return damping_coefficient; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue