void CollisionObject2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { Transform2D global_transform = get_global_transform(); if (area) Physics2DServer::get_singleton()->area_set_transform(rid, global_transform); else Physics2DServer::get_singleton()->body_set_state(rid, Physics2DServer::BODY_STATE_TRANSFORM, global_transform); last_transform = global_transform; RID space = get_world_2d()->get_space(); if (area) { Physics2DServer::get_singleton()->area_set_space(rid, space); } else Physics2DServer::get_singleton()->body_set_space(rid, space); _update_pickable(); //get space } case NOTIFICATION_VISIBILITY_CHANGED: { _update_pickable(); } break; case NOTIFICATION_TRANSFORM_CHANGED: { Transform2D global_transform = get_global_transform(); if (only_update_transform_changes && global_transform == last_transform) { return; } if (area) Physics2DServer::get_singleton()->area_set_transform(rid, global_transform); else Physics2DServer::get_singleton()->body_set_state(rid, Physics2DServer::BODY_STATE_TRANSFORM, global_transform); last_transform = global_transform; } break; case NOTIFICATION_EXIT_TREE: { if (area) { Physics2DServer::get_singleton()->area_set_space(rid, RID()); } else Physics2DServer::get_singleton()->body_set_space(rid, RID()); } break; } }
void CollisionObject2D::set_pickable(bool p_enabled) { if (pickable == p_enabled) return; pickable = p_enabled; _update_pickable(); }
void SoftBody::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_WORLD: { if (Engine::get_singleton()->is_editor_hint()) add_change_receptor(this); RID space = get_world()->get_space(); PhysicsServer::get_singleton()->soft_body_set_space(physics_rid, space); PhysicsServer::get_singleton()->soft_body_set_transform(physics_rid, get_global_transform()); update_physics_server(); } break; case NOTIFICATION_READY: { if (!parent_collision_ignore.is_empty()) add_collision_exception_with(get_node(parent_collision_ignore)); } break; case NOTIFICATION_TRANSFORM_CHANGED: { if (!simulation_started) { PhysicsServer::get_singleton()->soft_body_set_transform(physics_rid, get_global_transform()); _update_cache_pin_points_datas(); // Submit bone attachment const int pinned_points_indices_size = pinned_points_indices.size(); PoolVector<PinnedPoint>::Read r = pinned_points_indices.read(); for (int i = 0; i < pinned_points_indices_size; ++i) { if (!r[i].spatial_attachment) { // Use soft body position to update the point position PhysicsServer::get_singleton()->soft_body_move_point(physics_rid, r[i].point_index, (get_global_transform() * r[i].vertex_offset_transform).origin); } else { PhysicsServer::get_singleton()->soft_body_move_point(physics_rid, r[i].point_index, (r[i].spatial_attachment->get_global_transform() * r[i].vertex_offset_transform).origin); } } } } break; case NOTIFICATION_VISIBILITY_CHANGED: { _update_pickable(); } break; case NOTIFICATION_EXIT_WORLD: { PhysicsServer::get_singleton()->soft_body_set_space(physics_rid, RID()); } break; } #ifdef TOOLS_ENABLED if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) { if (Engine::get_singleton()->is_editor_hint()) { update_configuration_warning(); } } #endif }
void CollisionObject::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_WORLD: { if (area) PhysicsServer::get_singleton()->area_set_transform(rid, get_global_transform()); else PhysicsServer::get_singleton()->body_set_state(rid, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform()); RID space = get_world()->get_space(); if (area) { PhysicsServer::get_singleton()->area_set_space(rid, space); } else PhysicsServer::get_singleton()->body_set_space(rid, space); _update_pickable(); //get space }; case NOTIFICATION_TRANSFORM_CHANGED: { if (area) PhysicsServer::get_singleton()->area_set_transform(rid, get_global_transform()); else PhysicsServer::get_singleton()->body_set_state(rid, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform()); } break; case NOTIFICATION_VISIBILITY_CHANGED: { _update_pickable(); } break; case NOTIFICATION_EXIT_WORLD: { if (area) { PhysicsServer::get_singleton()->area_set_space(rid, RID()); } else PhysicsServer::get_singleton()->body_set_space(rid, RID()); } break; } }
void SoftBody::set_ray_pickable(bool p_ray_pickable) { ray_pickable = p_ray_pickable; _update_pickable(); }
void SoftBody::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_WORLD: { if (Engine::get_singleton()->is_editor_hint()) { add_change_receptor(this); } RID space = get_world()->get_space(); PhysicsServer::get_singleton()->soft_body_set_space(physics_rid, space); update_physics_server(); } break; case NOTIFICATION_READY: { if (!parent_collision_ignore.is_empty()) add_collision_exception_with(get_node(parent_collision_ignore)); } break; case NOTIFICATION_TRANSFORM_CHANGED: { if (Engine::get_singleton()->is_editor_hint()) { _reset_points_offsets(); return; } PhysicsServer::get_singleton()->soft_body_set_transform(physics_rid, get_global_transform()); set_notify_transform(false); // Required to be top level with Transform at center of world in order to modify VisualServer only to support custom Transform set_as_toplevel(true); set_transform(Transform()); 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(); } break; case NOTIFICATION_EXIT_WORLD: { PhysicsServer::get_singleton()->soft_body_set_space(physics_rid, RID()); } break; } #ifdef TOOLS_ENABLED if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) { if (Engine::get_singleton()->is_editor_hint()) { update_configuration_warning(); } } #endif }
void CollisionObject::set_ray_pickable(bool p_ray_pickable) { ray_pickable = p_ray_pickable; _update_pickable(); }