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 {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ point_count = 3
|
|||
|
||||
[sub_resource type="Curve" id="Curve_o3i6r"]
|
||||
_limits = [0.0, 1.0, 0.0, 5.0]
|
||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.5354336, 1), 0.0, 0.0, 0, 0, Vector2(5, 0), 0.0, 0.0, 0, 0]
|
||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1.215907, 1), 0.0, 0.0, 0, 0, Vector2(1.8194687, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 3
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_kbmr5"]
|
||||
|
|
@ -86,37 +86,37 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 784.91595, 251.11382, 135.921
|
|||
distance_weight_curve = SubResource("Curve_chm2y")
|
||||
|
||||
[node name="TerrainModifierPath2" type="TerrainModifierPath" parent="Terrain" unique_id=515690726]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 368.5579, 5.0770416, 414.4787)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 368.5579, 8.567036, 412.4803)
|
||||
curve_left = SubResource("Curve_o3i6r")
|
||||
|
||||
[node name="TerrainModifierPathPoint7" type="TerrainModifierPathPoint" parent="Terrain/TerrainModifierPath2" unique_id=283037782]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 30.025024, -5.665145, -37.19107)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 30.025024, -9.3514, -37.19107)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="TerrainModifierPathPoint6" type="TerrainModifierPathPoint" parent="Terrain/TerrainModifierPath2" unique_id=1696432484]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12.917389, -9.399911, -41.447937)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12.917389, -11.265772, -41.447937)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="TerrainModifierPathPoint" type="TerrainModifierPathPoint" parent="Terrain/TerrainModifierPath2" unique_id=870583505]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.7605286, -10.70397, -33.974182)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.7605286, -11.487162, -33.974182)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="TerrainModifierPathPoint2" type="TerrainModifierPathPoint" parent="Terrain/TerrainModifierPath2" unique_id=2085062411]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -17.681885, -11.332738, -8.841034)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -17.681885, -12.115929, -8.841034)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="TerrainModifierPathPoint3" type="TerrainModifierPathPoint" parent="Terrain/TerrainModifierPath2" unique_id=1608777346]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -21.356476, -11.604663, 8.474121)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -21.356476, -12.387854, 8.474121)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="TerrainModifierPathPoint4" type="TerrainModifierPathPoint" parent="Terrain/TerrainModifierPath2" unique_id=2089784013]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14.419983, -9.546529, 16.345459)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14.419983, -10.32972, 16.345459)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="TerrainModifierPathPoint5" type="TerrainModifierPathPoint" parent="Terrain/TerrainModifierPath2" unique_id=732306824]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.16311646, -7.533708, 20.998108)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.16311646, -8.924315, 20.998108)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=1089775425]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 625.56537, 191.07982, 795.4992)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 352.22195, 0, 401.61105)
|
||||
mesh = SubResource("BoxMesh_kbmr5")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue