[Bf-blender-cvs] [f534e9928d1] soc-2020-testing-frameworks: Added FluidSpec for Fluid simulations and a test.
calra123
noreply at git.blender.org
Sun Jul 26 21:27:53 CEST 2020
Commit: f534e9928d123646faaf5bad88578aad81d8ffab
Author: calra123
Date: Tue Jul 21 14:08:00 2020 +0530
Branches: soc-2020-testing-frameworks
https://developer.blender.org/rBf534e9928d123646faaf5bad88578aad81d8ffab
Added FluidSpec for Fluid simulations and a test.
Note the test should be run in 2.90
===================================================================
M tests/python/modules/mesh_test.py
A tests/python/physics_fluid.py
===================================================================
diff --git a/tests/python/modules/mesh_test.py b/tests/python/modules/mesh_test.py
index c2d130776b6..c8640aa9a2e 100644
--- a/tests/python/modules/mesh_test.py
+++ b/tests/python/modules/mesh_test.py
@@ -98,16 +98,16 @@ class PhysicsSpec:
class FluidSpec:
"""
- Holds one Physics modifier and its parameters.
+ Holds a Fluid modifier and its parameters.
"""
def __init__(self, modifier_name: str, fluid_type: str, modifier_parameters: dict, frame_end: int):
"""
- Constructs a physics spec.
+ Constructs a Fluid spec.
:param modifier_name: str - name of object modifier, e.g. "FLUID"
:param fluid_type: str - type of fluid, e.g. "Domain"
- :param modifier_parameters: dict - {name : val} dictionary giving modifier parameters, e.g. {"quality" : 4}
- :param frame_end:int - the last frame of the simulation at which it is baked
+ :param modifier_parameters: dict - {name : val} dictionary giving modifier parameters, e.g. {"use_mesh" : True}
+ :param frame_end:int - the frame at which the modifier is "applied"
"""
self.modifier_name = modifier_name
self.fluid_type = fluid_type
@@ -116,7 +116,7 @@ class FluidSpec:
self.frame_end = frame_end
def __str__(self):
- return "Physics Modifier: " + self.modifier_name + " of type " + self.modifier_type + \
+ return "Fluid Modifier: " + self.modifier_name + " of type " + self.modifier_type + \
" with parameters: " + str(self.modifier_parameters) + " with frame end: " + str(self.frame_end)
@@ -383,13 +383,16 @@ class MeshTest:
scene.frame_set(1)
modifier = test_object.modifiers.new(fluid_spec.modifier_name,
fluid_spec.modifier_type)
- # fluid_settings = str(fluid_spec.fluid_type).lower() + "_settings"
- # physics_setting = modifier + str(".") + fluid_settings
+
modifier.fluid_type = fluid_spec.fluid_type
- if str(fluid_spec.fluid_type).lower() == "domain":
+ if str(fluid_spec.fluid_type) == "DOMAIN":
physics_setting = modifier.domain_settings
- # modifier.fluid_type = fluid_spec.fluid_type
+ elif str(fluid_spec.fluid_type) == "FLOW":
+ physics_setting = modifier.flow_settings
+ elif str(fluid_spec.fluid_type) == "EFFECTOR":
+ physics_setting = modifier.effector_settings
+
if self.verbose:
print("Created modifier '{}' of type '{}'.".
@@ -407,8 +410,9 @@ class MeshTest:
raise AttributeError("Modifier '{}' has no parameter named '{}'".
format(fluid_spec.modifier_type, param_name))
- # bpy.ops.fluid.free_all()
bpy.ops.fluid.bake_all()
+
+ # Jump to the frame specified by user to apply the modifier.
scene.frame_set(fluid_spec.frame_end)
if self.apply_modifier:
diff --git a/tests/python/physics_fluid.py b/tests/python/physics_fluid.py
new file mode 100644
index 00000000000..34809e7d801
--- /dev/null
+++ b/tests/python/physics_fluid.py
@@ -0,0 +1,53 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+import os
+import sys
+
+import bpy
+
+sys.path.append(os.path.dirname(os.path.realpath(__file__)))
+from modules.mesh_test import ModifierTest, FluidSpec
+
+
+def main():
+ test = [
+
+ ["FluidLiquid", "test", "exp",
+ [FluidSpec('fluid_liquid', 'DOMAIN', {'domain_type': 'LIQUID', 'use_mesh': True, 'cache_type': 'ALL',
+ 'cache_frame_end': 20}, 20)]],
+ ]
+ fluid_test = ModifierTest(test)
+
+ command = list(sys.argv)
+ for i, cmd in enumerate(command):
+ if cmd == "--run-all-tests":
+ fluid_test.apply_modifiers = True
+ fluid_test.run_all_tests()
+ break
+ elif cmd == "--run-test":
+ fluid_test.apply_modifiers = False
+ name = str(command[i + 1])
+ fluid_test.run_test(name)
+ break
+
+
+if __name__ == "__main__":
+ main()
More information about the Bf-blender-cvs
mailing list