Beispiel #1
0
void SPHSystem::computeDensityPressure()
{
	int i, j, s, numNei;
	float lapc, c, d;
	float w;
	float vj;       // volumn
	float lenij;    // length (i,j)
	Point3f n;
	Point3f vecij;  // vector (i,j)
	
	for(i=0; i<p.size(); ++i) {
		p[i]->vol = p[i]->m/p[i]->d;
	}

	#pragma omp parallel for private(s, j, numNei, lapc, c, d, w, vj, lenij, n, vecij )
	for(i=0; i<p.size(); ++i) {
		lapc = 0;
		c = 0;
		d = 0;
		n.Zero();
		numNei = p[i]->pq.getSize();
		for(s=1; s<=numNei; ++s) {
			j = p[i]->pq.queue[s];
			vj = p[j]->vol;
			vecij = *p[i]-*p[j];
			lenij = vecij.Length();
			w = k->w(lenij);
			
			c += p[j]->c*p[j]->m*(vj)*w;
			n += p[j]->m*(vj)*k->w1(lenij)*(vecij);
			lapc += p[j]->m*(vj)*k->w2(lenij);
			
			d += p[j]->m*w;
		}
		p[i]->lapc = lapc;										// laplacian of c
		p[i]->c = c;											// color field
		p[i]->n = n;											// inward surface normal
		
		p[i]->d = d;											// density
		p[i]->p = (K*RHO/7.0f)*(pow((d/RHO),7.0f)-1);           // pressure (Tait Equation, http://graphics.stanford.edu/~wicke/eg09-tutorial/coursenotes.pdf)
		if(p[i]->p < 0)											// correct pressure if p<0
			p[i]->p *= Z;										// reduce it to a tiny number (~=0)
			
	}

}
Beispiel #2
0
void ShadowMap::Update(){
  lastL.Zero();
}