您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ zero_v3函数代码示例

51自学网 2021-06-03 11:58:56
  C++
这篇教程C++ zero_v3函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中zero_v3函数的典型用法代码示例。如果您正苦于以下问题:C++ zero_v3函数的具体用法?C++ zero_v3怎么用?C++ zero_v3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了zero_v3函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: apply_objects_internal

//.........这里部分代码省略.........			ED_armature_apply_transform(ob, mat);		}		else if (ob->type == OB_LATTICE) {			Lattice *lt = ob->data;			BKE_lattice_transform(lt, mat, true);		}		else if (ob->type == OB_MBALL) {			MetaBall *mb = ob->data;			BKE_mball_transform(mb, mat);		}		else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {			Curve *cu = ob->data;			scale = mat3_to_scale(rsmat);			BKE_curve_transform_ex(cu, mat, true, scale);		}		else if (ob->type == OB_FONT) {			Curve *cu = ob->data;			int i;			scale = mat3_to_scale(rsmat);			for (i = 0; i < cu->totbox; i++) {				TextBox *tb = &cu->tb[i];				tb->x *= scale;				tb->y *= scale;				tb->w *= scale;				tb->h *= scale;			}			cu->fsize *= scale;		}		else if (ob->type == OB_CAMERA) {			MovieClip *clip = BKE_object_movieclip_get(scene, ob, false);			/* applying scale on camera actually scales clip's reconstruction.			 * of there's clip assigned to camera nothing to do actually.			 */			if (!clip)				continue;			if (apply_scale)				BKE_tracking_reconstruction_scale(&clip->tracking, ob->size);		}		else if (ob->type == OB_EMPTY) {			/* It's possible for empties too, even though they don't 			 * really have obdata, since we can simply apply the maximum			 * scaling to the empty's drawsize.			 *			 * Core Assumptions:			 * 1) Most scaled empties have uniform scaling 			 *    (i.e. for visibility reasons), AND/OR			 * 2) Preserving non-uniform scaling is not that important,			 *    and is something that many users would be willing to			 *    sacrifice for having an easy way to do this.			 */			if ((apply_loc == false) &&			    (apply_rot == false) &&			    (apply_scale == true))			{				float max_scale = max_fff(fabsf(ob->size[0]), fabsf(ob->size[1]), fabsf(ob->size[2]));				ob->empty_drawsize *= max_scale;			}		}		else {			continue;		}		if (apply_loc)			zero_v3(ob->loc);		if (apply_scale)			ob->size[0] = ob->size[1] = ob->size[2] = 1.0f;		if (apply_rot) {			zero_v3(ob->rot);			unit_qt(ob->quat);			unit_axis_angle(ob->rotAxis, &ob->rotAngle);		}		BKE_object_where_is_calc(scene, ob);		if (ob->type == OB_ARMATURE) {			BKE_pose_where_is(scene, ob); /* needed for bone parents */		}		ignore_parent_tx(bmain, scene, ob);		DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);		changed = true;	}	CTX_DATA_END;	if (!changed) {		BKE_report(reports, RPT_WARNING, "Objects have no data to transform");		return OPERATOR_CANCELLED;	}	WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);	return OPERATOR_FINISHED;}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:101,


示例2: make_duplis_font

static void make_duplis_font(const DupliContext *ctx){	Object *par = ctx->object;	GHash *family_gh;	Object *ob;	Curve *cu;	struct CharTrans *ct, *chartransdata = NULL;	float vec[3], obmat[4][4], pmat[4][4], fsize, xof, yof;	int text_len, a;	size_t family_len;	const wchar_t *text = NULL;	bool text_free = false;	/* font dupliverts not supported inside groups */	if (ctx->group)		return;	copy_m4_m4(pmat, par->obmat);	/* in par the family name is stored, use this to find the other objects */	BKE_vfont_to_curve_ex(G.main, par, FO_DUPLI, NULL,	                      &text, &text_len, &text_free, &chartransdata);	if (text == NULL || chartransdata == NULL) {		return;	}	cu = par->data;	fsize = cu->fsize;	xof = cu->xof;	yof = cu->yof;	ct = chartransdata;	/* cache result */	family_len = strlen(cu->family);	family_gh = BLI_ghash_int_new_ex(__func__, 256);	/* advance matching BLI_strncpy_wchar_from_utf8 */	for (a = 0; a < text_len; a++, ct++) {		ob = find_family_object(cu->family, family_len, (unsigned int)text[a], family_gh);		if (ob) {			vec[0] = fsize * (ct->xof - xof);			vec[1] = fsize * (ct->yof - yof);			vec[2] = 0.0;			mul_m4_v3(pmat, vec);			copy_m4_m4(obmat, par->obmat);			if (UNLIKELY(ct->rot != 0.0f)) {				float rmat[4][4];				zero_v3(obmat[3]);				unit_m4(rmat);				rotate_m4(rmat, 'Z', -ct->rot);				mul_m4_m4m4(obmat, obmat, rmat);			}			copy_v3_v3(obmat[3], vec);			make_dupli(ctx, ob, obmat, a, false, false);		}	}	if (text_free) {		MEM_freeN((void *)text);	}	BLI_ghash_free(family_gh, NULL, NULL);	MEM_freeN(chartransdata);}
开发者ID:DrangPo,项目名称:blender,代码行数:75,


示例3: cloth_calc_spring_force

BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, float time){	Cloth *cloth = clmd->clothObject;	ClothSimSettings *parms = clmd->sim_parms;	Implicit_Data *data = cloth->implicit;	ClothVertex *verts = cloth->verts;		bool no_compress = parms->flags & CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS;		zero_v3(s->f);	zero_m3(s->dfdx);	zero_m3(s->dfdv);		s->flags &= ~CLOTH_SPRING_FLAG_NEEDED;		// calculate force of structural + shear springs	if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR) || (s->type & CLOTH_SPRING_TYPE_SEWING) ) {#ifdef CLOTH_FORCE_SPRING_STRUCTURAL		float k, scaling;				s->flags |= CLOTH_SPRING_FLAG_NEEDED;				scaling = parms->structural + s->stiffness * fabsf(parms->max_struct - parms->structural);		k = scaling / (parms->avg_spring_len + FLT_EPSILON);				if (s->type & CLOTH_SPRING_TYPE_SEWING) {			// TODO: verify, half verified (couldn't see error)			// sewing springs usually have a large distance at first so clamp the force so we don't get tunnelling through colission objects			BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, k, parms->Cdis, no_compress, parms->max_sewing, s->f, s->dfdx, s->dfdv);		}		else {			BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, k, parms->Cdis, no_compress, 0.0f, s->f, s->dfdx, s->dfdv);		}#endif	}	else if (s->type & CLOTH_SPRING_TYPE_GOAL) {#ifdef CLOTH_FORCE_SPRING_GOAL		float goal_x[3], goal_v[3];		float k, scaling;				s->flags |= CLOTH_SPRING_FLAG_NEEDED;				// current_position = xold + t * (newposition - xold)		/* divide by time_scale to prevent goal vertices' delta locations from being multiplied */		interp_v3_v3v3(goal_x, verts[s->ij].xold, verts[s->ij].xconst, time / parms->time_scale);		sub_v3_v3v3(goal_v, verts[s->ij].xconst, verts[s->ij].xold); // distance covered over dt==1				scaling = parms->goalspring + s->stiffness * fabsf(parms->max_struct - parms->goalspring);		k = verts[s->ij].goal * scaling / (parms->avg_spring_len + FLT_EPSILON);				BPH_mass_spring_force_spring_goal(data, s->ij, goal_x, goal_v, k, parms->goalfrict * 0.01f, s->f, s->dfdx, s->dfdv);#endif	}	else if (s->type & CLOTH_SPRING_TYPE_BENDING) {  /* calculate force of bending springs */#ifdef CLOTH_FORCE_SPRING_BEND		float kb, cb, scaling;				s->flags |= CLOTH_SPRING_FLAG_NEEDED;				scaling = parms->bending + s->stiffness * fabsf(parms->max_bend - parms->bending);		kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));				// Fix for [#45084] for cloth stiffness must have cb proportional to kb		cb = kb * parms->bending_damping;				BPH_mass_spring_force_spring_bending(data, s->ij, s->kl, s->restlen, kb, cb, s->f, s->dfdx, s->dfdv);#endif	}	else if (s->type & CLOTH_SPRING_TYPE_BENDING_ANG) {#ifdef CLOTH_FORCE_SPRING_BEND		float kb, cb, scaling;				s->flags |= CLOTH_SPRING_FLAG_NEEDED;				/* XXX WARNING: angular bending springs for hair apply stiffness factor as an overall factor, unlike cloth springs!		 * this is crap, but needed due to cloth/hair mixing ...		 * max_bend factor is not even used for hair, so ...		 */		scaling = s->stiffness * parms->bending;		kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));				// Fix for [#45084] for cloth stiffness must have cb proportional to kb		cb = kb * parms->bending_damping;				/* XXX assuming same restlen for ij and jk segments here, this can be done correctly for hair later */		BPH_mass_spring_force_spring_bending_angular(data, s->ij, s->kl, s->mn, s->target, kb, cb);		#if 0		{			float x_kl[3], x_mn[3], v[3], d[3];						BPH_mass_spring_get_motion_state(data, s->kl, x_kl, v);			BPH_mass_spring_get_motion_state(data, s->mn, x_mn, v);						BKE_sim_debug_data_add_dot(clmd->debug_data, x_kl, 0.9, 0.9, 0.9, "target", 7980, s->kl);			BKE_sim_debug_data_add_line(clmd->debug_data, x_kl, x_mn, 0.8, 0.8, 0.8, "target", 7981, s->kl);						copy_v3_v3(d, s->target);			BKE_sim_debug_data_add_vector(clmd->debug_data, x_kl, d, 0.8, 0.8, 0.2, "target", 7982, s->kl);			//.........这里部分代码省略.........
开发者ID:diekev,项目名称:blender,代码行数:101,


示例4: distribute_grid

static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys){	ParticleData *pa=NULL;	float min[3], max[3], delta[3], d;	MVert *mv, *mvert = dm->getVertDataArray(dm,0);	int totvert=dm->getNumVerts(dm), from=psys->part->from;	int i, j, k, p, res=psys->part->grid_res, size[3], axis;	/* find bounding box of dm */	if (totvert > 0) {		mv=mvert;		copy_v3_v3(min, mv->co);		copy_v3_v3(max, mv->co);		mv++;		for (i = 1; i < totvert; i++, mv++) {			minmax_v3v3_v3(min, max, mv->co);		}	}	else {		zero_v3(min);		zero_v3(max);	}	sub_v3_v3v3(delta, max, min);	/* determine major axis */	axis = axis_dominant_v3_single(delta);	d = delta[axis]/(float)res;	size[axis] = res;	size[(axis+1)%3] = (int)ceil(delta[(axis+1)%3]/d);	size[(axis+2)%3] = (int)ceil(delta[(axis+2)%3]/d);	/* float errors grrr.. */	size[(axis+1)%3] = MIN2(size[(axis+1)%3],res);	size[(axis+2)%3] = MIN2(size[(axis+2)%3],res);	size[0] = MAX2(size[0], 1);	size[1] = MAX2(size[1], 1);	size[2] = MAX2(size[2], 1);	/* no full offset for flat/thin objects */	min[0]+= d < delta[0] ? d/2.f : delta[0]/2.f;	min[1]+= d < delta[1] ? d/2.f : delta[1]/2.f;	min[2]+= d < delta[2] ? d/2.f : delta[2]/2.f;	for (i=0,p=0,pa=psys->particles; i<res; i++) {		for (j=0; j<res; j++) {			for (k=0; k<res; k++,p++,pa++) {				pa->fuv[0] = min[0] + (float)i*d;				pa->fuv[1] = min[1] + (float)j*d;				pa->fuv[2] = min[2] + (float)k*d;				pa->flag |= PARS_UNEXIST;				pa->hair_index = 0; /* abused in volume calculation */			}		}	}	/* enable particles near verts/edges/faces/inside surface */	if (from==PART_FROM_VERT) {		float vec[3];		pa=psys->particles;		min[0] -= d/2.0f;		min[1] -= d/2.0f;		min[2] -= d/2.0f;		for (i=0,mv=mvert; i<totvert; i++,mv++) {			sub_v3_v3v3(vec,mv->co,min);			vec[0]/=delta[0];			vec[1]/=delta[1];			vec[2]/=delta[2];			pa[((int)(vec[0] * (size[0] - 1))  * res +			    (int)(vec[1] * (size[1] - 1))) * res +			    (int)(vec[2] * (size[2] - 1))].flag &= ~PARS_UNEXIST;		}	}	else if (ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) {		float co1[3], co2[3];		MFace *mface= NULL, *mface_array;		float v1[3], v2[3], v3[3], v4[4], lambda;		int a, a1, a2, a0mul, a1mul, a2mul, totface;		int amax= from==PART_FROM_FACE ? 3 : 1;		totface=dm->getNumTessFaces(dm);		mface=mface_array=dm->getTessFaceDataArray(dm,CD_MFACE);		for (a=0; a<amax; a++) {			if (a==0) { a0mul=res*res; a1mul=res; a2mul=1; }			else if (a==1) { a0mul=res; a1mul=1; a2mul=res*res; }			else { a0mul=1; a1mul=res*res; a2mul=res; }			for (a1=0; a1<size[(a+1)%3]; a1++) {				for (a2=0; a2<size[(a+2)%3]; a2++) {					mface= mface_array;					pa = psys->particles + a1*a1mul + a2*a2mul;//.........这里部分代码省略.........
开发者ID:Ichthyostega,项目名称:blender,代码行数:101,


示例5: BKE_mesh_validate_arrays

int BKE_mesh_validate_arrays(Mesh *mesh,                             MVert *mverts, unsigned int totvert,                             MEdge *medges, unsigned int totedge,                             MFace *mfaces, unsigned int totface,                             MLoop *mloops, unsigned int totloop,                             MPoly *mpolys, unsigned int totpoly,                             MDeformVert *dverts, /* assume totvert length */                             const bool do_verbose, const bool do_fixes){#   define REMOVE_EDGE_TAG(_me) { _me->v2 = _me->v1; do_edge_free = true; } (void)0#   define IS_REMOVED_EDGE(_me) (_me->v2 == _me->v1)#   define REMOVE_LOOP_TAG(_ml) { _ml->e = INVALID_LOOP_EDGE_MARKER; do_polyloop_free = true; } (void)0#   define REMOVE_POLY_TAG(_mp) { _mp->totloop *= -1; do_polyloop_free = true; } (void)0	MVert *mv = mverts;	MEdge *me;	MLoop *ml;	MPoly *mp;	unsigned int i, j;	int *v;	bool do_edge_free = false;	bool do_face_free = false;	bool do_polyloop_free = false; /* This regroups loops and polys! */	bool verts_fixed = false;	bool vert_weights_fixed = false;	bool msel_fixed = false;	bool do_edge_recalc = false;	EdgeHash *edge_hash = BLI_edgehash_new();	BLI_assert(!(do_fixes && mesh == NULL));	PRINT("%s: verts(%u), edges(%u), loops(%u), polygons(%u)/n",	      __func__, totvert, totedge, totloop, totpoly);	if (totedge == 0 && totpoly != 0) {		PRINT("/tLogical error, %u polygons and 0 edges/n", totpoly);		do_edge_recalc = do_fixes;	}	for (i = 1; i < totvert; i++, mv++) {		int fix_normal = TRUE;		for (j = 0; j < 3; j++) {			if (!finite(mv->co[j])) {				PRINT("/tVertex %u: has invalid coordinate/n", i);				if (do_fixes) {					zero_v3(mv->co);					verts_fixed = TRUE;				}			}			if (mv->no[j] != 0)				fix_normal = FALSE;		}		if (fix_normal) {			PRINT("/tVertex %u: has zero normal, assuming Z-up normal/n", i);			if (do_fixes) {				mv->no[2] = SHRT_MAX;				verts_fixed = TRUE;			}		}	}	for (i = 0, me = medges; i < totedge; i++, me++) {		int remove = FALSE;		if (me->v1 == me->v2) {			PRINT("/tEdge %u: has matching verts, both %u/n", i, me->v1);			remove = do_fixes;		}		if (me->v1 >= totvert) {			PRINT("/tEdge %u: v1 index out of range, %u/n", i, me->v1);			remove = do_fixes;		}		if (me->v2 >= totvert) {			PRINT("/tEdge %u: v2 index out of range, %u/n", i, me->v2);			remove = do_fixes;		}		if (BLI_edgehash_haskey(edge_hash, me->v1, me->v2)) {			PRINT("/tEdge %u: is a duplicate of %d/n", i,			      GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, me->v1, me->v2)));			remove = do_fixes;		}		if (remove == FALSE) {			BLI_edgehash_insert(edge_hash, me->v1, me->v2, SET_INT_IN_POINTER(i));		}		else {			REMOVE_EDGE_TAG(me);		}	}//.........这里部分代码省略.........
开发者ID:244xiao,项目名称:blender,代码行数:101,


示例6: ED_armature_origin_set

/* 0 == do center, 1 == center new, 2 == center cursor */void ED_armature_origin_set(Scene *scene, Object *ob, float cursor[3], int centermode, int around){	Object *obedit = scene->obedit; // XXX get from context	EditBone *ebone;	bArmature *arm = ob->data;	float cent[3];	/* Put the armature into editmode */	if (ob != obedit) {		ED_armature_to_edit(ob);		obedit = NULL; /* we cant use this so behave as if there is no obedit */	}	/* Find the centerpoint */	if (centermode == 2) {		copy_v3_v3(cent, cursor);		invert_m4_m4(ob->imat, ob->obmat);		mul_m4_v3(ob->imat, cent);	}	else {		if (around == V3D_CENTROID) {			int total = 0;			zero_v3(cent);			for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {				total += 2;				add_v3_v3(cent, ebone->head);				add_v3_v3(cent, ebone->tail);			}			if (total) {				mul_v3_fl(cent, 1.0f / (float)total);			}		}		else {			float min[3], max[3];			INIT_MINMAX(min, max);			for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {				minmax_v3v3_v3(min, max, ebone->head);				minmax_v3v3_v3(min, max, ebone->tail);			}			mid_v3_v3v3(cent, min, max);		}	}		/* Do the adjustments */	for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {		sub_v3_v3(ebone->head, cent);		sub_v3_v3(ebone->tail, cent);	}		/* Turn the list into an armature */	if (obedit == NULL) {		ED_armature_from_edit(ob);		ED_armature_edit_free(ob);	}	/* Adjust object location for new centerpoint */	if (centermode && obedit == NULL) {		mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */		add_v3_v3(ob->loc, cent);	}}
开发者ID:244xiao,项目名称:blender,代码行数:62,


示例7: BLI_array_alloca

//.........这里部分代码省略.........			float vec[3] = {0, 1, 0};			float cross1[3];			float cross2[3];			cross_v3_v3v3(cross1, vec, axis_vec);			mul_v3_m3v3(cross2, mtx3_tx, cross1);			{				float c1[3];				float c2[3];				float axis_tmp[3];				cross_v3_v3v3(c1, cross2, axis_vec);				cross_v3_v3v3(c2, axis_vec, c1);				angle = angle_v3v3(cross1, c2);				cross_v3_v3v3(axis_tmp, cross1, c2);				normalize_v3(axis_tmp);				if (len_v3v3(axis_tmp, axis_vec) > 1.0f)					angle = -angle;			}		}#endif	}	else {		/* exis char is used by i_rotate*/		axis_char = (char)(axis_char + ltmd->axis); /* 'X' + axis */		/* useful to be able to use the axis vec in some cases still */		zero_v3(axis_vec);		axis_vec[ltmd->axis] = 1.0f;	}	/* apply the multiplier */	angle *= (float)ltmd->iter;	screw_ofs *= (float)ltmd->iter;	uv_u_scale = 1.0f / (float)(step_tot);	/* multiplying the steps is a bit tricky, this works best */	step_tot = ((step_tot + 1) * ltmd->iter) - (ltmd->iter - 1);	/* will the screw be closed?	 * Note! smaller then FLT_EPSILON * 100 gives problems with float precision so its never closed. */	if (fabsf(screw_ofs) <= (FLT_EPSILON * 100.0f) &&	    fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON * 100.0f))	{		close = 1;		step_tot--;		if (step_tot < 3) step_tot = 3;			maxVerts = totvert  * step_tot;   /* -1 because we're joining back up */		maxEdges = (totvert * step_tot) + /* these are the edges between new verts */		           (totedge * step_tot);  /* -1 because vert edges join */		maxPolys = totedge * step_tot;		screw_ofs = 0.0f;	}	else {		close = 0;		if (step_tot < 3) step_tot = 3;		maxVerts =  totvert  * step_tot; /* -1 because we're joining back up */
开发者ID:linkedinyou,项目名称:blender-git,代码行数:67,


示例8: UNUSED

//.........这里部分代码省略.........            float vec[3] = {0,1,0};            float cross1[3];            float cross2[3];            cross_v3_v3v3(cross1, vec, axis_vec);            mul_v3_m3v3(cross2, mtx3_tx, cross1);            {                float c1[3];                float c2[3];                float axis_tmp[3];                cross_v3_v3v3(c1, cross2, axis_vec);                cross_v3_v3v3(c2, axis_vec, c1);                angle= angle_v3v3(cross1, c2);                cross_v3_v3v3(axis_tmp, cross1, c2);                normalize_v3(axis_tmp);                if(len_v3v3(axis_tmp, axis_vec) > 1.0f)                    angle= -angle;            }        }#endif    }    else {        /* exis char is used by i_rotate*/        axis_char += ltmd->axis; /* 'X' + axis */        /* useful to be able to use the axis vec in some cases still */        zero_v3(axis_vec);        axis_vec[ltmd->axis]= 1.0f;    }    /* apply the multiplier */    angle *= ltmd->iter;    screw_ofs *= ltmd->iter;    /* multiplying the steps is a bit tricky, this works best */    step_tot = ((step_tot + 1) * ltmd->iter) - (ltmd->iter - 1);    /* will the screw be closed?     * Note! smaller then FLT_EPSILON*100 gives problems with float precision so its never closed. */    if (fabsf(screw_ofs) <= (FLT_EPSILON*100.0f) && fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON*100.0f)) {        close= 1;        step_tot--;        if(step_tot < 3) step_tot= 3;        maxVerts =	totvert  * step_tot; /* -1 because we're joining back up */        maxEdges =	(totvert * step_tot) + /* these are the edges between new verts */                    (totedge * step_tot); /* -1 because vert edges join */        maxFaces =	totedge * step_tot;        screw_ofs= 0.0f;    }    else {        close= 0;        if(step_tot < 3) step_tot= 3;        maxVerts =	totvert  * step_tot; /* -1 because we're joining back up */        maxEdges =	(totvert * (step_tot-1)) + /* these are the edges between new verts */                    (totedge * step_tot); /* -1 because vert edges join */        maxFaces =	totedge * (step_tot-1);
开发者ID:mik0001,项目名称:Blender,代码行数:67,


示例9: rna_Object_ray_cast

static void rna_Object_ray_cast(Object *ob,                                bContext *C,                                ReportList *reports,                                float origin[3],                                float direction[3],                                float distance,                                PointerRNA *rnaptr_depsgraph,                                bool *r_success,                                float r_location[3],                                float r_normal[3],                                int *r_index){  bool success = false;  if (ob->runtime.mesh_eval == NULL &&      (ob = eval_object_ensure(ob, C, reports, rnaptr_depsgraph)) == NULL) {    return;  }  /* Test BoundBox first (efficiency) */  BoundBox *bb = BKE_object_boundbox_get(ob);  float distmin;  normalize_v3(      direction); /* Needed for valid distance check from isect_ray_aabb_v3_simple() call. */  if (!bb ||      (isect_ray_aabb_v3_simple(origin, direction, bb->vec[0], bb->vec[6], &distmin, NULL) &&       distmin <= distance)) {    BVHTreeFromMesh treeData = {NULL};    /* No need to managing allocation or freeing of the BVH data.     * This is generated and freed as needed. */    BKE_bvhtree_from_mesh_get(&treeData, ob->runtime.mesh_eval, BVHTREE_FROM_LOOPTRI, 4);    /* may fail if the mesh has no faces, in that case the ray-cast misses */    if (treeData.tree != NULL) {      BVHTreeRayHit hit;      hit.index = -1;      hit.dist = distance;      if (BLI_bvhtree_ray_cast(treeData.tree,                               origin,                               direction,                               0.0f,                               &hit,                               treeData.raycast_callback,                               &treeData) != -1) {        if (hit.dist <= distance) {          *r_success = success = true;          copy_v3_v3(r_location, hit.co);          copy_v3_v3(r_normal, hit.no);          *r_index = mesh_looptri_to_poly_index(ob->runtime.mesh_eval,                                                &treeData.looptri[hit.index]);        }      }      free_bvhtree_from_mesh(&treeData);    }  }  if (success == false) {    *r_success = false;    zero_v3(r_location);    zero_v3(r_normal);    *r_index = -1;  }}
开发者ID:dfelinto,项目名称:blender,代码行数:68,


示例10: pointdensity_cache_psys

static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, ParticleSystem *psys){	DerivedMesh* dm;	ParticleKey state;	ParticleCacheKey *cache;	ParticleSimulationData sim= {NULL};	ParticleData *pa=NULL;	float cfra = BKE_scene_frame_get(re->scene);	int i /*, childexists*/ /* UNUSED */;	int total_particles, offset=0;	int data_used = point_data_used(pd);	float partco[3];	float obview[4][4];		/* init everything */	if (!psys || !ob || !pd) return;	mul_m4_m4m4(obview, ob->obmat, re->viewinv);		/* Just to create a valid rendering context for particles */	psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, 0);		dm = mesh_create_derived_render(re->scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL);		if ( !psys_check_enabled(ob, psys)) {		psys_render_restore(ob, psys);		return;	}		sim.scene= re->scene;	sim.ob= ob;	sim.psys= psys;	/* in case ob->imat isn't up-to-date */	invert_m4_m4(ob->imat, ob->obmat);		total_particles = psys->totpart+psys->totchild;	psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);		pd->point_tree = BLI_bvhtree_new(total_particles, 0.0, 4, 6);	alloc_point_data(pd, total_particles, data_used);	pd->totpoints = total_particles;	if (data_used & POINT_DATA_VEL) offset = pd->totpoints*3;	#if 0 /* UNUSED */	if (psys->totchild > 0 && !(psys->part->draw & PART_DRAW_PARENT))		childexists = 1;#endif	for (i=0, pa=psys->particles; i < total_particles; i++, pa++) {		if (psys->part->type == PART_HAIR) {			/* hair particles */			if (i < psys->totpart && psys->pathcache)				cache = psys->pathcache[i];			else if (i >= psys->totpart && psys->childcache)				cache = psys->childcache[i - psys->totpart];			else				continue;			cache += cache->segments; /* use endpoint */			copy_v3_v3(state.co, cache->co);			zero_v3(state.vel);			state.time = 0.0f;		}		else {			/* emitter particles */			state.time = cfra;			if (!psys_get_particle_state(&sim, i, &state, 0))				continue;			if (data_used & POINT_DATA_LIFE) {				if (i < psys->totpart) {					state.time = (cfra - pa->time)/pa->lifetime;				}				else {					ChildParticle *cpa= (psys->child + i) - psys->totpart;					float pa_birthtime, pa_dietime;										state.time = psys_get_child_time(psys, cpa, cfra, &pa_birthtime, &pa_dietime);				}			}		}		copy_v3_v3(partco, state.co);				if (pd->psys_cache_space == TEX_PD_OBJECTSPACE)			mul_m4_v3(ob->imat, partco);		else if (pd->psys_cache_space == TEX_PD_OBJECTLOC) {			sub_v3_v3(partco, ob->loc);		}		else {			/* TEX_PD_WORLDSPACE */		}				BLI_bvhtree_insert(pd->point_tree, i, partco, 1);				if (data_used & POINT_DATA_VEL) {//.........这里部分代码省略.........
开发者ID:akonneker,项目名称:blensor,代码行数:101,


示例11: initFlyInfo

static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent *event){	wmWindow *win = CTX_wm_window(C);	rctf viewborder;	float upvec[3]; /* tmp */	float mat[3][3];	fly->rv3d = CTX_wm_region_view3d(C);	fly->v3d = CTX_wm_view3d(C);	fly->ar = CTX_wm_region(C);	fly->scene = CTX_data_scene(C);#ifdef NDOF_FLY_DEBUG	puts("/n-- fly begin --");#endif	/* sanity check: for rare but possible case (if lib-linking the camera fails) */	if ((fly->rv3d->persp == RV3D_CAMOB) && (fly->v3d->camera == NULL)) {		fly->rv3d->persp = RV3D_PERSP;	}	if (fly->rv3d->persp == RV3D_CAMOB && ID_IS_LINKED(fly->v3d->camera)) {		BKE_report(op->reports, RPT_ERROR, "Cannot fly a camera from an external library");		return false;	}	if (ED_view3d_offset_lock_check(fly->v3d, fly->rv3d)) {		BKE_report(op->reports, RPT_ERROR, "Cannot fly when the view offset is locked");		return false;	}	if (fly->rv3d->persp == RV3D_CAMOB && fly->v3d->camera->constraints.first) {		BKE_report(op->reports, RPT_ERROR, "Cannot fly an object with constraints");		return false;	}	fly->state = FLY_RUNNING;	fly->speed = 0.0f;	fly->axis = 2;	fly->pan_view = false;	fly->xlock = FLY_AXISLOCK_STATE_OFF;	fly->zlock = FLY_AXISLOCK_STATE_OFF;	fly->xlock_momentum = 0.0f;	fly->zlock_momentum = 0.0f;	fly->grid = 1.0f;	fly->use_precision = false;	fly->use_freelook = false;#ifdef NDOF_FLY_DRAW_TOOMUCH	fly->redraw = 1;#endif	zero_v3(fly->dvec_prev);	fly->timer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, 0.01f);	copy_v2_v2_int(fly->mval, event->mval);#ifdef WITH_INPUT_NDOF	fly->ndof = NULL;#endif	fly->time_lastdraw = fly->time_lastwheel = PIL_check_seconds_timer();	fly->draw_handle_pixel = ED_region_draw_cb_activate(fly->ar->type, drawFlyPixel, fly, REGION_DRAW_POST_PIXEL);	fly->rv3d->rflag |= RV3D_NAVIGATING;	/* detect whether to start with Z locking */	copy_v3_fl3(upvec, 1.0f, 0.0f, 0.0f);	copy_m3_m4(mat, fly->rv3d->viewinv);	mul_m3_v3(mat, upvec);	if (fabsf(upvec[2]) < 0.1f) {		fly->zlock = FLY_AXISLOCK_STATE_IDLE;	}	fly->v3d_camera_control = ED_view3d_cameracontrol_acquire(	        fly->scene, fly->v3d, fly->rv3d,	        (U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);	/* calculate center */	if (fly->scene->camera) {		ED_view3d_calc_camera_border(fly->scene, fly->ar, fly->v3d, fly->rv3d, &viewborder, false);		fly->width = BLI_rctf_size_x(&viewborder);		fly->height = BLI_rctf_size_y(&viewborder);		fly->center_mval[0] = viewborder.xmin + fly->width / 2;		fly->center_mval[1] = viewborder.ymin + fly->height / 2;	}	else {		fly->width = fly->ar->winx;		fly->height = fly->ar->winy;		fly->center_mval[0] = fly->width / 2;		fly->center_mval[1] = fly->height / 2;	}	/* center the mouse, probably the UI mafia are against this but without its quite annoying */	WM_cursor_warp(win, fly->ar->winrct.xmin + fly->center_mval[0], fly->ar->winrct.ymin + fly->center_mval[1]);//.........这里部分代码省略.........
开发者ID:Ichthyostega,项目名称:blender,代码行数:101,


示例12: recalc_face_normals_find_index

/** * /return a face index in /a faces and set /a r_is_flip * if the face is flipped away from the center. */static int recalc_face_normals_find_index(BMesh *bm,                                          BMFace **faces,                                          const int faces_len,                                          bool *r_is_flip){  const float eps = FLT_EPSILON;  float cent_area_accum = 0.0f;  float cent[3];  const float cent_fac = 1.0f / (float)faces_len;  bool is_flip = false;  int f_start_index;  int i;  /** Search for the best loop. Members are compared in-order defined here. */  struct {    /**     * Squared distance from the center to the loops vertex 'l->v'.     * The normalized direction between the center and this vertex     * is also used for the dot-products below.     */    float dist_sq;    /**     * Signed dot product using the normalized edge vector,     * (best of 'l->prev->v' or 'l->next->v').     */    float edge_dot;    /**     * Unsigned dot product using the loop-normal     * (sign is used to check if we need to flip).     */    float loop_dot;  } best, test;  UNUSED_VARS_NDEBUG(bm);  zero_v3(cent);  /* first calculate the center */  for (i = 0; i < faces_len; i++) {    float f_cent[3];    const float f_area = BM_face_calc_area(faces[i]);    BM_face_calc_center_median_weighted(faces[i], f_cent);    madd_v3_v3fl(cent, f_cent, cent_fac * f_area);    cent_area_accum += f_area;    BLI_assert(BMO_face_flag_test(bm, faces[i], FACE_TEMP) == 0);    BLI_assert(BM_face_is_normal_valid(faces[i]));  }  if (cent_area_accum != 0.0f) {    mul_v3_fl(cent, 1.0f / cent_area_accum);  }  /* Distances must start above zero,   * or we can't do meaningful calculations based on the direction to the center */  best.dist_sq = eps;  best.edge_dot = best.loop_dot = -FLT_MAX;  /* used in degenerate cases only */  f_start_index = 0;  /**   * Find the outer-most vertex, comparing distance to the center,   * then the outer-most loop attached to that vertex.   *   * Important this is correctly detected,   * where casting a ray from the center wont hit any loops past this one.   * Otherwise the result may be incorrect.   */  for (i = 0; i < faces_len; i++) {    BMLoop *l_iter, *l_first;    l_iter = l_first = BM_FACE_FIRST_LOOP(faces[i]);    do {      bool is_best_dist_sq;      float dir[3];      sub_v3_v3v3(dir, l_iter->v->co, cent);      test.dist_sq = len_squared_v3(dir);      is_best_dist_sq = (test.dist_sq > best.dist_sq);      if (is_best_dist_sq || (test.dist_sq == best.dist_sq)) {        float edge_dir_pair[2][3];        mul_v3_fl(dir, 1.0f / sqrtf(test.dist_sq));        sub_v3_v3v3(edge_dir_pair[0], l_iter->next->v->co, l_iter->v->co);        sub_v3_v3v3(edge_dir_pair[1], l_iter->prev->v->co, l_iter->v->co);        if ((normalize_v3(edge_dir_pair[0]) > eps) && (normalize_v3(edge_dir_pair[1]) > eps)) {          bool is_best_edge_dot;          test.edge_dot = max_ff(dot_v3v3(dir, edge_dir_pair[0]), dot_v3v3(dir, edge_dir_pair[1]));          is_best_edge_dot = (test.edge_dot > best.edge_dot);          if (is_best_dist_sq || is_best_edge_dot || (test.edge_dot == best.edge_dot)) {            float loop_dir[3];            cross_v3_v3v3(loop_dir, edge_dir_pair[0], edge_dir_pair[1]);            if (normalize_v3(loop_dir) > eps) {              float loop_dir_dot;//.........这里部分代码省略.........
开发者ID:dfelinto,项目名称:blender,代码行数:101,


示例13: boid_brain

/* determines the velocity the boid wants to have */void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa){	BoidRule *rule;	BoidSettings *boids = bbd->part->boids;	BoidValues val;	BoidState *state = get_boid_state(boids, pa);	BoidParticle *bpa = pa->boid;	ParticleSystem *psys = bbd->sim->psys;	int rand;	//BoidCondition *cond;	if (bpa->data.health <= 0.0f) {		pa->alive = PARS_DYING;		pa->dietime = bbd->cfra;		return;	}	//planned for near future	//cond = state->conditions.first;	//for (; cond; cond=cond->next) {	//	if (boid_condition_is_true(cond)) {	//		pa->boid->state_id = cond->state_id;	//		state = get_boid_state(boids, pa);	//		break; /* only first true condition is used */	//	}	//}	zero_v3(bbd->wanted_co);	bbd->wanted_speed = 0.0f;	/* create random seed for every particle & frame */	rand = (int)(psys_frand(psys, psys->seed + p) * 1000);	rand = (int)(psys_frand(psys, (int)bbd->cfra + rand) * 1000);	set_boid_values(&val, bbd->part->boids, pa);	/* go through rules */	switch (state->ruleset_type) {		case eBoidRulesetType_Fuzzy:		{			for (rule = state->rules.first; rule; rule = rule->next) {				if (apply_boid_rule(bbd, rule, &val, pa, state->rule_fuzziness))					break; /* only first nonzero rule that comes through fuzzy rule is applied */			}			break;		}		case eBoidRulesetType_Random:		{			/* use random rule for each particle (always same for same particle though) */			rule = BLI_findlink(&state->rules, rand % BLI_listbase_count(&state->rules));			apply_boid_rule(bbd, rule, &val, pa, -1.0);			break;		}		case eBoidRulesetType_Average:		{			float wanted_co[3] = {0.0f, 0.0f, 0.0f}, wanted_speed = 0.0f;			int n = 0;			for (rule = state->rules.first; rule; rule=rule->next) {				if (apply_boid_rule(bbd, rule, &val, pa, -1.0f)) {					add_v3_v3(wanted_co, bbd->wanted_co);					wanted_speed += bbd->wanted_speed;					n++;					zero_v3(bbd->wanted_co);					bbd->wanted_speed = 0.0f;				}			}			if (n > 1) {				mul_v3_fl(wanted_co, 1.0f/(float)n);				wanted_speed /= (float)n;			}			copy_v3_v3(bbd->wanted_co, wanted_co);			bbd->wanted_speed = wanted_speed;			break;		}	}	/* decide on jumping & liftoff */	if (bpa->data.mode == eBoidMode_OnLand) {		/* fuzziness makes boids capable of misjudgement */		float mul = 1.0f + state->rule_fuzziness;				if (boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f) {			float cvel[3], dir[3];			copy_v3_v3(dir, pa->prev_state.ave);			normalize_v2(dir);			copy_v3_v3(cvel, bbd->wanted_co);			normalize_v2(cvel);			if (dot_v2v2(cvel, dir) > 0.95f / mul)				bpa->data.mode = eBoidMode_Liftoff;		}		else if (val.jump_speed > 0.0f) {			float jump_v[3];//.........这里部分代码省略.........
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:101,


示例14: walkApply

//.........这里部分代码省略.........				if (moffset[0]) {					float x;					/* if we're upside down invert the moffset */					copy_v3_fl3(upvec, 0.0f, 1.0f, 0.0f);					mul_m3_v3(mat, upvec);					if (upvec[2] < 0.0f)						moffset[0] = -moffset[0];					/* relative offset */					x = (float) moffset[0] / ar->winx;					/* speed factor */					x *= WALK_ROTATE_FAC;					/* user adjustement factor */					x *= walk->mouse_speed;					copy_v3_fl3(upvec, 0.0f, 0.0f, 1.0f);					/* Rotate about the relative up vec */					axis_angle_normalized_to_quat(tmp_quat, upvec, x);					mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat);				}			}			/* WASD - 'move' translation code */			if ((walk->active_directions) &&			    (walk->gravity_state == WALK_GRAVITY_STATE_OFF))			{				short direction;				zero_v3(dvec);				if ((walk->active_directions & WALK_BIT_FORWARD) ||				    (walk->active_directions & WALK_BIT_BACKWARD))				{					direction = 0;					if ((walk->active_directions & WALK_BIT_FORWARD))						direction += 1;					if ((walk->active_directions & WALK_BIT_BACKWARD))						direction -= 1;					copy_v3_fl3(dvec_tmp, 0.0f, 0.0f, direction);					mul_m3_v3(mat, dvec_tmp);					if (walk->navigation_mode == WALK_MODE_GRAVITY) {						dvec_tmp[2] = 0.0f;					}					normalize_v3(dvec_tmp);					add_v3_v3(dvec, dvec_tmp);				}				if ((walk->active_directions & WALK_BIT_LEFT) ||				    (walk->active_directions & WALK_BIT_RIGHT))				{					direction = 0;					if ((walk->active_directions & WALK_BIT_LEFT))
开发者ID:Bforartists,项目名称:Bforartists,代码行数:67,


示例15: apply_objects_internal

//.........这里部分代码省略.........		}		/* apply to object data */		if (ob->type == OB_MESH) {			Mesh *me = ob->data;			MVert *mvert;			multiresModifier_scale_disp(scene, ob);						/* adjust data */			mvert = me->mvert;			for (a = 0; a < me->totvert; a++, mvert++)				mul_m4_v3(mat, mvert->co);						if (me->key) {				KeyBlock *kb;								for (kb = me->key->block.first; kb; kb = kb->next) {					float *fp = kb->data;										for (a = 0; a < kb->totelem; a++, fp += 3)						mul_m4_v3(mat, fp);				}			}						/* update normals */			BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL);		}		else if (ob->type == OB_ARMATURE) {			ED_armature_apply_transform(ob, mat);		}		else if (ob->type == OB_LATTICE) {			Lattice *lt = ob->data;			BPoint *bp = lt->def;			int a = lt->pntsu * lt->pntsv * lt->pntsw;						while (a--) {				mul_m4_v3(mat, bp->vec);				bp++;			}		}		else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {			Curve *cu = ob->data;			Nurb *nu;			BPoint *bp;			BezTriple *bezt;			scale = mat3_to_scale(rsmat);			for (nu = cu->nurb.first; nu; nu = nu->next) {				if (nu->type == CU_BEZIER) {					a = nu->pntsu;					for (bezt = nu->bezt; a--; bezt++) {						mul_m4_v3(mat, bezt->vec[0]);						mul_m4_v3(mat, bezt->vec[1]);						mul_m4_v3(mat, bezt->vec[2]);						bezt->radius *= scale;					}					BKE_nurb_handles_calc(nu);				}				else {					a = nu->pntsu * nu->pntsv;					for (bp = nu->bp; a--; bp++)						mul_m4_v3(mat, bp->vec);				}			}		}		else			continue;		if (apply_loc)			zero_v3(ob->loc);		if (apply_scale)			ob->size[0] = ob->size[1] = ob->size[2] = 1.0f;		if (apply_rot) {			zero_v3(ob->rot);			unit_qt(ob->quat);			unit_axis_angle(ob->rotAxis, &ob->rotAngle);		}		BKE_object_where_is_calc(scene, ob);		if (ob->type == OB_ARMATURE) {			BKE_pose_where_is(scene, ob); /* needed for bone parents */		}		ignore_parent_tx(bmain, scene, ob);		DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);		change = 1;	}	CTX_DATA_END;	if (!change)		return OPERATOR_CANCELLED;	WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);	return OPERATOR_FINISHED;}
开发者ID:vanangamudi,项目名称:blender-main,代码行数:101,


示例16: do_physical_effector

//.........这里部分代码省略.........				cross_v3_v3v3(force, efd->nor2, temp);				mul_v3_fl(force, strength * efd->falloff);								madd_v3_v3fl(temp, point->vel, -point->vel_to_sec);				add_v3_v3(force, temp);			}			break;		case PFIELD_MAGNET:			if (eff->pd->shape == PFIELD_SHAPE_POINT)				/* magnetic field of a moving charge */				cross_v3_v3v3(temp, efd->nor, efd->vec_to_point);			else				copy_v3_v3(temp, efd->nor);			normalize_v3(temp);			mul_v3_fl(temp, strength * efd->falloff);			cross_v3_v3v3(force, point->vel, temp);			mul_v3_fl(force, point->vel_to_sec);			break;		case PFIELD_HARMONIC:			mul_v3_fl(force, -strength * efd->falloff);			copy_v3_v3(temp, point->vel);			mul_v3_fl(temp, -damp * 2.0f * sqrtf(fabsf(strength)) * point->vel_to_sec);			add_v3_v3(force, temp);			break;		case PFIELD_CHARGE:			mul_v3_fl(force, point->charge * strength * efd->falloff);			break;		case PFIELD_LENNARDJ:			fac = pow((efd->size + point->size) / efd->distance, 6.0);						fac = - fac * (1.0f - fac) / efd->distance;			/* limit the repulsive term drastically to avoid huge forces */			fac = ((fac>2.0f) ? 2.0f : fac);			mul_v3_fl(force, strength * fac);			break;		case PFIELD_BOID:			/* Boid field is handled completely in boids code. */			return;		case PFIELD_TURBULENCE:			if (pd->flag & PFIELD_GLOBAL_CO) {				copy_v3_v3(temp, point->loc);			}			else {				add_v3_v3v3(temp, efd->vec_to_point2, efd->nor2);			}			force[0] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[0], temp[1], temp[2], 2, 0, 2);			force[1] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[1], temp[2], temp[0], 2, 0, 2);			force[2] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[2], temp[0], temp[1], 2, 0, 2);			mul_v3_fl(force, strength * efd->falloff);			break;		case PFIELD_DRAG:			copy_v3_v3(force, point->vel);			fac = normalize_v3(force) * point->vel_to_sec;			strength = MIN2(strength, 2.0f);			damp = MIN2(damp, 2.0f);			mul_v3_fl(force, -efd->falloff * fac * (strength * fac + damp));			break;		case PFIELD_SMOKEFLOW:			zero_v3(force);			if (pd->f_source) {				float density;				if ((density = smoke_get_velocity_at(pd->f_source, point->loc, force)) >= 0.0f) {					float influence = strength * efd->falloff;					if (pd->flag & PFIELD_SMOKE_DENSITY)						influence *= density;					mul_v3_fl(force, influence);					/* apply flow */					madd_v3_v3fl(total_force, point->vel, -pd->f_flow * influence);				}			}			break;	}	if (pd->flag & PFIELD_DO_LOCATION) {		madd_v3_v3fl(total_force, force, 1.0f/point->vel_to_sec);		if (ELEM(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG, PFIELD_SMOKEFLOW)==0 && pd->f_flow != 0.0f) {			madd_v3_v3fl(total_force, point->vel, -pd->f_flow * efd->falloff);		}	}	if (point->ave)		zero_v3(point->ave);	if (pd->flag & PFIELD_DO_ROTATION && point->ave && point->rot) {		float xvec[3] = {1.0f, 0.0f, 0.0f};		float dave[3];		mul_qt_v3(point->rot, xvec);		cross_v3_v3v3(dave, xvec, force);		if (pd->f_flow != 0.0f) {			madd_v3_v3fl(dave, point->ave, -pd->f_flow * efd->falloff);		}		add_v3_v3(point->ave, dave);	}}
开发者ID:Rojuinex,项目名称:Blender,代码行数:101,


示例17: object_clear_rot

/* clear rotation of object */static void object_clear_rot(Object *ob){	/* clear rotations that aren't locked */	if (ob->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) {		if (ob->protectflag & OB_LOCK_ROT4D) {			/* perform clamping on a component by component basis */			if (ob->rotmode == ROT_MODE_AXISANGLE) {				if ((ob->protectflag & OB_LOCK_ROTW) == 0)					ob->rotAngle= ob->drotAngle= 0.0f;				if ((ob->protectflag & OB_LOCK_ROTX) == 0)					ob->rotAxis[0]= ob->drotAxis[0]= 0.0f;				if ((ob->protectflag & OB_LOCK_ROTY) == 0)					ob->rotAxis[1]= ob->drotAxis[1]= 0.0f;				if ((ob->protectflag & OB_LOCK_ROTZ) == 0)					ob->rotAxis[2]= ob->drotAxis[2]= 0.0f;									/* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */				if (IS_EQF(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQF(ob->rotAxis[1], ob->rotAxis[2]))					ob->rotAxis[1] = 1.0f;				if (IS_EQF(ob->drotAxis[0], ob->drotAxis[1]) && IS_EQF(ob->drotAxis[1], ob->drotAxis[2]))					ob->drotAxis[1]= 1.0f;			}			else if (ob->rotmode == ROT_MODE_QUAT) {				if ((ob->protectflag & OB_LOCK_ROTW) == 0)					ob->quat[0]= ob->dquat[0]= 1.0f;				if ((ob->protectflag & OB_LOCK_ROTX) == 0)					ob->quat[1]= ob->dquat[1]= 0.0f;				if ((ob->protectflag & OB_LOCK_ROTY) == 0)					ob->quat[2]= ob->dquat[2]= 0.0f;				if ((ob->protectflag & OB_LOCK_ROTZ) == 0)					ob->quat[3]= ob->dquat[3]= 0.0f;									// TODO: does this quat need normalising now?			}			else {				/* the flag may have been set for the other modes, so just ignore the extra flag... */				if ((ob->protectflag & OB_LOCK_ROTX) == 0)					ob->rot[0]= ob->drot[0]= 0.0f;				if ((ob->protectflag & OB_LOCK_ROTY) == 0)					ob->rot[1]= ob->drot[1]= 0.0f;				if ((ob->protectflag & OB_LOCK_ROTZ) == 0)					ob->rot[2]= ob->drot[2]= 0.0f;			}		}		else {			/* perform clamping using euler form (3-components) */			// FIXME: deltas are not handled for these cases yet...			float eul[3], oldeul[3], quat1[4] = {0};						if (ob->rotmode == ROT_MODE_QUAT) {				copy_qt_qt(quat1, ob->quat);				quat_to_eul(oldeul, ob->quat);			}			else if (ob->rotmode == ROT_MODE_AXISANGLE) {				axis_angle_to_eulO(oldeul, EULER_ORDER_DEFAULT, ob->rotAxis, ob->rotAngle);			}			else {				copy_v3_v3(oldeul, ob->rot);			}						eul[0]= eul[1]= eul[2]= 0.0f;						if (ob->protectflag & OB_LOCK_ROTX)				eul[0]= oldeul[0];			if (ob->protectflag & OB_LOCK_ROTY)				eul[1]= oldeul[1];			if (ob->protectflag & OB_LOCK_ROTZ)				eul[2]= oldeul[2];						if (ob->rotmode == ROT_MODE_QUAT) {				eul_to_quat(ob->quat, eul);				/* quaternions flip w sign to accumulate rotations correctly */				if ((quat1[0]<0.0f && ob->quat[0]>0.0f) || (quat1[0]>0.0f && ob->quat[0]<0.0f)) {					mul_qt_fl(ob->quat, -1.0f);				}			}			else if (ob->rotmode == ROT_MODE_AXISANGLE) {				eulO_to_axis_angle(ob->rotAxis, &ob->rotAngle,eul, EULER_ORDER_DEFAULT);			}			else {				copy_v3_v3(ob->rot, eul);			}		}	}						 // Duplicated in source/blender/editors/armature/editarmature.c	else { 		if (ob->rotmode == ROT_MODE_QUAT) {			unit_qt(ob->quat);			unit_qt(ob->dquat);		}		else if (ob->rotmode == ROT_MODE_AXISANGLE) {			unit_axis_angle(ob->rotAxis, &ob->rotAngle);			unit_axis_angle(ob->drotAxis, &ob->drotAngle);		}		else {			zero_v3(ob->rot);			zero_v3(ob->drot);		}	}}
开发者ID:mik0001,项目名称:Blender,代码行数:100,


示例18: rotateDifferentialCoordinates

static void rotateDifferentialCoordinates(LaplacianSystem *sys){	float alpha, beta, gamma;	float pj[3], ni[3], di[3];	float uij[3], dun[3], e2[3], pi[3], fni[3], vn[4][3];	int i, j, lvin, num_fni, k, fi;	int *fidn;	for (i = 0; i < sys->total_verts; i++) {		copy_v3_v3(pi, sys->co[i]);		copy_v3_v3(ni, sys->no[i]);		k = sys->unit_verts[i];		copy_v3_v3(pj, sys->co[k]);		sub_v3_v3v3(uij, pj, pi);		mul_v3_v3fl(dun, ni, dot_v3v3(uij, ni));		sub_v3_v3(uij, dun);		normalize_v3(uij);		cross_v3_v3v3(e2, ni, uij);		copy_v3_v3(di, sys->delta[i]);		alpha = dot_v3v3(ni, di);		beta = dot_v3v3(uij, di);		gamma = dot_v3v3(e2, di);		pi[0] = nlGetVariable(0, i);		pi[1] = nlGetVariable(1, i);		pi[2] = nlGetVariable(2, i);		zero_v3(ni);		num_fni = 0;		num_fni = sys->ringf_map[i].count;		for (fi = 0; fi < num_fni; fi++) {			const unsigned int *vin;			fidn = sys->ringf_map[i].indices;			vin = sys->faces[fidn[fi]];			lvin = vin[3] ? 4 : 3;			for (j = 0; j < lvin; j++) {				vn[j][0] = nlGetVariable(0, vin[j]);				vn[j][1] = nlGetVariable(1, vin[j]);				vn[j][2] = nlGetVariable(2, vin[j]);				if (vin[j] == sys->unit_verts[i]) {					copy_v3_v3(pj, vn[j]);				}			}			if (lvin == 3) {				normal_tri_v3(fni, vn[0], vn[1], vn[2]);			}			else if (lvin == 4) {				normal_quad_v3(fni, vn[0], vn[1], vn[2], vn[3]);			}			add_v3_v3(ni, fni);		}		normalize_v3(ni);		sub_v3_v3v3(uij, pj, pi);		mul_v3_v3fl(dun, ni, dot_v3v3(uij, ni));		sub_v3_v3(uij, dun);		normalize_v3(uij);		cross_v3_v3v3(e2, ni, uij);		fni[0] = alpha * ni[0] + beta * uij[0] + gamma * e2[0];		fni[1] = alpha * ni[1] + beta * uij[1] + gamma * e2[1];		fni[2] = alpha * ni[2] + beta * uij[2] + gamma * e2[2];		if (len_squared_v3(fni) > FLT_EPSILON) {			nlRightHandSideSet(0, i, fni[0]);			nlRightHandSideSet(1, i, fni[1]);			nlRightHandSideSet(2, i, fni[2]);		}		else {			nlRightHandSideSet(0, i, sys->delta[i][0]);			nlRightHandSideSet(1, i, sys->delta[i][1]);			nlRightHandSideSet(2, i, sys->delta[i][2]);		}	}}
开发者ID:YasirArafath,项目名称:blender-git,代码行数:74,


示例19: brush_defaults

static void brush_defaults(Brush *brush){	brush->blend = 0;	brush->flag = 0;	brush->ob_mode = OB_MODE_ALL_PAINT;	/* BRUSH SCULPT TOOL SETTINGS */	brush->weight = 1.0f; /* weight of brush 0 - 1.0 */	brush->size = 35; /* radius of the brush in pixels */	brush->alpha = 0.5f; /* brush strength/intensity probably variable should be renamed? */	brush->autosmooth_factor = 0.0f;	brush->crease_pinch_factor = 0.5f;	brush->sculpt_plane = SCULPT_DISP_DIR_AREA;	brush->plane_offset = 0.0f; /* how far above or below the plane that is found by averaging the faces */	brush->plane_trim = 0.5f;	brush->clone.alpha = 0.5f;	brush->normal_weight = 0.0f;	brush->fill_threshold = 0.2f;	brush->flag |= BRUSH_ALPHA_PRESSURE;	/* BRUSH PAINT TOOL SETTINGS */	brush->rgb[0] = 1.0f; /* default rgb color of the brush when painting - white */	brush->rgb[1] = 1.0f;	brush->rgb[2] = 1.0f;	zero_v3(brush->secondary_rgb);	/* BRUSH STROKE SETTINGS */	brush->flag |= (BRUSH_SPACE | BRUSH_SPACE_ATTEN);	brush->spacing = 10; /* how far each brush dot should be spaced as a percentage of brush diameter */	brush->smooth_stroke_radius = 75;	brush->smooth_stroke_factor = 0.9f;	brush->rate = 0.1f; /* time delay between dots of paint or sculpting when doing airbrush mode */	brush->jitter = 0.0f;	/* BRUSH TEXTURE SETTINGS */	BKE_texture_mtex_default(&brush->mtex);	BKE_texture_mtex_default(&brush->mask_mtex);	brush->texture_sample_bias = 0; /* value to added to texture samples */	brush->texture_overlay_alpha = 33;	brush->mask_overlay_alpha = 33;	brush->cursor_overlay_alpha = 33;	brush->overlay_flags = 0;	/* brush appearance  */	brush->add_col[0] = 1.00; /* add mode color is light red */	brush->add_col[1] = 0.39;	brush->add_col[2] = 0.39;	brush->sub_col[0] = 0.39; /* subtract mode color is light blue */	brush->sub_col[1] = 0.39;	brush->sub_col[2] = 1.00;	brush->stencil_pos[0] = 256;	brush->stencil_pos[1] = 256;	brush->stencil_dimension[0] = 256;	brush->stencil_dimension[1] = 256;}
开发者ID:wisaac407,项目名称:blender,代码行数:65,


示例20: BM_verts_sort_radial_plane

/** * Makes an NGon from an un-ordered set of verts * * assumes... * - that verts are only once in the list. * - that the verts have roughly planer bounds * - that the verts are roughly circular * there can be concave areas but overlapping folds from the center point will fail. * * a brief explanation of the method used * - find the center point * - find the normal of the vcloud * - order the verts around the face based on their angle to the normal vector at the center point. * * /note Since this is a vcloud there is no direction. */void BM_verts_sort_radial_plane(BMVert **vert_arr, int len){	struct SortIntByFloat *vang = BLI_array_alloca(vang, len);	BMVert **vert_arr_map = BLI_array_alloca(vert_arr_map, len);	float totv_inv = 1.0f / (float)len;	int i = 0;	float cent[3], nor[3];	const float *far = NULL, *far_cross = NULL;	float far_vec[3];	float far_cross_vec[3];	float sign_vec[3]; /* work out if we are pos/neg angle */	float far_dist_sq, far_dist_max_sq;	float far_cross_dist, far_cross_best = 0.0f;	/* get the center point and collect vector array since we loop over these a lot */	zero_v3(cent);	for (i = 0; i < len; i++) {		madd_v3_v3fl(cent, vert_arr[i]->co, totv_inv);	}	/* find the far point from cent */	far_dist_max_sq = 0.0f;	for (i = 0; i < len; i++) {		far_dist_sq = len_squared_v3v3(vert_arr[i]->co, cent);		if (far_dist_sq > far_dist_max_sq || far == NULL) {			far = vert_arr[i]->co;			far_dist_max_sq = far_dist_sq;		}	}	sub_v3_v3v3(far_vec, far, cent);	// far_dist = len_v3(far_vec); /* real dist */ /* UNUSED */	/* --- */	/* find a point 90deg about to compare with */	far_cross_best = 0.0f;	for (i = 0; i < len; i++) {		if (far == vert_arr[i]->co) {			continue;		}		sub_v3_v3v3(far_cross_vec, vert_arr[i]->co, cent);		far_cross_dist = normalize_v3(far_cross_vec);		/* more of a weight then a distance */		far_cross_dist = (/* first we want to have a value close to zero mapped to 1 */		                  1.0f - fabsf(dot_v3v3(far_vec, far_cross_vec)) *		                  /* second  we multiply by the distance		                   * so points close to the center are not preferred */		                  far_cross_dist);		if (far_cross_dist > far_cross_best || far_cross == NULL) {			far_cross = vert_arr[i]->co;			far_cross_best = far_cross_dist;		}	}	sub_v3_v3v3(far_cross_vec, far_cross, cent);	/* --- */	/* now we have 2 vectors we can have a cross product */	cross_v3_v3v3(nor, far_vec, far_cross_vec);	normalize_v3(nor);	cross_v3_v3v3(sign_vec, far_vec, nor); /* this vector should match 'far_cross_vec' closely */	/* --- */	/* now calculate every points angle around the normal (signed) */	for (i = 0; i < len; i++) {		vang[i].sort_value = angle_signed_on_axis_v3v3v3_v3(far, cent, vert_arr[i]->co, nor);		vang[i].data = i;		vert_arr_map[i] = vert_arr[i];	}//.........这里部分代码省略.........
开发者ID:bdancer,项目名称:blender-for-vray,代码行数:101,


示例21: snap_curs_to_sel_ex

static bool snap_curs_to_sel_ex(bContext *C, float cursor[3]){	Object *obedit = CTX_data_edit_object(C);	Scene *scene = CTX_data_scene(C);	View3D *v3d = CTX_wm_view3d(C);	TransVertStore tvs = {NULL};	TransVert *tv;	float bmat[3][3], vec[3], min[3], max[3], centroid[3];	int count, a;	count = 0;	INIT_MINMAX(min, max);	zero_v3(centroid);	if (obedit) {		if (ED_transverts_check_obedit(obedit))			ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS | TM_SKIP_HANDLES);		if (tvs.transverts_tot == 0) {			return false;		}		copy_m3_m4(bmat, obedit->obmat);				tv = tvs.transverts;		for (a = 0; a < tvs.transverts_tot; a++, tv++) {			copy_v3_v3(vec, tv->loc);			mul_m3_v3(bmat, vec);			add_v3_v3(vec, obedit->obmat[3]);			add_v3_v3(centroid, vec);			minmax_v3v3_v3(min, max, vec);		}				if (v3d->around == V3D_AROUND_CENTER_MEAN) {			mul_v3_fl(centroid, 1.0f / (float)tvs.transverts_tot);			copy_v3_v3(cursor, centroid);		}		else {			mid_v3_v3v3(cursor, min, max);		}		ED_transverts_free(&tvs);	}	else {		Object *obact = CTX_data_active_object(C);				if (obact && (obact->mode & OB_MODE_POSE)) {			bArmature *arm = obact->data;			bPoseChannel *pchan;			for (pchan = obact->pose->chanbase.first; pchan; pchan = pchan->next) {				if (arm->layer & pchan->bone->layer) {					if (pchan->bone->flag & BONE_SELECTED) {						copy_v3_v3(vec, pchan->pose_head);						mul_m4_v3(obact->obmat, vec);						add_v3_v3(centroid, vec);						minmax_v3v3_v3(min, max, vec);						count++;					}				}			}		}		else {			CTX_DATA_BEGIN (C, Object *, ob, selected_objects)			{				copy_v3_v3(vec, ob->obmat[3]);				/* special case for camera -- snap to bundles */				if (ob->type == OB_CAMERA) {					/* snap to bundles should happen only when bundles are visible */					if (v3d->flag2 & V3D_SHOW_RECONSTRUCTION) {						bundle_midpoint(scene, ob, vec);					}				}				add_v3_v3(centroid, vec);				minmax_v3v3_v3(min, max, vec);				count++;			}			CTX_DATA_END;		}		if (count == 0) {			return false;		}		if (v3d->around == V3D_AROUND_CENTER_MEAN) {			mul_v3_fl(centroid, 1.0f / (float)count);			copy_v3_v3(cursor, centroid);		}		else {			mid_v3_v3v3(cursor, min, max);		}	}
开发者ID:diekev,项目名称:blender,代码行数:94,


示例22: BLI_scanfill_calc_ex

unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float nor_proj[3]){	/*	 * - fill works with its own lists, so create that first (no faces!)	 * - for vertices, put in ->tmp.v the old pointer	 * - struct elements xs en ys are not used here: don't hide stuff in it	 * - edge flag ->f becomes 2 when it's a new edge	 * - mode: & 1 is check for crossings, then create edges (TO DO )	 * - returns number of triangle faces added.	 */	ListBase tempve, temped;	ScanFillVert *eve;	ScanFillEdge *eed, *eed_next;	PolyFill *pflist, *pf;	float *min_xy_p, *max_xy_p;	unsigned int totfaces = 0;  /* total faces added */	unsigned short a, c, poly = 0;	bool ok;	float mat_2d[3][3];	BLI_assert(!nor_proj || len_squared_v3(nor_proj) > FLT_EPSILON);#ifdef DEBUG	for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {		/* these values used to be set,		 * however they should always be zero'd so check instead */		BLI_assert(eve->f == 0);		BLI_assert(sf_ctx->poly_nr || eve->poly_nr == 0);		BLI_assert(eve->edge_tot == 0);	}#endif#if 0	if (flag & BLI_SCANFILL_CALC_QUADTRI_FASTPATH) {		const int totverts = BLI_countlist(&sf_ctx->fillvertbase);		if (totverts == 3) {			eve = sf_ctx->fillvertbase.first;			addfillface(sf_ctx, eve, eve->next, eve->next->next);			return 1;		}		else if (totverts == 4) {			float vec1[3], vec2[3];			eve = sf_ctx->fillvertbase.first;			/* no need to check 'eve->next->next->next' is valid, already counted */			/* use shortest diagonal for quad */			sub_v3_v3v3(vec1, eve->co, eve->next->next->co);			sub_v3_v3v3(vec2, eve->next->co, eve->next->next->next->co);			if (dot_v3v3(vec1, vec1) < dot_v3v3(vec2, vec2)) {				addfillface(sf_ctx, eve, eve->next, eve->next->next);				addfillface(sf_ctx, eve->next->next, eve->next->next->next, eve);			}			else {				addfillface(sf_ctx, eve->next, eve->next->next, eve->next->next->next);				addfillface(sf_ctx, eve->next->next->next, eve, eve->next);			}			return 2;		}	}#endif	/* first test vertices if they are in edges */	/* including resetting of flags */	for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {		BLI_assert(sf_ctx->poly_nr != SF_POLY_UNSET || eed->poly_nr == SF_POLY_UNSET);		eed->v1->f = SF_VERT_AVAILABLE;		eed->v2->f = SF_VERT_AVAILABLE;	}	for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {		if (eve->f == SF_VERT_AVAILABLE) {			break;		}	}	if (UNLIKELY(eve == NULL)) {		return 0;	}	else {		float n[3];		if (nor_proj) {			copy_v3_v3(n, nor_proj);		}		else {			/* define projection: with 'best' normal */			/* Newell's Method */			/* Similar code used elsewhere, but this checks for double ups			 * which historically this function supports so better not change */			/* warning: this only gives stable direction with single polygons,			 * ideally we'd calcualte connectivity and calculate each polys normal, see T41047 */			const float *v_prev;			zero_v3(n);			eve = sf_ctx->fillvertbase.last;			v_prev = eve->co;//.........这里部分代码省略.........
开发者ID:sftd,项目名称:blender,代码行数:101,


示例23: collision_response

static bool collision_response(ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair, float dt, float restitution, float r_impulse[3]){	Cloth *cloth = clmd->clothObject;	int index = collpair->ap1;	bool result = false;		float v1[3], v2_old[3], v2_new[3], v_rel_old[3], v_rel_new[3];	float epsilon2 = BLI_bvhtree_get_epsilon(collmd->bvhtree);	float margin_distance = (float)collpair->distance - epsilon2;	float mag_v_rel;		zero_v3(r_impulse);		if (margin_distance > 0.0f)		return false; /* XXX tested before already? */		/* only handle static collisions here */	if ( collpair->flag & COLLISION_IN_FUTURE )		return false;		/* velocity */	copy_v3_v3(v1, cloth->verts[index].v);	collision_get_collider_velocity(v2_old, v2_new, collmd, collpair);	/* relative velocity = velocity of the cloth point relative to the collider */	sub_v3_v3v3(v_rel_old, v1, v2_old);	sub_v3_v3v3(v_rel_new, v1, v2_new);	/* normal component of the relative velocity */	mag_v_rel = dot_v3v3(v_rel_old, collpair->normal);		/* only valid when moving toward the collider */	if (mag_v_rel < -ALMOST_ZERO) {		float v_nor_old, v_nor_new;		float v_tan_old[3], v_tan_new[3];		float bounce, repulse;				/* Collision response based on		 * "Simulating Complex Hair with Robust Collision Handling" (Choe, Choi, Ko, ACM SIGGRAPH 2005)		 * http://graphics.snu.ac.kr/publications/2005-choe-HairSim/Choe_2005_SCA.pdf		 */				v_nor_old = mag_v_rel;		v_nor_new = dot_v3v3(v_rel_new, collpair->normal);				madd_v3_v3v3fl(v_tan_old, v_rel_old, collpair->normal, -v_nor_old);		madd_v3_v3v3fl(v_tan_new, v_rel_new, collpair->normal, -v_nor_new);				bounce = -v_nor_old * restitution;				repulse = -margin_distance / dt; /* base repulsion velocity in normal direction */		/* XXX this clamping factor is quite arbitrary ...		 * not sure if there is a more scientific approach, but seems to give good results		 */		CLAMP(repulse, 0.0f, 4.0f * bounce);				if (margin_distance < -epsilon2) {			mul_v3_v3fl(r_impulse, collpair->normal, max_ff(repulse, bounce) - v_nor_new);		}		else {			bounce = 0.0f;			mul_v3_v3fl(r_impulse, collpair->normal, repulse - v_nor_new);		}				result = true;	}		return result;}
开发者ID:diekev,项目名称:blender,代码行数:68,


示例24: initWalkInfo

static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op){	wmWindow *win = CTX_wm_window(C);	walk->rv3d = CTX_wm_region_view3d(C);	walk->v3d = CTX_wm_view3d(C);	walk->ar = CTX_wm_region(C);	walk->scene = CTX_data_scene(C);#ifdef NDOF_WALK_DEBUG	puts("/n-- walk begin --");#endif	/* sanity check: for rare but possible case (if lib-linking the camera fails) */	if ((walk->rv3d->persp == RV3D_CAMOB) && (walk->v3d->camera == NULL)) {		walk->rv3d->persp = RV3D_PERSP;	}	if (walk->rv3d->persp == RV3D_CAMOB && walk->v3d->camera->id.lib) {		BKE_report(op->reports, RPT_ERROR, "Cannot navigate a camera from an external library");		return false;	}	if (ED_view3d_offset_lock_check(walk->v3d, walk->rv3d)) {		BKE_report(op->reports, RPT_ERROR, "Cannot navigate when the view offset is locked");		return false;	}	if (walk->rv3d->persp == RV3D_CAMOB && walk->v3d->camera->constraints.first) {		BKE_report(op->reports, RPT_ERROR, "Cannot navigate an object with constraints");		return false;	}	walk->state = WALK_RUNNING;	if (fabsf(U.walk_navigation.walk_speed - userdef_speed) > 0.1f) {		base_speed = U.walk_navigation.walk_speed;		userdef_speed = U.walk_navigation.walk_speed;	}	walk->speed = 0.0f;	walk->is_fast = false;	walk->is_slow = false;	walk->grid = (walk->scene->unit.system == USER_UNIT_NONE) ? 1.f : 1.f / walk->scene->unit.scale_length;	/* user preference settings */	walk->teleport.duration = U.walk_navigation.teleport_time;	walk->mouse_speed = U.walk_navigation.mouse_speed;	if ((U.walk_navigation.flag & USER_WALK_GRAVITY))		walk_navigation_mode_set(C, op, walk, WALK_MODE_GRAVITY);	else		walk_navigation_mode_set(C, op, walk, WALK_MODE_FREE);	walk->view_height = U.walk_navigation.view_height;	walk->jump_height = U.walk_navigation.jump_height;	walk->speed = U.walk_navigation.walk_speed;	walk->speed_factor = U.walk_navigation.walk_speed_factor;	walk->gravity_state = WALK_GRAVITY_STATE_OFF;	if ((walk->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY)) {		walk->gravity = fabsf(walk->scene->physics_settings.gravity[2]);	}	else {		walk->gravity = 9.80668f; /* m/s2 */	}	walk->is_reversed = ((U.walk_navigation.flag & USER_WALK_MOUSE_REVERSE) != 0);#ifdef USE_TABLET_SUPPORT	walk->is_cursor_first = true;	walk->is_cursor_absolute = false;#endif	walk->active_directions = 0;#ifdef NDOF_WALK_DRAW_TOOMUCH	walk->redraw = 1;#endif	zero_v3(walk->dvec_prev);	walk->timer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, 0.01f);	walk->ndof = NULL;	walk->time_lastdraw = PIL_check_seconds_timer();	walk->draw_handle_pixel = ED_region_draw_cb_activate(walk->ar->type, drawWalkPixel, walk, REGION_DRAW_POST_PIXEL);	walk->rv3d->rflag |= RV3D_NAVIGATING;	walk->v3d_camera_control = ED_view3d_cameracontrol_acquire(	        walk->scene, walk->v3d, walk->rv3d,	        (U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);	/* center the mouse */	walk->center_mval[0] = walk->ar->winx * 0.5f;//.........这里部分代码省略.........
开发者ID:Bforartists,项目名称:Bforartists,代码行数:101,


示例25: zero_v3

/* XXX this is nasty: cloth meshes do not explicitly store * the order of hair segments! * We have to rely on the spring build function for now, * which adds structural springs in reverse order: *   (3,4), (2,3), (1,2) * This is currently the only way to figure out hair geometry inside this code ... */static LinkNode *cloth_continuum_add_hair_segments(HairGrid *grid, const float cell_scale, const float cell_offset[3], Cloth *cloth, LinkNode *spring_link){	Implicit_Data *data = cloth->implicit;	LinkNode *next_spring_link = NULL; /* return value */	ClothSpring *spring1, *spring2, *spring3;	// ClothVertex *verts = cloth->verts;	// ClothVertex *vert3, *vert4;	float x1[3], v1[3], x2[3], v2[3], x3[3], v3[3], x4[3], v4[3];	float dir1[3], dir2[3], dir3[3];		spring1 = NULL;	spring2 = NULL;	spring3 = (ClothSpring *)spring_link->link;		zero_v3(x1); zero_v3(v1);	zero_v3(dir1);	zero_v3(x2); zero_v3(v2);	zero_v3(dir2);		// vert3 = &verts[spring3->kl];	cloth_get_grid_location(data, cell_scale, cell_offset, spring3->kl, x3, v3);	// vert4 = &verts[spring3->ij];	cloth_get_grid_location(data, cell_scale, cell_offset, spring3->ij, x4, v4);	sub_v3_v3v3(dir3, x4, x3);	normalize_v3(dir3);		while (spring_link) {		/* move on */		spring1 = spring2;		spring2 = spring3;				// vert3 = vert4;				copy_v3_v3(x1, x2); copy_v3_v3(v1, v2);		copy_v3_v3(x2, x3); copy_v3_v3(v2, v3);		copy_v3_v3(x3, x4); copy_v3_v3(v3, v4);				copy_v3_v3(dir1, dir2);		copy_v3_v3(dir2, dir3);				/* read next segment */		next_spring_link = spring_link->next;		spring_link = hair_spring_next(spring_link);				if (spring_link) {			spring3 = (ClothSpring *)spring_link->link;			// vert4 = &verts[spring3->ij];			cloth_get_grid_location(data, cell_scale, cell_offset, spring3->ij, x4, v4);			sub_v3_v3v3(dir3, x4, x3);			normalize_v3(dir3);		}		else {			spring3 = NULL;			// vert4 = NULL;			zero_v3(x4); zero_v3(v4);			zero_v3(dir3);		}				BPH_hair_volume_add_segment(grid, x1, v1, x2, v2, x3, v3, x4, v4,		                            spring1 ? dir1 : NULL,		                            dir2,		                            spring3 ? dir3 : NULL);	}		return next_spring_link;}
开发者ID:diekev,项目名称:blender,代码行数:73,


示例26: CalcSnapGeometry

static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)){	if (t->spacetype == SPACE_VIEW3D) {		float loc[3];		float no[3];		float mval[2];		bool found = false;		float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here				mval[0] = t->mval[0];		mval[1] = t->mval[1];				if (t->tsnap.mode == SCE_SNAP_MODE_VOLUME) {			found = peelObjectsTransform(			        t, mval,			        (t->settings->snap_flag & SCE_SNAP_PEEL_OBJECT) != 0,			        loc, no, NULL);		}		else {			zero_v3(no);  /* objects won't set this */			found = snapObjectsTransform(			        t, mval, &dist_px,			        loc, no);		}				if (found == true) {			copy_v3_v3(t->tsnap.snapPoint, loc);			copy_v3_v3(t->tsnap.snapNormal, no);			t->tsnap.status |=  POINT_INIT;		}		else {			t->tsnap.status &= ~POINT_INIT;		}	}	else if (t->spacetype == SPACE_IMAGE && t->obedit != NULL && t->obedit->type == OB_MESH) {		/* same as above but for UV's */		Image *ima = ED_space_image(t->sa->spacedata.first);		float co[2];				UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], &co[0], &co[1]);		if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) {			t->tsnap.snapPoint[0] *= t->aspect[0];			t->tsnap.snapPoint[1] *= t->aspect[1];			t->tsnap.status |=  POINT_INIT;		}		else {			t->tsnap.status &= ~POINT_INIT;		}	}	else if (t->spacetype == SPACE_NODE) {		float loc[2];		float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here		char node_border;				if (snapNodesTransform(t, t->mval, t->tsnap.modeSelect, loc, &dist_px, &node_border)) {			copy_v2_v2(t->tsnap.snapPoint, loc);			t->tsnap.snapNodeBorder = node_border;						t->tsnap.status |=  POINT_INIT;		}		else {			t->tsnap.status &= ~POINT_INIT;		}	}}
开发者ID:diekev,项目名称:blender,代码行数:68,



注:本文中的zero_v3函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ zeromem函数代码示例
C++ zero_user_segment函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。