@@ -13,6 +13,7 @@ var start_point := Vector3(0, 0, 0);
1313var side : VMFSide ;
1414var brush : VMFSolid ;
1515var vertices : PackedVector3Array ;
16+ var elevation : float = 0.0 ;
1617
1718func _to_string () -> String :
1819 return "VMFDisplacementInfo(verts_count=%d , edges_count=%d , start_point=%s , side_id=%d , brush_id=%d )" % [verts_count , edges_count , start_point , side .id , brush .id ];
@@ -35,9 +36,13 @@ func _init(raw: Dictionary, side: VMFSide, brush: VMFSolid) -> void:
3536 offsets = _parse_vectors ('offsets' );
3637 offset_normals = _parse_vectors ('offset_normals' );
3738 alphas = _parse_floats ('alphas' );
38- vertices = PackedVector3Array ( get_vertices ( ));
39+ elevation = float ( raw . get ( 'elevation' , 0.0 ));
3940 disp_info = null ;
4041
42+ ## Called from the VMFSide during the calculation of its vertices.
43+ func calculate_vertices () -> void :
44+ vertices = PackedVector3Array (get_vertices ());
45+
4146func get_normal (x : float , y : float ) -> Vector3 :
4247 var index = y + x * verts_count ;
4348 if normals .size () == 0 :
@@ -96,7 +101,7 @@ func get_vertices() -> Array[Vector3]:
96101 var vr := tr .lerp (br , rblend );
97102 var vert := vl .lerp (vr , cblend );
98103
99- vert += get_distance (x , y ) + get_offset (x , y ) + side .plane .normal * disp_info . elevation ;
104+ vert += get_distance (x , y ) + get_offset (x , y ) + side .plane .normal * elevation ;
100105
101106 res .append (vert );
102107
0 commit comments