当前位置: 首页>>代码示例>>C++>>正文


C++ CustomData_has_layer函数代码示例

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


在下文中一共展示了CustomData_has_layer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: BM_mesh_cd_flag_from_bmesh

char BM_mesh_cd_flag_from_bmesh(BMesh *bm)
{
	char cd_flag = 0;
	if (CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) {
		cd_flag |= ME_CDFLAG_VERT_BWEIGHT;
	}
	if (CustomData_has_layer(&bm->edata, CD_BWEIGHT)) {
		cd_flag |= ME_CDFLAG_EDGE_BWEIGHT;
	}
	if (CustomData_has_layer(&bm->edata, CD_CREASE)) {
		cd_flag |= ME_CDFLAG_EDGE_CREASE;
	}
	return cd_flag;
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:14,代码来源:bmesh_mesh_conv.c

示例3: createVertexColorSource

void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
{
	if (!CustomData_has_layer(&me->fdata, CD_MCOL))
		return;

	MFace *f;
	int totcolor = 0, i, j;

	for (i = 0, f = me->mface; i < me->totface; i++, f++)
		totcolor += f->v4 ? 4 : 3;

	COLLADASW::FloatSourceF source(mSW);
	source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::COLOR));
	source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::COLOR) + ARRAY_ID_SUFFIX);
	source.setAccessorCount(totcolor);
	source.setAccessorStride(3);

	COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
	param.push_back("R");
	param.push_back("G");
	param.push_back("B");

	source.prepareToAppendValues();

	int index = CustomData_get_active_layer_index(&me->fdata, CD_MCOL);

	MCol *mcol = (MCol*)me->fdata.layers[index].data;
	MCol *c = mcol;

	for (i = 0, f = me->mface; i < me->totface; i++, c += 4, f++)
		for (j = 0; j < (f->v4 ? 4 : 3); j++)
			source.appendValues(c[j].b / 255.0f, c[j].g / 255.0f, c[j].r / 255.0f);
	
	source.finish();
}
开发者ID:ryden,项目名称:blender-mirror,代码行数:35,代码来源:GeometryExporter.cpp

示例4: CustomData_copy

// =================================================================
// This functin is copied from source/blender/editors/mesh/mesh_data.c
//
// TODO: (As discussed with sergey-) :
// Maybe move this function to blenderkernel/intern/mesh.c 
// and add definition to BKE_mesh.c
// =================================================================
void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
{
	CustomData edata;
	MEdge *medge;
	int i, totedge;

	if (len == 0)
		return;

	totedge = mesh->totedge + len;

	/* update customdata  */
	CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge);
	CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);

	if (!CustomData_has_layer(&edata, CD_MEDGE))
		CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);

	CustomData_free(&mesh->edata, mesh->totedge);
	mesh->edata = edata;
	BKE_mesh_update_customdata_pointers(mesh, false); /* new edges don't change tessellation */

	/* set default flags */
	medge = &mesh->medge[mesh->totedge];
	for (i = 0; i < len; i++, medge++)
		medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;

	mesh->totedge = totedge;
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:36,代码来源:MeshImporter.cpp

示例5: navmesh_face_add_exec

static int navmesh_face_add_exec(bContext *C, wmOperator *UNUSED(op))
{
	Object *obedit= CTX_data_edit_object(C);
	EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
	EditFace *ef;

	if(CustomData_has_layer(&em->fdata, CD_RECAST)) {
		int targetPolyIdx= findFreeNavPolyIndex(em);

		if(targetPolyIdx>0) {
			/* set target poly idx to selected faces */
			ef= (EditFace*)em->faces.last;
			while(ef) {
				if(ef->f & SELECT) {
					int *recastDataBlock= (int*)CustomData_em_get(&em->fdata, ef->data, CD_RECAST);
					*recastDataBlock= targetPolyIdx;
				}
				ef= ef->prev;
			}
		}
	}

	DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA);
	WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);

	BKE_mesh_end_editmesh((Mesh*)obedit->data, em);
	return OPERATOR_FINISHED;
}
开发者ID:BHCLL,项目名称:blendocv,代码行数:28,代码来源:mesh_navmesh.c

示例6: BPY_BM_CHECK_OBJ

