• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ CLAMPIS函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: RE_set_customdata_names

void RE_set_customdata_names(ObjectRen *obr, CustomData *data)
{
	/* CustomData layer names are stored per object here, because the
	 * DerivedMesh which stores the layers is freed */
	
	CustomDataLayer *layer;
	int numtf = 0, numcol = 0, i, mtfn, mcn;

	if (CustomData_has_layer(data, CD_MTFACE)) {
		numtf= CustomData_number_of_layers(data, CD_MTFACE);
		obr->mtface= MEM_callocN(sizeof(*obr->mtface)*numtf, "mtfacenames");
	}

	if (CustomData_has_layer(data, CD_MCOL)) {
		numcol= CustomData_number_of_layers(data, CD_MCOL);
		obr->mcol= MEM_callocN(sizeof(*obr->mcol)*numcol, "mcolnames");
	}

	for (i=0, mtfn=0, mcn=0; i < data->totlayer; i++) {
		layer= &data->layers[i];

		if (layer->type == CD_MTFACE) {
			BLI_strncpy(obr->mtface[mtfn++], layer->name, sizeof(layer->name));
			obr->actmtface= CLAMPIS(layer->active_rnd, 0, numtf);
			obr->bakemtface= layer->active;
		}
		else if (layer->type == CD_MCOL) {
			BLI_strncpy(obr->mcol[mcn++], layer->name, sizeof(layer->name));
			obr->actmcol= CLAMPIS(layer->active_rnd, 0, numcol);
		}
	}
}
开发者ID:GeniaPenksik,项目名称:blender,代码行数:32,代码来源:renderdatabase.c


示例2: console_char_pick

int console_char_pick(struct SpaceConsole *sc, ARegion *ar, const int mval[2])
{
	int pos_pick = 0;
	void *mouse_pick = NULL;
	int mval_clamp[2];

	mval_clamp[0] = CLAMPIS(mval[0], CONSOLE_DRAW_MARGIN, ar->winx - CONSOLE_DRAW_MARGIN);
	mval_clamp[1] = CLAMPIS(mval[1], CONSOLE_DRAW_MARGIN, ar->winy - CONSOLE_DRAW_MARGIN);

	console_textview_main__internal(sc, ar, 0, mval_clamp, &mouse_pick, &pos_pick);
	return pos_pick;
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:12,代码来源:console_draw.c


示例3: SetValueOperation

void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
	SetValueOperation *operation = new SetValueOperation();
	this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
	bNode *node = this->getbNode();

	/* stack order output: fac */
	float fac = 0.0f;
	const int framenumber = context->getFramenumber();

	if (framenumber < node->custom1) {
		fac = 0.0f;
	}
	else if (framenumber > node->custom2) {
		fac = 1.0f;
	}
	else if (node->custom1 < node->custom2) {
		fac = (context->getFramenumber() - node->custom1) / (float)(node->custom2 - node->custom1);
	}

	curvemapping_initialize((CurveMapping *)node->storage);
	fac = curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac);
	operation->setValue(CLAMPIS(fac, 0.0f, 1.0f));
	graph->addOperation(operation);
}
开发者ID:BlueLabelStudio,项目名称:blender,代码行数:25,代码来源:COM_TimeNode.cpp


示例4: cosf

/*
 * This calls the new bevel code (added since 2.64)
 */
