Commit: 8d40c8de5adc97259c64917657070956189c4cc9 Author: Roman Pogribnyi Date: Sun Oct 26 21:59:40 2014 +0100 Branches: soc-2014-fluid https://developer.blender.org/rB8d40c8de5adc97259c64917657070956189c4cc9
Defining Interfaces for Manta_API =================================================================== M intern/smoke/extern/smoke_API.h M intern/smoke/intern/smoke_API.cpp M source/blender/makesdna/DNA_smoke_types.h =================================================================== diff --git a/intern/smoke/extern/smoke_API.h b/intern/smoke/extern/smoke_API.h index 938cd7a..cb6f8e5 100644 --- a/intern/smoke/extern/smoke_API.h +++ b/intern/smoke/extern/smoke_API.h @@ -35,6 +35,7 @@ extern "C" { #endif +#ifndef USE_MANTA /*old Blender Solver*/ struct FLUID_3D; // low res @@ -70,14 +71,11 @@ unsigned char *smoke_get_obstacle(struct FLUID_3D *fluid); size_t smoke_get_index(int x, int max_x, int y, int max_y, int z); size_t smoke_get_index2d(int x, int max_x, int y); - void smoke_dissolve(struct FLUID_3D *fluid, int speed, int log); - // wavelet turbulence functions struct WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int noisetype, const char *noisefile_path, int use_fire, int use_colors); void smoke_turbulence_free(struct WTURBULENCE *wt); void smoke_turbulence_step(struct WTURBULENCE *wt, struct FLUID_3D *fluid); - float *smoke_turbulence_get_density(struct WTURBULENCE *wt); float *smoke_turbulence_get_color_r(struct WTURBULENCE *wt); float *smoke_turbulence_get_color_g(struct WTURBULENCE *wt); @@ -92,27 +90,103 @@ int smoke_turbulence_get_cells(struct WTURBULENCE *wt); void smoke_turbulence_set_noise(struct WTURBULENCE *wt, int type, const char *noisefile_path); void smoke_initWaveletBlenderRNA(struct WTURBULENCE *wt, float *strength); void smoke_dissolve_wavelet(struct WTURBULENCE *wt, int speed, int log); - /* export */ void smoke_export(struct FLUID_3D *fluid, float *dt, float *dx, float **dens, float **react, float **flame, float **fuel, float **heat, float **heatold, float **vx, float **vy, float **vz, float **r, float **g, float **b, unsigned char **obstacles); void smoke_turbulence_export(struct WTURBULENCE *wt, float **dens, float **react, float **flame, float **fuel, float **r, float **g, float **b, float **tcu, float **tcv, float **tcw); - /* flame spectrum */ void flame_get_spectrum(unsigned char *spec, int width, float t1, float t2); - /* data fields */ int smoke_has_heat(struct FLUID_3D *fluid); int smoke_has_fuel(struct FLUID_3D *fluid); int smoke_has_colors(struct FLUID_3D *fluid); int smoke_turbulence_has_fuel(struct WTURBULENCE *wt); int smoke_turbulence_has_colors(struct WTURBULENCE *wt); - void smoke_ensure_heat(struct FLUID_3D *fluid); void smoke_ensure_fire(struct FLUID_3D *fluid, struct WTURBULENCE *wt); void smoke_ensure_colors(struct FLUID_3D *fluid, struct WTURBULENCE *wt, float init_r, float init_g, float init_b); + + +#else /* using Mantaflow structures */ + struct Manta_API; + struct Manta_API *smoke_init(int *res, float dx, float dtdef, int use_heat, int use_fire, int use_colors); + void smoke_free(struct Manta_API *fluid); + + void smoke_initBlenderRNA(struct Manta_API *fluid, float *alpha, float *beta, float *dt_factor, float *vorticity, int *border_colli, float *burning_rate, + float *flame_smoke, float *flame_smoke_color, float *flame_vorticity, float *flame_ignition_temp, float *flame_max_temp); + void smoke_step(struct Manta_API *fluid, float gravity[3], float dtSubdiv); + + float *smoke_get_density(struct Manta_API *fluid); + float *smoke_get_flame(struct Manta_API *fluid); + float *smoke_get_fuel(struct Manta_API *fluid); + float *smoke_get_react(struct Manta_API *fluid); + float *smoke_get_color_r(struct Manta_API *fluid); + float *smoke_get_color_g(struct Manta_API *fluid); + float *smoke_get_color_b(struct Manta_API *fluid); + void smoke_get_rgba(struct Manta_API *fluid, float *data, int sequential); + void smoke_get_rgba_from_density(struct Manta_API *fluid, float color[3], float *data, int sequential); + float *smoke_get_heat(struct Manta_API *fluid); + float *smoke_get_velocity_x(struct Manta_API *fluid); + float *smoke_get_velocity_y(struct Manta_API *fluid); + float *smoke_get_velocity_z(struct Manta_API *fluid); + + /* Moving obstacle velocity provided by blender */ + void smoke_get_ob_velocity(struct Manta_API *fluid, float **x, float **y, float **z); + + float *smoke_get_force_x(struct Manta_API *fluid); + float *smoke_get_force_y(struct Manta_API *fluid); + float *smoke_get_force_z(struct Manta_API *fluid); + + unsigned char *smoke_get_obstacle(struct Manta_API *fluid); + + size_t smoke_get_index(int x, int max_x, int y, int max_y, int z); + size_t smoke_get_index2d(int x, int max_x, int y); + + void smoke_dissolve(struct Manta_API *fluid, int speed, int log); + + // wavelet turbulence functions + struct WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int noisetype, const char *noisefile_path, int use_fire, int use_colors); + void smoke_turbulence_free(struct WTURBULENCE *wt); + void smoke_turbulence_step(struct WTURBULENCE *wt, struct Manta_API *fluid); + + float *smoke_turbulence_get_density(struct WTURBULENCE *wt); + float *smoke_turbulence_get_color_r(struct WTURBULENCE *wt); + float *smoke_turbulence_get_color_g(struct WTURBULENCE *wt); + float *smoke_turbulence_get_color_b(struct WTURBULENCE *wt); + void smoke_turbulence_get_rgba(struct WTURBULENCE *wt, float *data, int sequential); + void smoke_turbulence_get_rgba_from_density(struct WTURBULENCE *wt, float color[3], float *data, int sequential); + float *smoke_turbulence_get_flame(struct WTURBULENCE *wt); + float *smoke_turbulence_get_fuel(struct WTURBULENCE *wt); + float *smoke_turbulence_get_react(struct WTURBULENCE *wt); + void smoke_turbulence_get_res(struct WTURBULENCE *wt, int *res); + int smoke_turbulence_get_cells(struct WTURBULENCE *wt); + void smoke_turbulence_set_noise(struct WTURBULENCE *wt, int type, const char *noisefile_path); + void smoke_initWaveletBlenderRNA(struct WTURBULENCE *wt, float *strength); + void smoke_dissolve_wavelet(struct WTURBULENCE *wt, int speed, int log); + + /* export */ + void smoke_export(struct Manta_API *fluid, float *dt, float *dx, float **dens, float **react, float **flame, float **fuel, float **heat, float **heatold, + float **vx, float **vy, float **vz, float **r, float **g, float **b, unsigned char **obstacles); + void smoke_turbulence_export(struct WTURBULENCE *wt, float **dens, float **react, float **flame, float **fuel, + float **r, float **g, float **b, float **tcu, float **tcv, float **tcw); + + /* flame spectrum */ + void flame_get_spectrum(unsigned char *spec, int width, float t1, float t2); + + /* data fields */ + int smoke_has_heat(struct Manta_API *fluid); + int smoke_has_fuel(struct Manta_API *fluid); + int smoke_has_colors(struct Manta_API *fluid); + int smoke_turbulence_has_fuel(struct WTURBULENCE *wt); + int smoke_turbulence_has_colors(struct WTURBULENCE *wt); + + void smoke_ensure_heat(struct Manta_API *fluid); + void smoke_ensure_fire(struct Manta_API *fluid, struct WTURBULENCE *wt); + void smoke_ensure_colors(struct Manta_API *fluid, struct WTURBULENCE *wt, float init_r, float init_g, float init_b); +#endif /*USE_MANTA*/ + /*Mantaflow functions*/ int smoke_mantaflow_read(struct SmokeDomainSettings *sds, char* name, bool with_wavelets); //1:success, 0: no file,error void smoke_mantaflow_write_scene_file(struct SmokeModifierData *smd); diff --git a/intern/smoke/intern/smoke_API.cpp b/intern/smoke/intern/smoke_API.cpp index abb5427..edd803c 100644 --- a/intern/smoke/intern/smoke_API.cpp +++ b/intern/smoke/intern/smoke_API.cpp @@ -39,6 +39,8 @@ #include "../extern/smoke_API.h" /* to ensure valid prototypes */ +#ifndef USE_MANTA + extern "C" FLUID_3D *smoke_init(int *res, float dx, float dtdef, int use_heat, int use_fire, int use_colors) { FLUID_3D *fluid = new FLUID_3D(res, dx, dtdef, use_heat, use_fire, use_colors); @@ -500,6 +502,471 @@ extern "C" void smoke_ensure_colors(FLUID_3D *fluid, WTURBULENCE *wt, float init } } +#else /* USE_MANTA */ + +extern "C" Manta_API *smoke_init(int *res, float dx, float dtdef, int use_heat, int use_fire, int use_colors) +{ + Manta_API *fluid = new Manta_API(res, dx, dtdef, use_heat, use_fire, use_colors); + return fluid; +} + +extern "C" WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int noisetype, const char *noisefile_path, int use_fire, int use_colors) +{ + if (amplify) + return new WTURBULENCE(res[0],res[1],res[2], amplify, noisetype, noisefile_path, use_fire, use_colors); + else + return NULL; +} + +extern "C" void smoke_free(Manta_API *fluid) +{ + delete fluid; + fluid = NULL; +} + +extern "C" void smoke_turbulence_free(WTURBULENCE *wt) +{ + delete wt; + wt = NULL; +} + +extern "C" size_t smoke_get_index(int x, int max_x, int y, int max_y, int z /*, int max_z */) +{ + return x + y * max_x + z * max_x*max_y; +} + +extern "C" size_t smoke_get_index2d(int x, int max_x, int y /*, int max_y, int z, int max_z */) +{ + return x + y * max_x; +} + +extern "C" void smoke_step(Manta_API *fluid, float gravity[3], float dtSubdiv) +{ + if (fluid->_fuel) { + fluid->processBurn(fluid->_fuel, fluid->_density, fluid->_react, fluid->_flame, fluid->_heat, + fluid->_color_r, fluid->_color_g, fluid->_color_b, fluid->_totalCells, (*fluid->_dtFactor)*dtSubdiv); + } + fluid->step(dtSubdiv, gravity); +} + +extern "C" void smoke_turbulence_step(WTURBULENCE *wt, Manta_API *fluid) +{ + if (wt->_fuelBig) { + fluid->processBurn(wt->_fuelBig, wt->_densityBig, wt->_reactBig, wt->_flameBig, 0, + wt->_color_rBig, wt->_color_gBig, wt->_color_bBig, wt->_totalCellsBig, fluid->_dt); + } + wt->stepTurbulenceFull(fluid->_dt/fluid->_dx, fluid->_xVelocity, fluid->_yVelocity, fluid->_zVelocity, fluid->_obstacles); +} + +extern "C" void smoke_initBlenderRNA(Manta_API *fluid, float *alpha, float *beta, float *dt_factor, float *vorticity, int *border_colli, float *burning_rate, + float *flame_smoke, float *flame_smoke_color, float *flame_vorticity, float *flame_ignition_temp, float *flame_max_temp) +{ + fluid->initBlenderRNA(alpha, beta, dt_factor, vorticity, border_colli, burning_rate, flame_smoke, flame_smoke_color, flame_vorticity, flame_ignition_temp, flame_max_temp); +} + +extern "C" void smoke_initWaveletBlenderRNA(WTURBULENCE *wt, float *strength) +{ + wt->initBlenderRNA(strength); +} + +static void data_dissolve(float *density, float *heat, float *r, float *g, float *b, int total_cells, int speed, int log) +{ + if (log) { + /* max density/speed = dydx */ + float fac = 1.0f - (1 @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs