[Bf-blender-cvs] [1340530] fluid-mantaflow: created separate mantaflow directory for api files
SebastiaÌn Barschkis
noreply at git.blender.org
Mon Mar 7 22:58:18 CET 2016
Commit: 1340530c8c871d8d28e67db98996a1df4a3db7a6
Author: Sebastián Barschkis
Date: Mon Mar 7 22:57:48 2016 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rB1340530c8c871d8d28e67db98996a1df4a3db7a6
created separate mantaflow directory for api files
===================================================================
M intern/CMakeLists.txt
A intern/mantaflow/CMakeLists.txt
A intern/mantaflow/extern/manta_smoke_API.h
A intern/mantaflow/intern/MANTA.cpp
A intern/mantaflow/intern/MANTA.h
A intern/mantaflow/intern/manta_smoke_API.cpp
A intern/mantaflow/intern/strings/smoke.h
M source/blender/blenkernel/CMakeLists.txt
M source/blender/blenkernel/intern/smoke.c
M source/blender/makesdna/DNA_smoke_types.h
===================================================================
diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt
index 275524f..c95dffe 100644
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@ -82,3 +82,7 @@ endif()
if(WIN32)
add_subdirectory(utfconv)
endif()
+
+if(WITH_MOD_MANTA)
+ add_subdirectory(mantaflow)
+endif()
diff --git a/intern/mantaflow/CMakeLists.txt b/intern/mantaflow/CMakeLists.txt
new file mode 100644
index 0000000..6497997
--- /dev/null
+++ b/intern/mantaflow/CMakeLists.txt
@@ -0,0 +1,48 @@
+# ***** 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.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Sebastian Barschkis (sebbas)
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+ intern
+ extern
+ intern/strings
+ ../../source/blender/makesdna
+ ../../source/blender/blenlib
+)
+
+set(INC_SYS
+ ${PYTHON_INCLUDE_DIRS}
+)
+
+set(SRC
+ intern/MANTA.cpp
+ intern/MANTA.h
+ intern/smoke_API.cpp
+ intern/strings/smoke.h
+
+ extern/smoke_API.h
+)
+
+#blender_add_lib(bf_intern_mantaflow "${SRC}" "${INC}" "${INC_SYS}")
+
diff --git a/intern/mantaflow/extern/manta_smoke_API.h b/intern/mantaflow/extern/manta_smoke_API.h
new file mode 100644
index 0000000..e86fa95
--- /dev/null
+++ b/intern/mantaflow/extern/manta_smoke_API.h
@@ -0,0 +1,95 @@
+/*
+ * ***** 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 SMOKE_API_H_
+#define SMOKE_API_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int *smoke_get_manta_flags(struct MANTA *manta);
+struct MANTA *smoke_init(int *res, float dx, float dtdef, int use_heat, int use_fire, int use_colors, struct SmokeModifierData *smd);
+void smoke_free(struct MANTA *manta);
+size_t smoke_get_index(int x, int max_x, int y, int max_y, int z /*, int max_z */);
+size_t smoke_get_index2d(int x, int max_x, int y /*, int max_y, int z, int max_z */);
+void smoke_manta_export(SmokeModifierData *smd);
+void smoke_step(struct MANTA *manta, float gravity[3], float dtSubdiv);
+void smoke_initBlenderRNA(SmokeDomainSettings *sds);
+static void data_dissolve(float *density, float *heat, float *r, float *g, float *b, int total_cells, int speed, int log);
+void smoke_dissolve(struct MANTA *manta, int speed, int log);
+void smoke_export(struct MANTA *manta, float *dt, float *dx, float **dens, float **react, float **flame, float **fuel, float **heat,
+ float **manta_inflow, float **vx, float **vy, float **vz, float **r, float **g, float **b, unsigned char **obstacles);
+float *smoke_get_density(struct MANTA *manta);
+float *smoke_get_fuel(struct MANTA *manta);
+float *smoke_get_react(struct MANTA *manta);
+float *smoke_get_heat(struct MANTA *manta);
+float *smoke_get_velocity_x(struct MANTA *manta);
+float *smoke_get_velocity_y(struct MANTA *manta);
+float *smoke_get_velocity_z(struct MANTA *manta);
+float *smoke_get_force_x(struct MANTA *manta);
+float *smoke_get_force_y(struct MANTA *manta)
+float *smoke_get_force_z(struct MANTA *manta);
+float *smoke_get_flame(struct MANTA *manta);
+float *smoke_get_color_r(struct MANTA *manta);
+float *smoke_get_color_g(struct MANTA *manta);
+float *smoke_get_color_b(struct MANTA *manta);
+void smoke_get_rgba(struct MANTA *manta, float *data, int sequential);
+void smoke_high_get_rgba(struct MANTA *manta, float *data, int sequential);
+void smoke_get_rgba_from_density(struct MANTA *manta, float color[3], float *data, int sequential);
+void smoke_high_get_rgba_from_density(struct MANTA *manta, float color[3], float *data, int sequential);
+float *smoke_high_get_density(struct MANTA *manta);
+float *smoke_high_get_fuel(struct MANTA *manta);
+float *smoke_high_get_react(struct MANTA *manta);
+float *smoke_high_get_color_r(struct MANTA *manta);
+float *smoke_high_get_color_g(struct MANTA *manta);
+float *smoke_high_get_color_b(struct MANTA *manta);
+float *smoke_high_get_flame(struct MANTA *manta);
+void smoke_high_get_res(struct MANTA *manta, int *res);
+int smoke_high_get_cells(struct MANTA *manta);
+unsigned char *smoke_get_obstacle(struct MANTA *manta);
+void smoke_get_ob_velocity(struct MANTA *manta, float **x, float **y, float **z);
+void flame_get_spectrum(unsigned char *spec, int width, float t1, float t2);
+int smoke_has_heat(struct MANTA *manta);
+int smoke_has_fuel(struct MANTA *manta);
+int smoke_has_colors(struct MANTA *manta);
+int smoke_high_has_fuel(struct MANTA *manta);
+int smoke_high_has_colors(struct MANTA *manta);
+void smoke_ensure_heat(struct MANTA *manta);
+void smoke_ensure_fire(struct MANTA *manta);
+void smoke_ensure_colors(struct MANTA *manta, float init_r, float init_g, float init_b);
+float *smoke_get_inflow_grid(struct MANTA *manta);
+float *smoke_get_fuel_inflow(struct MANTA *manta);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SMOKE_API_H_ */
diff --git a/intern/mantaflow/intern/MANTA.cpp b/intern/mantaflow/intern/MANTA.cpp
new file mode 100644
index 0000000..2845b3e
--- /dev/null
+++ b/intern/mantaflow/intern/MANTA.cpp
@@ -0,0 +1,669 @@
+/*
+ * ***** 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/intern/MANTA.cpp
+ * \ingroup mantaflow
+ */
+
+#include "MANTA.h"
+
+MANTA::MANTA(int *res, float dx, float dtdef, int init_heat, int init_fire, int init_colors, SmokeModifierData *smd) :
+_xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f)
+{
+ std::cout << "MANTA" << std::endl;
+ // set simulation consts
+ _dt = dtdef; // just in case. set in step from a RNA factor
+
+ _iterations = 100;
+ _tempAmb = 0;
+ _heatDiffusion = 1e-3;
+ _totalTime = 0.0f;
+ _totalSteps = 0;
+ _maxRes = MAX3(_xRes, _yRes, _zRes);
+
+ if (!dx)
+ _dx = 1.0f / (float)_maxRes;
+ else
+ _dx = dx;
+ _constantScaling = 64.0f / _maxRes;
+ _constantScaling = (_constantScaling < 1.0f) ? 1.0f : _constantScaling;
+ _vorticityEps = 2.0f / _constantScaling; // Just in case set a default value
+
+ _totalCells = _xRes * _yRes * _zRes;
+
+ // allocate arrays
+ _manta_inflow = NULL;
+ _fuel_inflow = NULL;
+ _manta_flags = NULL;
+ _xVelocity = NULL;
+ _yVelocity = NULL;
+ _zVelocity = NULL;
+ _xVelocityOb = NULL;
+ _yVelocityOb = NULL;
+ _zVelocityOb = NULL;
+ _xForce = NULL;
+ _yForce = NULL;
+ _zForce = NULL;
+ _density = NULL;
+ _obstacles = new unsigned char[_totalCells]; // set 0 at end of step
+
+ _using_heat = false;
+ _using_fire = false;
+ _using_colors = false;
+
+ MANTA::start_mantaflow();
+
+ // Base setup low res
+ std::string setup_script =
+ manta_import +
+ solver_setup_low +
+ uv_setup +
+ alloc_base_grids_low +
+ prep_domain_low +
+ flags +
+ manta_step +
+ smoke_step_low;
+ std::string final_script = MANTA::parse_script(setup_script, smd);
+ PyGILState_STATE gilstate = PyGILState_Ensure();
+ PyRun_SimpleString(final_script.c_str());
+ PyGILState_Release(gilstate);
+
+ smd->domain->manta = this;
+
+ /* heat */
+ _heat = NULL;
+ if (init_heat) {
+ initHeat();
+ }
+ // Fire simulation
+ _flame = NULL;
+ _fuel = NULL;
+ _react = NULL;
+ if (init_fire) {
+ initFire();
+ }
+ // Smoke color
+ _color_r = NULL;
+ _color_g = NULL;
+ _color_b = NULL;
+ if (init_colors) {
+ initColors(0.0f, 0.0f, 0.0f);
+ }
+
+ MANTA::update_pointers();
+
+ // High resolution
+ _xResBig = _amplify * _xRes;
+ _yResBig = _amplify * _yRes;
+ _zResBig = _amplify * _zRes;
+ _slabSizeBig = _xResBig * _yResBig;
+ _totalCellsBig = _slabSizeBig * _zResBig;
+
+ // allocate high resolution density field
+ _densityBig = NULL;
+ _flameBig = NULL;
+ _fuelBig = NULL;
+ _reactBig = NULL;
+
+ _color_rBig = NULL;
+ _color_gBig = NULL;
+ _color_bBig = NULL;
+
+ // Base setup high res
+ std::string setup_script =
+ solver_setup_high +
+ alloc_base_grids_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list