Make softbody completelly stiff to attachment point
This commit is contained in:
parent
de932a5285
commit
ca7ee56759
3 changed files with 23 additions and 21 deletions
|
@ -168,6 +168,7 @@ void SoftBodyBullet::set_node_position(int p_node_index, const Vector3 &p_global
|
||||||
|
|
||||||
void SoftBodyBullet::set_node_position(int p_node_index, const btVector3 &p_global_position) {
|
void SoftBodyBullet::set_node_position(int p_node_index, const btVector3 &p_global_position) {
|
||||||
if (bt_soft_body) {
|
if (bt_soft_body) {
|
||||||
|
bt_soft_body->m_nodes[p_node_index].m_q = bt_soft_body->m_nodes[p_node_index].m_x;
|
||||||
bt_soft_body->m_nodes[p_node_index].m_x = p_global_position;
|
bt_soft_body->m_nodes[p_node_index].m_x = p_global_position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,7 @@ bool SoftBody::_get_property_pinned_points(int p_item, const String &p_what, Var
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftBody::_changed_callback(Object *p_changed, const char *p_prop) {
|
void SoftBody::_changed_callback(Object *p_changed, const char *p_prop) {
|
||||||
update_physics_server();
|
prepare_physics_server();
|
||||||
_reset_points_offsets();
|
_reset_points_offsets();
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
if (p_changed == this) {
|
if (p_changed == this) {
|
||||||
|
@ -267,7 +267,7 @@ void SoftBody::_notification(int p_what) {
|
||||||
|
|
||||||
RID space = get_world()->get_space();
|
RID space = get_world()->get_space();
|
||||||
PhysicsServer::get_singleton()->soft_body_set_space(physics_rid, space);
|
PhysicsServer::get_singleton()->soft_body_set_space(physics_rid, space);
|
||||||
update_physics_server();
|
prepare_physics_server();
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_READY: {
|
case NOTIFICATION_READY: {
|
||||||
if (!parent_collision_ignore.is_empty())
|
if (!parent_collision_ignore.is_empty())
|
||||||
|
@ -290,21 +290,6 @@ void SoftBody::_notification(int p_what) {
|
||||||
set_notify_transform(true);
|
set_notify_transform(true);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
|
|
||||||
|
|
||||||
if (!simulation_started)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_update_cache_pin_points_datas();
|
|
||||||
// Submit bone attachment
|
|
||||||
const int pinned_points_indices_size = pinned_points.size();
|
|
||||||
PoolVector<PinnedPoint>::Read r = pinned_points.read();
|
|
||||||
for (int i = 0; i < pinned_points_indices_size; ++i) {
|
|
||||||
if (r[i].spatial_attachment) {
|
|
||||||
PhysicsServer::get_singleton()->soft_body_move_point(physics_rid, r[i].point_index, r[i].spatial_attachment->get_global_transform().xform(r[i].offset));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||||
|
|
||||||
_update_pickable();
|
_update_pickable();
|
||||||
|
@ -421,6 +406,21 @@ String SoftBody::get_configuration_warning() const {
|
||||||
return warning;
|
return warning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoftBody::_update_physics_server() {
|
||||||
|
if (!simulation_started)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_update_cache_pin_points_datas();
|
||||||
|
// Submit bone attachment
|
||||||
|
const int pinned_points_indices_size = pinned_points.size();
|
||||||
|
PoolVector<PinnedPoint>::Read r = pinned_points.read();
|
||||||
|
for (int i = 0; i < pinned_points_indices_size; ++i) {
|
||||||
|
if (r[i].spatial_attachment) {
|
||||||
|
PhysicsServer::get_singleton()->soft_body_move_point(physics_rid, r[i].point_index, r[i].spatial_attachment->get_global_transform().xform(r[i].offset));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SoftBody::_draw_soft_mesh() {
|
void SoftBody::_draw_soft_mesh() {
|
||||||
if (get_mesh().is_null())
|
if (get_mesh().is_null())
|
||||||
return;
|
return;
|
||||||
|
@ -435,6 +435,8 @@ void SoftBody::_draw_soft_mesh() {
|
||||||
call_deferred("set_transform", Transform());
|
call_deferred("set_transform", Transform());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_update_physics_server();
|
||||||
|
|
||||||
visual_server_handler.open();
|
visual_server_handler.open();
|
||||||
PhysicsServer::get_singleton()->soft_body_update_visual_server(physics_rid, &visual_server_handler);
|
PhysicsServer::get_singleton()->soft_body_update_visual_server(physics_rid, &visual_server_handler);
|
||||||
visual_server_handler.close();
|
visual_server_handler.close();
|
||||||
|
@ -442,7 +444,7 @@ void SoftBody::_draw_soft_mesh() {
|
||||||
visual_server_handler.commit_changes();
|
visual_server_handler.commit_changes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftBody::update_physics_server() {
|
void SoftBody::prepare_physics_server() {
|
||||||
|
|
||||||
if (Engine::get_singleton()->is_editor_hint()) {
|
if (Engine::get_singleton()->is_editor_hint()) {
|
||||||
|
|
||||||
|
@ -706,8 +708,6 @@ SoftBody::SoftBody() :
|
||||||
ray_pickable(true) {
|
ray_pickable(true) {
|
||||||
|
|
||||||
PhysicsServer::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id());
|
PhysicsServer::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id());
|
||||||
//set_notify_transform(true);
|
|
||||||
set_physics_process_internal(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SoftBody::~SoftBody() {
|
SoftBody::~SoftBody() {
|
||||||
|
|
|
@ -116,10 +116,11 @@ protected:
|
||||||
virtual String get_configuration_warning() const;
|
virtual String get_configuration_warning() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void _update_physics_server();
|
||||||
void _draw_soft_mesh();
|
void _draw_soft_mesh();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void update_physics_server();
|
void prepare_physics_server();
|
||||||
void become_mesh_owner();
|
void become_mesh_owner();
|
||||||
|
|
||||||
void set_collision_mask(uint32_t p_mask);
|
void set_collision_mask(uint32_t p_mask);
|
||||||
|
|
Loading…
Reference in a new issue