fix snow cap
This commit is contained in:
@@ -20,17 +20,14 @@ const SNOW_CAP_SHADER: Shader = preload("res://core/daynight/snow_cap.gdshader")
|
|||||||
|
|
||||||
var _mesh_instance: MeshInstance3D
|
var _mesh_instance: MeshInstance3D
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
add_to_group("weather_overlay_ignore")
|
add_to_group("weather_overlay_ignore")
|
||||||
_ensure_mesh_instance()
|
_ensure_mesh_instance()
|
||||||
_rebuild()
|
_rebuild()
|
||||||
|
|
||||||
|
|
||||||
func rebuild() -> void:
|
func rebuild() -> void:
|
||||||
_rebuild()
|
_rebuild()
|
||||||
|
|
||||||
|
|
||||||
func _ensure_mesh_instance() -> void:
|
func _ensure_mesh_instance() -> void:
|
||||||
_mesh_instance = get_node_or_null("SnowCapMesh") as MeshInstance3D
|
_mesh_instance = get_node_or_null("SnowCapMesh") as MeshInstance3D
|
||||||
if _mesh_instance != null:
|
if _mesh_instance != null:
|
||||||
@@ -41,7 +38,6 @@ func _ensure_mesh_instance() -> void:
|
|||||||
_mesh_instance.add_to_group("weather_overlay_ignore")
|
_mesh_instance.add_to_group("weather_overlay_ignore")
|
||||||
add_child(_mesh_instance)
|
add_child(_mesh_instance)
|
||||||
|
|
||||||
|
|
||||||
func _rebuild() -> void:
|
func _rebuild() -> void:
|
||||||
var cap_width: float = 0.0
|
var cap_width: float = 0.0
|
||||||
var cap_depth: float = 0.0
|
var cap_depth: float = 0.0
|
||||||
@@ -78,7 +74,6 @@ func _rebuild() -> void:
|
|||||||
_mesh_instance.material_override = _build_material(cap_width, cap_depth)
|
_mesh_instance.material_override = _build_material(cap_width, cap_depth)
|
||||||
_mesh_instance.visible = true
|
_mesh_instance.visible = true
|
||||||
|
|
||||||
|
|
||||||
func _build_material(cap_width: float, cap_depth: float) -> ShaderMaterial:
|
func _build_material(cap_width: float, cap_depth: float) -> ShaderMaterial:
|
||||||
var material := ShaderMaterial.new()
|
var material := ShaderMaterial.new()
|
||||||
material.shader = SNOW_CAP_SHADER
|
material.shader = SNOW_CAP_SHADER
|
||||||
@@ -87,7 +82,6 @@ func _build_material(cap_width: float, cap_depth: float) -> ShaderMaterial:
|
|||||||
material.set_shader_parameter("half_depth", cap_depth * 0.5)
|
material.set_shader_parameter("half_depth", cap_depth * 0.5)
|
||||||
return material
|
return material
|
||||||
|
|
||||||
|
|
||||||
func _get_target_aabb(target_mesh: MeshInstance3D) -> AABB:
|
func _get_target_aabb(target_mesh: MeshInstance3D) -> AABB:
|
||||||
var points: Array[Vector3] = []
|
var points: Array[Vector3] = []
|
||||||
for point in _get_aabb_points(target_mesh.get_aabb()):
|
for point in _get_aabb_points(target_mesh.get_aabb()):
|
||||||
@@ -98,7 +92,6 @@ func _get_target_aabb(target_mesh: MeshInstance3D) -> AABB:
|
|||||||
merged = merged.expand(point)
|
merged = merged.expand(point)
|
||||||
return merged
|
return merged
|
||||||
|
|
||||||
|
|
||||||
func _get_aabb_points(aabb: AABB) -> Array[Vector3]:
|
func _get_aabb_points(aabb: AABB) -> Array[Vector3]:
|
||||||
var p: Vector3 = aabb.position
|
var p: Vector3 = aabb.position
|
||||||
var s: Vector3 = aabb.size
|
var s: Vector3 = aabb.size
|
||||||
|
|||||||
Reference in New Issue
Block a user