static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
{
  Mesh *result;
  BMesh *bm;
  BMIter iter;
  BMEdge *e;
  BMVert *v;
  float weight, weight2;
  int vgroup = -1;
  MDeformVert *dvert = NULL;
  BevelModifierData *bmd = (BevelModifierData *)md;
  const float threshold = cosf(bmd->bevel_angle + 0.000000175f);
  const bool vertex_only = (bmd->flags & MOD_BEVEL_VERT) != 0;
  const bool do_clamp = !(bmd->flags & MOD_BEVEL_OVERLAP_OK);
  const int offset_type = bmd->val_flags;
  const float value = bmd->value;
  const int mat = CLAMPIS(bmd->mat, -1, ctx->object->totcol - 1);
  const bool loop_slide = (bmd->flags & MOD_BEVEL_EVEN_WIDTHS) == 0;
  const bool mark_seam = (bmd->edge_flags & MOD_BEVEL_MARK_SEAM);
  const bool mark_sharp = (bmd->edge_flags & MOD_BEVEL_MARK_SHARP);
  bool harden_normals = (bmd->flags & MOD_BEVEL_HARDEN_NORMALS);
  const int face_strength_mode = bmd->face_str_mode;
  const int miter_outer = bmd->miter_outer;
  const int miter_inner = bmd->miter_inner;
  const float spread = bmd->spread;

  bm = BKE_mesh_to_bmesh_ex(mesh,
                            &(struct BMeshCreateParams){0},
开发者ID:dfelinto,项目名称:blender,代码行数:31,代码来源:MOD_bevel.c


示例5: do_clump_level

static float do_clump_level(float result[3], const float co[3], const float par_co[3], float time,
                            float clumpfac, float clumppow, float pa_clump, CurveMapping *clumpcurve)
{
	float clump = 0.0f;
	
	if (clumpcurve) {
		clump = pa_clump * (1.0f - CLAMPIS(curvemapping_evaluateF(clumpcurve, 0, time), 0.0f, 1.0f));
		
		interp_v3_v3v3(result, co, par_co, clump);
	}
	else if (clumpfac != 0.0f) {
		float cpow;

		if (clumppow < 0.0f)
			cpow = 1.0f + clumppow;
		else
			cpow = 1.0f + 9.0f * clumppow;

		if (clumpfac < 0.0f) /* clump roots instead of tips */
			clump = -clumpfac * pa_clump * (float)pow(1.0 - (double)time, (double)cpow);
		else
			clump = clumpfac * pa_clump * (float)pow((double)time, (double)cpow);

		interp_v3_v3v3(result, co, par_co, clump);
	}
	
	return clump;
}
开发者ID:diekev,项目名称:blender,代码行数:28,代码来源:particle_child.c


示例6: where_on_path_deform

/* this makes sure we can extend for non-cyclic.
 *
 * returns OK: 1/0
 */
static bool where_on_path_deform(
    Object *ob, float ctime, float vec[4], float dir[3], float quat[4], float *radius)
{
  BevList *bl;
  float ctime1;
  int cycl = 0;

  /* test for cyclic */
  bl = ob->runtime.curve_cache->bev.first;
  if (!bl->nr) {
    return false;
  }
  if (bl->poly > -1) {
    cycl = 1;
  }

  if (cycl == 0) {
    ctime1 = CLAMPIS(ctime, 0.0f, 1.0f);
  }
  else {
    ctime1 = ctime;
  }

  /* vec needs 4 items */
  if (where_on_path(ob, ctime1, vec, dir, quat, radius, NULL)) {

    if (cycl == 0) {
      Path *path = ob->runtime.curve_cache->path;
      float dvec[3];

      if (ctime < 0.0f) {
        sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec);
        mul_v3_fl(dvec, ctime * (float)path->len);
        add_v3_v3(vec, dvec);
        if (quat) {
          copy_qt_qt(quat, path->data[0].quat);
        }
        if (radius) {
          *radius = path->data[0].radius;
        }
      }
      else if (ctime > 1.0f) {
        sub_v3_v3v3(dvec, path->data[path->len - 1].vec, path->data[path->len - 2].vec);
        mul_v3_fl(dvec, (ctime - 1.0f) * (float)path->len);
        add_v3_v3(vec, dvec);
        if (quat) {
          copy_qt_qt(quat, path->data[path->len - 1].quat);
        }
        if (radius) {
          *radius = path->data[path->len - 1].radius;
        }
        /* weight - not used but could be added */
      }
    }
    return true;
  }
  return false;
}
开发者ID:dfelinto,项目名称:blender,代码行数:62,代码来源:lattice.c


示例7: PaletteColor_color_set

void PaletteColor_color_set(PointerRNA *ptr, const float values[3])
{
	PaletteColor *data = (PaletteColor *)(ptr->data);
	unsigned int i;

	for (i = 0; i < 3; i++) {
		((float *)data->rgb)[i] = CLAMPIS(values[i], 0.0f, 1.0f);
	}
}
开发者ID:akashmanna,项目名称:MyBlenderBuild,代码行数:9,代码来源:rna_palette_gen.c


示例8: MovieClip_display_aspect_set

void MovieClip_display_aspect_set(PointerRNA *ptr, const float values[2])
{
	MovieClip *data = (MovieClip *)(ptr->data);
	unsigned int i;

	for (i = 0; i < 2; i++) {
		(&data->aspx)[i] = CLAMPIS(values[i], 0.1000000015f, FLT_MAX);
	}
}
开发者ID:akashmanna,项目名称:MyBlenderBuild,代码行数:9,代码来源:rna_movieclip_gen.c


示例9: rna_render_slots_active_set

static void rna_render_slots_active_set(PointerRNA *ptr, PointerRNA value)
{
	Image *image = (Image *)ptr->id.data;
	if (value.id.data == image) {
		RenderSlot *render_slot = (RenderSlot *)value.data;
		int index = render_slot - image->render_slots;
		image->render_slot = CLAMPIS(index, 0, IMA_MAX_RENDER_SLOT - 1);
	}
}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:9,代码来源:rna_image.c


示例10: draw_seq_handle_size_get_clamped

/* clamp handles to defined size in pixel space */
static float draw_seq_handle_size_get_clamped(Sequence *seq, const float pixelx)
{
	const float minhandle = pixelx * SEQ_HANDLE_SIZE_MIN;
	const float maxhandle = pixelx * SEQ_HANDLE_SIZE_MAX;
	float size = CLAMPIS(seq->handsize, minhandle, maxhandle);

	/* ensure we're not greater than half width */
	return min_ff(size, ((float)(seq->enddisp - seq->startdisp) / 2.0f) / pixelx);
}
开发者ID:pawkoz,项目名称:dyplom,代码行数:10,代码来源:sequencer_draw.c


示例11: eff_calc_visibility

// get visibility of a wind ray
static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, EffectorData *efd, EffectedPoint *point)
{
	const int raycast_flag = BVH_RAYCAST_DEFAULT & ~(BVH_RAYCAST_WATERTIGHT);
	ListBase *colls = colliders;
	ColliderCache *col;
	float norm[3], len = 0.0;
	float visibility = 1.0, absorption = 0.0;
	
	if (!(eff->pd->flag & PFIELD_VISIBILITY))
		return visibility;

	if (!colls)
		colls = get_collider_cache(eff->scene, eff->ob, NULL);

	if (!colls)
		return visibility;

	negate_v3_v3(norm, efd->vec_to_point);
	len = normalize_v3(norm);
	
	/* check all collision objects */
	for (col = colls->first; col; col = col->next) {
		CollisionModifierData *collmd = col->collmd;

		if (col->ob == eff->ob)
			continue;

		if (collmd->bvhtree) {
			BVHTreeRayHit hit;

			hit.index = -1;
			hit.dist = len + FLT_EPSILON;

			/* check if the way is blocked */
			if (BLI_bvhtree_ray_cast_ex(
			        collmd->bvhtree, point->loc, norm, 0.0f, &hit,
			        eff_tri_ray_hit, NULL, raycast_flag) != -1)
			{
				absorption= col->ob->pd->absorption;

				/* visibility is only between 0 and 1, calculated from 1-absorption */
				visibility *= CLAMPIS(1.0f-absorption, 0.0f, 1.0f);
				
				if (visibility <= 0.0f)
					break;
			}
		}
	}

	if (!colliders)
		free_collider_cache(&colls);
	
	return visibility;
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:55,代码来源:effect.c


示例12: node_composit_exec_curves_time

static void node_composit_exec_curves_time(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out)
{
	RenderData *rd= data;
	/* stack order output: fac */
	float fac= 0.0f;
	
	if (node->custom1 < node->custom2)
		fac= (rd->cfra - node->custom1)/(float)(node->custom2-node->custom1);
	
	fac= curvemapping_evaluateF(node->storage, 0, fac);
	out[0]->vec[0]= CLAMPIS(fac, 0.0f, 1.0f);
}
开发者ID:vanangamudi,项目名称:blender-main,代码行数:12,代码来源:node_composite_curves.c


示例13: bpy_bmdeformvert_ass_subscript

static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key, PyObject *value)
{
	if (PyIndex_Check(key)) {
		int i;

		i = PyNumber_AsSsize_t(key, PyExc_IndexError);
		if (i == -1 && PyErr_Occurred()) {
			return -1;
		}

		if (value) {
			/* dvert[group_index] = 0.5 */
			if (i < 0) {
				PyErr_SetString(PyExc_KeyError, "BMDeformVert[key] = x: "
				                "weight keys can't be negative");
				return -1;
			}
			else {
				MDeformWeight *dw = defvert_verify_index(self->data, i);
				const float f = PyFloat_AsDouble(value);
				if (f == -1 && PyErr_Occurred()) { // parsed key not a number
					PyErr_SetString(PyExc_TypeError,
					                "BMDeformVert[key] = x: "
					                "assigned value not a number");
					return -1;
				}

				dw->weight = CLAMPIS(f, 0.0f, 1.0f);
			}
		}
		else {
			/* del dvert[group_index] */
			MDeformWeight *dw = defvert_find_index(self->data, i);

			if (dw == NULL) {
				PyErr_SetString(PyExc_KeyError, "del BMDeformVert[key]: "
				                "key not found");
			}
			defvert_remove_group(self->data, dw);
		}

		return 0;

	}
	else {
		PyErr_Format(PyExc_TypeError,
		             "BMDeformVert keys must be integers, not %.200s",
		             Py_TYPE(key)->tp_name);
		return -1;
	}
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:51,代码来源:bmesh_py_types_meshdata.c


示例14: edbm_bevel_calc

static bool edbm_bevel_calc(wmOperator *op)
{
	BevelData *opdata = op->customdata;
	BMEditMesh *em = opdata->em;
	BMOperator bmop;
	const float offset = RNA_float_get(op->ptr, "offset");
	const int offset_type = RNA_enum_get(op->ptr, "offset_type");
	const int segments = RNA_int_get(op->ptr, "segments");
	const float profile = RNA_float_get(op->ptr, "profile");
	const bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only");
	const bool clamp_overlap = RNA_boolean_get(op->ptr, "clamp_overlap");
	int material = RNA_int_get(op->ptr, "material");
	const bool loop_slide = RNA_boolean_get(op->ptr, "loop_slide");

	/* revert to original mesh */
	if (opdata->is_modal) {
		EDBM_redo_state_restore(opdata->mesh_backup, em, false);
	}

	if (em->ob) {
		material = CLAMPIS(material, -1, em->ob->totcol - 1);
	}

	EDBM_op_init(em, &bmop, op,
	             "bevel geom=%hev offset=%f segments=%i vertex_only=%b offset_type=%i profile=%f clamp_overlap=%b "
	             "material=%i loop_slide=%b",
	             BM_ELEM_SELECT, offset, segments, vertex_only, offset_type, profile,
	             clamp_overlap, material, loop_slide);

	BMO_op_exec(em->bm, &bmop);

	if (offset != 0.0f) {
		/* not essential, but we may have some loose geometry that
		 * won't get bevel'd and better not leave it selected */
		EDBM_flag_disable_all(em, BM_ELEM_SELECT);
		BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
	}

	/* no need to de-select existing geometry */
	if (!EDBM_op_finish(em, &bmop, op, true)) {
		return false;
	}

	EDBM_mesh_normals_update(opdata->em);

	EDBM_update_generic(opdata->em, true, true);

	return true;
}
开发者ID:wisaac407,项目名称:blender,代码行数:49,代码来源:editmesh_bevel.c


示例15: GPU_simple_shader_colors

void GPU_simple_shader_colors(const float diffuse[3], const float specular[3],
	int shininess, float alpha)
{
	float gl_diffuse[4], gl_specular[4];

	copy_v3_v3(gl_diffuse, diffuse);
	gl_diffuse[3] = alpha;

	copy_v3_v3(gl_specular, specular);
	gl_specular[3] = 1.0f;

	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, gl_diffuse);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, gl_specular);
	glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, CLAMPIS(shininess, 1, 128));
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:15,代码来源:gpu_simple_shader.c


