Thanks Jesper and Erik by your comments.<br><br>I'll give you more details about what I trying to do, but I believe that the suggestion here will help me. :)<br><br>I'm coding a "terrain" maker for Wings3d (heightmap plugin). There are some parameters in the form that will result in many different calculations. You can see them in this picture: <a href="http://imageshack.us/f/820/density100.png/">http://imageshack.us/f/820/density100.png/</a><br>
As the list of vertices can be ~147K, I would like to minimize the calcs by fragmenting the code.<br>If the density is changed, then the entire parameters (vertices and faces) need to be recalculated. But if the used just decide to create or not the side faces then I don't need to calculate everything again.<br>
<br>What I thought was to check for every field (parameter) in the form and build an list of what I need to recalculate. I used to store in a {key,data} format because some operations (function to be called) will be repeated for different parameters, but - at the end - it would exists only once in the list.<br>
<br>I've it implemented this way:<br><br><span style="font-family:courier new,monospace">:<br> case changed_field(Old_Res,Res) of <br> {bf, _} -><br> VsBottom0=create_normalized_bottom(W,H,What,VsTop),<br>
FsBottom0=create_faces_bottom(W,H,What),<br> FsSide0=create_faces_side(W,H,What),<br> He0=create_hard_edges(W,H,What,HardEdges),<br> {{VsTop,VsBottom0},{FsTop,FsBottom0,FsSide0},He0};<br>
{sf, _} -><br> VsBottom0=create_normalized_bottom(W,H,What,VsTop),<br> FsBottom0=create_faces_bottom(W,H,What),<br> FsSide0=create_faces_side(W,H,What),<br> He0=create_hard_edges(W,H,What,HardEdges),<br>
{{VsTop,VsBottom0},{FsTop,FsBottom0,FsSide0},He0};<br> {gv, _} -><br> VsTop0=set_ground(CLo,VsTop),<br> {{VsTop0,VsBottom},{FsTop,FsBottom,FsSide},He};<br> {he, Value} -><br>
He0=create_hard_edges(W,H,What,Value),<br> {{VsTop,VsBottom},{FsTop,FsBottom,FsSide},He0};<br> {Fld, _} when Fld=:=density; Fld=:=ih; Fld=:=iw-><br> process_surface(Res);<br> {Fld, _} when Fld=:=scut_lo; Fld=:=scut_hi; Fld=:=es; Fld=:=hs; Fld=:=ws; Fld=:=ar -><br>
Els=wings_pref:get_value(heightmap_elevation),<br> VsTop3=create_normalized_top(W,H,Els),<br> VsBottom1=create_normalized_bottom(W,H,What,VsTop3),<br> VsTop2=set_ground(CLo,VsTop3),<br>
VsTop1=cut(CLo,CHi,VsTop2),<br> {VsTop0,VsBottom0}=scale(Wm,Em,Hm,{VsTop1,VsBottom1}),<br> {{VsTop0,VsBottom0},{FsTop,FsBottom,FsSide},He};<br> _ -> <br> Old_Data<br>
end.<br>:</span><br><br>it's supposing that there is only one field being changed each time it is processed, but it should check for a list. So, that "case" should be in a lists:foreach and the code that has being ran for each option should be processed only after I build this list of function I'm looking for.<br>
<br>I hope I could clarify about what I'm trying to do. (English is not my first language)<br><br>/Micheus<br>