Commit: f5200ea512f79ec34e84aed7e7b7fcbc021f6838
Author: Sebastián Barschkis
Date:   Wed Mar 16 21:54:46 2016 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rBf5200ea512f79ec34e84aed7e7b7fcbc021f6838

added macros to kernel code to use new manta smoke api

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

M       source/blender/blenkernel/intern/pointcache.c
M       source/blender/blenkernel/intern/smoke.c
M       source/blender/editors/physics/physics_fluid.c
M       source/blender/editors/space_view3d/drawobject.c
M       source/blender/gpu/intern/gpu_draw.c
M       source/blender/makesrna/intern/rna_smoke.c
M       source/blender/render/intern/source/voxeldata.c

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

diff --git a/source/blender/blenkernel/intern/pointcache.c 
b/source/blender/blenkernel/intern/pointcache.c
index 4eb3af6..2da127f 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -80,7 +80,11 @@
 
 /* both in intern */
 #ifdef WITH_SMOKE
-#include "smoke_API.h"
+#ifndef WITH_MANTA
+       #include "smoke_API.h"
+#else
+       #include "manta_smoke_API.h"
+#endif
 #endif
 
 #ifdef WITH_LZO
@@ -638,7 +642,11 @@ static int  ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
                ret = 1;
        }
 
+#ifndef WITH_MANTA
        if (sds->wt) {
+#else
+       if (sds->fluid && sds->flags & MOD_SMOKE_HIGHRES) {
+#endif
                int res_big_array[3];
                int res_big;
                int res = sds->res[0]*sds->res[1]*sds->res[2];
@@ -648,7 +656,11 @@ static int  ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
                unsigned char *out;
                int mode;
 
+#ifndef WITH_MANTA
                smoke_turbulence_get_res(sds->wt, res_big_array);
+#else
+               smoke_turbulence_get_res(sds->fluid, res_big_array);
+#endif
                res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
                //mode =  res_big >= 1000000 ? 2 : 1;
                mode = 1;       // light
@@ -656,7 +668,11 @@ static int  ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
 
                in_len_big = sizeof(float) * (unsigned int)res_big;
 
+#ifndef WITH_MANTA
                smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, 
&r, &g, &b, &tcu, &tcv, &tcw);
+#else
+               smoke_turbulence_export(sds->fluid, &dens, &react, &flame, 
&fuel, &r, &g, &b, &tcu, &tcv, &tcw);
+#endif
 
                out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), 
"pointcache_lzo_buffer");
                ptcache_file_compressed_write(pf, (unsigned char *)dens, 
in_len_big, out, mode);
@@ -732,18 +748,30 @@ static int ptcache_smoke_read_old(PTCacheFile *pf, void 
*smoke_v)
 
                MEM_freeN(tmp_array);
 
