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

C++ BaseMath_ReadCallback函数代码示例

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

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



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

示例1: PyErr_SetString

/* subtraction in-place: obj -= obj */
static PyObject *Color_isub(PyObject *v1, PyObject *v2)
{
	ColorObject *color1= NULL, *color2= NULL;

	if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) {
		PyErr_SetString(PyExc_TypeError,
		                "Color subtraction: "
		                "arguments not valid for this operation");
		return NULL;
	}
	color1 = (ColorObject*)v1;
	color2 = (ColorObject*)v2;

	if(BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
		return NULL;

	sub_vn_vn(color1->col, color2->col, COLOR_SIZE);

	(void)BaseMath_WriteCallback(color1);
	Py_INCREF(v1);
	return v1;
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:23,代码来源:mathutils_Color.c


示例2: validate_array

static int validate_array(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop,
                          int lvalue_dim, ItemTypeCheckFunc check_item_type, const char *item_type_str, int *totitem,
                          const char *error_prefix)
{
	int dimsize[MAX_ARRAY_DIMENSION];
	int totdim = RNA_property_array_dimension(ptr, prop, dimsize);

	/* validate type first because length validation may modify property array length */


#ifdef USE_MATHUTILS
	if (lvalue_dim == 0) { /* only valid for first level array */
		if (MatrixObject_Check(rvalue)) {
			MatrixObject *pymat = (MatrixObject *)rvalue;

			if (BaseMath_ReadCallback(pymat) == -1)
				return -1;

			if (RNA_property_type(prop) != PROP_FLOAT) {
				PyErr_Format(PyExc_ValueError, "%s %.200s.%.200s, matrix assign to non float array",
				             error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
				return -1;
			}
			else if (totdim != 2) {
				PyErr_Format(PyExc_ValueError, "%s %.200s.%.200s, matrix assign array with %d dimensions",
				             error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), totdim);
				return -1;
			}
			else if (pymat->num_col != dimsize[0] || pymat->num_row != dimsize[1]) {
				PyErr_Format(PyExc_ValueError, "%s %.200s.%.200s, matrix assign dimension size mismatch, "
				             "is %dx%d, expected be %dx%d",
				             error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop),
				             pymat->num_col, pymat->num_row, dimsize[0], dimsize[1]);
				return -1;
			}
			else {
				*totitem = dimsize[0] * dimsize[1];
				return 0;
			}
		}
	}
#endif /* USE_MATHUTILS */


	{
		if (validate_array_type(rvalue, lvalue_dim, totdim, dimsize, check_item_type, item_type_str, error_prefix) == -1)
			return -1;

		return validate_array_length(rvalue, ptr, prop, lvalue_dim, totitem, error_prefix);
	}
}
开发者ID:vanangamudi,项目名称:blender-main,代码行数:51,代码来源:bpy_rna_array.c


示例3: newVectorObject

static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObject* args)
{
	VectorObject *line_a1, *line_a2, *line_b1, *line_b2;
	float vi[2];
	if(!PyArg_ParseTuple(args, "O!O!O!O!:intersect_line_line_2d",
	  &vector_Type, &line_a1,
	  &vector_Type, &line_a2,
	  &vector_Type, &line_b1,
	  &vector_Type, &line_b2)
	) {
		return NULL;
	}
	
	if(BaseMath_ReadCallback(line_a1) == -1 || BaseMath_ReadCallback(line_a2) == -1 || BaseMath_ReadCallback(line_b1) == -1 || BaseMath_ReadCallback(line_b2) == -1)
		return NULL;

	if(isect_seg_seg_v2_point(line_a1->vec, line_a2->vec, line_b1->vec, line_b2->vec, vi) == 1) {
		return newVectorObject(vi, 2, Py_NEW, NULL);
	}
	else {
		Py_RETURN_NONE;
	}
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:23,代码来源:mathutils_geometry.c


示例4: PyErr_Format

/* subtraction in-place: obj -= obj */
static PyObject *Color_isub(PyObject *v1, PyObject *v2)
{
	ColorObject *color1= NULL, *color2= NULL;

	if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) {
		PyErr_Format(PyExc_TypeError,
		             "Color subtraction: (%s -= %s) "
		             "invalid type for this operation",
		             Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name);
		return NULL;
	}
	color1 = (ColorObject*)v1;
	color2 = (ColorObject*)v2;

	if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
		return NULL;

	sub_vn_vn(color1->col, color2->col, COLOR_SIZE);

	(void)BaseMath_WriteCallback(color1);
	Py_INCREF(v1);
	return v1;
}
开发者ID:mik0001,项目名称:Blender,代码行数:24,代码来源:mathutils_Color.c