static PyObject *bpy_bmlayercollection_new(BPy_BMLayerCollection *self, PyObject *args)
{
	const char *name = NULL;
	int index;
	CustomData *data;

	BPY_BM_CHECK_OBJ(self);

	if (!PyArg_ParseTuple(args, "|s:new", &name)) {
		return NULL;
	}

	data = bpy_bm_customdata_get(self->bm, self->htype);

	if (CustomData_layertype_is_singleton(self->type) &&
	    CustomData_has_layer(data, self->type))
	{
		PyErr_SetString(PyExc_ValueError,
		                "layers.new(): is a singleton, use verify() instead");
		return NULL;
	}

	if (name) {
		BM_data_layer_add_named(self->bm, data, self->type, name);
	}
	else {
		BM_data_layer_add(self->bm, data, self->type);
	}

	index = CustomData_number_of_layers(data, self->type) - 1;
	BLI_assert(index >= 0);

	return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
}
开发者ID:wchargin,项目名称:blender,代码行数:34,代码来源:bmesh_py_types_customdata.c

示例7: rna_Mesh_create_normals_split

static void rna_Mesh_create_normals_split(Mesh *mesh)
{
	if (!CustomData_has_layer(&mesh->ldata, CD_NORMAL)) {
		CustomData_add_layer(&mesh->ldata, CD_NORMAL, CD_CALLOC, NULL, mesh->totloop);
		CustomData_set_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
	}
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:7,代码来源:rna_mesh_api.c

示例8: mesh_add_faces

static void mesh_add_faces(Mesh *mesh, int len)
{
	CustomData fdata;
	MFace *mface;
	int i, totface;

	if(len == 0)
		return;

	totface= mesh->totface + len;	/* new face count */

	/* update customdata */
	CustomData_copy(&mesh->fdata, &fdata, CD_MASK_MESH, CD_DEFAULT, totface);
	CustomData_copy_data(&mesh->fdata, &fdata, 0, 0, mesh->totface);

	if(!CustomData_has_layer(&fdata, CD_MFACE))
		CustomData_add_layer(&fdata, CD_MFACE, CD_CALLOC, NULL, totface);

	CustomData_free(&mesh->fdata, mesh->totface);
	mesh->fdata= fdata;
	mesh_update_customdata_pointers(mesh);

	/* set default flags */
	mface= &mesh->mface[mesh->totface];
	for(i=0; i<len; i++, mface++)
		mface->flag= ME_FACE_SEL;

	mesh->totface= totface;
}
开发者ID:rexbron,项目名称:blender-ocio,代码行数:29,代码来源:mesh_data.c

示例9: mesh_add_verts

static void mesh_add_verts(Mesh *mesh, int len)
{
	CustomData vdata;
	MVert *mvert;
	int i, totvert;

	if(len == 0)
		return;

	totvert= mesh->totvert + len;
	CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH, CD_DEFAULT, totvert);
	CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);

	if(!CustomData_has_layer(&vdata, CD_MVERT))
		CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert);

	CustomData_free(&mesh->vdata, mesh->totvert);
	mesh->vdata= vdata;
	mesh_update_customdata_pointers(mesh);

	/* scan the input list and insert the new vertices */

	mvert= &mesh->mvert[mesh->totvert];
	for(i=0; i<len; i++, mvert++)
		mvert->flag |= SELECT;

	/* set final vertex list size */
	mesh->totvert= totvert;
}
开发者ID:rexbron,项目名称:blender-ocio,代码行数:29,代码来源:mesh_data.c

示例10: vert_mask_set

/* Set a vertex's paint-mask value
 *
 * Has no effect is no paint-mask layer is present */
static void vert_mask_set(BMesh *bm, BMVert *v, float new_mask)
{
	CustomData *cd = &bm->vdata;
	if (CustomData_has_layer(cd, CD_PAINT_MASK)) {
		float *mask = CustomData_bmesh_get(cd, v->head.data, CD_PAINT_MASK);
		(*mask) = new_mask;
	}
}
开发者ID:danielmarg,项目名称:blender-main,代码行数:11,代码来源:bmesh_log.c

示例11: navmesh_obmode_data_poll

static int navmesh_obmode_data_poll(bContext *C)
{
	Object *ob = ED_object_active_context(C);
	if (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
		Mesh *me= ob->data;
		return CustomData_has_layer(&me->fdata, CD_RECAST);
	}
	return FALSE;
}
开发者ID:BHCLL,项目名称:blendocv,代码行数:9,代码来源:mesh_navmesh.c

示例12: skin_resize_poll

