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

smokehighres.c « intern « blenkernel « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6a2e0549158729c64aa6922f406d2edc0bbb1381 (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
126
127
128
129
130
131
132
133
134
135
136
137
/**
 * smokehighres.c
 *
 * $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) Blender Foundation.
 * All rights reserved.
 *
 * The Original Code is: all of this file.
 *
 * Contributor(s): Daniel Genrich
 *
 * ***** END GPL LICENSE BLOCK *****
 */

/* Part of the code copied from elbeem fluid library, copyright by Nils Thuerey */

#include "DNA_scene_types.h"
#include "DNA_listBase.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_smoke_types.h"

#include "BKE_modifier.h"
#include "BKE_smoke.h"
#include "BKE_pointcache.h"

#include "smoke_API.h"

// we need different handling for the high-res feature
/*
if(bigdensity)
{
	// init all surrounding cells according to amplification, too
	int i, j, k;

	smoke_turbulence_get_res(smd->domain->wt, bigres);

	for(i = 0; i < smd->domain->amplify + 1; i++)
		for(j = 0; j < smd->domain->amplify + 1; j++)
			for(k = 0; k < smd->domain->amplify + 1; k++)
			{
				index = smoke_get_index((smd->domain->amplify + 1)* cell[0] + i, bigres[0], (smd->domain->amplify + 1)* cell[1] + j, bigres[1], (smd->domain->amplify + 1)* cell[2] + k);
				bigdensity[index] = sfs->density;
			}
}
*/

static void smokeHRinit(SmokeHRModifierData *shrmd, SmokeDomainSettings *sds)
{
	if(!shrmd->wt)
	{
		shrmd->wt = smoke_turbulence_init(sds->res,  shrmd->amplify + 1, shrmd->noise);
		smoke_turbulence_initBlenderRNA(shrmd->wt, &shrmd->strength);
	}
}

void smokeHRModifier_free(SmokeHRModifierData *shrmd)
{
	if(shrmd->wt)
		smoke_turbulence_free(shrmd->wt);

	BKE_ptcache_free_list(&shrmd->ptcaches);
	shrmd->point_cache = NULL;
}

void smokeHRModifier_do(SmokeHRModifierData *shrmd, Scene *scene, Object *ob, int useRenderParams, int isFinalCalc)
{
	ModifierData *md = NULL;
	SmokeModifierData *smd = NULL;
	SmokeDomainSettings *sds = NULL;

	// find underlaying smoke domain
	smd = (SmokeModifierData *)modifiers_findByType(ob, eModifierType_Smoke);
	if(!(smd && smd->type == MOD_SMOKE_TYPE_DOMAIN))
		return;

	sds = smd->domain;

	smokeHRinit(shrmd, sds);

	// smoke_turbulence_dissolve(shrmd->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);

	// smoke_turbulence_step(shrmd->wt, sds->fluid);
}


// update necessary information for 3dview ("high res" option)
void smoke_prepare_bigView(SmokeHRModifierData *shrmd, float *light)
{
	float *density = NULL;
	size_t i = 0;
	int bigres[3];
/*
	smoke_turbulence_get_res(shrmd->wt, bigres);

	if(!smd->domain->traybig)
	{
		// TRay is for self shadowing
		smd->domain->traybig = MEM_callocN(sizeof(float)*bigres[0]*bigres[1]*bigres[2], "Smoke_tRayBig");
	}
	if(!smd->domain->tvoxbig)
	{
		// TVox is for tranaparency
		smd->domain->tvoxbig = MEM_callocN(sizeof(float)*bigres[0]*bigres[1]*bigres[2], "Smoke_tVoxBig");
	}

	density = smoke_turbulence_get_density(smd->domain->wt);
	for (i = 0; i < bigres[0] * bigres[1] * bigres[2]; i++)
	{
		// Transparency computation
		// formula taken from "Visual Simulation of Smoke" / Fedkiw et al. pg. 4
		// T_vox = exp(-C_ext * h)
		// C_ext/sigma_t = density * C_ext
		smoke_set_bigtvox(smd, i, exp(-density[i] * 7.0 * smd->domain->dx / (smd->domain->amplify + 1)) );
	}
	smoke_calc_transparency(smd, light, 1);
	*/
}