示例5: mathutils_dynstr_to_py

static PyObject *Euler_str(EulerObject *self)
{
	DynStr *ds;

	if (BaseMath_ReadCallback(self) == -1)
		return NULL;

	ds = BLI_dynstr_new();

	BLI_dynstr_appendf(ds, "<Euler (x=%.4f, y=%.4f, z=%.4f), order='%s'>",
	                   self->eul[0], self->eul[1], self->eul[2], euler_order_str(self));

	return mathutils_dynstr_to_py(ds); /* frees ds */
}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:14,代码来源:mathutils_Euler.c


示例6:

static PyObject *Color_repr(ColorObject * self)
{
	PyObject *ret, *tuple;

	if (BaseMath_ReadCallback(self) == -1)
		return NULL;

	tuple= Color_ToTupleExt(self, -1);

	ret= PyUnicode_FromFormat("Color(%R)", tuple);

	Py_DECREF(tuple);
	return ret;
}
开发者ID:mik0001,项目名称:Blender,代码行数:14,代码来源:mathutils_Color.c


示例7: mathutils_dynstr_to_py

static PyObject *Color_str(ColorObject *self)
{
	DynStr *ds;

	if (BaseMath_ReadCallback(self) == -1)
		return NULL;

	ds = BLI_dynstr_new();

	BLI_dynstr_appendf(ds, "<Color (r=%.4f, g=%.4f, b=%.4f)>",
	                   self->col[0], self->col[1], self->col[2]);

	return mathutils_dynstr_to_py(ds); /* frees ds */
}
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:14,代码来源:mathutils_Color.c


示例8: BaseMath_ReadCallback

static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObject *args)
{
	VectorObject *pt_vec, *tri_p1, *tri_p2, *tri_p3;
	
	if (!PyArg_ParseTuple(args, "O!O!O!O!:intersect_point_tri_2d",
	                      &vector_Type, &pt_vec,
	                      &vector_Type, &tri_p1,
	                      &vector_Type, &tri_p2,
	                      &vector_Type, &tri_p3))
	{
		return NULL;
	}
	
	if (BaseMath_ReadCallback(pt_vec) == -1 ||
	    BaseMath_ReadCallback(tri_p1) == -1 ||
	    BaseMath_ReadCallback(tri_p2) == -1 ||
	    BaseMath_ReadCallback(tri_p3) == -1)
	{
		return NULL;
	}

	return PyLong_FromLong(isect_point_tri_v2(pt_vec->vec, tri_p1->vec, tri_p2->vec, tri_p3->vec));
}
开发者ID:vanangamudi,项目名称:blender-main,代码行数:23,代码来源:mathutils_geometry.c


示例9: PyErr_SetString