示例16: area_sample

static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD)
{
	int xs, ys, clip = 0;
	float tc[4], xsd, ysd, cw = 0.f;
	const float ux = ibuf->x*AFD->dxt[0], uy = ibuf->y*AFD->dxt[1];
	const float vx = ibuf->x*AFD->dyt[0], vy = ibuf->y*AFD->dyt[1];
	int xsam = (int)(0.5f*sqrtf(ux*ux + uy*uy) + 0.5f);
	int ysam = (int)(0.5f*sqrtf(vx*vx + vy*vy) + 0.5f);
	const int minsam = AFD->intpol ? 2 : 4;
	xsam = CLAMPIS(xsam, minsam, ibuf->x*2);
	ysam = CLAMPIS(ysam, minsam, ibuf->y*2);
	xsd = 1.f / xsam;
	ysd = 1.f / ysam;
	texr->tr = texr->tg = texr->tb = texr->ta = 0.f;
	for (ys=0; ys<ysam; ++ys) {
		for (xs=0; xs<xsam; ++xs) {
			const float su = (xs + ((ys & 1) + 0.5f)*0.5f)*xsd - 0.5f;
			const float sv = (ys + ((xs & 1) + 0.5f)*0.5f)*ysd - 0.5f;
			const float pu = fx + su*AFD->dxt[0] + sv*AFD->dyt[0];
			const float pv = fy + su*AFD->dxt[1] + sv*AFD->dyt[1];
			const int out = ibuf_get_color_clip_bilerp(tc, ibuf, pu*ibuf->x, pv*ibuf->y, AFD->intpol, AFD->extflag);
			clip |= out;
			cw += out ? 0.f : 1.f;
			texr->tr += tc[0];
			texr->tg += tc[1];
			texr->tb += tc[2];
			texr->ta += texr->talpha ? tc[3] : 0.f;
		}
	}
	xsd *= ysd;
	texr->tr *= xsd;
	texr->tg *= xsd;
	texr->tb *= xsd;
	/* clipping can be ignored if alpha used, texr->ta already includes filtered edge */
	texr->ta = texr->talpha ? texr->ta*xsd : (clip ? cw*xsd : 1.f);
}
开发者ID:wisaac407,项目名称:blender,代码行数:36,代码来源:imagetexture.c