static int skin_resize_poll(bContext *C)
{
	struct Object *obedit = CTX_data_edit_object(C);
	if (obedit && obedit->type == OB_MESH) {
		BMEditMesh *em = BKE_editmesh_from_object(obedit);
		return (em && CustomData_has_layer(&em->bm->vdata, CD_MVERT_SKIN));
	}
	return 0;
}
开发者ID:LucaRood,项目名称:Blender,代码行数:9,代码来源:transform_ops.c

示例13: float

void GeometryExporter::create_normals(std::vector<Normal> &normals, std::vector<BCPolygonNormalsIndices> &polygons_normals, Mesh *me)
{
	std::map<Normal, unsigned int> shared_normal_indices;
	int last_normal_index = -1;

	MVert *verts  = me->mvert;
	MLoop *mloops = me->mloop;
	float(*lnors)[3];

	BKE_mesh_calc_normals_split(me);
	if (CustomData_has_layer(&me->ldata, CD_NORMAL)) {
		lnors = (float(*)[3])CustomData_get_layer(&me->ldata, CD_NORMAL);
	}

	for (int poly_index = 0; poly_index < me->totpoly; poly_index++) {
		MPoly *mpoly  = &me->mpoly[poly_index];

		if (!(mpoly->flag & ME_SMOOTH)) {
			// For flat faces use face normal as vertex normal:

			float vector[3];
			BKE_mesh_calc_poly_normal(mpoly, mloops+mpoly->loopstart, verts, vector);

			Normal n = { vector[0], vector[1], vector[2] };
			normals.push_back(n);
			last_normal_index++;
		}

		MLoop *mloop = mloops + mpoly->loopstart;
		BCPolygonNormalsIndices poly_indices;
		for (int loop_index = 0; loop_index < mpoly->totloop; loop_index++) {
			unsigned int loop_idx = mpoly->loopstart + loop_index;
			if (mpoly->flag & ME_SMOOTH) {

				float normalized[3];
				normalize_v3_v3(normalized, lnors[loop_idx]);
				Normal n = { normalized[0], normalized[1], normalized[2] };

				if (shared_normal_indices.find(n) != shared_normal_indices.end()) {
					poly_indices.add_index(shared_normal_indices[n]);
				}
				else {
					last_normal_index++;
					poly_indices.add_index(last_normal_index);
					shared_normal_indices[n] = last_normal_index;
					normals.push_back(n);
				}
			}
			else {
				poly_indices.add_index(last_normal_index);
			}
		}

		polygons_normals.push_back(poly_indices);
	}
}
开发者ID:mcgrathd,项目名称:blender,代码行数:56,代码来源:GeometryExporter.cpp

示例14: vert_mask_get

/* Get a vertex's paint-mask value
 *
 * Returns zero if no paint-mask layer is present */
static float vert_mask_get(BMesh *bm, BMVert *v)
{
	CustomData *cd = &bm->vdata;
	if (CustomData_has_layer(&bm->vdata, CD_PAINT_MASK)) {
		float *mask = CustomData_bmesh_get(cd, v->head.data, CD_PAINT_MASK);
		return *mask;
	}
	else {
		return 0;
	}
}
开发者ID:danielmarg,项目名称:blender-main,代码行数:14,代码来源:bmesh_log.c

示例15: rna_Mesh_calc_tangents

static void rna_Mesh_calc_tangents(Mesh *mesh, ReportList *reports, const char *uvmap)
{
	float (*r_looptangents)[4];

	if (CustomData_has_layer(&mesh->ldata, CD_MLOOPTANGENT)) {
		r_looptangents = CustomData_get_layer(&mesh->ldata, CD_MLOOPTANGENT);
		memset(r_looptangents, 0, sizeof(float[4]) * mesh->totloop);
	}
	else {
		r_looptangents = CustomData_add_layer(&mesh->ldata, CD_MLOOPTANGENT, CD_CALLOC, NULL, mesh->totloop);
		CustomData_set_layer_flag(&mesh->ldata, CD_MLOOPTANGENT, CD_FLAG_TEMPORARY);
	}

	/* Compute loop normals if needed. */
	if (!CustomData_has_layer(&mesh->ldata, CD_NORMAL)) {
		BKE_mesh_calc_normals_split(mesh);
	}

	BKE_mesh_loop_tangents(mesh, uvmap, r_looptangents, reports);
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:20,代码来源:rna_mesh_api.c


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