static PyObject *M_Geometry_ClosestPointOnLine( PyObject * self, PyObject * args )
{
	VectorObject *pt, *line_1, *line_2;
	float pt_in[3], pt_out[3], l1[3], l2[3];
	float lambda;
	PyObject *ret;
	
	if( !PyArg_ParseTuple ( args, "O!O!O!",
	&vector_Type, &pt,
	&vector_Type, &line_1,
	&vector_Type, &line_2)
	  ) {
		PyErr_SetString( PyExc_TypeError, "expected 3 vector types\n" );
		return NULL;
	}
	
	if(!BaseMath_ReadCallback(pt) || !BaseMath_ReadCallback(line_1) || !BaseMath_ReadCallback(line_2))
		return NULL;
	
	/* accept 2d verts */
	if (pt->size==3) { VECCOPY(pt_in, pt->vec);}
	else { pt_in[2]=0.0;	VECCOPY2D(pt_in, pt->vec) }
	
	if (line_1->size==3) { VECCOPY(l1, line_1->vec);}
	else { l1[2]=0.0;	VECCOPY2D(l1, line_1->vec) }
	
	if (line_2->size==3) { VECCOPY(l2, line_2->vec);}
	else { l2[2]=0.0;	VECCOPY2D(l2, line_2->vec) }
	
	/* do the calculation */
	lambda = lambda_cp_line_ex(pt_in, l1, l2, pt_out);
	
	ret = PyTuple_New(2);
	PyTuple_SET_ITEM( ret, 0, newVectorObject(pt_out, 3, Py_NEW, NULL) );
	PyTuple_SET_ITEM( ret, 1, PyFloat_FromDouble(lambda) );
	return ret;
}
开发者ID:jinjoh,项目名称:NOOR,代码行数:37,代码来源:Geometry.c


示例10: PyErr_SetString

static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject *args)
{
	VectorObject *vec1, *vec2, *vec3;

	if (!PyArg_ParseTuple(args, "O!O!O!:area_tri",
	                      &vector_Type, &vec1,
	                      &vector_Type, &vec2,
	                      &vector_Type, &vec3))
	{
		return NULL;
	}

	if (vec1->size != vec2->size || vec1->size != vec3->size) {
		PyErr_SetString(PyExc_ValueError,
		                "vectors must be of the same size");
		return NULL;
	}

	if (BaseMath_ReadCallback(vec1) == -1 ||
	    BaseMath_ReadCallback(vec2) == -1 ||
	    BaseMath_ReadCallback(vec3) == -1)
	{
		return NULL;
	}

	if (vec1->size == 3) {
		return PyFloat_FromDouble(area_tri_v3(vec1->vec, vec2->vec, vec3->vec));
	}
	else if (vec1->size == 2) {
		return PyFloat_FromDouble(area_tri_v2(vec1->vec, vec2->vec, vec3->vec));
	}
	else {
		PyErr_SetString(PyExc_ValueError,
		                "only 2D,3D vectors are supported");
		return NULL;
	}
}
开发者ID:vanangamudi,项目名称:blender-main,代码行数:37,代码来源:mathutils_geometry.c


示例11: Py_INCREF

/* returns -1 exception, 0 false, 1 true */
static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op)
{
	PyObject *res;
	int ok = -1; /* zero is true */

	if (ColorObject_Check(a) && ColorObject_Check(b)) {
		ColorObject *colA = (ColorObject *)a;
		ColorObject *colB = (ColorObject *)b;

		if (BaseMath_ReadCallback(colA) == -1 || BaseMath_ReadCallback(colB) == -1)
			return NULL;

		ok = EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1;
	}

	switch (op) {
		case Py_NE:
			ok = !ok;
			/* fall-through */
		case Py_EQ:
			res = ok ? Py_False : Py_True;
			break;

		case Py_LT:
		case Py_LE:
		case Py_GT:
		case Py_GE:
			res = Py_NotImplemented;
			break;
		default:
			PyErr_BadArgument();
			return NULL;
	}

	return Py_INCREF(res), res;
}
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:37,代码来源:mathutils_Color.c


示例12: float_array_from_PyObject