示例17: BPY_BM_CHECK_OBJ

static PyObject *bpy_bm_utils_edge_split(PyObject *UNUSED(self), PyObject *args)
{
	BPy_BMEdge *py_edge;
	BPy_BMVert *py_vert;
	float fac;

	BMesh *bm;
	BMVert *v_new = NULL;
	BMEdge *e_new = NULL;

	if (!PyArg_ParseTuple(args, "O!O!f:edge_split",
	                      &BPy_BMEdge_Type, &py_edge,
	                      &BPy_BMVert_Type, &py_vert,
	                      &fac))
	{
		return NULL;
	}

	BPY_BM_CHECK_OBJ(py_edge);
	BPY_BM_CHECK_OBJ(py_vert);

	/* this doubles for checking that the verts are in the same mesh */
	if (!(py_edge->e->v1 == py_vert->v ||
	      py_edge->e->v2 == py_vert->v))
	{
		PyErr_SetString(PyExc_ValueError,
		                "edge_split(edge, vert): the vertex is not found in the edge");
		return NULL;
	}

	bm = py_edge->bm;

	v_new = BM_edge_split(bm, py_edge->e, py_vert->v, &e_new, CLAMPIS(fac, 0.0f, 1.0f));

	if (v_new && e_new) {
		PyObject *ret = PyTuple_New(2);
		PyTuple_SET_ITEMS(ret,
		        BPy_BMEdge_CreatePyObject(bm, e_new),
		        BPy_BMVert_CreatePyObject(bm, v_new));
		return ret;
	}
	else {
		PyErr_SetString(PyExc_ValueError,
		                "edge_split(edge, vert): couldn't split the edge, internal error");
		return NULL;
	}
}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:47,代码来源:bmesh_py_utils.c