+#ifndef WITH_MANTA
                if (pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->wt) {
+#else
+               if (pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->fluid 
&& sds->flags & MOD_SMOKE_HIGHRES) {
+#endif
                        int res_big, res_big_array[3];
                        float *tcu, *tcv, *tcw;
                        unsigned int out_len_big;
                        unsigned char *tmp_array_big;
+#ifndef WITH_MANTA
                        smoke_turbulence_get_res(sds->wt, res_big_array);
+#else
+                       smoke_turbulence_get_res(sds->fluid, res_big_array);
+#endif
                        res_big = 
res_big_array[0]*res_big_array[1]*res_big_array[2];
                        out_len_big = sizeof(float) * (unsigned int)res_big;
 
                        tmp_array_big = MEM_callocN(out_len_big, "Smoke old 
cache tmp");
 
+#ifndef WITH_MANTA
                        smoke_turbulence_export(sds->wt, &dens, NULL, NULL, 
NULL, NULL, NULL, NULL, &tcu, &tcv, &tcw);
+#else
+                       smoke_turbulence_export(sds->fluid, &dens, NULL, NULL, 
NULL, NULL, NULL, NULL, &tcu, &tcv, &tcw);
+#endif
 
                        ptcache_file_compressed_read(pf, (unsigned char*)dens, 
out_len_big);
                        ptcache_file_compressed_read(pf, (unsigned 
char*)tmp_array_big, out_len_big);
@@ -854,19 +882,30 @@ static int ptcache_smoke_read(PTCacheFile *pf, void 
*smoke_v)
                ptcache_file_read(pf, &sds->active_color, 3, sizeof(float));
        }
 
+#ifndef WITH_MANTA
        if (pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->wt) {
+#else
+       if (pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->fluid && 
sds->flags & MOD_SMOKE_HIGHRES) {
+#endif
                        int res = sds->res[0]*sds->res[1]*sds->res[2];
                        int res_big, res_big_array[3];
                        float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, 
*r, *g, *b;
                        unsigned int out_len = sizeof(float)*(unsigned int)res;
                        unsigned int out_len_big;
 
+#ifndef WITH_MANTA
                        smoke_turbulence_get_res(sds->wt, res_big_array);
+#else
+                       smoke_turbulence_get_res(sds->fluid, res_big_array);
+#endif
                        res_big = 
res_big_array[0]*res_big_array[1]*res_big_array[2];
                        out_len_big = sizeof(float) * (unsigned int)res_big;
 
+#ifndef WITH_MANTA
                        smoke_turbulence_export(sds->wt, &dens, &react, &flame, 
&fuel, &r, &g, &b, &tcu, &tcv, &tcw);
-
+#else
+                       smoke_turbulence_export(sds->fluid, &dens, &react, 
&flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw);
+#endif
                        ptcache_file_compressed_read(pf, (unsigned char *)dens, 
out_len_big);
                        if (cache_fields & SM_ACTIVE_FIRE) {
                                ptcache_file_compressed_read(pf, (unsigned char 
*)flame, out_len_big);
@@ -1258,8 +1297,13 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct 
Object *ob, struct SmokeMo
 
        if (sds->fluid)
                pid->data_types |= (1<<BPHYS_DATA_SMOKE_LOW);
+#ifndef WITH_MANTA
        if (sds->wt)
                pid->data_types |= (1<<BPHYS_DATA_SMOKE_HIGH);
+#else
+       if (sds->fluid && sds->flags & MOD_SMOKE_HIGHRES)
+               pid->data_types |= (1<<BPHYS_DATA_SMOKE_HIGH);
+#endif
 
        pid->default_step = 1;
        pid->max_step = 1;
diff --git a/source/blender/blenkernel/intern/smoke.c 
b/source/blender/blenkernel/intern/smoke.c
index 363765d..219d97b 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -176,6 +176,7 @@ void flame_get_spectrum(unsigned char *UNUSED(spec), int 
UNUSED(width), float UN
 
 void smoke_reallocate_fluid(SmokeDomainSettings *sds, float dx, int res[3], 
int free_old)
 {
+#ifndef WITH_MANTA
        int use_heat = (sds->active_fields & SM_ACTIVE_HEAT);
        int use_fire = (sds->active_fields & SM_ACTIVE_FIRE);
        int use_colors = (sds->active_fields & SM_ACTIVE_COLORS);
@@ -187,14 +188,19 @@ void smoke_reallocate_fluid(SmokeDomainSettings *sds, 
float dx, int res[3], int
                return;
        }
        
-       #ifndef WITH_MANTA
-               sds->fluid = smoke_init(res, dx, DT_DEFAULT, use_heat, 
use_fire, use_colors);
-       #else
-               sds->fluid = smoke_init(res, dx, DT_DEFAULT, use_heat, 
use_fire, use_colors, sds->smd);
-       #endif
-
+       sds->fluid = smoke_init(res, dx, DT_DEFAULT, use_heat, use_fire, 
use_colors);
        smoke_initBlenderRNA(sds->fluid, &(sds->alpha), &(sds->beta), 
&(sds->time_scale), &(sds->vorticity), &(sds->border_collisions),
-                            &(sds->burning_rate), &(sds->flame_smoke), 
sds->flame_smoke_color, &(sds->flame_vorticity), &(sds->flame_ignition), 
&(sds->flame_max_temp));
+                                        &(sds->burning_rate), 
&(sds->flame_smoke), sds->flame_smoke_color, &(sds->flame_vorticity), 
&(sds->flame_ignition), &(sds->flame_max_temp));
+#else
+       if (free_old && sds->fluid)
+               smoke_free(sds->fluid);
+       if (!min_iii(res[0], res[1], res[2])) {
+               sds->fluid = NULL;
+               return;
+       }
+       
+       sds->fluid = smoke_init(res, sds->smd);
+#endif
 
        /* reallocate shadow buffer */
        if (sds->shadow)
@@ -204,6 +210,7 @@ void smoke_reallocate_fluid(SmokeDomainSettings *sds, float 
dx, int res[3], int
 
 void smoke_reallocate_highres_fluid(SmokeDomainSettings *sds, float dx, int 
res[3], int free_old)
 {
+#ifndef WITH_MANTA
        int use_fire = (sds->active_fields & (SM_ACTIVE_HEAT | SM_ACTIVE_FIRE));
        int use_colors = (sds->active_fields & SM_ACTIVE_COLORS);
 
@@ -217,19 +224,19 @@ void smoke_reallocate_highres_fluid(SmokeDomainSettings 
*sds, float dx, int res[
        /* smoke_turbulence_init uses non-threadsafe functions from fftw3 lib 
(like fftw_plan & co). */
        BLI_lock_thread(LOCK_FFTW);
 
-       #ifndef WITH_MANTA
-               sds->wt = smoke_turbulence_init(res, sds->amplify + 1, 
sds->noise, BKE_tempdir_session(), use_fire, use_colors);
-       #else
-               sds->wt = smoke_turbulence_init(res, sds->amplify + 1, 
sds->noise, BKE_tempdir_session(), use_fire, use_colors, sds);
-       #endif
+       sds->wt = smoke_turbulence_init(res, sds->amplify + 1, sds->noise, 
BKE_tempdir_session(), use_fire, use_colors);
 
        BLI_unlock_thread(LOCK_FFTW);
+#endif
 
        sds->res_wt[0] = res[0] * (sds->amplify + 1);
        sds->res_wt[1] = res[1] * (sds->amplify + 1);
        sds->res_wt[2] = res[2] * (sds->amplify + 1);
        sds->dx_wt = dx / (sds->amplify + 1);
+       
+#ifndef WITH_MANTA
        smoke_initWaveletBlenderRNA(sds->wt, &(sds->strength));
+#endif
 }
 
 /* convert global position to domain cell space */
@@ -400,8 +407,10 @@ static void smokeModifier_freeDomain(SmokeModifierData 
*smd)
                if (smd->domain->fluid_mutex)
                        BLI_rw_mutex_free(smd->domain->fluid_mutex);
 
+#ifndef WITH_MANTA
                if (smd->domain->wt)
                        smoke_turbulence_free(smd->domain->wt);
+#endif
 
                if (smd->domain->effector_weights)
                        MEM_freeN(smd->domain->effector_weights);
@@ -452,11 +461,13 @@ static void smokeModifier_freeCollision(SmokeModifierData 
*smd)
 
 void smokeModifier_reset_turbulence(struct SmokeModifierData *smd)
 {
+#ifndef WITH_MANTA
        if (smd && smd->domain && smd->domain->wt)
        {
                smoke_turbulence_free(smd->domain->wt);
                smd->domain->wt = NULL;
        }
+#endif
 }
 
 static void smokeModifier_reset_ex(struct SmokeModifierData *smd, bool 
need_lock)
@@ -1761,16 +1772,27 @@ static void adjustDomainResolution(SmokeDomainSettings 
*sds, int new_shift[3], E
        int x, y, z;
        float *density = smoke_get_density(sds->fluid);
        float *fuel = smoke_get_fuel(sds->fluid);
+#ifndef WITH_MANTA
        float *bigdensity = smoke_turbulence_get_density(sds->wt);
        float *bigfuel = smoke_turbulence_get_fuel(sds->wt);
+#else
+       float *bigdensity = smoke_turbulence_get_density(sds->fluid);
+       float *bigfuel = smoke_turbulence_get_fuel(sds->fluid);
+#endif
        float *vx = smoke_get_velocity_x(sds->fluid);
        float *vy = smoke_get_velocity_y(sds->fluid);
        float *vz = smoke_get_velocity_z(sds->fluid);
        int wt_res[3];
 
+#ifndef WITH_MANTA
        if (sds->flags & MOD_SMOKE_HIGHRES && sds->wt) {
                smoke_turbulence_get_res(sds->wt, wt_res);
        }
+#else
+       if (sds->flags & MOD_SMOKE_HIGHRES && sds->fluid) {
+               smoke_turbulence_get_res(sds->fluid, wt_res);
+       }
+#endif
 
        INIT_MINMAX(min_vel, max_vel);
 
@@ -1793,7 +1815,11 @@ static void adjustDomainResolution(SmokeDomainSettings 
*sds, int new_shift[3], E
                                max_den = (fuel) ? MAX2(density[index], 
fuel[index]) : density[index];
 
                                /* check high resolution bounds if max density 
isnt already high enough */
+#ifndef WITH_MANTA
                                if (max_den < sds->adapt_threshold && 
sds->flags & MOD_SMOKE_HIGHRES && sds->wt) {
+#else
+                               if (max_den < sds->adapt_threshold && 
sds->flags & MOD_SMOKE_HIGHRES && sds->fluid) {
+#endif
                                        int i, j, k;
                                        /* high res grid index */
                                        int xx = (x - sds->res_min[0]) * 
block_size;
@@ -1884,8 +1910,12 @@ static void adjustDomainResolution(SmokeDomainSettings 
*sds, int new_shift[3], E
        }
 
        if (res_changed || shift_changed) {
+#ifndef WITH_MANTA
                struct FLUID_3D *fluid_old = sds->fluid;
                struct WTURBULENCE *turb_old = sds->wt;
+#else
+               struct MANTA *fluid_old = sds->fluid;
+#endif
                /* al

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to