feat: removed practically unneeded properties
This commit is contained in:
parent
2efd3d2ddf
commit
65bf506f0b
3 changed files with 43 additions and 106 deletions
|
|
@ -6,7 +6,6 @@
|
|||
#include <algorithm>
|
||||
|
||||
void TerrainModifier::_bind_methods() {
|
||||
BIND_HPROPERTY(Variant::INT, blend_mode, PROPERTY_HINT_ENUM, BlendMode_hint());
|
||||
BIND_PROPERTY(Variant::FLOAT, blend_distance);
|
||||
}
|
||||
|
||||
|
|
@ -35,22 +34,10 @@ float TerrainModifier::blend(float under, float over) {
|
|||
: this->blend_distance * 0.25f - distance / this->blend_distance
|
||||
};
|
||||
if (center_distance < 0.f) {
|
||||
if (this->blend_mode == Override) {
|
||||
return over;
|
||||
} else if (this->blend_mode == Add) {
|
||||
return under > over ? under : over;
|
||||
} else {
|
||||
return under > over ? over : under;
|
||||
}
|
||||
return over;
|
||||
}
|
||||
float const smooth_center_distance{ center_distance * center_distance };
|
||||
if (this->blend_mode == Override) {
|
||||
return over + smooth_center_distance;
|
||||
} else {
|
||||
return (this->blend_mode == Add
|
||||
? (under > over ? under : over) + smooth_center_distance
|
||||
: (under > over ? over : under) - smooth_center_distance);
|
||||
}
|
||||
return over + smooth_center_distance;
|
||||
}
|
||||
|
||||
void TerrainModifier::push_changed(Rect2 area) {
|
||||
|
|
@ -77,14 +64,6 @@ float TerrainModifier::get_blend_distance() const {
|
|||
return this->blend_distance;
|
||||
}
|
||||
|
||||
void TerrainModifier::set_blend_mode(BlendMode mode) {
|
||||
this->blend_mode = mode;
|
||||
}
|
||||
|
||||
TerrainModifier::BlendMode TerrainModifier::get_blend_mode() const {
|
||||
return this->blend_mode;
|
||||
}
|
||||
|
||||
void SharedMutex::lock_shared() {
|
||||
this->lock.lock();
|
||||
this->shared_count++;
|
||||
|
|
@ -113,14 +92,10 @@ void SharedMutex::unlock_exclusive() {
|
|||
|
||||
void TerrainModifierDistance::_bind_methods() {
|
||||
BIND_HPROPERTY(Variant::OBJECT, distance_weight_curve, PROPERTY_HINT_RESOURCE_TYPE, "Curve");
|
||||
BIND_HPROPERTY(Variant::OBJECT, distance_height_curve, PROPERTY_HINT_RESOURCE_TYPE, "Curve");
|
||||
}
|
||||
|
||||
void TerrainModifierDistance::curves_changed() {
|
||||
this->lock.lock_exclusive();
|
||||
if (this->distance_height_curve.is_valid()) {
|
||||
this->distance_height_curve->bake();
|
||||
}
|
||||
if (this->distance_weight_curve.is_valid()) {
|
||||
this->distance_weight_curve->bake();
|
||||
}
|
||||
|
|
@ -180,7 +155,7 @@ float TerrainModifierDistance::distance_at(Vector2 const &world_coordinate) {
|
|||
|
||||
float TerrainModifierDistance::evaluate_at(Vector2 world_coordinate, float before) {
|
||||
this->lock.lock_shared();
|
||||
if (this->distance_weight_curve.is_null() || this->distance_height_curve.is_null()) {
|
||||
if (this->distance_weight_curve.is_null()) {
|
||||
this->lock.unlock_shared();
|
||||
return before;
|
||||
}
|
||||
|
|
@ -192,18 +167,14 @@ float TerrainModifierDistance::evaluate_at(Vector2 world_coordinate, float befor
|
|||
float const weight_offset{
|
||||
std::clamp(distance, this->distance_weight_curve->get_min_domain(), this->distance_weight_curve->get_max_domain())
|
||||
};
|
||||
float const height_offset{
|
||||
std::clamp(distance, this->distance_height_curve->get_min_domain(), this->distance_height_curve->get_max_domain())
|
||||
};
|
||||
this->lock.unlock_shared();
|
||||
|
||||
this->lock.lock_exclusive();
|
||||
float const weight{ this->distance_weight_curve->sample_baked(weight_offset) };
|
||||
float const height{ this->distance_height_curve->sample_baked(height_offset) };
|
||||
this->lock.unlock_exclusive();
|
||||
|
||||
this->lock.lock_shared();
|
||||
float out{ weight <= 0.f ? before : Math::lerp(before, blend(before, height + get_thread_safe_global_position().y), weight) };
|
||||
float out{ weight <= 0.f ? before : Math::lerp(before, blend(before, get_thread_safe_global_position().y), weight) };
|
||||
this->lock.unlock_shared();
|
||||
|
||||
return out;
|
||||
|
|
@ -214,9 +185,6 @@ PackedStringArray TerrainModifierDistance::get_configuration_warnings() const {
|
|||
if (this->distance_weight_curve.is_null()) {
|
||||
warnings.push_back("distance_weight_curve is invalid, add a valid distance_weight_curve");
|
||||
}
|
||||
if (this->distance_height_curve.is_null()) {
|
||||
warnings.push_back("distance_height_curve is invalid, add a valid distance_height_curve");
|
||||
}
|
||||
return warnings;
|
||||
}
|
||||
|
||||
|
|
@ -239,23 +207,3 @@ void TerrainModifierDistance::set_distance_weight_curve(Ref<Curve> curve) {
|
|||
Ref<Curve> TerrainModifierDistance::get_distance_weight_curve() const {
|
||||
return this->distance_weight_curve;
|
||||
}
|
||||
|
||||
void TerrainModifierDistance::set_distance_height_curve(Ref<Curve> curve) {
|
||||
this->lock.lock_exclusive();
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
if (this->distance_height_curve.is_valid()) {
|
||||
this->distance_height_curve->disconnect_changed(callable_mp(this, &self_type::curves_changed));
|
||||
}
|
||||
if (curve.is_valid()) {
|
||||
curve->connect_changed(callable_mp(this, &self_type::curves_changed));
|
||||
}
|
||||
}
|
||||
this->distance_height_curve = curve;
|
||||
this->lock.unlock_exclusive();
|
||||
curves_changed();
|
||||
update_configuration_warnings();
|
||||
}
|
||||
|
||||
Ref<Curve> TerrainModifierDistance::get_distance_height_curve() const {
|
||||
return this->distance_height_curve;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@ class TerrainModifier : public Marker3D {
|
|||
GDCLASS(TerrainModifier, Marker3D);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
GDENUM(BlendMode, Add, Subtract, Override);
|
||||
|
||||
protected:
|
||||
void _notification(int what);
|
||||
float blend(float under, float over);
|
||||
|
|
@ -25,7 +22,6 @@ public:
|
|||
|
||||
private:
|
||||
float blend_distance{ 10.0 };
|
||||
BlendMode blend_mode{ Add };
|
||||
Vector3 thread_safe_global_position{};
|
||||
Terrain *terrain{ nullptr };
|
||||
Rect2 bounds{ { -INFINITY, -INFINITY }, { INFINITY, INFINITY } };
|
||||
|
|
@ -37,13 +33,9 @@ public:
|
|||
Vector3 get_thread_safe_global_position() const;
|
||||
void set_blend_distance(float value);
|
||||
float get_blend_distance() const;
|
||||
void set_blend_mode(BlendMode mode);
|
||||
BlendMode get_blend_mode() const;
|
||||
GET_SET_FNS(Terrain *, terrain);
|
||||
};
|
||||
|
||||
MAKE_TYPE_INFO(TerrainModifier::BlendMode, Variant::INT);
|
||||
|
||||
struct SharedMutex {
|
||||
void lock_shared();
|
||||
void unlock_shared();
|
||||
|
|
@ -72,11 +64,8 @@ public:
|
|||
private:
|
||||
SharedMutex lock{};
|
||||
Ref<Curve> distance_weight_curve{};
|
||||
Ref<Curve> distance_height_curve{};
|
||||
|
||||
public:
|
||||
void set_distance_weight_curve(Ref<Curve> curve);
|
||||
Ref<Curve> get_distance_weight_curve() const;
|
||||
void set_distance_height_curve(Ref<Curve> curve);
|
||||
Ref<Curve> get_distance_height_curve() const;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,32 +12,25 @@ sky_material = SubResource("ProceduralSkyMaterial_kbmr5")
|
|||
background_mode = 2
|
||||
sky = SubResource("Sky_w3uoq")
|
||||
|
||||
[sub_resource type="Curve" id="Curve_chm2y"]
|
||||
_limits = [0.0, 1.0, 0.0, 500.0]
|
||||
_data = [Vector2(0, 1), 0.0, -0.0016919965, 0, 0, Vector2(228.71338, 0.44817185), -0.0011880936, -0.0011880936, 0, 0, Vector2(500, 0), 7.00571e-05, -0.05797184, 0, 0]
|
||||
point_count = 3
|
||||
|
||||
[sub_resource type="Curve" id="Curve_o3i6r"]
|
||||
_limits = [-30.0, 0.0, 0.0, 100.0]
|
||||
_data = [Vector2(0, 0), 0.0, -0.56894803, 0, 0]
|
||||
point_count = 1
|
||||
|
||||
[sub_resource type="Curve" id="Curve_kbmr5"]
|
||||
_limits = [0.0, 1.0, 0.0, 323.34308]
|
||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(134.4993, 0.6274206), -0.006221681, -0.006221681, 0, 0, Vector2(237.39348, 0.0977577), -0.0030463666, -0.0030463666, 0, 0, Vector2(323.34308, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 4
|
||||
|
||||
[sub_resource type="Curve" id="Curve_w3uoq"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_nonsf"]
|
||||
_limits = [0.0, 1.0, 0.0, 500.0]
|
||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(275.82242, 0.47838098), -0.0056187166, -0.0056187166, 0, 0, Vector2(500, 0), 0.0, 0.0, 0, 0]
|
||||
_data = [Vector2(47.722435, 1), 0.0, -9.816581e-05, 0, 0, Vector2(342.76538, 0.38576716), -0.0041318936, -0.0041318936, 0, 0, Vector2(500, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 3
|
||||
|
||||
[sub_resource type="Curve" id="Curve_4kj3c"]
|
||||
_limits = [0.0, 1.0, 0.0, 100.0]
|
||||
_data = [Vector2(0, 1), 0.036407854, 0.0, 0, 0]
|
||||
point_count = 1
|
||||
[sub_resource type="Curve" id="Curve_w3uoq"]
|
||||
_limits = [0.0, 1.0, 0.0, 500.0]
|
||||
_data = [Vector2(0, 1), 0.0, -9.816581e-05, 0, 0, Vector2(336.56702, 0.4844582), -0.00438691, -0.00438691, 0, 0, Vector2(500, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 3
|
||||
|
||||
[sub_resource type="Curve" id="Curve_kbmr5"]
|
||||
_limits = [0.0, 1.0, 0.0, 300.0]
|
||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(126.071, 0.5549462), -0.009107173, -0.009107173, 0, 0, Vector2(186.00266, 0.15958571), -0.004071936, -0.004071936, 0, 0, Vector2(300, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 4
|
||||
|
||||
[sub_resource type="Curve" id="Curve_chm2y"]
|
||||
_limits = [0.0, 1.0, 0.0, 300.0]
|
||||
_data = [Vector2(0, 1), -0.005856493, -0.0037222188, 0, 0, Vector2(300, 0), 7.00571e-05, -0.05797184, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_kbmr5"]
|
||||
|
||||
|
|
@ -49,26 +42,33 @@ environment = SubResource("Environment_o3i6r")
|
|||
[node name="Terrain" type="Terrain" parent="." unique_id=1169843565]
|
||||
side_length = 1000
|
||||
chunk_size = 100
|
||||
thread_count = 2
|
||||
|
||||
[node name="TerrainModifierDistance3" type="TerrainModifierDistance" parent="Terrain" unique_id=1846439541]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 392.32507, 273.6683, 272.20636)
|
||||
blend_distance = 4.0
|
||||
distance_weight_curve = SubResource("Curve_chm2y")
|
||||
distance_height_curve = SubResource("Curve_o3i6r")
|
||||
|
||||
[node name="TerrainModifierDistance" type="TerrainModifierDistance" parent="Terrain" unique_id=1885116624]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 115.563965, 111.77251, 558.931)
|
||||
blend_distance = 4.0
|
||||
distance_weight_curve = SubResource("Curve_kbmr5")
|
||||
distance_height_curve = SubResource("Curve_w3uoq")
|
||||
thread_count = 5
|
||||
|
||||
[node name="TerrainModifierDistance2" type="TerrainModifierDistance" parent="Terrain" unique_id=2110821264]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 788.26746, -118.721924, 675.6073)
|
||||
blend_mode = 2
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 818.99365, -123.52425, 223.5953)
|
||||
blend_distance = 0.0
|
||||
distance_weight_curve = SubResource("Curve_nonsf")
|
||||
distance_height_curve = SubResource("Curve_4kj3c")
|
||||
|
||||
[node name="TerrainModifierDistance5" type="TerrainModifierDistance" parent="Terrain" unique_id=54251754]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 587.8701, -100.01076, 96.289734)
|
||||
blend_distance = 0.0
|
||||
distance_weight_curve = SubResource("Curve_w3uoq")
|
||||
|
||||
[node name="TerrainModifierDistance4" type="TerrainModifierDistance" parent="Terrain" unique_id=961725906]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 945.23486, -103.52425, 674.6181)
|
||||
blend_distance = 0.0
|
||||
distance_weight_curve = SubResource("Curve_nonsf")
|
||||
|
||||
[node name="TerrainModifierDistance" type="TerrainModifierDistance" parent="Terrain" unique_id=1885116624]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 111.654144, 74.591, 740.1567)
|
||||
blend_distance = 0.0
|
||||
distance_weight_curve = SubResource("Curve_kbmr5")
|
||||
|
||||
[node name="TerrainModifierDistance3" type="TerrainModifierDistance" parent="Terrain" unique_id=1846439541]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 260.8238, 202.32297, 899.09283)
|
||||
blend_distance = 0.0
|
||||
distance_weight_curve = SubResource("Curve_chm2y")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=1089775425]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 98.446144, 24.222893, 90.491714)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 625.56537, 191.07982, 795.4992)
|
||||
mesh = SubResource("BoxMesh_kbmr5")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue