From 5a0422c64fb00c61d8d6e76179523f372994d3f8 Mon Sep 17 00:00:00 2001 From: DissonantVoid Date: Mon, 6 Jan 2025 15:30:00 +0100 Subject: [PATCH] added max slope variable to Project on Terrain modifier for Proton Scatter --- .../terrain_3d/extras/project_on_terrain3d.gd | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/project/addons/terrain_3d/extras/project_on_terrain3d.gd b/project/addons/terrain_3d/extras/project_on_terrain3d.gd index 44df20c3..81e25f6c 100644 --- a/project/addons/terrain_3d/extras/project_on_terrain3d.gd +++ b/project/addons/terrain_3d/extras/project_on_terrain3d.gd @@ -21,6 +21,7 @@ # #@export var terrain_node : NodePath #@export var align_with_collision_normal := false +#@export var max_slope := 90.0 # #var _terrain: Terrain3D # @@ -69,17 +70,26 @@ ## Get global transform #var gt: Transform3D = domain.get_global_transform() #var gt_inverse := gt.affine_inverse() + #var new_transforms_array : Array[Transform3D] = [] #for i in transforms.list.size(): - #var location: Vector3 = (gt * transforms.list[i]).origin + #var t: Transform3D = transforms.list[i] + # + #var location: Vector3 = (gt * t).origin #var height: float = _terrain.data.get_height(location) #var normal: Vector3 = _terrain.data.get_normal(location) # #if align_with_collision_normal and not is_nan(normal.x): - #transforms.list[i].basis.y = normal - #transforms.list[i].basis.x = -transforms.list[i].basis.z.cross(normal) - #transforms.list[i].basis = transforms.list[i].basis.orthonormalized() + #t.basis.y = normal + #t.basis.x = -t.basis.z.cross(normal) + #t.basis = t.basis.orthonormalized() +# + #var remapped_max_slope = remap(max_slope, 0.0, 90.0, 0.0, 1.0) + #if abs(Vector3.UP.dot(normal)) >= (1.0 - remapped_max_slope): + #t.origin.y = gt.origin.y if is_nan(height) else height - gt.origin.y + #new_transforms_array.push_back(t) # - #transforms.list[i].origin.y = gt.origin.y if is_nan(height) else height - gt.origin.y + #transforms.list.clear() + #transforms.list.append_array(new_transforms_array) # #if transforms.is_empty(): #warning += """Every point has been removed. Possible reasons include: \n