bool SoftBody::_set_property_pinned_points_indices(const Array &p_indices) { const int p_indices_size = p_indices.size(); { // Remove the pined points on physics server that will be removed by resize PoolVector<PinnedPoint>::Read r = pinned_points.read(); if (p_indices_size < pinned_points.size()) { for (int i = pinned_points.size() - 1; i >= p_indices_size; --i) { pin_point(r[i].point_index, false); } } } pinned_points.resize(p_indices_size); PoolVector<PinnedPoint>::Write w = pinned_points.write(); int point_index; for (int i = 0; i < p_indices_size; ++i) { point_index = p_indices.get(i); if (w[i].point_index != point_index) { if (-1 != w[i].point_index) pin_point(w[i].point_index, false); w[i].point_index = point_index; pin_point(w[i].point_index, true); } } return true; }
void SoftBody::set_pinned_points_indices(PoolVector<SoftBody::PinnedPoint> p_pinned_points_indices) { pinned_points = p_pinned_points_indices; PoolVector<PinnedPoint>::Read w = pinned_points.read(); for (int i = pinned_points.size() - 1; 0 <= i; --i) { pin_point(p_pinned_points_indices[i].point_index, true); } }
bool SoftBody::_set_property_pinned_points_attachment(int p_item, const String &p_what, const Variant &p_value) { if (pinned_points_indices.size() <= p_item) { return false; } if ("spatial_attachment_path" == p_what) { PoolVector<PinnedPoint>::Write w = pinned_points_indices.write(); pin_point(w[p_item].point_index, true, p_value); } else { return false; } return true; }
void SoftBody::pin_point_toggle(int p_point_index) { pin_point(p_point_index, !(-1 != _has_pinned_point(p_point_index))); }