示例18: render_frame

static int render_frame(int argc, const char **argv, void *data)
{
	bContext *C = data;
	Scene *scene = CTX_data_scene(C);
	if (scene) {
		Main *bmain = CTX_data_main(C);

		if (argc > 1) {
			Render *re = RE_NewRender(scene->id.name);
			int frame;
			ReportList reports;

			switch (*argv[1]) {
				case '+':
					frame = scene->r.sfra + atoi(argv[1] + 1);
					break;
				case '-':
					frame = (scene->r.efra - atoi(argv[1] + 1)) + 1;
					break;
				default:
					frame = atoi(argv[1]);
					break;
			}

			BLI_begin_threaded_malloc();
			BKE_reports_init(&reports, RPT_PRINT);

			frame = CLAMPIS(frame, MINAFRAME, MAXFRAME);

			RE_SetReports(re, &reports);
			RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, frame, frame, scene->r.frame_step);
			RE_SetReports(re, NULL);
			BLI_end_threaded_malloc();
			return 1;
		}
		else {
			printf("\nError: frame number must follow '-f / --render-frame'.\n");
			return 0;
		}
	}
	else {
		printf("\nError: no blend loaded. cannot use '-f / --render-frame'.\n");
		return 0;
	}
}
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:45,代码来源:creator.c


