summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/soft_body.cpp40
-rw-r--r--scene/3d/soft_body.h3
2 files changed, 22 insertions, 21 deletions
diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body.cpp
index ef13985bf4..435bef7247 100644
--- a/scene/3d/soft_body.cpp
+++ b/scene/3d/soft_body.cpp
@@ -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) {
- update_physics_server();
+ prepare_physics_server();
_reset_points_offsets();
#ifdef TOOLS_ENABLED
if (p_changed == this) {
@@ -267,7 +267,7 @@ void SoftBody::_notification(int p_what) {
RID space = get_world()->get_space();
PhysicsServer::get_singleton()->soft_body_set_space(physics_rid, space);
- update_physics_server();
+ prepare_physics_server();
} break;
case NOTIFICATION_READY: {
if (!parent_collision_ignore.is_empty())
@@ -290,21 +290,6 @@ void SoftBody::_notification(int p_what) {
set_notify_transform(true);
} 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: {
_update_pickable();
@@ -421,6 +406,21 @@ String SoftBody::get_configuration_warning() const {
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() {
if (get_mesh().is_null())
return;
@@ -435,6 +435,8 @@ void SoftBody::_draw_soft_mesh() {
call_deferred("set_transform", Transform());
}
+ _update_physics_server();
+
visual_server_handler.open();
PhysicsServer::get_singleton()->soft_body_update_visual_server(physics_rid, &visual_server_handler);
visual_server_handler.close();
@@ -442,7 +444,7 @@ void SoftBody::_draw_soft_mesh() {
visual_server_handler.commit_changes();
}
-void SoftBody::update_physics_server() {
+void SoftBody::prepare_physics_server() {
if (Engine::get_singleton()->is_editor_hint()) {
@@ -706,8 +708,6 @@ SoftBody::SoftBody() :
ray_pickable(true) {
PhysicsServer::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id());
- //set_notify_transform(true);
- set_physics_process_internal(true);
}
SoftBody::~SoftBody() {
diff --git a/scene/3d/soft_body.h b/scene/3d/soft_body.h
index 629c2e42a5..800db12594 100644
--- a/scene/3d/soft_body.h
+++ b/scene/3d/soft_body.h
@@ -116,10 +116,11 @@ protected:
virtual String get_configuration_warning() const;
protected:
+ void _update_physics_server();
void _draw_soft_mesh();
public:
- void update_physics_server();
+ void prepare_physics_server();
void become_mesh_owner();
void set_collision_mask(uint32_t p_mask);