bool float_array_from_PyObject(PyObject *obj, float *v, int n)
{
	if (VectorObject_Check(obj) && ((VectorObject *)obj)->size == n) {
		if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
			return 0;
		for (int i = 0; i < n; i++)
			v[i] = ((VectorObject *)obj)->vec[i];
		return 1;
	}
	else if (ColorObject_Check(obj) && n == 3) {
		if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
			return 0;
		for (int i = 0; i < n; i++)
			v[i] = ((ColorObject *)obj)->col[i];
		return 1;
	}
	else if (PyList_Check(obj) && PyList_GET_SIZE(obj) == n) {
		return float_array_from_PyList(obj, v, n);
	}
	else if (PyTuple_Check(obj) && PyTuple_GET_SIZE(obj) == n) {
		return float_array_from_PyTuple(obj, v, n);
	}
	return 0;
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:24,代码来源:BPy_Convert.cpp


示例13: Py_INCREF

static PyObject *Euler_richcmpr(PyObject *a, PyObject *b, int op)
{
	PyObject *res;
	int ok = -1; /* zero is true */

	if (EulerObject_Check(a) && EulerObject_Check(b)) {
		EulerObject *eulA = (EulerObject *)a;
		EulerObject *eulB = (EulerObject *)b;

		if (BaseMath_ReadCallback(eulA) == -1 || BaseMath_ReadCallback(eulB) == -1)
			return NULL;

		ok = ((eulA->order == eulB->order) && EXPP_VectorsAreEqual(eulA->eul, eulB->eul, EULER_SIZE, 1)) ? 0 : -1;
	}

	switch (op) {
		case Py_NE:
			ok = !ok;
			/* fall-through */
		case Py_EQ:
			res = ok ? Py_False : Py_True;
			break;

		case Py_LT:
		case Py_LE:
		case Py_GT:
		case Py_GE:
			res = Py_NotImplemented;
			break;
		default:
			PyErr_BadArgument();
			return NULL;
	}

	return Py_INCREF(res), res;
}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:36,代码来源:mathutils_Euler.c


示例14:

static PyObject *Color_hsv_get(ColorObject *self, void *UNUSED(closure))
{
	float hsv[3];
	PyObject *ret;

	if (BaseMath_ReadCallback(self) == -1)
		return NULL;

	rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));

	ret = PyTuple_New(3);
	PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(hsv[0]));
	PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(hsv[1]));
	PyTuple_SET_ITEM(ret, 2, PyFloat_FromDouble(hsv[2]));
	return ret;
}
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:16,代码来源:mathutils_Color.c


示例15: PyErr_SetString

static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args)
{
	VectorObject *vec1, *vec2, *vec3, *vec4;
	float n[3];

	if(PyTuple_GET_SIZE(args) == 3) {
		if(!PyArg_ParseTuple(args, "O!O!O!:normal", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) {
			return NULL;
		}
		if(vec1->size != vec2->size || vec1->size != vec3->size) {
			PyErr_SetString(PyExc_ValueError,
			                "vectors must be of the same size");
			return NULL;
		}
		if(vec1->size < 3) {
			PyErr_SetString(PyExc_ValueError,
			                "2D vectors unsupported");
			return NULL;
		}

		if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1)
			return NULL;

		normal_tri_v3(n, vec1->vec, vec2->vec, vec3->vec);
	}
	else {
		if(!PyArg_ParseTuple(args, "O!O!O!O!:normal", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) {
			return NULL;
		}
		if(vec1->size != vec2->size || vec1->size != vec3->size || vec1->size != vec4->size) {
			PyErr_SetString(PyExc_ValueError,
			                "vectors must be of the same size");
			return NULL;
		}
		if(vec1->size < 3) {
			PyErr_SetString(PyExc_ValueError,
			                "2D vectors unsupported");
			return NULL;
		}

		if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(vec4) == -1)
			return NULL;

		normal_quad_v3(n, vec1->vec, vec2->vec, vec3->vec, vec4->vec);
	}

	return newVectorObject(n, 3, Py_NEW, NULL);
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:48,代码来源:mathutils_geometry.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ BaseObjectPtr函数代码示例发布时间:2022-05-30
下一篇:
C++ BaseFinalRelease函数代码示例发布时间: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