[Bf-blender-cvs] [2aa4301c88a] master: Mantaflow [Part 2]: Added fluid wrapper files

Sebastián Barschkis noreply at git.blender.org
Mon Dec 16 16:29:12 CET 2019


Commit: 2aa4301c88aac15d81e08b1f5ac24da2a9279243
Author: Sebastián Barschkis
Date:   Mon Dec 16 15:41:07 2019 +0100
Branches: master
https://developer.blender.org/rB2aa4301c88aac15d81e08b1f5ac24da2a9279243

Mantaflow [Part 2]: Added fluid wrapper files

Files from /intern/mantaflow handle the communication between core Blender code and Mantaflow itself. It's the bridge to communicate with Mantas Python functions.

Code from /intern/mantaflow/intern/strings/ is pure Manta code and would likely need less attention in the review.

Reviewed By: sergey

Maniphest Tasks: T59995

Differential Revision: https://developer.blender.org/D3851

===================================================================

A	intern/mantaflow/CMakeLists.txt
A	intern/mantaflow/extern/manta_fluid_API.h
A	intern/mantaflow/extern/manta_python_API.h
A	intern/mantaflow/intern/MANTA_main.cpp
A	intern/mantaflow/intern/MANTA_main.h
A	intern/mantaflow/intern/manta_fluid_API.cpp
A	intern/mantaflow/intern/manta_python_API.cpp
A	intern/mantaflow/intern/strings/fluid_script.h
A	intern/mantaflow/intern/strings/liquid_script.h
A	intern/mantaflow/intern/strings/smoke_script.h

===================================================================

