Welcome to mirror list, hosted at ThFree Co, Russian Federation.

smoke_API.cpp « intern « smoke « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c81d6fb8c50b24334406d0a37262f082efa974d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
 * $Id$
 *
 * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * The Original Code is Copyright (C) 2009 by Daniel Genrich
 * All rights reserved.
 *
 * Contributor(s): None
 *
 * ***** END GPL LICENSE BLOCK *****
 */

#include "FLUID_3D.h"

#include <stdio.h>
#include <stdlib.h>

// y in smoke is z in blender
extern "C" FLUID_3D *smoke_init(int *res, int amplify, float *p0, float *p1, float dt)
{
	// smoke lib uses y as top-bottom/vertical axis where blender uses z
	FLUID_3D *fluid = new FLUID_3D(res, amplify, p0, p1, dt);

	// printf("xres: %d, yres: %d, zres: %d\n", res[0], res[1], res[2]);

	return fluid;
}

extern "C" void smoke_free(FLUID_3D *fluid)
{
	delete fluid;
	fluid = NULL;
}

extern "C" void smoke_step(FLUID_3D *fluid, float dx)
{
	// fluid->addSmokeColumn();
	fluid->step();
}

extern "C" void smoke_initBlenderRNA(FLUID_3D *fluid, float *alpha, float *beta)
{
	fluid->initBlenderRNA(alpha, beta);
}

template < class T > inline T ABS( T a ) {
	return (0 < a) ? a : -a ;
}

extern "C" float *smoke_get_density(FLUID_3D *fluid)
{
	return fluid->_density;
}

extern "C" float *smoke_get_heat(FLUID_3D *fluid)
{
	return fluid->_heat;
}

extern "C" float *smoke_get_velocity_x(FLUID_3D *fluid)
{
	return fluid->_xVorticity;
}

extern "C" float *smoke_get_velocity_y(FLUID_3D *fluid)
{
	return fluid->_yVorticity;
}

extern "C" float *smoke_get_velocity_z(FLUID_3D *fluid)
{
	return fluid->_zVorticity;
}

extern "C" float *smoke_get_bigdensity(FLUID_3D *fluid)
{
	return fluid->_wTurbulence->getDensityBig();
}

extern "C" void smoke_get_bigres(FLUID_3D *fluid, int *res)
{
	Vec3Int r = fluid->_wTurbulence->getResBig();
	res[0] = r[0];
	res[1] = r[1];
	res[2] = r[2];
}

extern "C" unsigned char *smoke_get_obstacle(FLUID_3D *fluid)
{
	return fluid->_obstacles;
}

extern "C" size_t smoke_get_index(int x, int max_x, int y, int max_y, int z, int max_z)
{
	// // const int index = x + y * smd->res[0] + z * smd->res[0]*smd->res[1];
	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_set_noise(FLUID_3D *fluid, int type)
{
	fluid->_wTurbulence->setNoise(type);
}