14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
17
- import sys , os , shutil , json , traceback , math
17
+ import sys , os , shutil , json , traceback , math , time
18
18
19
19
from .objects import flip_fluid_map
20
20
from .objects import flip_fluid_geometry_database
@@ -160,7 +160,8 @@ def __extract_keyframed_mesh(object_name, frameno):
160
160
raise Exception (msg )
161
161
162
162
tmesh = TriangleMesh .from_bobj (bobj_data )
163
- tmesh .apply_transform (__extract_transform_data (object_name , frameno ))
163
+ transform_data = __extract_transform_data (object_name , frameno )
164
+ tmesh .apply_transform (transform_data )
164
165
165
166
data = __get_simulation_data ()
166
167
scale = data .domain_data .initialize .scale
@@ -1044,6 +1045,11 @@ def __initialize_fluid_simulation_settings(fluidsim, data):
1044
1045
# World Settings
1045
1046
world = dprops .world
1046
1047
fluidsim .add_body_force (__get_parameter_data (world .gravity , frameno ))
1048
+ fluidsim .force_field_weight_fluid_particles = __get_parameter_data (world .force_field_weight_fluid_particles , frameno )
1049
+ fluidsim .force_field_weight_whitewater_foam = __get_parameter_data (world .force_field_weight_whitewater_foam , frameno )
1050
+ fluidsim .force_field_weight_whitewater_bubble = __get_parameter_data (world .force_field_weight_whitewater_bubble , frameno )
1051
+ fluidsim .force_field_weight_whitewater_spray = __get_parameter_data (world .force_field_weight_whitewater_spray , frameno )
1052
+ fluidsim .force_field_weight_whitewater_dust = __get_parameter_data (world .force_field_weight_whitewater_dust , frameno )
1047
1053
1048
1054
# Caches created in older versions may not contain force field data. Ignore these features
1049
1055
# if force field data cannot be found in the cache
@@ -1295,6 +1301,9 @@ def __initialize_fluid_simulation_settings(fluidsim, data):
1295
1301
fluidsim .enable_asynchronous_meshing = \
1296
1302
__get_parameter_data (advanced .enable_asynchronous_meshing , frameno )
1297
1303
1304
+ fluidsim .enable_fracture_optimization = \
1305
+ __get_parameter_data (advanced .enable_fracture_optimization , frameno )
1306
+
1298
1307
fluidsim .enable_static_solid_levelset_precomputation = \
1299
1308
__get_parameter_data (advanced .precompute_static_obstacles , frameno )
1300
1309
@@ -1633,15 +1642,20 @@ def __update_dynamic_force_field_mesh(animated_object, object_data):
1633
1642
animated_object .update_mesh_animated (mesh_previous , mesh_current , mesh_next )
1634
1643
1635
1644
1636
- def __update_animatable_inflow_properties (data , frameid ):
1645
+ def __update_animatable_inflow_properties (data , mesh_geometry_data , frameid ):
1637
1646
inflow_objects = data .inflow_objects
1638
1647
inflow_data = data .inflow_data
1639
1648
1640
1649
for idx , inflow in enumerate (inflow_objects ):
1641
1650
data = inflow_data [idx ]
1642
1651
1643
- if __is_object_dynamic (data .name ):
1644
- __update_dynamic_object_mesh (inflow , data )
1652
+ name_slug = __get_name_slug (data .name )
1653
+ object_geometry_data = mesh_geometry_data [name_slug ]
1654
+ if object_geometry_data ["is_motion_dynamic" ]:
1655
+ mesh_previous = object_geometry_data ["triangle_mesh_previous" ]
1656
+ mesh_current = object_geometry_data ["triangle_mesh_current" ]
1657
+ mesh_next = object_geometry_data ["triangle_mesh_next" ]
1658
+ inflow .update_mesh_animated (mesh_previous , mesh_current , mesh_next )
1645
1659
1646
1660
inflow .enable = __get_parameter_data (data .is_enabled , frameid )
1647
1661
inflow .set_velocity (__get_inflow_object_velocity (data , frameid ))
@@ -1662,15 +1676,20 @@ def __update_animatable_inflow_properties(data, frameid):
1662
1676
inflow .set_source_color (__get_parameter_data (data .color , frameid ))
1663
1677
1664
1678
1665
- def __update_animatable_outflow_properties (data , frameid ):
1679
+ def __update_animatable_outflow_properties (data , mesh_geometry_data , frameid ):
1666
1680
outflow_objects = data .outflow_objects
1667
1681
outflow_data = data .outflow_data
1668
1682
1669
1683
for idx , outflow in enumerate (outflow_objects ):
1670
1684
data = outflow_data [idx ]
1671
1685
1672
- if __is_object_dynamic (data .name ):
1673
- __update_dynamic_object_mesh (outflow , data )
1686
+ name_slug = __get_name_slug (data .name )
1687
+ object_geometry_data = mesh_geometry_data [name_slug ]
1688
+ if object_geometry_data ["is_motion_dynamic" ]:
1689
+ mesh_previous = object_geometry_data ["triangle_mesh_previous" ]
1690
+ mesh_current = object_geometry_data ["triangle_mesh_current" ]
1691
+ mesh_next = object_geometry_data ["triangle_mesh_next" ]
1692
+ outflow .update_mesh_animated (mesh_previous , mesh_current , mesh_next )
1674
1693
1675
1694
outflow .enable = __get_parameter_data (data .is_enabled , frameid )
1676
1695
outflow .fluid_outflow = __get_parameter_data (data .remove_fluid , frameid )
@@ -1716,7 +1735,7 @@ def __update_animatable_force_field_properties(data, frameid):
1716
1735
force_field .gravity_scale_width = __get_parameter_data (data .gravity_scale_width_curve , frameid )
1717
1736
1718
1737
1719
- def __update_animatable_obstacle_properties (data , frameid ):
1738
+ def __update_animatable_obstacle_properties (data , mesh_geometry_data , frameid ):
1720
1739
obstacle_objects = data .obstacle_objects
1721
1740
obstacle_data = data .obstacle_data
1722
1741
@@ -1752,11 +1771,19 @@ def __update_animatable_obstacle_properties(data, frameid):
1752
1771
1753
1772
#### END WORKAROUND ####
1754
1773
1774
+ total_update_time = 0.0
1775
+ start_mesh_object = time .time ()
1776
+
1755
1777
for idx , mesh_object in enumerate (obstacle_objects ):
1756
1778
data = obstacle_data [idx ]
1757
1779
1758
- if __is_object_dynamic (data .name ):
1759
- __update_dynamic_object_mesh (mesh_object , data )
1780
+ name_slug = __get_name_slug (data .name )
1781
+ object_geometry_data = mesh_geometry_data [name_slug ]
1782
+ if object_geometry_data ["is_motion_dynamic" ]:
1783
+ mesh_previous = object_geometry_data ["triangle_mesh_previous" ]
1784
+ mesh_current = object_geometry_data ["triangle_mesh_current" ]
1785
+ mesh_next = object_geometry_data ["triangle_mesh_next" ]
1786
+ mesh_object .update_mesh_animated (mesh_previous , mesh_current , mesh_next )
1760
1787
1761
1788
mesh_object .enable = __get_parameter_data (data .is_enabled , frameid )
1762
1789
mesh_object .friction = __get_parameter_data (data .friction , frameid , value_min = 0.0 )
@@ -2009,6 +2036,17 @@ def __update_animatable_domain_properties(fluidsim, data, frameno):
2009
2036
gravity = [0.0 , 0.0 , 0.0 ]
2010
2037
__set_body_force_property (fluidsim , gravity )
2011
2038
2039
+ weight_fluid_particles = __get_parameter_data (world .force_field_weight_fluid_particles , frameno )
2040
+ weight_whitewater_foam = __get_parameter_data (world .force_field_weight_whitewater_foam , frameno )
2041
+ weight_whitewater_bubble = __get_parameter_data (world .force_field_weight_whitewater_bubble , frameno )
2042
+ weight_whitewater_spray = __get_parameter_data (world .force_field_weight_whitewater_spray , frameno )
2043
+ weight_whitewater_dust = __get_parameter_data (world .force_field_weight_whitewater_dust , frameno )
2044
+ __set_property (fluidsim , 'force_field_weight_fluid_particles' , weight_fluid_particles )
2045
+ __set_property (fluidsim , 'force_field_weight_whitewater_foam' , weight_whitewater_foam )
2046
+ __set_property (fluidsim , 'force_field_weight_whitewater_bubble' , weight_whitewater_bubble )
2047
+ __set_property (fluidsim , 'force_field_weight_whitewater_spray' , weight_whitewater_spray )
2048
+ __set_property (fluidsim , 'force_field_weight_whitewater_dust' , weight_whitewater_dust )
2049
+
2012
2050
is_viscosity_enabled = __get_parameter_data (world .enable_viscosity , frameno )
2013
2051
if is_viscosity_enabled :
2014
2052
surface = dprops .surface
@@ -2190,6 +2228,9 @@ def __update_animatable_domain_properties(fluidsim, data, frameno):
2190
2228
enable_async_meshing = __get_parameter_data (advanced .enable_asynchronous_meshing , frameno )
2191
2229
__set_property (fluidsim , 'enable_asynchronous_meshing' , enable_async_meshing )
2192
2230
2231
+ enable_fracture_optimization = __get_parameter_data (advanced .enable_fracture_optimization , frameno )
2232
+ __set_property (fluidsim , 'enable_fracture_optimization' , enable_fracture_optimization )
2233
+
2193
2234
precomp_static_sdf = __get_parameter_data (advanced .precompute_static_obstacles , frameno )
2194
2235
__set_property (fluidsim , 'enable_static_solid_levelset_precomputation' , precomp_static_sdf )
2195
2236
@@ -2211,10 +2252,15 @@ def __update_animatable_domain_properties(fluidsim, data, frameno):
2211
2252
2212
2253
2213
2254
def __update_animatable_properties (fluidsim , data , frameno ):
2214
- __update_animatable_inflow_properties (data , frameno )
2215
- __update_animatable_outflow_properties (data , frameno )
2255
+ geometry_database = __get_geometry_database ()
2256
+ simulation_data = __get_simulation_data ()
2257
+ timeline_frame = __get_timeline_frame ()
2258
+ geometry_data = geometry_database .get_mesh_geometry_data_dict_for_frame (simulation_data , timeline_frame )
2259
+
2260
+ __update_animatable_inflow_properties (data , geometry_data , frameno )
2261
+ __update_animatable_outflow_properties (data , geometry_data , frameno )
2216
2262
__update_animatable_force_field_properties (data , frameno )
2217
- __update_animatable_obstacle_properties (data , frameno )
2263
+ __update_animatable_obstacle_properties (data , geometry_data , frameno )
2218
2264
__update_animatable_meshing_volume_properties (data , frameno )
2219
2265
__update_animatable_domain_properties (fluidsim , data , frameno )
2220
2266
0 commit comments