示例19: do_rough_curve

static void do_rough_curve(const float loc[3], float mat[4][4], float time, float fac, float size, CurveMapping *roughcurve, ParticleKey *state)
{
	float rough[3];
	float rco[3];
	
	if (!roughcurve)
		return;
	
	fac *= CLAMPIS(curvemapping_evaluateF(roughcurve, 0, time), 0.0f, 1.0f);
	
	copy_v3_v3(rco, loc);
	mul_v3_fl(rco, time);
	rough[0] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2, 0, 2);
	rough[1] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2, 0, 2);
	rough[2] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2, 0, 2);
	
	madd_v3_v3fl(state->co, mat[0], fac * rough[0]);
	madd_v3_v3fl(state->co, mat[1], fac * rough[1]);
	madd_v3_v3fl(state->co, mat[2], fac * rough[2]);
}
开发者ID:diekev,项目名称:blender,代码行数:20,代码来源:particle_child.c


示例20: BKE_mask_spline_feather_resolution

unsigned int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, int height)
{
	const float max_segment = 0.005;
	unsigned int resol = BKE_mask_spline_resolution(spline, width, height);
	float max_jump = 0.0f;
	int i;

	/* avoid checking the featrher if we already hit the maximum value */
	if (resol >= MASK_RESOL_MAX) {
		return MASK_RESOL_MAX;
	}

	for (i = 0; i < spline->tot_point; i++) {
		MaskSplinePoint *point = &spline->points[i];
		float prev_u, prev_w;
		int j;

		prev_u = 0.0f;
		prev_w = point->bezt.weight;

		for (j = 0; j < point->tot_uw; j++) {
			const float w_diff = (point->uw[j].w - prev_w);
			const float u_diff = (point->uw[j].u - prev_u);

			/* avoid divide by zero and very high values,
			 * though these get clamped eventually */
			if (u_diff > FLT_EPSILON) {
				float jump = fabsf(w_diff / u_diff);

				max_jump = max_ff(max_jump, jump);
			}

			prev_u = point->uw[j].u;
			prev_w = point->uw[j].w;
		}
	}

	resol += max_jump / max_segment;

	return CLAMPIS(resol, 1, MASK_RESOL_MAX);
}
开发者ID:wisaac407,项目名称:blender,代码行数:41,代码来源:mask_evaluate.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CLASSERT函数代码示例发布时间:2022-05-30
下一篇:
C++ CKeyingMaterial函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap