feat: paths support 1 curve
This commit is contained in:
parent
fac1f4c733
commit
7a2ed4a785
2 changed files with 25 additions and 25 deletions
|
|
@ -223,7 +223,7 @@ void TerrainModifierPath::curves_changed() {
|
|||
bool TerrainModifierPath::update_bounds() {
|
||||
Vector2 min{}, max{};
|
||||
this->lock.lock_shared();
|
||||
if (this->points.is_empty() || this->curve_left.is_null() || this->curve_right.is_null()) {
|
||||
if (this->points.is_empty() || this->curve_left.is_null()) {
|
||||
Vector3 point{ this->get_thread_safe_global_position() };
|
||||
min.x = point.x;
|
||||
min.y = point.z;
|
||||
|
|
@ -237,10 +237,13 @@ bool TerrainModifierPath::update_bounds() {
|
|||
min.y = min.y < point.z ? min.y : point.z;
|
||||
}
|
||||
float max_distance_left{ this->curve_left->get_max_domain() };
|
||||
float max_distance_right{ this->curve_right->get_max_domain() };
|
||||
float max_distance{ max_distance_left > max_distance_right ? max_distance_left : max_distance_right };
|
||||
float max_distance{ max_distance_left };
|
||||
if (this->curve_right.is_valid()) {
|
||||
float max_distance_right{ this->curve_right->get_max_domain() };
|
||||
max_distance = max_distance_right > max_distance ? max_distance_right : max_distance;
|
||||
}
|
||||
min -= { max_distance, max_distance };
|
||||
max += { max_distance, max_distance };
|
||||
max += { max_distance * 2.f, max_distance * 2.f };
|
||||
}
|
||||
Rect2 bounds{ min, max - min };
|
||||
bool const changed{ bounds != get_bounds() };
|
||||
|
|
@ -371,10 +374,7 @@ void TerrainModifierPath::path_changed() {
|
|||
PackedStringArray TerrainModifierPath::get_configuration_warnings() const {
|
||||
PackedStringArray warnings{ super_type::get_configuration_warnings() };
|
||||
if (this->curve_left.is_null()) {
|
||||
warnings.push_back("distance_weight_curve is invalid, add a valid curve_left");
|
||||
}
|
||||
if (this->curve_right.is_null()) {
|
||||
warnings.push_back("distance_weight_curve is invalid, add a valid curve_right");
|
||||
warnings.push_back("curve_left is invalid, add a valid curve_left");
|
||||
}
|
||||
return warnings;
|
||||
}
|
||||
|
|
@ -383,11 +383,6 @@ void TerrainModifierPath::set_curve_left(Ref<Curve> curve) {
|
|||
this->lock.lock_exclusive();
|
||||
if (curve.is_valid() && curve == this->curve_right) {
|
||||
curve = curve->duplicate();
|
||||
} else if (!curve.is_valid() && this->curve_right.is_valid()) {
|
||||
curve = this->curve_right;
|
||||
this->lock.unlock_exclusive();
|
||||
set_curve_right(nullptr);
|
||||
this->lock.lock_exclusive();
|
||||
}
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
if (this->curve_left.is_valid()) {
|
||||
|
|
@ -399,8 +394,13 @@ void TerrainModifierPath::set_curve_left(Ref<Curve> curve) {
|
|||
}
|
||||
this->curve_left = curve;
|
||||
this->lock.unlock_exclusive();
|
||||
curves_changed();
|
||||
update_configuration_warnings();
|
||||
if (!curve.is_valid() && this->curve_right.is_valid()) {
|
||||
curve = this->curve_right;
|
||||
set_curve_right(nullptr);
|
||||
} else {
|
||||
curves_changed();
|
||||
update_configuration_warnings();
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Curve> TerrainModifierPath::get_curve_left() const {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue