Cleanup: style
This commit is contained in:
		@@ -479,7 +479,7 @@ static void distribute_from_verts_exec(ParticleTask *thread, ParticleData *pa, i
 | 
				
			|||||||
		int w, maxw;
 | 
							int w, maxw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		psys_particle_on_dm(ctx->dm,from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co1,0,0,0,orco1,0);
 | 
							psys_particle_on_dm(ctx->dm,from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co1,0,0,0,orco1,0);
 | 
				
			||||||
		BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1);
 | 
							BKE_mesh_orco_verts_transform((Mesh *)ob->data, &orco1, 1, 1);
 | 
				
			||||||
		maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,ptn,3);
 | 
							maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,ptn,3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (w=0; w<maxw; w++) {
 | 
							for (w=0; w<maxw; w++) {
 | 
				
			||||||
@@ -665,7 +665,7 @@ static void distribute_children_exec(ParticleTask *thread, ChildParticle *cpa, i
 | 
				
			|||||||
		float pweight[10];
 | 
							float pweight[10];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		psys_particle_on_dm(dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,NULL,NULL,orco1,NULL);
 | 
							psys_particle_on_dm(dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,NULL,NULL,orco1,NULL);
 | 
				
			||||||
		BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1);
 | 
							BKE_mesh_orco_verts_transform((Mesh *)ob->data, &orco1, 1, 1);
 | 
				
			||||||
		maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,ptn,3);
 | 
							maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,ptn,3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		maxd=ptn[maxw-1].dist;
 | 
							maxd=ptn[maxw-1].dist;
 | 
				
			||||||
@@ -865,7 +865,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
 | 
				
			|||||||
				dm = finaldm;
 | 
									dm = finaldm;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else {
 | 
								else {
 | 
				
			||||||
				dm = CDDM_from_mesh((Mesh*)ob->data);
 | 
									dm = CDDM_from_mesh((Mesh *)ob->data);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			DM_ensure_tessface(dm);
 | 
								DM_ensure_tessface(dm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -894,7 +894,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		for (p=0,pa=psys->particles; p<totpart; p++,pa++) {
 | 
							for (p=0,pa=psys->particles; p<totpart; p++,pa++) {
 | 
				
			||||||
			psys_particle_on_dm(dm,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco,NULL);
 | 
								psys_particle_on_dm(dm,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco,NULL);
 | 
				
			||||||
			BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco, 1, 1);
 | 
								BKE_mesh_orco_verts_transform((Mesh *)ob->data, &orco, 1, 1);
 | 
				
			||||||
			BLI_kdtree_insert(tree, p, orco);
 | 
								BLI_kdtree_insert(tree, p, orco);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -910,7 +910,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
 | 
				
			|||||||
		if (psys->part->use_modifier_stack)
 | 
							if (psys->part->use_modifier_stack)
 | 
				
			||||||
			dm = finaldm;
 | 
								dm = finaldm;
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			dm= CDDM_from_mesh((Mesh*)ob->data);
 | 
								dm= CDDM_from_mesh((Mesh *)ob->data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		DM_ensure_tessface(dm);
 | 
							DM_ensure_tessface(dm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -928,7 +928,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
 | 
				
			|||||||
			for (p=0; p<totvert; p++) {
 | 
								for (p=0; p<totvert; p++) {
 | 
				
			||||||
				if (orcodata) {
 | 
									if (orcodata) {
 | 
				
			||||||
					copy_v3_v3(co,orcodata[p]);
 | 
										copy_v3_v3(co,orcodata[p]);
 | 
				
			||||||
					BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co, 1, 1);
 | 
										BKE_mesh_orco_verts_transform((Mesh *)ob->data, &co, 1, 1);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				else
 | 
									else
 | 
				
			||||||
					copy_v3_v3(co,mv[p].co);
 | 
										copy_v3_v3(co,mv[p].co);
 | 
				
			||||||
@@ -974,23 +974,23 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
 | 
				
			|||||||
				copy_v3_v3(co1, orcodata[mf->v1]);
 | 
									copy_v3_v3(co1, orcodata[mf->v1]);
 | 
				
			||||||
				copy_v3_v3(co2, orcodata[mf->v2]);
 | 
									copy_v3_v3(co2, orcodata[mf->v2]);
 | 
				
			||||||
				copy_v3_v3(co3, orcodata[mf->v3]);
 | 
									copy_v3_v3(co3, orcodata[mf->v3]);
 | 
				
			||||||
				BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co1, 1, 1);
 | 
									BKE_mesh_orco_verts_transform((Mesh *)ob->data, &co1, 1, 1);
 | 
				
			||||||
				BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co2, 1, 1);
 | 
									BKE_mesh_orco_verts_transform((Mesh *)ob->data, &co2, 1, 1);
 | 
				
			||||||
				BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co3, 1, 1);
 | 
									BKE_mesh_orco_verts_transform((Mesh *)ob->data, &co3, 1, 1);
 | 
				
			||||||
				if (mf->v4) {
 | 
									if (mf->v4) {
 | 
				
			||||||
					copy_v3_v3(co4, orcodata[mf->v4]);
 | 
										copy_v3_v3(co4, orcodata[mf->v4]);
 | 
				
			||||||
					BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co4, 1, 1);
 | 
										BKE_mesh_orco_verts_transform((Mesh *)ob->data, &co4, 1, 1);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else {
 | 
								else {
 | 
				
			||||||
				v1= (MVert*)dm->getVertData(dm,mf->v1,CD_MVERT);
 | 
									v1= (MVert *)dm->getVertData(dm,mf->v1,CD_MVERT);
 | 
				
			||||||
				v2= (MVert*)dm->getVertData(dm,mf->v2,CD_MVERT);
 | 
									v2= (MVert *)dm->getVertData(dm,mf->v2,CD_MVERT);
 | 
				
			||||||
				v3= (MVert*)dm->getVertData(dm,mf->v3,CD_MVERT);
 | 
									v3= (MVert *)dm->getVertData(dm,mf->v3,CD_MVERT);
 | 
				
			||||||
				copy_v3_v3(co1, v1->co);
 | 
									copy_v3_v3(co1, v1->co);
 | 
				
			||||||
				copy_v3_v3(co2, v2->co);
 | 
									copy_v3_v3(co2, v2->co);
 | 
				
			||||||
				copy_v3_v3(co3, v3->co);
 | 
									copy_v3_v3(co3, v3->co);
 | 
				
			||||||
				if (mf->v4) {
 | 
									if (mf->v4) {
 | 
				
			||||||
					v4= (MVert*)dm->getVertData(dm,mf->v4,CD_MVERT);
 | 
										v4= (MVert *)dm->getVertData(dm,mf->v4,CD_MVERT);
 | 
				
			||||||
					copy_v3_v3(co4, v4->co);
 | 
										copy_v3_v3(co4, v4->co);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -167,9 +167,9 @@ char *BLI_cpu_brand_string(void)
 | 
				
			|||||||
	int result[4] = { 0 };
 | 
						int result[4] = { 0 };
 | 
				
			||||||
	__cpuid(result, 0x80000000);
 | 
						__cpuid(result, 0x80000000);
 | 
				
			||||||
	if (result[0] >= (int)0x80000004) {
 | 
						if (result[0] >= (int)0x80000004) {
 | 
				
			||||||
		__cpuid((int*)(buf + 0), 0x80000002);
 | 
							__cpuid((int *)(buf + 0), 0x80000002);
 | 
				
			||||||
		__cpuid((int*)(buf + 16), 0x80000003);
 | 
							__cpuid((int *)(buf + 16), 0x80000003);
 | 
				
			||||||
		__cpuid((int*)(buf + 32), 0x80000004);
 | 
							__cpuid((int *)(buf + 32), 0x80000004);
 | 
				
			||||||
		char *brand = BLI_strdup(buf);
 | 
							char *brand = BLI_strdup(buf);
 | 
				
			||||||
		/* TODO(sergey): Make it a bit more presentable by removing trademark. */
 | 
							/* TODO(sergey): Make it a bit more presentable by removing trademark. */
 | 
				
			||||||
		return brand;
 | 
							return brand;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -210,9 +210,9 @@ void DEG_editors_update_pre(struct Main *bmain, struct Scene *scene, bool time);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Evaluation Debug ------------------------------ */
 | 
					/* Evaluation Debug ------------------------------ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DEG_debug_print_eval(const char* function_name,
 | 
					void DEG_debug_print_eval(const char *function_name,
 | 
				
			||||||
                          const char* object_name,
 | 
					                          const char *object_name,
 | 
				
			||||||
                          const void* object_address);
 | 
					                          const void *object_address);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DEG_debug_print_eval_subdata(const char *function_name,
 | 
					void DEG_debug_print_eval_subdata(const char *function_name,
 | 
				
			||||||
                                  const char *object_name,
 | 
					                                  const char *object_name,
 | 
				
			||||||
@@ -229,9 +229,9 @@ void DEG_debug_print_eval_subdata_index(const char *function_name,
 | 
				
			|||||||
                                        const void *subdata_address,
 | 
					                                        const void *subdata_address,
 | 
				
			||||||
                                        const int subdata_index);
 | 
					                                        const int subdata_index);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DEG_debug_print_eval_time(const char* function_name,
 | 
					void DEG_debug_print_eval_time(const char *function_name,
 | 
				
			||||||
                               const char* object_name,
 | 
					                               const char *object_name,
 | 
				
			||||||
                               const void* object_address,
 | 
					                               const void *object_address,
 | 
				
			||||||
                               float time);
 | 
					                               float time);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4189,7 +4189,7 @@ static void p_add_ngon(ParamHandle *handle, ParamKey key, int nverts,
 | 
				
			|||||||
	float normal[3];
 | 
						float normal[3];
 | 
				
			||||||
	zero_v3(normal);
 | 
						zero_v3(normal);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const float *co_curr, *co_prev = co[nverts-1];
 | 
						const float *co_curr, *co_prev = co[nverts - 1];
 | 
				
			||||||
	for (int j = 0; j < nverts; j++) {
 | 
						for (int j = 0; j < nverts; j++) {
 | 
				
			||||||
		co_curr = co[j];
 | 
							co_curr = co[j];
 | 
				
			||||||
		add_newell_cross_v3_v3v3(normal, co_prev, co_curr);
 | 
							add_newell_cross_v3_v3v3(normal, co_prev, co_curr);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -149,7 +149,7 @@ static bool collision_response(ClothModifierData *clmd, CollisionModifierData *c
 | 
				
			|||||||
		return false; /* XXX tested before already? */
 | 
							return false; /* XXX tested before already? */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* only handle static collisions here */
 | 
						/* only handle static collisions here */
 | 
				
			||||||
	if ( collpair->flag & COLLISION_IN_FUTURE )
 | 
						if (collpair->flag & COLLISION_IN_FUTURE)
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* velocity */
 | 
						/* velocity */
 | 
				
			||||||
@@ -260,8 +260,8 @@ static void cloth_setup_constraints(ClothModifierData *clmd, ColliderContacts *c
 | 
				
			|||||||
 * collisions*/
 | 
					 * collisions*/
 | 
				
			||||||
static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothModifierData *clmd, float (*initial_cos)[3], float UNUSED(step), float dt)
 | 
					static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothModifierData *clmd, float (*initial_cos)[3], float UNUSED(step), float dt)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Cloth *cloth= clmd->clothObject;
 | 
						Cloth *cloth = clmd->clothObject;
 | 
				
			||||||
	float (*cos)[3] = (float (*)[3])MEM_callocN(sizeof(float[3]) * cloth->mvert_num, "cos cloth_calc_helper_forces");
 | 
						float(*cos)[3] = (float(*)[3])MEM_callocN(sizeof(float[3]) * cloth->mvert_num, "cos cloth_calc_helper_forces");
 | 
				
			||||||
	float *masses = (float *)MEM_callocN(sizeof(float) * cloth->mvert_num, "cos cloth_calc_helper_forces");
 | 
						float *masses = (float *)MEM_callocN(sizeof(float) * cloth->mvert_num, "cos cloth_calc_helper_forces");
 | 
				
			||||||
	LinkNode *node;
 | 
						LinkNode *node;
 | 
				
			||||||
	ClothSpring *spring;
 | 
						ClothSpring *spring;
 | 
				
			||||||
@@ -281,8 +281,8 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	steps = 55;
 | 
						steps = 55;
 | 
				
			||||||
	for (i=0; i<steps; i++) {
 | 
						for (i = 0; i < steps; i++) {
 | 
				
			||||||
		for (node=cloth->springs; node; node=node->next) {
 | 
							for (node = cloth->springs; node; node = node->next) {
 | 
				
			||||||
			/* ClothVertex *cv1, *cv2; */ /* UNUSED */
 | 
								/* ClothVertex *cv1, *cv2; */ /* UNUSED */
 | 
				
			||||||
			int v1, v2;
 | 
								int v1, v2;
 | 
				
			||||||
			float len, c, l, vec[3];
 | 
								float len, c, l, vec[3];
 | 
				
			||||||
@@ -322,7 +322,7 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		/*compute forces*/
 | 
							/*compute forces*/
 | 
				
			||||||
		sub_v3_v3v3(vec, cos[i], cv->tx);
 | 
							sub_v3_v3v3(vec, cos[i], cv->tx);
 | 
				
			||||||
		mul_v3_fl(vec, cv->mass*dt*20.0f);
 | 
							mul_v3_fl(vec, cv->mass * dt * 20.0f);
 | 
				
			||||||
		add_v3_v3(cv->tv, vec);
 | 
							add_v3_v3(cv->tv, vec);
 | 
				
			||||||
		//copy_v3_v3(cv->tx, cos[i]);
 | 
							//copy_v3_v3(cv->tx, cos[i]);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -481,7 +481,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB
 | 
				
			|||||||
	/* handle external forces like wind */
 | 
						/* handle external forces like wind */
 | 
				
			||||||
	if (effectors) {
 | 
						if (effectors) {
 | 
				
			||||||
		/* cache per-vertex forces to avoid redundant calculation */
 | 
							/* cache per-vertex forces to avoid redundant calculation */
 | 
				
			||||||
		float (*winvec)[3] = (float (*)[3])MEM_callocN(sizeof(float[3]) * mvert_num, "effector forces");
 | 
							float(*winvec)[3] = (float(*)[3])MEM_callocN(sizeof(float[3]) * mvert_num, "effector forces");
 | 
				
			||||||
		for (i = 0; i < cloth->mvert_num; i++) {
 | 
							for (i = 0; i < cloth->mvert_num; i++) {
 | 
				
			||||||
			float x[3], v[3];
 | 
								float x[3], v[3];
 | 
				
			||||||
			EffectedPoint epoint;
 | 
								EffectedPoint epoint;
 | 
				
			||||||
@@ -526,8 +526,8 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB
 | 
				
			|||||||
				else
 | 
									else
 | 
				
			||||||
					BPH_mass_spring_force_vertex_wind(data, i, 1.0f, winvec);
 | 
										BPH_mass_spring_force_vertex_wind(data, i, 1.0f, winvec);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		MEM_freeN(winvec);
 | 
							MEM_freeN(winvec);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -744,16 +744,16 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
 | 
				
			|||||||
			zero_v3(b);
 | 
								zero_v3(b);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			offset[axis] = shift * clmd->hair_grid_cellsize;
 | 
								offset[axis] = shift * clmd->hair_grid_cellsize;
 | 
				
			||||||
			a[(axis+1) % 3] = clmd->hair_grid_max[(axis+1) % 3] - clmd->hair_grid_min[(axis+1) % 3];
 | 
								a[(axis + 1) % 3] = clmd->hair_grid_max[(axis + 1) % 3] - clmd->hair_grid_min[(axis + 1) % 3];
 | 
				
			||||||
			b[(axis+2) % 3] = clmd->hair_grid_max[(axis+2) % 3] - clmd->hair_grid_min[(axis+2) % 3];
 | 
								b[(axis + 2) % 3] = clmd->hair_grid_max[(axis + 2) % 3] - clmd->hair_grid_min[(axis + 2) % 3];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			BKE_sim_debug_data_clear_category(clmd->debug_data, "grid velocity");
 | 
								BKE_sim_debug_data_clear_category(clmd->debug_data, "grid velocity");
 | 
				
			||||||
			for (j = 0; j < size; ++j) {
 | 
								for (j = 0; j < size; ++j) {
 | 
				
			||||||
				for (i = 0; i < size; ++i) {
 | 
									for (i = 0; i < size; ++i) {
 | 
				
			||||||
					float x[3], v[3], gvel[3], gvel_smooth[3], gdensity;
 | 
										float x[3], v[3], gvel[3], gvel_smooth[3], gdensity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					madd_v3_v3v3fl(x, offset, a, (float)i / (float)(size-1));
 | 
										madd_v3_v3v3fl(x, offset, a, (float)i / (float)(size - 1));
 | 
				
			||||||
					madd_v3_v3fl(x, b, (float)j / (float)(size-1));
 | 
										madd_v3_v3fl(x, b, (float)j / (float)(size - 1));
 | 
				
			||||||
					zero_v3(v);
 | 
										zero_v3(v);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					BPH_hair_volume_grid_interpolate(grid, x, &gdensity, gvel, gvel_smooth, NULL, NULL);
 | 
										BPH_hair_volume_grid_interpolate(grid, x, &gdensity, gvel, gvel_smooth, NULL, NULL);
 | 
				
			||||||
@@ -872,7 +872,7 @@ static void cloth_collision_solve_extra(Object *ob, ClothModifierData *clmd, Lis
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0 /* unused */
 | 
					#if 0 /* unused */
 | 
				
			||||||
	for (i=0, cv=cloth->verts; i<cloth->mvert_num; i++, cv++) {
 | 
						for (i = 0, cv = cloth->verts; i < cloth->mvert_num; i++, cv++) {
 | 
				
			||||||
		copy_v3_v3(initial_cos[i], cv->tx);
 | 
							copy_v3_v3(initial_cos[i], cv->tx);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -896,7 +896,7 @@ static void cloth_collision_solve_extra(Object *ob, ClothModifierData *clmd, Lis
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			float newv[3];
 | 
								float newv[3];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
 | 
								if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts[i].flags & CLOTH_VERT_FLAG_PINNED))
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			BPH_mass_spring_set_new_position(id, i, verts[i].tx);
 | 
								BPH_mass_spring_set_new_position(id, i, verts[i].tx);
 | 
				
			||||||
@@ -975,10 +975,10 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
 | 
				
			|||||||
	 */
 | 
						 */
 | 
				
			||||||
	const bool is_hair = (clmd->hairdata != NULL);
 | 
						const bool is_hair = (clmd->hairdata != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	unsigned int i=0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
	float step=0.0f, tf=clmd->sim_parms->timescale;
 | 
						float step = 0.0f, tf = clmd->sim_parms->timescale;
 | 
				
			||||||
	Cloth *cloth = clmd->clothObject;
 | 
						Cloth *cloth = clmd->clothObject;
 | 
				
			||||||
	ClothVertex *verts = cloth->verts/*, *cv*/;
 | 
						ClothVertex *verts = cloth->verts /*, *cv*/;
 | 
				
			||||||
	unsigned int mvert_num = cloth->mvert_num;
 | 
						unsigned int mvert_num = cloth->mvert_num;
 | 
				
			||||||
	float dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame;
 | 
						float dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame;
 | 
				
			||||||
	Implicit_Data *id = cloth->implicit;
 | 
						Implicit_Data *id = cloth->implicit;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,7 +67,7 @@ public:
 | 
				
			|||||||
			coeffRef(k) = v[k];
 | 
								coeffRef(k) = v[k];
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Vector3& operator = (const ctype &v)
 | 
						Vector3& operator =(const ctype &v)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		for (int k = 0; k < 3; ++k)
 | 
							for (int k = 0; k < 3; ++k)
 | 
				
			||||||
			coeffRef(k) = v[k];
 | 
								coeffRef(k) = v[k];
 | 
				
			||||||
@@ -98,7 +98,7 @@ public:
 | 
				
			|||||||
				coeffRef(l, k) = v[k][l];
 | 
									coeffRef(l, k) = v[k][l];
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Matrix3& operator = (const ctype &v)
 | 
						Matrix3& operator =(const ctype &v)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		for (int k = 0; k < 3; ++k)
 | 
							for (int k = 0; k < 3; ++k)
 | 
				
			||||||
			for (int l = 0; l < 3; ++l)
 | 
								for (int l = 0; l < 3; ++l)
 | 
				
			||||||
@@ -126,18 +126,18 @@ public:
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	template <typename T>
 | 
						template <typename T>
 | 
				
			||||||
	lVector3f& operator = (T rhs)
 | 
						lVector3f& operator =(T rhs)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		base_t::operator=(rhs);
 | 
							base_t::operator=(rhs);
 | 
				
			||||||
		return *this;
 | 
							return *this;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	float* v3(int vertex)
 | 
						float *v3(int vertex)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		return &coeffRef(3 * vertex);
 | 
							return &coeffRef(3 * vertex);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const float* v3(int vertex) const
 | 
						const float *v3(int vertex) const
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		return &coeffRef(3 * vertex);
 | 
							return &coeffRef(3 * vertex);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -93,7 +93,7 @@ typedef struct HairGrid {
 | 
				
			|||||||
	float cellsize, inv_cellsize;
 | 
						float cellsize, inv_cellsize;
 | 
				
			||||||
} HairGrid;
 | 
					} HairGrid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis) ( min_ii( max_ii( (int)((vec[axis] - gmin[axis]) * scale), 0), res[axis]-2 ) )
 | 
					#define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis) (min_ii(max_ii( (int)((vec[axis] - gmin[axis]) * scale), 0), res[axis] - 2) )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BLI_INLINE int hair_grid_offset(const float vec[3], const int res[3], const float gmin[3], float scale)
 | 
					BLI_INLINE int hair_grid_offset(const float vec[3], const int res[3], const float gmin[3], float scale)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -101,7 +101,7 @@ BLI_INLINE int hair_grid_offset(const float vec[3], const int res[3], const floa
 | 
				
			|||||||
	i = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 0);
 | 
						i = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 0);
 | 
				
			||||||
	j = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 1);
 | 
						j = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 1);
 | 
				
			||||||
	k = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 2);
 | 
						k = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 2);
 | 
				
			||||||
	return i + (j + k*res[1])*res[0];
 | 
						return i + (j + k * res[1]) * res[0];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BLI_INLINE int hair_grid_interp_weights(const int res[3], const float gmin[3], float scale, const float vec[3], float uvw[3])
 | 
					BLI_INLINE int hair_grid_interp_weights(const int res[3], const float gmin[3], float scale, const float vec[3], float uvw[3])
 | 
				
			||||||
@@ -111,7 +111,7 @@ BLI_INLINE int hair_grid_interp_weights(const int res[3], const float gmin[3], f
 | 
				
			|||||||
	i = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 0);
 | 
						i = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 0);
 | 
				
			||||||
	j = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 1);
 | 
						j = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 1);
 | 
				
			||||||
	k = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 2);
 | 
						k = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 2);
 | 
				
			||||||
	offset = i + (j + k*res[1])*res[0];
 | 
						offset = i + (j + k * res[1]) * res[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uvw[0] = (vec[0] - gmin[0]) * scale - (float)i;
 | 
						uvw[0] = (vec[0] - gmin[0]) * scale - (float)i;
 | 
				
			||||||
	uvw[1] = (vec[1] - gmin[1]) * scale - (float)j;
 | 
						uvw[1] = (vec[1] - gmin[1]) * scale - (float)j;
 | 
				
			||||||
@@ -124,7 +124,8 @@ BLI_INLINE int hair_grid_interp_weights(const int res[3], const float gmin[3], f
 | 
				
			|||||||
	return offset;
 | 
						return offset;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid, const int res[3], const float gmin[3], float scale, const float vec[3],
 | 
					BLI_INLINE void hair_grid_interpolate(
 | 
				
			||||||
 | 
					        const HairGridVert *grid, const int res[3], const float gmin[3], float scale, const float vec[3],
 | 
				
			||||||
        float *density, float velocity[3], float vel_smooth[3], float density_gradient[3], float velocity_gradient[3][3])
 | 
					        float *density, float velocity[3], float vel_smooth[3], float density_gradient[3], float velocity_gradient[3][3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	HairGridVert data[8];
 | 
						HairGridVert data[8];
 | 
				
			||||||
@@ -138,56 +139,56 @@ BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid, const int res[3]
 | 
				
			|||||||
	muvw[2] = 1.0f - uvw[2];
 | 
						muvw[2] = 1.0f - uvw[2];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	data[0] = grid[offset                    ];
 | 
						data[0] = grid[offset                    ];
 | 
				
			||||||
	data[1] = grid[offset            +1];
 | 
						data[1] = grid[offset                 + 1];
 | 
				
			||||||
	data[2] = grid[offset     +res[0]  ];
 | 
						data[2] = grid[offset        + res[0]    ];
 | 
				
			||||||
	data[3] = grid[offset     +res[0]+1];
 | 
						data[3] = grid[offset        + res[0] + 1];
 | 
				
			||||||
	data[4] = grid[offset+res2         ];
 | 
						data[4] = grid[offset + res2             ];
 | 
				
			||||||
	data[5] = grid[offset+res2       +1];
 | 
						data[5] = grid[offset + res2          + 1];
 | 
				
			||||||
	data[6] = grid[offset+res2+res[0]  ];
 | 
						data[6] = grid[offset + res2 + res[0]    ];
 | 
				
			||||||
	data[7] = grid[offset+res2+res[0]+1];
 | 
						data[7] = grid[offset + res2 + res[0] + 1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (density) {
 | 
						if (density) {
 | 
				
			||||||
		*density = muvw[2]*( muvw[1]*( muvw[0]*data[0].density + uvw[0]*data[1].density )   +
 | 
							*density = muvw[2] * (muvw[1] * (muvw[0] * data[0].density + uvw[0] * data[1].density)  +
 | 
				
			||||||
		                      uvw[1]*( muvw[0]*data[2].density + uvw[0]*data[3].density ) ) +
 | 
							                       uvw[1] * (muvw[0] * data[2].density + uvw[0] * data[3].density)) +
 | 
				
			||||||
		            uvw[2]*( muvw[1]*( muvw[0]*data[4].density + uvw[0]*data[5].density )   +
 | 
							            uvw[2] * (muvw[1] * (muvw[0] * data[4].density + uvw[0] * data[5].density)  +
 | 
				
			||||||
		                      uvw[1]*( muvw[0]*data[6].density + uvw[0]*data[7].density ) );
 | 
							                       uvw[1] * (muvw[0] * data[6].density + uvw[0] * data[7].density));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (velocity) {
 | 
						if (velocity) {
 | 
				
			||||||
		int k;
 | 
							int k;
 | 
				
			||||||
		for (k = 0; k < 3; ++k) {
 | 
							for (k = 0; k < 3; ++k) {
 | 
				
			||||||
			velocity[k] = muvw[2]*( muvw[1]*( muvw[0]*data[0].velocity[k] + uvw[0]*data[1].velocity[k] )   +
 | 
								velocity[k] = muvw[2] * (muvw[1] * (muvw[0] * data[0].velocity[k] + uvw[0] * data[1].velocity[k])   +
 | 
				
			||||||
			                         uvw[1]*( muvw[0]*data[2].velocity[k] + uvw[0]*data[3].velocity[k] ) ) +
 | 
								                          uvw[1] * (muvw[0] * data[2].velocity[k] + uvw[0] * data[3].velocity[k]) ) +
 | 
				
			||||||
			               uvw[2]*( muvw[1]*( muvw[0]*data[4].velocity[k] + uvw[0]*data[5].velocity[k] )   +
 | 
								               uvw[2] * (muvw[1] * (muvw[0] * data[4].velocity[k] + uvw[0] * data[5].velocity[k])   +
 | 
				
			||||||
			                         uvw[1]*( muvw[0]*data[6].velocity[k] + uvw[0]*data[7].velocity[k] ) );
 | 
								                          uvw[1] * (muvw[0] * data[6].velocity[k] + uvw[0] * data[7].velocity[k]) );
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (vel_smooth) {
 | 
						if (vel_smooth) {
 | 
				
			||||||
		int k;
 | 
							int k;
 | 
				
			||||||
		for (k = 0; k < 3; ++k) {
 | 
							for (k = 0; k < 3; ++k) {
 | 
				
			||||||
			vel_smooth[k] = muvw[2]*( muvw[1]*( muvw[0]*data[0].velocity_smooth[k] + uvw[0]*data[1].velocity_smooth[k] )   +
 | 
								vel_smooth[k] = muvw[2] * (muvw[1] * (muvw[0] * data[0].velocity_smooth[k] + uvw[0] * data[1].velocity_smooth[k])   +
 | 
				
			||||||
			                           uvw[1]*( muvw[0]*data[2].velocity_smooth[k] + uvw[0]*data[3].velocity_smooth[k] ) ) +
 | 
								                            uvw[1] * (muvw[0] * data[2].velocity_smooth[k] + uvw[0] * data[3].velocity_smooth[k]) ) +
 | 
				
			||||||
			                 uvw[2]*( muvw[1]*( muvw[0]*data[4].velocity_smooth[k] + uvw[0]*data[5].velocity_smooth[k] )   +
 | 
								                 uvw[2] * (muvw[1] * (muvw[0] * data[4].velocity_smooth[k] + uvw[0] * data[5].velocity_smooth[k])   +
 | 
				
			||||||
			                           uvw[1]*( muvw[0]*data[6].velocity_smooth[k] + uvw[0]*data[7].velocity_smooth[k] ) );
 | 
								                            uvw[1] * (muvw[0] * data[6].velocity_smooth[k] + uvw[0] * data[7].velocity_smooth[k]) );
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (density_gradient) {
 | 
						if (density_gradient) {
 | 
				
			||||||
		density_gradient[0] = muvw[1] * muvw[2] * ( data[0].density - data[1].density ) +
 | 
							density_gradient[0] = muvw[1] * muvw[2] * (data[0].density - data[1].density) +
 | 
				
			||||||
		                       uvw[1] * muvw[2] * ( data[2].density - data[3].density ) +
 | 
							                       uvw[1] * muvw[2] * (data[2].density - data[3].density) +
 | 
				
			||||||
		                      muvw[1] *  uvw[2] * ( data[4].density - data[5].density ) +
 | 
							                      muvw[1] *  uvw[2] * (data[4].density - data[5].density) +
 | 
				
			||||||
		                       uvw[1] *  uvw[2] * ( data[6].density - data[7].density );
 | 
							                       uvw[1] *  uvw[2] * (data[6].density - data[7].density);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		density_gradient[1] = muvw[2] * muvw[0] * ( data[0].density - data[2].density ) +
 | 
							density_gradient[1] = muvw[2] * muvw[0] * (data[0].density - data[2].density) +
 | 
				
			||||||
		                       uvw[2] * muvw[0] * ( data[4].density - data[6].density ) +
 | 
							                       uvw[2] * muvw[0] * (data[4].density - data[6].density) +
 | 
				
			||||||
		                      muvw[2] *  uvw[0] * ( data[1].density - data[3].density ) +
 | 
							                      muvw[2] *  uvw[0] * (data[1].density - data[3].density) +
 | 
				
			||||||
		                       uvw[2] *  uvw[0] * ( data[5].density - data[7].density );
 | 
							                       uvw[2] *  uvw[0] * (data[5].density - data[7].density);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		density_gradient[2] = muvw[2] * muvw[0] * ( data[0].density - data[4].density ) +
 | 
							density_gradient[2] = muvw[2] * muvw[0] * (data[0].density - data[4].density) +
 | 
				
			||||||
		                       uvw[2] * muvw[0] * ( data[1].density - data[5].density ) +
 | 
							                       uvw[2] * muvw[0] * (data[1].density - data[5].density) +
 | 
				
			||||||
		                      muvw[2] *  uvw[0] * ( data[2].density - data[6].density ) +
 | 
							                      muvw[2] *  uvw[0] * (data[2].density - data[6].density) +
 | 
				
			||||||
		                       uvw[2] *  uvw[0] * ( data[3].density - data[7].density );
 | 
							                       uvw[2] *  uvw[0] * (data[3].density - data[7].density);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (velocity_gradient) {
 | 
						if (velocity_gradient) {
 | 
				
			||||||
@@ -196,7 +197,8 @@ BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid, const int res[3]
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BPH_hair_volume_vertex_grid_forces(HairGrid *grid, const float x[3], const float v[3],
 | 
					void BPH_hair_volume_vertex_grid_forces(
 | 
				
			||||||
 | 
					        HairGrid *grid, const float x[3], const float v[3],
 | 
				
			||||||
        float smoothfac, float pressurefac, float minpressure,
 | 
					        float smoothfac, float pressurefac, float minpressure,
 | 
				
			||||||
        float f[3], float dfdx[3][3], float dfdv[3][3])
 | 
					        float f[3], float dfdx[3][3], float dfdv[3][3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -220,13 +222,15 @@ void BPH_hair_volume_vertex_grid_forces(HairGrid *grid, const float x[3], const
 | 
				
			|||||||
	mul_m3_fl(dfdv, smoothfac);
 | 
						mul_m3_fl(dfdv, smoothfac);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BPH_hair_volume_grid_interpolate(HairGrid *grid, const float x[3],
 | 
					void BPH_hair_volume_grid_interpolate(
 | 
				
			||||||
 | 
					        HairGrid *grid, const float x[3],
 | 
				
			||||||
        float *density, float velocity[3], float velocity_smooth[3], float density_gradient[3], float velocity_gradient[3][3])
 | 
					        float *density, float velocity[3], float velocity_smooth[3], float density_gradient[3], float velocity_gradient[3][3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	hair_grid_interpolate(grid->verts, grid->res, grid->gmin, grid->inv_cellsize, x, density, velocity, velocity_smooth, density_gradient, velocity_gradient);
 | 
						hair_grid_interpolate(grid->verts, grid->res, grid->gmin, grid->inv_cellsize, x, density, velocity, velocity_smooth, density_gradient, velocity_gradient);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BPH_hair_volume_grid_velocity(HairGrid *grid, const float x[3], const float v[3],
 | 
					void BPH_hair_volume_grid_velocity(
 | 
				
			||||||
 | 
					        HairGrid *grid, const float x[3], const float v[3],
 | 
				
			||||||
        float fluid_factor,
 | 
					        float fluid_factor,
 | 
				
			||||||
        float r_v[3])
 | 
					        float r_v[3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -287,20 +291,20 @@ BLI_INLINE int hair_grid_weights(const int res[3], const float gmin[3], float sc
 | 
				
			|||||||
	i = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 0);
 | 
						i = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 0);
 | 
				
			||||||
	j = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 1);
 | 
						j = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 1);
 | 
				
			||||||
	k = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 2);
 | 
						k = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 2);
 | 
				
			||||||
	offset = i + (j + k*res[1])*res[0];
 | 
						offset = i + (j + k * res[1]) * res[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uvw[0] = (vec[0] - gmin[0]) * scale;
 | 
						uvw[0] = (vec[0] - gmin[0]) * scale;
 | 
				
			||||||
	uvw[1] = (vec[1] - gmin[1]) * scale;
 | 
						uvw[1] = (vec[1] - gmin[1]) * scale;
 | 
				
			||||||
	uvw[2] = (vec[2] - gmin[2]) * scale;
 | 
						uvw[2] = (vec[2] - gmin[2]) * scale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	weights[0] = dist_tent_v3f3(uvw, (float)i      , (float)j      , (float)k      );
 | 
						weights[0] = dist_tent_v3f3(uvw, (float)i      , (float)j      , (float)k      );
 | 
				
			||||||
	weights[1] = dist_tent_v3f3(uvw, (float)(i+1), (float)j    , (float)k    );
 | 
						weights[1] = dist_tent_v3f3(uvw, (float)(i + 1), (float)j      , (float)k      );
 | 
				
			||||||
	weights[2] = dist_tent_v3f3(uvw, (float)i    , (float)(j+1), (float)k    );
 | 
						weights[2] = dist_tent_v3f3(uvw, (float)i      , (float)(j + 1), (float)k      );
 | 
				
			||||||
	weights[3] = dist_tent_v3f3(uvw, (float)(i+1), (float)(j+1), (float)k    );
 | 
						weights[3] = dist_tent_v3f3(uvw, (float)(i + 1), (float)(j + 1), (float)k      );
 | 
				
			||||||
	weights[4] = dist_tent_v3f3(uvw, (float)i    , (float)j    , (float)(k+1));
 | 
						weights[4] = dist_tent_v3f3(uvw, (float)i      , (float)j      , (float)(k + 1));
 | 
				
			||||||
	weights[5] = dist_tent_v3f3(uvw, (float)(i+1), (float)j    , (float)(k+1));
 | 
						weights[5] = dist_tent_v3f3(uvw, (float)(i + 1), (float)j      , (float)(k + 1));
 | 
				
			||||||
	weights[6] = dist_tent_v3f3(uvw, (float)i    , (float)(j+1), (float)(k+1));
 | 
						weights[6] = dist_tent_v3f3(uvw, (float)i      , (float)(j + 1), (float)(k + 1));
 | 
				
			||||||
	weights[7] = dist_tent_v3f3(uvw, (float)(i+1), (float)(j+1), (float)(k+1));
 | 
						weights[7] = dist_tent_v3f3(uvw, (float)(i + 1), (float)(j + 1), (float)(k + 1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//	BLI_assert(fabsf(weights_sum(weights) - 1.0f) < 0.0001f);
 | 
					//	BLI_assert(fabsf(weights_sum(weights) - 1.0f) < 0.0001f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -329,8 +333,8 @@ void BPH_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[
 | 
				
			|||||||
	for (di = 0; di < 2; ++di) {
 | 
						for (di = 0; di < 2; ++di) {
 | 
				
			||||||
		for (dj = 0; dj < 2; ++dj) {
 | 
							for (dj = 0; dj < 2; ++dj) {
 | 
				
			||||||
			for (dk = 0; dk < 2; ++dk) {
 | 
								for (dk = 0; dk < 2; ++dk) {
 | 
				
			||||||
				int voffset = offset + di + (dj + dk*res[1])*res[0];
 | 
									int voffset = offset + di + (dj + dk * res[1]) * res[0];
 | 
				
			||||||
				int iw = di + dj*2 + dk*4;
 | 
									int iw = di + dj * 2 + dk * 4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				grid->verts[voffset].density += weights[iw];
 | 
									grid->verts[voffset].density += weights[iw];
 | 
				
			||||||
				madd_v3_v3fl(grid->verts[voffset].velocity, v, weights[iw]);
 | 
									madd_v3_v3fl(grid->verts[voffset].velocity, v, weights[iw]);
 | 
				
			||||||
@@ -340,7 +344,8 @@ void BPH_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
BLI_INLINE void hair_volume_eval_grid_vertex(HairGridVert *vert, const float loc[3], float radius, float dist_scale,
 | 
					BLI_INLINE void hair_volume_eval_grid_vertex(
 | 
				
			||||||
 | 
					        HairGridVert *vert, const float loc[3], float radius, float dist_scale,
 | 
				
			||||||
        const float x2[3], const float v2[3], const float x3[3], const float v3[3])
 | 
					        const float x2[3], const float v2[3], const float x3[3], const float v3[3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	float closest[3], lambda, dist, weight;
 | 
						float closest[3], lambda, dist, weight;
 | 
				
			||||||
@@ -368,7 +373,8 @@ BLI_INLINE int major_axis_v3(const float v[3])
 | 
				
			|||||||
	return a > b ? (a > c ? 0 : 2) : (b > c ? 1 : 2);
 | 
						return a > b ? (a > c ? 0 : 2) : (b > c ? 1 : 2);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
 | 
					BLI_INLINE void hair_volume_add_segment_2D(
 | 
				
			||||||
 | 
					        HairGrid *grid,
 | 
				
			||||||
        const float UNUSED(x1[3]), const float UNUSED(v1[3]), const float x2[3], const float v2[3],
 | 
					        const float UNUSED(x1[3]), const float UNUSED(v1[3]), const float x2[3], const float v2[3],
 | 
				
			||||||
        const float x3[3], const float v3[3], const float UNUSED(x4[3]), const float UNUSED(v4[3]),
 | 
					        const float x3[3], const float v3[3], const float UNUSED(x4[3]), const float UNUSED(v4[3]),
 | 
				
			||||||
        const float UNUSED(dir1[3]), const float dir2[3], const float UNUSED(dir3[3]),
 | 
					        const float UNUSED(dir1[3]), const float dir2[3], const float UNUSED(dir3[3]),
 | 
				
			||||||
@@ -383,9 +389,9 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/* boundary checks to be safe */
 | 
						/* boundary checks to be safe */
 | 
				
			||||||
	CLAMP_MIN(jmin, 0);
 | 
						CLAMP_MIN(jmin, 0);
 | 
				
			||||||
	CLAMP_MAX(jmax, resj-1);
 | 
						CLAMP_MAX(jmax, resj - 1);
 | 
				
			||||||
	CLAMP_MIN(kmin, 0);
 | 
						CLAMP_MIN(kmin, 0);
 | 
				
			||||||
	CLAMP_MAX(kmax, resk-1);
 | 
						CLAMP_MAX(kmax, resk - 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	HairGridVert *vert_j = vert + jmin * stride_j;
 | 
						HairGridVert *vert_j = vert + jmin * stride_j;
 | 
				
			||||||
	float loc_j[3] = { loc[0], loc[1], loc[2] };
 | 
						float loc_j[3] = { loc[0], loc[1], loc[2] };
 | 
				
			||||||
@@ -429,7 +435,8 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void BPH_hair_volume_add_segment(HairGrid *grid,
 | 
					void BPH_hair_volume_add_segment(
 | 
				
			||||||
 | 
					        HairGrid *grid,
 | 
				
			||||||
        const float x1[3], const float v1[3], const float x2[3], const float v2[3],
 | 
					        const float x1[3], const float v1[3], const float x2[3], const float v2[3],
 | 
				
			||||||
        const float x3[3], const float v3[3], const float x4[3], const float v4[3],
 | 
					        const float x3[3], const float v3[3], const float x4[3], const float v4[3],
 | 
				
			||||||
        const float dir1[3], const float dir2[3], const float dir3[3])
 | 
					        const float dir1[3], const float dir2[3], const float dir3[3])
 | 
				
			||||||
@@ -461,7 +468,7 @@ void BPH_hair_volume_add_segment(HairGrid *grid,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/* range along primary direction */
 | 
						/* range along primary direction */
 | 
				
			||||||
	const int imin = max_ii(floor_int(start[axis0]) - 1, 0);
 | 
						const int imin = max_ii(floor_int(start[axis0]) - 1, 0);
 | 
				
			||||||
	const int imax = min_ii(floor_int(end[axis0]) + 2, res[axis0]-1);
 | 
						const int imax = min_ii(floor_int(end[axis0]) + 2, res[axis0] - 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	float h = 0.0f;
 | 
						float h = 0.0f;
 | 
				
			||||||
	HairGridVert *vert0;
 | 
						HairGridVert *vert0;
 | 
				
			||||||
@@ -500,14 +507,16 @@ void BPH_hair_volume_add_segment(HairGrid *grid,
 | 
				
			|||||||
		loc0[axis1] = 0.0f;
 | 
							loc0[axis1] = 0.0f;
 | 
				
			||||||
		loc0[axis2] = 0.0f;
 | 
							loc0[axis2] = 0.0f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		hair_volume_add_segment_2D(grid, x1, v1, x2, v2, x3, v3, x4, v4, dir1, dir2, dir3,
 | 
							hair_volume_add_segment_2D(
 | 
				
			||||||
		                           res[axis1], res[axis2], jmin-1, jmax+2, kmin-1, kmax+2,
 | 
							        grid, x1, v1, x2, v2, x3, v3, x4, v4, dir1, dir2, dir3,
 | 
				
			||||||
 | 
							        res[axis1], res[axis2], jmin - 1, jmax + 2, kmin - 1, kmax + 2,
 | 
				
			||||||
		        vert0, stride1, stride2, loc0, axis1, axis2,
 | 
							        vert0, stride1, stride2, loc0, axis1, axis2,
 | 
				
			||||||
		        i);
 | 
							        i);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
BLI_INLINE void hair_volume_eval_grid_vertex_sample(HairGridVert *vert, const float loc[3], float radius, float dist_scale,
 | 
					BLI_INLINE void hair_volume_eval_grid_vertex_sample(
 | 
				
			||||||
 | 
					        HairGridVert *vert, const float loc[3], float radius, float dist_scale,
 | 
				
			||||||
        const float x[3], const float v[3])
 | 
					        const float x[3], const float v[3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	float dist, weight;
 | 
						float dist, weight;
 | 
				
			||||||
@@ -526,7 +535,8 @@ BLI_INLINE void hair_volume_eval_grid_vertex_sample(HairGridVert *vert, const fl
 | 
				
			|||||||
/* XXX simplified test implementation using a series of discrete sample along the segment,
 | 
					/* XXX simplified test implementation using a series of discrete sample along the segment,
 | 
				
			||||||
 * instead of finding the closest point for all affected grid vertices.
 | 
					 * instead of finding the closest point for all affected grid vertices.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void BPH_hair_volume_add_segment(HairGrid *grid,
 | 
					void BPH_hair_volume_add_segment(
 | 
				
			||||||
 | 
					        HairGrid *grid,
 | 
				
			||||||
        const float UNUSED(x1[3]), const float UNUSED(v1[3]), const float x2[3], const float v2[3],
 | 
					        const float UNUSED(x1[3]), const float UNUSED(v1[3]), const float x2[3], const float v2[3],
 | 
				
			||||||
        const float x3[3], const float v3[3], const float UNUSED(x4[3]), const float UNUSED(v4[3]),
 | 
					        const float x3[3], const float v3[3], const float UNUSED(x4[3]), const float UNUSED(v4[3]),
 | 
				
			||||||
        const float UNUSED(dir1[3]), const float UNUSED(dir2[3]), const float UNUSED(dir3[3]))
 | 
					        const float UNUSED(dir1[3]), const float UNUSED(dir2[3]), const float UNUSED(dir3[3]))
 | 
				
			||||||
@@ -544,16 +554,16 @@ void BPH_hair_volume_add_segment(HairGrid *grid,
 | 
				
			|||||||
		float x[3], v[3];
 | 
							float x[3], v[3];
 | 
				
			||||||
		int i, j, k;
 | 
							int i, j, k;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		float f = (float)s / (float)(num_samples-1);
 | 
							float f = (float)s / (float)(num_samples - 1);
 | 
				
			||||||
		interp_v3_v3v3(x, x2, x3, f);
 | 
							interp_v3_v3v3(x, x2, x3, f);
 | 
				
			||||||
		interp_v3_v3v3(v, v2, v3, f);
 | 
							interp_v3_v3v3(v, v2, v3, f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		int imin = max_ii(floor_int(x[0]) - 2, 0);
 | 
							int imin = max_ii(floor_int(x[0]) - 2, 0);
 | 
				
			||||||
		int imax = min_ii(floor_int(x[0]) + 2, res[0]-1);
 | 
							int imax = min_ii(floor_int(x[0]) + 2, res[0] - 1);
 | 
				
			||||||
		int jmin = max_ii(floor_int(x[1]) - 2, 0);
 | 
							int jmin = max_ii(floor_int(x[1]) - 2, 0);
 | 
				
			||||||
		int jmax = min_ii(floor_int(x[1]) + 2, res[1]-1);
 | 
							int jmax = min_ii(floor_int(x[1]) + 2, res[1] - 1);
 | 
				
			||||||
		int kmin = max_ii(floor_int(x[2]) - 2, 0);
 | 
							int kmin = max_ii(floor_int(x[2]) - 2, 0);
 | 
				
			||||||
		int kmax = min_ii(floor_int(x[2]) + 2, res[2]-1);
 | 
							int kmax = min_ii(floor_int(x[2]) + 2, res[2] - 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (k = kmin; k <= kmax; ++k) {
 | 
							for (k = kmin; k <= kmax; ++k) {
 | 
				
			||||||
			for (j = jmin; j <= jmax; ++j) {
 | 
								for (j = jmin; j <= jmax; ++j) {
 | 
				
			||||||
@@ -576,7 +586,7 @@ void BPH_hair_volume_normalize_vertex_grid(HairGrid *grid)
 | 
				
			|||||||
	for (i = 0; i < size; i++) {
 | 
						for (i = 0; i < size; i++) {
 | 
				
			||||||
		float density = grid->verts[i].density;
 | 
							float density = grid->verts[i].density;
 | 
				
			||||||
		if (density > 0.0f)
 | 
							if (density > 0.0f)
 | 
				
			||||||
			mul_v3_fl(grid->verts[i].velocity, 1.0f/density);
 | 
								mul_v3_fl(grid->verts[i].velocity, 1.0f / density);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -620,16 +630,16 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
 | 
				
			|||||||
#define MARGIN_i0 (i < 1)
 | 
					#define MARGIN_i0 (i < 1)
 | 
				
			||||||
#define MARGIN_j0 (j < 1)
 | 
					#define MARGIN_j0 (j < 1)
 | 
				
			||||||
#define MARGIN_k0 (k < 1)
 | 
					#define MARGIN_k0 (k < 1)
 | 
				
			||||||
#define MARGIN_i1 (i >= resA[0]-1)
 | 
					#define MARGIN_i1 (i >= resA[0] - 1)
 | 
				
			||||||
#define MARGIN_j1 (j >= resA[1]-1)
 | 
					#define MARGIN_j1 (j >= resA[1] - 1)
 | 
				
			||||||
#define MARGIN_k1 (k >= resA[2]-1)
 | 
					#define MARGIN_k1 (k >= resA[2] - 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define NEIGHBOR_MARGIN_i0 (i < 2)
 | 
					#define NEIGHBOR_MARGIN_i0 (i < 2)
 | 
				
			||||||
#define NEIGHBOR_MARGIN_j0 (j < 2)
 | 
					#define NEIGHBOR_MARGIN_j0 (j < 2)
 | 
				
			||||||
#define NEIGHBOR_MARGIN_k0 (k < 2)
 | 
					#define NEIGHBOR_MARGIN_k0 (k < 2)
 | 
				
			||||||
#define NEIGHBOR_MARGIN_i1 (i >= resA[0]-2)
 | 
					#define NEIGHBOR_MARGIN_i1 (i >= resA[0] - 2)
 | 
				
			||||||
#define NEIGHBOR_MARGIN_j1 (j >= resA[1]-2)
 | 
					#define NEIGHBOR_MARGIN_j1 (j >= resA[1] - 2)
 | 
				
			||||||
#define NEIGHBOR_MARGIN_k1 (k >= resA[2]-2)
 | 
					#define NEIGHBOR_MARGIN_k1 (k >= resA[2] - 2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	BLI_assert(num_cells >= 1);
 | 
						BLI_assert(num_cells >= 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -895,18 +905,18 @@ BLI_INLINE void hair_volume_filter_box_convolute(HairVertexGrid *grid, float inv
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	int res = grid->res;
 | 
						int res = grid->res;
 | 
				
			||||||
	int p, q, r;
 | 
						int p, q, r;
 | 
				
			||||||
	int minp = max_ii(i - kernel_size[0], 0), maxp = min_ii(i + kernel_size[0], res-1);
 | 
						int minp = max_ii(i - kernel_size[0], 0), maxp = min_ii(i + kernel_size[0], res - 1);
 | 
				
			||||||
	int minq = max_ii(j - kernel_size[1], 0), maxq = min_ii(j + kernel_size[1], res-1);
 | 
						int minq = max_ii(j - kernel_size[1], 0), maxq = min_ii(j + kernel_size[1], res - 1);
 | 
				
			||||||
	int minr = max_ii(k - kernel_size[2], 0), maxr = min_ii(k + kernel_size[2], res-1);
 | 
						int minr = max_ii(k - kernel_size[2], 0), maxr = min_ii(k + kernel_size[2], res - 1);
 | 
				
			||||||
	int offset, kernel_offset, kernel_dq, kernel_dr;
 | 
						int offset, kernel_offset, kernel_dq, kernel_dr;
 | 
				
			||||||
	HairGridVert *verts;
 | 
						HairGridVert *verts;
 | 
				
			||||||
	float *vel_smooth;
 | 
						float *vel_smooth;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	offset = i + (j + k*res)*res;
 | 
						offset = i + (j + k * res) * res;
 | 
				
			||||||
	verts = grid->verts;
 | 
						verts = grid->verts;
 | 
				
			||||||
	vel_smooth = verts[offset].velocity_smooth;
 | 
						vel_smooth = verts[offset].velocity_smooth;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kernel_offset = minp + (minq + minr*res)*res;
 | 
						kernel_offset = minp + (minq + minr * res) * res;
 | 
				
			||||||
	kernel_dq = res;
 | 
						kernel_dq = res;
 | 
				
			||||||
	kernel_dr = res * res;
 | 
						kernel_dr = res * res;
 | 
				
			||||||
	for (r = minr; r <= maxr; ++r) {
 | 
						for (r = minr; r <= maxr; ++r) {
 | 
				
			||||||
@@ -935,7 +945,7 @@ void BPH_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid, int kernel_siz
 | 
				
			|||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tot = kernel_size * 2 + 1;
 | 
						tot = kernel_size * 2 + 1;
 | 
				
			||||||
	invD = 1.0f / (float)(tot*tot*tot);
 | 
						invD = 1.0f / (float)(tot * tot * tot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* clear values for convolution */
 | 
						/* clear values for convolution */
 | 
				
			||||||
	for (i = 0; i < size; ++i) {
 | 
						for (i = 0; i < size; ++i) {
 | 
				
			||||||
@@ -1063,7 +1073,7 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
 | 
				
			|||||||
			float weights[8];
 | 
								float weights[8];
 | 
				
			||||||
			int di, dj, dk;
 | 
								int di, dj, dk;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			for (v=0; v < col->collmd->numverts; v++, loc0++, loc1++) {
 | 
								for (v = 0; v < col->collmd->numverts; v++, loc0++, loc1++) {
 | 
				
			||||||
				int offset;
 | 
									int offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (!hair_grid_point_valid(loc1->co, gmin, gmax))
 | 
									if (!hair_grid_point_valid(loc1->co, gmin, gmax))
 | 
				
			||||||
@@ -1076,8 +1086,8 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
 | 
				
			|||||||
				for (di = 0; di < 2; ++di) {
 | 
									for (di = 0; di < 2; ++di) {
 | 
				
			||||||
					for (dj = 0; dj < 2; ++dj) {
 | 
										for (dj = 0; dj < 2; ++dj) {
 | 
				
			||||||
						for (dk = 0; dk < 2; ++dk) {
 | 
											for (dk = 0; dk < 2; ++dk) {
 | 
				
			||||||
							int voffset = offset + di + (dj + dk*res)*res;
 | 
												int voffset = offset + di + (dj + dk * res) * res;
 | 
				
			||||||
							int iw = di + dj*2 + dk*4;
 | 
												int iw = di + dj * 2 + dk * 4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							collgrid[voffset].density += weights[iw];
 | 
												collgrid[voffset].density += weights[iw];
 | 
				
			||||||
							madd_v3_v3fl(collgrid[voffset].velocity, vel, weights[iw]);
 | 
												madd_v3_v3fl(collgrid[voffset].velocity, vel, weights[iw]);
 | 
				
			||||||
@@ -1093,7 +1103,7 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
 | 
				
			|||||||
	for (i = 0; i < size; i++) {
 | 
						for (i = 0; i < size; i++) {
 | 
				
			||||||
		float density = collgrid[i].density;
 | 
							float density = collgrid[i].density;
 | 
				
			||||||
		if (density > 0.0f)
 | 
							if (density > 0.0f)
 | 
				
			||||||
			mul_v3_fl(collgrid[i].velocity, 1.0f/density);
 | 
								mul_v3_fl(collgrid[i].velocity, 1.0f / density);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return collgrid;
 | 
						return collgrid;
 | 
				
			||||||
@@ -1134,10 +1144,10 @@ bool BPH_hair_volume_get_texture_data(HairGrid *grid, VoxelData *vd)
 | 
				
			|||||||
					break;
 | 
										break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				case TEX_VD_HAIRVELOCITY: {
 | 
									case TEX_VD_HAIRVELOCITY: {
 | 
				
			||||||
					vd->dataset[i + 0*totres] = grid->verts[i].velocity[0];
 | 
										vd->dataset[i + 0 * totres] = grid->verts[i].velocity[0];
 | 
				
			||||||
					vd->dataset[i + 1*totres] = grid->verts[i].velocity[1];
 | 
										vd->dataset[i + 1 * totres] = grid->verts[i].velocity[1];
 | 
				
			||||||
					vd->dataset[i + 2*totres] = grid->verts[i].velocity[2];
 | 
										vd->dataset[i + 2 * totres] = grid->verts[i].velocity[2];
 | 
				
			||||||
					vd->dataset[i + 3*totres] = len_v3(grid->verts[i].velocity);
 | 
										vd->dataset[i + 3 * totres] = len_v3(grid->verts[i].velocity);
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				case TEX_VD_HAIRENERGY:
 | 
									case TEX_VD_HAIRENERGY:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -107,11 +107,11 @@ void BPH_mass_spring_force_drag(struct Implicit_Data *data, float drag);
 | 
				
			|||||||
/* Custom external force */
 | 
					/* Custom external force */
 | 
				
			||||||
void BPH_mass_spring_force_extern(struct Implicit_Data *data, int i, const float f[3], float dfdx[3][3], float dfdv[3][3]);
 | 
					void BPH_mass_spring_force_extern(struct Implicit_Data *data, int i, const float f[3], float dfdx[3][3], float dfdv[3][3]);
 | 
				
			||||||
/* Wind force, acting on a face */
 | 
					/* Wind force, acting on a face */
 | 
				
			||||||
void BPH_mass_spring_force_face_wind(struct Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3]);
 | 
					void BPH_mass_spring_force_face_wind(struct Implicit_Data *data, int v1, int v2, int v3, const float(*winvec)[3]);
 | 
				
			||||||
/* Wind force, acting on an edge */
 | 
					/* Wind force, acting on an edge */
 | 
				
			||||||
void BPH_mass_spring_force_edge_wind(struct Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float (*winvec)[3]);
 | 
					void BPH_mass_spring_force_edge_wind(struct Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float(*winvec)[3]);
 | 
				
			||||||
/* Wind force, acting on a vertex */
 | 
					/* Wind force, acting on a vertex */
 | 
				
			||||||
void BPH_mass_spring_force_vertex_wind(struct Implicit_Data *data, int v, float radius, const float (*winvec)[3]);
 | 
					void BPH_mass_spring_force_vertex_wind(struct Implicit_Data *data, int v, float radius, const float(*winvec)[3]);
 | 
				
			||||||
/* Linear spring force between two points */
 | 
					/* Linear spring force between two points */
 | 
				
			||||||
bool BPH_mass_spring_force_spring_linear(struct Implicit_Data *data, int i, int j, float restlen,
 | 
					bool BPH_mass_spring_force_spring_linear(struct Implicit_Data *data, int i, int j, float restlen,
 | 
				
			||||||
                                         float stiffness, float damping, bool no_compress, float clamp_force);
 | 
					                                         float stiffness, float damping, bool no_compress, float clamp_force);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -135,7 +135,7 @@ static void print_fvector(float m3[3])
 | 
				
			|||||||
// long float vector float (*)[3]
 | 
					// long float vector float (*)[3]
 | 
				
			||||||
///////////////////////////
 | 
					///////////////////////////
 | 
				
			||||||
/* print long vector on console: for debug output */
 | 
					/* print long vector on console: for debug output */
 | 
				
			||||||
DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts)
 | 
					DO_INLINE void print_lfvector(float(*fLongVector)[3], unsigned int verts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i = 0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
	for (i = 0; i < verts; i++) {
 | 
						for (i = 0; i < verts; i++) {
 | 
				
			||||||
@@ -152,7 +152,7 @@ DO_INLINE lfVector *create_lfvector(unsigned int verts)
 | 
				
			|||||||
	// return (lfVector *)cloth_aligned_malloc(&MEMORY_BASE, verts * sizeof(lfVector));
 | 
						// return (lfVector *)cloth_aligned_malloc(&MEMORY_BASE, verts * sizeof(lfVector));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* delete long vector */
 | 
					/* delete long vector */
 | 
				
			||||||
DO_INLINE void del_lfvector(float (*fLongVector)[3])
 | 
					DO_INLINE void del_lfvector(float(*fLongVector)[3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (fLongVector != NULL) {
 | 
						if (fLongVector != NULL) {
 | 
				
			||||||
		MEM_freeN(fLongVector);
 | 
							MEM_freeN(fLongVector);
 | 
				
			||||||
@@ -160,12 +160,12 @@ DO_INLINE void del_lfvector(float (*fLongVector)[3])
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* copy long vector */
 | 
					/* copy long vector */
 | 
				
			||||||
DO_INLINE void cp_lfvector(float (*to)[3], float (*from)[3], unsigned int verts)
 | 
					DO_INLINE void cp_lfvector(float(*to)[3], float(*from)[3], unsigned int verts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	memcpy(to, from, verts * sizeof(lfVector));
 | 
						memcpy(to, from, verts * sizeof(lfVector));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* init long vector with float[3] */
 | 
					/* init long vector with float[3] */
 | 
				
			||||||
DO_INLINE void init_lfvector(float (*fLongVector)[3], float vector[3], unsigned int verts)
 | 
					DO_INLINE void init_lfvector(float(*fLongVector)[3], float vector[3], unsigned int verts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i = 0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
	for (i = 0; i < verts; i++) {
 | 
						for (i = 0; i < verts; i++) {
 | 
				
			||||||
@@ -173,12 +173,12 @@ DO_INLINE void init_lfvector(float (*fLongVector)[3], float vector[3], unsigned
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* zero long vector with float[3] */
 | 
					/* zero long vector with float[3] */
 | 
				
			||||||
DO_INLINE void zero_lfvector(float (*to)[3], unsigned int verts)
 | 
					DO_INLINE void zero_lfvector(float(*to)[3], unsigned int verts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	memset(to, 0.0f, verts * sizeof(lfVector));
 | 
						memset(to, 0.0f, verts * sizeof(lfVector));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* multiply long vector with scalar*/
 | 
					/* multiply long vector with scalar*/
 | 
				
			||||||
DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scalar, unsigned int verts)
 | 
					DO_INLINE void mul_lfvectorS(float(*to)[3], float(*fLongVector)[3], float scalar, unsigned int verts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i = 0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -188,7 +188,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scal
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
/* multiply long vector with scalar*/
 | 
					/* multiply long vector with scalar*/
 | 
				
			||||||
/* A -= B * float */
 | 
					/* A -= B * float */
 | 
				
			||||||
DO_INLINE void submul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scalar, unsigned int verts)
 | 
					DO_INLINE void submul_lfvectorS(float(*to)[3], float(*fLongVector)[3], float scalar, unsigned int verts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i = 0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
	for (i = 0; i < verts; i++) {
 | 
						for (i = 0; i < verts; i++) {
 | 
				
			||||||
@@ -196,7 +196,7 @@ DO_INLINE void submul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float s
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* dot product for big vector */
 | 
					/* dot product for big vector */
 | 
				
			||||||
DO_INLINE float dot_lfvector(float (*fLongVectorA)[3], float (*fLongVectorB)[3], unsigned int verts)
 | 
					DO_INLINE float dot_lfvector(float(*fLongVectorA)[3], float(*fLongVectorB)[3], unsigned int verts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	long i = 0;
 | 
						long i = 0;
 | 
				
			||||||
	float temp = 0.0;
 | 
						float temp = 0.0;
 | 
				
			||||||
@@ -211,7 +211,7 @@ DO_INLINE float dot_lfvector(float (*fLongVectorA)[3], float (*fLongVectorB)[3],
 | 
				
			|||||||
	return temp;
 | 
						return temp;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* A = B + C  --> for big vector */
 | 
					/* A = B + C  --> for big vector */
 | 
				
			||||||
DO_INLINE void add_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], unsigned int verts)
 | 
					DO_INLINE void add_lfvector_lfvector(float(*to)[3], float(*fLongVectorA)[3], float(*fLongVectorB)[3], unsigned int verts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i = 0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -221,7 +221,7 @@ DO_INLINE void add_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* A = B + C * float --> for big vector */
 | 
					/* A = B + C * float --> for big vector */
 | 
				
			||||||
DO_INLINE void add_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], float bS, unsigned int verts)
 | 
					DO_INLINE void add_lfvector_lfvectorS(float(*to)[3], float(*fLongVectorA)[3], float(*fLongVectorB)[3], float bS, unsigned int verts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i = 0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -231,7 +231,7 @@ DO_INLINE void add_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* A = B * float + C * float --> for big vector */
 | 
					/* A = B * float + C * float --> for big vector */
 | 
				
			||||||
DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], float aS, float (*fLongVectorB)[3], float bS, unsigned int verts)
 | 
					DO_INLINE void add_lfvectorS_lfvectorS(float(*to)[3], float(*fLongVectorA)[3], float aS, float(*fLongVectorB)[3], float bS, unsigned int verts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i = 0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -240,7 +240,7 @@ DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* A = B - C * float --> for big vector */
 | 
					/* A = B - C * float --> for big vector */
 | 
				
			||||||
DO_INLINE void sub_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], float bS, unsigned int verts)
 | 
					DO_INLINE void sub_lfvector_lfvectorS(float(*to)[3], float(*fLongVectorA)[3], float(*fLongVectorB)[3], float bS, unsigned int verts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i = 0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
	for (i = 0; i < verts; i++) {
 | 
						for (i = 0; i < verts; i++) {
 | 
				
			||||||
@@ -249,7 +249,7 @@ DO_INLINE void sub_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* A = B - C --> for big vector */
 | 
					/* A = B - C --> for big vector */
 | 
				
			||||||
DO_INLINE void sub_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], unsigned int verts)
 | 
					DO_INLINE void sub_lfvector_lfvector(float(*to)[3], float(*fLongVectorA)[3], float(*fLongVectorB)[3], unsigned int verts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i = 0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -302,7 +302,7 @@ static void print_bfmatrix(fmatrix3x3 *m)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	int tot = m[0].vcount + m[0].scount;
 | 
						int tot = m[0].vcount + m[0].scount;
 | 
				
			||||||
	int size = m[0].vcount * 3;
 | 
						int size = m[0].vcount * 3;
 | 
				
			||||||
	float *t = MEM_callocN(sizeof(float) * size*size, "bfmatrix");
 | 
						float *t = MEM_callocN(sizeof(float) * size * size, "bfmatrix");
 | 
				
			||||||
	int q, i, j;
 | 
						int q, i, j;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (q = 0; q < tot; ++q) {
 | 
						for (q = 0; q < tot; ++q) {
 | 
				
			||||||
@@ -365,8 +365,8 @@ DO_INLINE void initdiag_fmatrixS(float to[3][3], float aS)
 | 
				
			|||||||
/* calculate determinant of 3x3 matrix */
 | 
					/* calculate determinant of 3x3 matrix */
 | 
				
			||||||
DO_INLINE float det_fmatrix(float m[3][3])
 | 
					DO_INLINE float det_fmatrix(float m[3][3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return  m[0][0]*m[1][1]*m[2][2] + m[1][0]*m[2][1]*m[0][2] + m[0][1]*m[1][2]*m[2][0] -
 | 
						return m[0][0] * m[1][1] * m[2][2] + m[1][0] * m[2][1] * m[0][2] + m[0][1] * m[1][2] * m[2][0] -
 | 
				
			||||||
	        m[0][0]*m[1][2]*m[2][1] - m[0][1]*m[1][0]*m[2][2] - m[2][0]*m[1][1]*m[0][2];
 | 
						       m[0][0] * m[1][2] * m[2][1] - m[0][1] * m[1][0] * m[2][2] - m[2][0] * m[1][1] * m[0][2];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3])
 | 
					DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3])
 | 
				
			||||||
@@ -374,18 +374,18 @@ DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3])
 | 
				
			|||||||
	unsigned int i, j;
 | 
						unsigned int i, j;
 | 
				
			||||||
	float d;
 | 
						float d;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((d=det_fmatrix(from)) == 0) {
 | 
						if ((d = det_fmatrix(from)) == 0) {
 | 
				
			||||||
		printf("can't build inverse");
 | 
							printf("can't build inverse");
 | 
				
			||||||
		exit(0);
 | 
							exit(0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for (i=0;i<3;i++) {
 | 
						for (i = 0; i < 3; i++) {
 | 
				
			||||||
		for (j=0;j<3;j++) {
 | 
							for (j = 0; j < 3; j++) {
 | 
				
			||||||
			int i1=(i+1)%3;
 | 
								int i1 = (i + 1) % 3;
 | 
				
			||||||
			int i2=(i+2)%3;
 | 
								int i2 = (i + 2) % 3;
 | 
				
			||||||
			int j1=(j+1)%3;
 | 
								int j1 = (j + 1) % 3;
 | 
				
			||||||
			int j2=(j+2)%3;
 | 
								int j2 = (j + 2) % 3;
 | 
				
			||||||
			/** Reverse indexes i&j to take transpose. */
 | 
								/** Reverse indexes i&j to take transpose. */
 | 
				
			||||||
			to[j][i] = (from[i1][j1]*from[i2][j2]-from[i1][j2]*from[i2][j1])/d;
 | 
								to[j][i] = (from[i1][j1] * from[i2][j2] - from[i1][j2] * from[i2][j1]) / d;
 | 
				
			||||||
			/**
 | 
								/**
 | 
				
			||||||
			 * <pre>
 | 
								 * <pre>
 | 
				
			||||||
			 * if (i == j) {
 | 
								 * if (i == j) {
 | 
				
			||||||
@@ -415,9 +415,9 @@ DO_INLINE void mul_fmatrix_S(float matrix[3][3], float scalar)
 | 
				
			|||||||
/* STATUS: verified */
 | 
					/* STATUS: verified */
 | 
				
			||||||
DO_INLINE void mul_fvector_fmatrix(float *to, float *from, float matrix[3][3])
 | 
					DO_INLINE void mul_fvector_fmatrix(float *to, float *from, float matrix[3][3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	to[0] = matrix[0][0]*from[0] + matrix[1][0]*from[1] + matrix[2][0]*from[2];
 | 
						to[0] = matrix[0][0] * from[0] + matrix[1][0] * from[1] + matrix[2][0] * from[2];
 | 
				
			||||||
	to[1] = matrix[0][1]*from[0] + matrix[1][1]*from[1] + matrix[2][1]*from[2];
 | 
						to[1] = matrix[0][1] * from[0] + matrix[1][1] * from[1] + matrix[2][1] * from[2];
 | 
				
			||||||
	to[2] = matrix[0][2]*from[0] + matrix[1][2]*from[1] + matrix[2][2]*from[2];
 | 
						to[2] = matrix[0][2] * from[0] + matrix[1][2] * from[1] + matrix[2][2] * from[2];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* 3x3 matrix multiplied by a vector */
 | 
					/* 3x3 matrix multiplied by a vector */
 | 
				
			||||||
@@ -560,7 +560,7 @@ DO_INLINE void del_bfmatrix(fmatrix3x3 *matrix)
 | 
				
			|||||||
DO_INLINE void cp_bfmatrix(fmatrix3x3 *to, fmatrix3x3 *from)
 | 
					DO_INLINE void cp_bfmatrix(fmatrix3x3 *to, fmatrix3x3 *from)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// TODO bounds checking
 | 
						// TODO bounds checking
 | 
				
			||||||
	memcpy(to, from, sizeof(fmatrix3x3) * (from[0].vcount+from[0].scount));
 | 
						memcpy(to, from, sizeof(fmatrix3x3) * (from[0].vcount + from[0].scount));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* init big matrix */
 | 
					/* init big matrix */
 | 
				
			||||||
@@ -569,7 +569,7 @@ DO_INLINE void init_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i;
 | 
						unsigned int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
 | 
						for (i = 0; i < matrix[0].vcount + matrix[0].scount; i++) {
 | 
				
			||||||
		cp_fmatrix(matrix[i].m, m3);
 | 
							cp_fmatrix(matrix[i].m, m3);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -584,14 +584,14 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
 | 
				
			|||||||
	for (i = 0; i < matrix[0].vcount; i++) {
 | 
						for (i = 0; i < matrix[0].vcount; i++) {
 | 
				
			||||||
		cp_fmatrix(matrix[i].m, m3);
 | 
							cp_fmatrix(matrix[i].m, m3);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for (j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++) {
 | 
						for (j = matrix[0].vcount; j < matrix[0].vcount + matrix[0].scount; j++) {
 | 
				
			||||||
		cp_fmatrix(matrix[j].m, tmatrix);
 | 
							cp_fmatrix(matrix[j].m, tmatrix);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* SPARSE SYMMETRIC multiply big matrix with long vector*/
 | 
					/* SPARSE SYMMETRIC multiply big matrix with long vector*/
 | 
				
			||||||
/* STATUS: verified */
 | 
					/* STATUS: verified */
 | 
				
			||||||
DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector *fLongVector)
 | 
					DO_INLINE void mul_bfmatrix_lfvector(float(*to)[3], fmatrix3x3 *from, lfVector *fLongVector)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i = 0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
	unsigned int vcount = from[0].vcount;
 | 
						unsigned int vcount = from[0].vcount;
 | 
				
			||||||
@@ -603,13 +603,13 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
#pragma omp section
 | 
					#pragma omp section
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++) {
 | 
								for (i = from[0].vcount; i < from[0].vcount + from[0].scount; i++) {
 | 
				
			||||||
				muladd_fmatrix_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]);
 | 
									muladd_fmatrix_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#pragma omp section
 | 
					#pragma omp section
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			for (i = 0; i < from[0].vcount+from[0].scount; i++) {
 | 
								for (i = 0; i < from[0].vcount + from[0].scount; i++) {
 | 
				
			||||||
				muladd_fmatrix_fvector(temp[from[i].r], from[i].m, fLongVector[from[i].c]);
 | 
									muladd_fmatrix_fvector(temp[from[i].r], from[i].m, fLongVector[from[i].c]);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -624,12 +624,12 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
 | 
				
			|||||||
/* SPARSE SYMMETRIC sub big matrix with big matrix*/
 | 
					/* SPARSE SYMMETRIC sub big matrix with big matrix*/
 | 
				
			||||||
/* A -= B * float + C * float --> for big matrix */
 | 
					/* A -= B * float + C * float --> for big matrix */
 | 
				
			||||||
/* VERIFIED */
 | 
					/* VERIFIED */
 | 
				
			||||||
DO_INLINE void subadd_bfmatrixS_bfmatrixS( fmatrix3x3 *to, fmatrix3x3 *from, float aS,  fmatrix3x3 *matrix, float bS)
 | 
					DO_INLINE void subadd_bfmatrixS_bfmatrixS(fmatrix3x3 *to, fmatrix3x3 *from, float aS,  fmatrix3x3 *matrix, float bS)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i = 0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* process diagonal elements */
 | 
						/* process diagonal elements */
 | 
				
			||||||
	for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
 | 
						for (i = 0; i < matrix[0].vcount + matrix[0].scount; i++) {
 | 
				
			||||||
		subadd_fmatrixS_fmatrixS(to[i].m, from[i].m, aS, matrix[i].m, bS);
 | 
							subadd_fmatrixS_fmatrixS(to[i].m, from[i].m, aS, matrix[i].m, bS);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -744,7 +744,7 @@ BLI_INLINE void root_to_world_m3(Implicit_Data *data, int index, float r[3][3],
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
 | 
					DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int i=0;
 | 
						unsigned int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < S[0].vcount; i++) {
 | 
						for (i = 0; i < S[0].vcount; i++) {
 | 
				
			||||||
		mul_m3_v3(S[i].m, V[S[i].r]);
 | 
							mul_m3_v3(S[i].m, V[S[i].r]);
 | 
				
			||||||
@@ -755,8 +755,8 @@ DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
 | 
				
			|||||||
static int  cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S)
 | 
					static int  cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// Solves for unknown X in equation AX=B
 | 
						// Solves for unknown X in equation AX=B
 | 
				
			||||||
	unsigned int conjgrad_loopcount=0, conjgrad_looplimit=100;
 | 
						unsigned int conjgrad_loopcount = 0, conjgrad_looplimit = 100;
 | 
				
			||||||
	float conjgrad_epsilon=0.0001f /* , conjgrad_lasterror=0 */ /* UNUSED */;
 | 
						float conjgrad_epsilon = 0.0001f /* , conjgrad_lasterror=0 */ /* UNUSED */;
 | 
				
			||||||
	lfVector *q, *d, *tmp, *r;
 | 
						lfVector *q, *d, *tmp, *r;
 | 
				
			||||||
	float s, starget, a, s_prev;
 | 
						float s, starget, a, s_prev;
 | 
				
			||||||
	unsigned int numverts = lA[0].vcount;
 | 
						unsigned int numverts = lA[0].vcount;
 | 
				
			||||||
@@ -782,13 +782,13 @@ static int  cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
 | 
				
			|||||||
	s = dot_lfvector(r, r, numverts);
 | 
						s = dot_lfvector(r, r, numverts);
 | 
				
			||||||
	starget = s * sqrtf(conjgrad_epsilon);
 | 
						starget = s * sqrtf(conjgrad_epsilon);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (s>starget && conjgrad_loopcount < conjgrad_looplimit) {
 | 
						while (s > starget && conjgrad_loopcount < conjgrad_looplimit) {
 | 
				
			||||||
		// Mul(q, A, d); // q = A*d;
 | 
							// Mul(q, A, d); // q = A*d;
 | 
				
			||||||
		mul_bfmatrix_lfvector(q, lA, d);
 | 
							mul_bfmatrix_lfvector(q, lA, d);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		filter(q, S);
 | 
							filter(q, S);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		a = s/dot_lfvector(d, q, numverts);
 | 
							a = s / dot_lfvector(d, q, numverts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// X = X + d*a;
 | 
							// X = X + d*a;
 | 
				
			||||||
		add_lfvector_lfvectorS(ldV, ldV, d, a, numverts);
 | 
							add_lfvector_lfvectorS(ldV, ldV, d, a, numverts);
 | 
				
			||||||
@@ -800,7 +800,7 @@ static int  cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
 | 
				
			|||||||
		s = dot_lfvector(r, r, numverts);
 | 
							s = dot_lfvector(r, r, numverts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//d = r+d*(s/s_prev);
 | 
							//d = r+d*(s/s_prev);
 | 
				
			||||||
		add_lfvector_lfvectorS(d, r, d, (s/s_prev), numverts);
 | 
							add_lfvector_lfvectorS(d, r, d, (s / s_prev), numverts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		filter(d, S);
 | 
							filter(d, S);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -814,15 +814,15 @@ static int  cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
 | 
				
			|||||||
	del_lfvector(r);
 | 
						del_lfvector(r);
 | 
				
			||||||
	// printf("W/O conjgrad_loopcount: %d\n", conjgrad_loopcount);
 | 
						// printf("W/O conjgrad_loopcount: %d\n", conjgrad_loopcount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return conjgrad_loopcount<conjgrad_looplimit;  // true means we reached desired accuracy in given time - ie stable
 | 
						return conjgrad_loopcount < conjgrad_looplimit;  // true means we reached desired accuracy in given time - ie stable
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, ImplicitSolverResult *result)
 | 
					static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, ImplicitSolverResult *result)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// Solves for unknown X in equation AX=B
 | 
						// Solves for unknown X in equation AX=B
 | 
				
			||||||
	unsigned int conjgrad_loopcount=0, conjgrad_looplimit=100;
 | 
						unsigned int conjgrad_loopcount = 0, conjgrad_looplimit = 100;
 | 
				
			||||||
	float conjgrad_epsilon=0.01f;
 | 
						float conjgrad_epsilon = 0.01f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	unsigned int numverts = lA[0].vcount;
 | 
						unsigned int numverts = lA[0].vcount;
 | 
				
			||||||
	lfVector *fB = create_lfvector(numverts);
 | 
						lfVector *fB = create_lfvector(numverts);
 | 
				
			||||||
@@ -839,7 +839,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z,
 | 
				
			|||||||
	cp_lfvector(fB, lB, numverts);
 | 
						cp_lfvector(fB, lB, numverts);
 | 
				
			||||||
	filter(fB, S);
 | 
						filter(fB, S);
 | 
				
			||||||
	bnorm2 = dot_lfvector(fB, fB, numverts);
 | 
						bnorm2 = dot_lfvector(fB, fB, numverts);
 | 
				
			||||||
	delta_target = conjgrad_epsilon*conjgrad_epsilon * bnorm2;
 | 
						delta_target = conjgrad_epsilon * conjgrad_epsilon * bnorm2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* r = filter(B - A * dV) */
 | 
						/* r = filter(B - A * dV) */
 | 
				
			||||||
	mul_bfmatrix_lfvector(AdV, lA, ldV);
 | 
						mul_bfmatrix_lfvector(AdV, lA, ldV);
 | 
				
			||||||
@@ -914,7 +914,7 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Take only the diagonal blocks of A
 | 
						// Take only the diagonal blocks of A
 | 
				
			||||||
// #pragma omp parallel for private(i) if (lA[0].vcount > CLOTH_OPENMP_LIMIT)
 | 
					// #pragma omp parallel for private(i) if (lA[0].vcount > CLOTH_OPENMP_LIMIT)
 | 
				
			||||||
	for (i = 0; i<lA[0].vcount; i++) {
 | 
						for (i = 0; i < lA[0].vcount; i++) {
 | 
				
			||||||
		// block diagonalizer
 | 
							// block diagonalizer
 | 
				
			||||||
		cp_fmatrix(P[i].m, lA[i].m);
 | 
							cp_fmatrix(P[i].m, lA[i].m);
 | 
				
			||||||
		inverse_fmatrix(Pinv[i].m, P[i].m);
 | 
							inverse_fmatrix(Pinv[i].m, P[i].m);
 | 
				
			||||||
@@ -926,9 +926,9 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
 | 
				
			|||||||
// version 1.3
 | 
					// version 1.3
 | 
				
			||||||
static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, fmatrix3x3 *P, fmatrix3x3 *Pinv)
 | 
					static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, fmatrix3x3 *P, fmatrix3x3 *Pinv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit=100;
 | 
						unsigned int numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit = 100;
 | 
				
			||||||
	float delta0 = 0, deltaNew = 0, deltaOld = 0, alpha = 0;
 | 
						float delta0 = 0, deltaNew = 0, deltaOld = 0, alpha = 0;
 | 
				
			||||||
	float conjgrad_epsilon=0.0001; // 0.2 is dt for steps=5
 | 
						float conjgrad_epsilon = 0.0001; // 0.2 is dt for steps=5
 | 
				
			||||||
	lfVector *r = create_lfvector(numverts);
 | 
						lfVector *r = create_lfvector(numverts);
 | 
				
			||||||
	lfVector *p = create_lfvector(numverts);
 | 
						lfVector *p = create_lfvector(numverts);
 | 
				
			||||||
	lfVector *s = create_lfvector(numverts);
 | 
						lfVector *s = create_lfvector(numverts);
 | 
				
			||||||
@@ -992,14 +992,14 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	printf("iterations: %d\n", iterations);
 | 
						printf("iterations: %d\n", iterations);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return iterations<conjgrad_looplimit;
 | 
						return iterations < conjgrad_looplimit;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// version 1.4
 | 
					// version 1.4
 | 
				
			||||||
static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, fmatrix3x3 *P, fmatrix3x3 *Pinv, fmatrix3x3 *bigI)
 | 
					static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, fmatrix3x3 *P, fmatrix3x3 *Pinv, fmatrix3x3 *bigI)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit=100;
 | 
						unsigned int numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit = 100;
 | 
				
			||||||
	float delta0 = 0, deltaNew = 0, deltaOld = 0, alpha = 0, tol = 0;
 | 
						float delta0 = 0, deltaNew = 0, deltaOld = 0, alpha = 0, tol = 0;
 | 
				
			||||||
	lfVector *r = create_lfvector(numverts);
 | 
						lfVector *r = create_lfvector(numverts);
 | 
				
			||||||
	lfVector *p = create_lfvector(numverts);
 | 
						lfVector *p = create_lfvector(numverts);
 | 
				
			||||||
@@ -1058,9 +1058,9 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
 | 
				
			|||||||
	double start = PIL_check_seconds_timer();
 | 
						double start = PIL_check_seconds_timer();
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tol = (0.01*0.2);
 | 
						tol = (0.01 * 0.2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while ((deltaNew > delta0*tol*tol) && (iterations < conjgrad_looplimit))
 | 
						while ((deltaNew > delta0 * tol * tol) && (iterations < conjgrad_looplimit))
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		iterations++;
 | 
							iterations++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1100,7 +1100,7 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// printf("iterations: %d\n", iterations);
 | 
						// printf("iterations: %d\n", iterations);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return iterations<conjgrad_looplimit;
 | 
						return iterations < conjgrad_looplimit;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1113,11 +1113,11 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	cp_bfmatrix(data->A, data->M);
 | 
						cp_bfmatrix(data->A, data->M);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	subadd_bfmatrixS_bfmatrixS(data->A, data->dFdV, dt, data->dFdX, (dt*dt));
 | 
						subadd_bfmatrixS_bfmatrixS(data->A, data->dFdV, dt, data->dFdX, (dt * dt));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mul_bfmatrix_lfvector(dFdXmV, data->dFdX, data->V);
 | 
						mul_bfmatrix_lfvector(dFdXmV, data->dFdX, data->V);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	add_lfvectorS_lfvectorS(data->B, data->F, dt, dFdXmV, (dt*dt), numverts);
 | 
						add_lfvectorS_lfvectorS(data->B, data->F, dt, dFdXmV, (dt * dt), numverts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef DEBUG_TIME
 | 
					#ifdef DEBUG_TIME
 | 
				
			||||||
	double start = PIL_check_seconds_timer();
 | 
						double start = PIL_check_seconds_timer();
 | 
				
			||||||
@@ -1399,7 +1399,7 @@ static float calc_nor_area_tri(float nor[3], const float v1[3], const float v2[3
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* XXX does not support force jacobians yet, since the effector system does not provide them either */
 | 
					/* XXX does not support force jacobians yet, since the effector system does not provide them either */
 | 
				
			||||||
void BPH_mass_spring_force_face_wind(Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3])
 | 
					void BPH_mass_spring_force_face_wind(Implicit_Data *data, int v1, int v2, int v3, const float(*winvec)[3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const float effector_scale = 0.02f;
 | 
						const float effector_scale = 0.02f;
 | 
				
			||||||
	float win[3], nor[3], area;
 | 
						float win[3], nor[3], area;
 | 
				
			||||||
@@ -1438,7 +1438,7 @@ static void edge_wind_vertex(const float dir[3], float length, float radius, con
 | 
				
			|||||||
	mul_v3_v3fl(f, wind, density * cross_section);
 | 
						mul_v3_v3fl(f, wind, density * cross_section);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float (*winvec)[3])
 | 
					void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float(*winvec)[3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	float win[3], dir[3], length;
 | 
						float win[3], dir[3], length;
 | 
				
			||||||
	float f[3], dfdx[3][3], dfdv[3][3];
 | 
						float f[3], dfdx[3][3], dfdv[3][3];
 | 
				
			||||||
@@ -1455,7 +1455,7 @@ void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, float
 | 
				
			|||||||
	add_v3_v3(data->F[v2], f);
 | 
						add_v3_v3(data->F[v2], f);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BPH_mass_spring_force_vertex_wind(Implicit_Data *data, int v, float UNUSED(radius), const float (*winvec)[3])
 | 
					void BPH_mass_spring_force_vertex_wind(Implicit_Data *data, int v, float UNUSED(radius), const float(*winvec)[3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const float density = 0.01f; /* XXX arbitrary value, corresponds to effect of air density */
 | 
						const float density = 0.01f; /* XXX arbitrary value, corresponds to effect of air density */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1474,7 +1474,7 @@ BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, fl
 | 
				
			|||||||
	outerproduct(to, dir, dir);
 | 
						outerproduct(to, dir, dir);
 | 
				
			||||||
	sub_m3_m3m3(to, I, to);
 | 
						sub_m3_m3m3(to, I, to);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mul_m3_fl(to, (L/length));
 | 
						mul_m3_fl(to, (L / length));
 | 
				
			||||||
	sub_m3_m3m3(to, to, I);
 | 
						sub_m3_m3m3(to, to, I);
 | 
				
			||||||
	mul_m3_fl(to, k);
 | 
						mul_m3_fl(to, k);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1487,7 +1487,7 @@ BLI_INLINE void dfdx_damp(float to[3][3], const float dir[3], float length, cons
 | 
				
			|||||||
	//  return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
 | 
						//  return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
 | 
				
			||||||
	mul_fvectorT_fvector(to, dir, dir);
 | 
						mul_fvectorT_fvector(to, dir, dir);
 | 
				
			||||||
	sub_fmatrix_fmatrix(to, I, to);
 | 
						sub_fmatrix_fmatrix(to, I, to);
 | 
				
			||||||
	mul_fmatrix_S(to,  (-damping * -(dot_v3v3(dir, vel)/MAX2(length, rest))));
 | 
						mul_fmatrix_S(to,  (-damping * -(dot_v3v3(dir, vel) / MAX2(length, rest))));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1509,7 +1509,7 @@ BLI_INLINE float fb(float length, float L)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
BLI_INLINE float fbderiv(float length, float L)
 | 
					BLI_INLINE float fbderiv(float length, float L)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	float x = length/L;
 | 
						float x = length / L;
 | 
				
			||||||
	float xx = x * x;
 | 
						float xx = x * x;
 | 
				
			||||||
	float xxx = xx * x;
 | 
						float xxx = xx * x;
 | 
				
			||||||
	return (-46.164f * xxx + 102.579f * xx - 78.166f * x + 23.116f);
 | 
						return (-46.164f * xxx + 102.579f * xx - 78.166f * x + 23.116f);
 | 
				
			||||||
@@ -1536,7 +1536,7 @@ BLI_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
 | 
				
			|||||||
		return -cb;
 | 
							return -cb;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
		return -kb * fbderiv(length, L);
 | 
							return -kb *fbderiv(length, L);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1551,7 +1551,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[
 | 
				
			|||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
		if (length > L) {
 | 
							if (length > L) {
 | 
				
			||||||
			if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
 | 
								if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
 | 
				
			||||||
			    ( ((length-L)*100.0f/L) > clmd->sim_parms->maxspringlen ))
 | 
								    ( ((length - L) * 100.0f / L) > clmd->sim_parms->maxspringlen))
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				// cut spring!
 | 
									// cut spring!
 | 
				
			||||||
				s->flags |= CSPRING_FLAG_DEACTIVATE;
 | 
									s->flags |= CSPRING_FLAG_DEACTIVATE;
 | 
				
			||||||
@@ -1559,7 +1559,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		mul_v3_v3fl(r_dir, r_extent, 1.0f/(*r_length));
 | 
							mul_v3_v3fl(r_dir, r_extent, 1.0f / (*r_length));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
		zero_v3(r_dir);
 | 
							zero_v3(r_dir);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -110,7 +110,7 @@ public:
 | 
				
			|||||||
			coeffRef(k) = v[k];
 | 
								coeffRef(k) = v[k];
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fVector& operator = (const ctype &v)
 | 
						fVector& operator =(const ctype &v)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		for (int k = 0; k < 3; ++k)
 | 
							for (int k = 0; k < 3; ++k)
 | 
				
			||||||
			coeffRef(k) = v[k];
 | 
								coeffRef(k) = v[k];
 | 
				
			||||||
@@ -141,7 +141,7 @@ public:
 | 
				
			|||||||
				coeffRef(l, k) = v[k][l];
 | 
									coeffRef(l, k) = v[k][l];
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fMatrix& operator = (const ctype &v)
 | 
						fMatrix& operator =(const ctype &v)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		for (int k = 0; k < 3; ++k)
 | 
							for (int k = 0; k < 3; ++k)
 | 
				
			||||||
			for (int l = 0; l < 3; ++l)
 | 
								for (int l = 0; l < 3; ++l)
 | 
				
			||||||
@@ -167,18 +167,18 @@ public:
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	template <typename T>
 | 
						template <typename T>
 | 
				
			||||||
	lVector& operator = (T rhs)
 | 
						lVector& operator =(T rhs)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		base_t::operator=(rhs);
 | 
							base_t::operator=(rhs);
 | 
				
			||||||
		return *this;
 | 
							return *this;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	float* v3(int vertex)
 | 
						float *v3(int vertex)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		return &coeffRef(3 * vertex);
 | 
							return &coeffRef(3 * vertex);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const float* v3(int vertex) const
 | 
						const float *v3(int vertex) const
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		return &coeffRef(3 * vertex);
 | 
							return &coeffRef(3 * vertex);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -516,10 +516,10 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
 | 
				
			|||||||
	cg.filter() = data->S;
 | 
						cg.filter() = data->S;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	data->A = data->M - dt * data->dFdV - dt*dt * data->dFdX;
 | 
						data->A = data->M - dt * data->dFdV - dt * dt * data->dFdX;
 | 
				
			||||||
	cg.compute(data->A);
 | 
						cg.compute(data->A);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	data->B = dt * data->F + dt*dt * data->dFdX * data->V;
 | 
						data->B = dt * data->F + dt * dt * data->dFdX * data->V;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
 | 
					#ifdef IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
 | 
				
			||||||
	printf("==== A ====\n");
 | 
						printf("==== A ====\n");
 | 
				
			||||||
@@ -786,7 +786,7 @@ static float calc_nor_area_tri(float nor[3], const float v1[3], const float v2[3
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* XXX does not support force jacobians yet, since the effector system does not provide them either */
 | 
					/* XXX does not support force jacobians yet, since the effector system does not provide them either */
 | 
				
			||||||
void BPH_mass_spring_force_face_wind(Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3])
 | 
					void BPH_mass_spring_force_face_wind(Implicit_Data *data, int v1, int v2, int v3, const float(*winvec)[3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const float effector_scale = 0.02f;
 | 
						const float effector_scale = 0.02f;
 | 
				
			||||||
	float win[3], nor[3], area;
 | 
						float win[3], nor[3], area;
 | 
				
			||||||
@@ -806,7 +806,7 @@ void BPH_mass_spring_force_face_wind(Implicit_Data *data, int v1, int v2, int v3
 | 
				
			|||||||
	madd_v3_v3fl(data->F.v3(v3), nor, factor * dot_v3v3(win, nor));
 | 
						madd_v3_v3fl(data->F.v3(v3), nor, factor * dot_v3v3(win, nor));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, const float (*winvec)[3])
 | 
					void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, const float(*winvec)[3])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const float effector_scale = 0.01;
 | 
						const float effector_scale = 0.01;
 | 
				
			||||||
	float win[3], dir[3], nor[3], length;
 | 
						float win[3], dir[3], nor[3], length;
 | 
				
			||||||
@@ -830,7 +830,7 @@ BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, fl
 | 
				
			|||||||
	outerproduct(to, dir, dir);
 | 
						outerproduct(to, dir, dir);
 | 
				
			||||||
	sub_m3_m3m3(to, I, to);
 | 
						sub_m3_m3m3(to, I, to);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mul_m3_fl(to, (L/length));
 | 
						mul_m3_fl(to, (L / length));
 | 
				
			||||||
	sub_m3_m3m3(to, to, I);
 | 
						sub_m3_m3m3(to, to, I);
 | 
				
			||||||
	mul_m3_fl(to, k);
 | 
						mul_m3_fl(to, k);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -843,7 +843,7 @@ BLI_INLINE void dfdx_damp(float to[3][3], const float dir[3], float length, cons
 | 
				
			|||||||
	//  return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
 | 
						//  return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
 | 
				
			||||||
	mul_fvectorT_fvector(to, dir, dir);
 | 
						mul_fvectorT_fvector(to, dir, dir);
 | 
				
			||||||
	sub_fmatrix_fmatrix(to, I, to);
 | 
						sub_fmatrix_fmatrix(to, I, to);
 | 
				
			||||||
	mul_fmatrix_S(to,  (-damping * -(dot_v3v3(dir, vel)/MAX2(length, rest))));
 | 
						mul_fmatrix_S(to,  (-damping * -(dot_v3v3(dir, vel) / MAX2(length, rest))));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -862,7 +862,7 @@ BLI_INLINE float fb(float length, float L)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
BLI_INLINE float fbderiv(float length, float L)
 | 
					BLI_INLINE float fbderiv(float length, float L)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	float x = length/L;
 | 
						float x = length / L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (-46.164f * powf(x, 3) + 102.579f * powf(x, 2) - 78.166f * x + 23.116f);
 | 
						return (-46.164f * powf(x, 3) + 102.579f * powf(x, 2) - 78.166f * x + 23.116f);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -888,7 +888,7 @@ BLI_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
 | 
				
			|||||||
		return -cb;
 | 
							return -cb;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
		return -kb * fbderiv(length, L);
 | 
							return -kb *fbderiv(length, L);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -903,7 +903,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[
 | 
				
			|||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
		if (length > L) {
 | 
							if (length > L) {
 | 
				
			||||||
			if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
 | 
								if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
 | 
				
			||||||
			    ( ((length-L)*100.0f/L) > clmd->sim_parms->maxspringlen ))
 | 
								    ( ((length - L) * 100.0f / L) > clmd->sim_parms->maxspringlen))
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				// cut spring!
 | 
									// cut spring!
 | 
				
			||||||
				s->flags |= CSPRING_FLAG_DEACTIVATE;
 | 
									s->flags |= CSPRING_FLAG_DEACTIVATE;
 | 
				
			||||||
@@ -911,7 +911,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		mul_v3_v3fl(r_dir, r_extent, 1.0f/(*r_length));
 | 
							mul_v3_v3fl(r_dir, r_extent, 1.0f / (*r_length));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
		zero_v3(r_dir);
 | 
							zero_v3(r_dir);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user