diff --git a/intern/mantaflow/CMakeLists.txt b/intern/mantaflow/CMakeLists.txt
new file mode 100644
index 00000000000..9fdd8b59aca
--- /dev/null
+++ b/intern/mantaflow/CMakeLists.txt
@@ -0,0 +1,67 @@
+# ***** 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.
+#
+# The Original Code is Copyright (C) 2019, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Sebastian Barschkis (sebbas)
+#
+# ***** END GPL LICENSE BLOCK *****
+
+add_definitions(-DWITH_FLUID=1)
+
+if(WITH_OPENVDB)
+  add_definitions(-DOPENVDB=1)
+endif()
+
+set(INC
+  extern
+  intern/strings
+  ../../source/blender/makesdna
+  ../../source/blender/blenlib
+)
+
+# Python is always required
+add_definitions(-DWITH_PYTHON)
+
+set(INC_SYS
+  ../../extern/mantaflow/helper/util
+  ../../extern/mantaflow/helper/pwrapper
+  ../../extern/mantaflow/preprocessed
+  ${PYTHON_INCLUDE_DIRS}
+  ${ZLIB_INCLUDE_DIRS}
+)
+
+set(SRC
+  intern/manta_python_API.cpp
+  intern/manta_fluid_API.cpp
+  intern/MANTA_main.cpp
+
+  extern/manta_python_API.h
+  extern/manta_fluid_API.h
+  intern/MANTA_main.h
+  intern/strings/fluid_script.h
+  intern/strings/smoke_script.h
+  intern/strings/liquid_script.h
+)
+
+set(LIB
+  extern_mantaflow
+)
+
+blender_add_lib(bf_intern_mantaflow "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
new file mode 100644
index 00000000000..9e0bd2d9a3e
--- /dev/null
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -0,0 +1,232 @@
+/*
+ * ***** 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.
+ *
+ * The Original Code is Copyright (C) 2016 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sebastian Barschkis (sebbas)
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file mantaflow/extern/manta_smoke_API.h
+ *  \ingroup mantaflow
+ */
+
+#ifndef MANTA_API_H
+#define MANTA_API_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct MANTA;
+
+/* Fluid functions */
+struct MANTA *manta_init(int *res, struct FluidModifierData *mmd);
+void manta_free(struct MANTA *fluid);
+void manta_ensure_obstacle(struct MANTA *fluid, struct FluidModifierData *mmd);
+void manta_ensure_guiding(struct MANTA *fluid, struct FluidModifierData *mmd);
+void manta_ensure_invelocity(struct MANTA *fluid, struct FluidModifierData *mmd);
+void manta_ensure_outflow(struct MANTA *fluid, struct FluidModifierData *mmd);
+int manta_write_config(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+int manta_write_data(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+int manta_read_config(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+int manta_read_data(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+int manta_read_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+int manta_read_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+int manta_read_particles(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+int manta_read_guiding(struct MANTA *fluid,
+                       struct FluidModifierData *mmd,
+                       int framenr,
+                       bool sourceDomain);
+int manta_update_liquid_structures(struct MANTA *fluid,
+                                   struct FluidModifierData *mmd,
+                                   int framenr);
+int manta_update_mesh_structures(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+int manta_update_particle_structures(struct MANTA *fluid,
+                                     struct FluidModifierData *mmd,
+                                     int framenr);
+int manta_bake_data(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+int manta_bake_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+int manta_bake_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+int manta_bake_particles(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+int manta_bake_guiding(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
+void manta_update_variables(struct MANTA *fluid, struct FluidModifierData *mmd);
+int manta_get_frame(struct MANTA *fluid);
+float manta_get_timestep(struct MANTA *fluid);
+void manta_adapt_timestep(struct MANTA *fluid);
+bool manta_needs_realloc(struct MANTA *fluid, struct FluidModifierData *mmd);
+
+/* Fluid accessors */
+size_t manta_get_index(int x, int max_x, int y, int max_y, int z /*, int max_z */);
+size_t manta_get_index2d(int x, int max_x, int y /*, int max_y, int z, int max_z */);
+float *manta_get_velocity_x(struct MANTA *fluid);
+float *manta_get_velocity_y(struct MANTA *fluid);
+float *manta_get_velocity_z(struct MANTA *fluid);
+float *manta_get_ob_velocity_x(struct MANTA *fluid);
+float *manta_get_ob_velocity_y(struct MANTA *fluid);
+float *manta_get_ob_velocity_z(struct MANTA *fluid);
+float *manta_get_guide_velocity_x(struct MANTA *fluid);
+float *manta_get_guide_velocity_y(struct MANTA *fluid);
+float *manta_get_guide_velocity_z(struct MANTA *fluid);
+float *manta_get_in_velocity_x(struct MANTA *fluid);
+float *manta_get_in_velocity_y(struct MANTA *fluid);
+float *manta_get_in_velocity_z(struct MANTA *fluid);
+float *manta_get_force_x(struct MANTA *fluid);
+float *manta_get_force_y(struct MANTA *fluid);
+float *manta_get_force_z(struct MANTA *fluid);
+float *manta_get_phiguide_in(struct MANTA *fluid);
+int *manta_get_num_obstacle(struct MANTA *fluid);
+int *manta_get_num_guide(struct MANTA *fluid);
+int manta_get_res_x(struct MANTA *fluid);
+int manta_get_res_y(struct MANTA *fluid);
+int manta_get_res_z(struct MANTA *fluid);
+float *manta_get_phi_in(struct MANTA *fluid);
+float *manta_get_phiobs_in(struct MANTA *fluid);
+float *manta_get_phiout_in(struct MANTA *fluid);
+
+/* Smoke functions */
+void manta_smoke_export_script(struct MANTA *smoke, struct FluidModifierData *mmd);
+void manta_smoke_export(struct MANTA *smoke,
+                        float *dt,
+                        float *dx,
+                        float **dens,
+                        float **react,
+                        float **flame,
+                        float **fuel,
+                        float **heat,
+                        float **vx,
+                        float **vy,
+                        float **vz,
+                        float **r,
+                        float **g,
+                        float **b,
+                        int **obstacles,
+                        float **shadow);
+void manta_smoke_turbulence_export(struct MANTA *smoke,
+                                   float **dens,
+                                   float **react,
+                                   float **flame,
+                                   float **fuel,
+                                   float **r,
+                                   float **g,
+                                   float **b,
+                                   float **tcu,
+                                   float **tcv,
+                                   float **tcw,
+                                   float **tcu2,
+                                   float **tcv2,
+                                   float **tcw2);
+void manta_smoke_get_rgba(struct MANTA *smoke, float *data, int sequential);
+void manta_smoke_turbulence_get_rgba(struct MANTA *smoke, float *data, int sequential);
+void manta_smoke_get_rgba_from_density(struct MANTA *smoke,
+                                       float color[3],
+                                       float *data,
+                                       int sequential);
+void manta_smoke_turbulence_get_rgba_from_density(struct MANTA *smoke,
+                                                  float color[3],
+                                                  float *data,
+                                                  int sequential);
+void manta_smoke_ensure_heat(struct MANTA *smoke, struct FluidModifierData *mmd);
+void manta_smoke_ensure_fire(struct MANTA *smoke, struct FluidModifierData *mmd);
+void manta_smoke_ensure_colors(struct MANTA *smoke, struct FluidModifierData *mmd);
+
+/* Smoke accessors */
+float *manta_smoke_get_density(struct MANTA *smoke);
+float *manta_smoke_get_fuel(struct MANTA *smoke);
+float *manta_smoke_get_react(struct MANTA *smoke);
+float *manta_smoke_get_heat(struct MANTA *smoke);
+float *manta_smoke_get_flame(struct MANTA *smoke);
+float *manta_smoke_get_shadow(struct MANTA *fluid);
+float *manta_smoke_get_color_r(struct MANTA *smoke);
+float *manta_smoke_get_color_g(struct MANTA *smoke);
+float *manta_smoke_get_color_b(struct MANTA *smoke);
+int *manta_smoke_get_obstacle(struct MANTA *smoke);
+float *manta_smoke_get_density_in(struct MANTA *sm

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list