svn merge -r36725:36801 https://svn.blender.org/svnroot/bf-blender/trunk/blender
This commit is contained in:
		| @@ -1674,7 +1674,7 @@ static PyObject *Matrix_getColSize(MatrixObject *self, void *UNUSED(closure)) | ||||
| 	return PyLong_FromLong((long) self->col_size); | ||||
| } | ||||
|  | ||||
| static PyObject *Matrix_getMedianScale(MatrixObject *self, void *UNUSED(closure)) | ||||
| static PyObject *Matrix_median_scale_get(MatrixObject *self, void *UNUSED(closure)) | ||||
| { | ||||
| 	float mat[3][3]; | ||||
|  | ||||
| @@ -1692,7 +1692,7 @@ static PyObject *Matrix_getMedianScale(MatrixObject *self, void *UNUSED(closure) | ||||
| 	return PyFloat_FromDouble(mat3_to_scale(mat)); | ||||
| } | ||||
|  | ||||
| static PyObject *Matrix_getIsNegative(MatrixObject *self, void *UNUSED(closure)) | ||||
| static PyObject *Matrix_is_negative_get(MatrixObject *self, void *UNUSED(closure)) | ||||
| { | ||||
| 	if(BaseMath_ReadCallback(self) == -1) | ||||
| 		return NULL; | ||||
| @@ -1708,6 +1708,21 @@ static PyObject *Matrix_getIsNegative(MatrixObject *self, void *UNUSED(closure)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closure)) | ||||
| { | ||||
| 	if(BaseMath_ReadCallback(self) == -1) | ||||
| 		return NULL; | ||||
|  | ||||
| 	/*must be 3-4 cols, 3-4 rows, square matrix*/ | ||||
| 	if(self->col_size == 4 && self->row_size == 4) | ||||
| 		return PyBool_FromLong(is_orthogonal_m4((float (*)[4])self->contigPtr)); | ||||
| 	else if(self->col_size == 3 && self->row_size == 3) | ||||
| 		return PyBool_FromLong(is_orthogonal_m3((float (*)[3])self->contigPtr)); | ||||
| 	else { | ||||
| 		PyErr_SetString(PyExc_AttributeError, "Matrix.is_orthogonal: inappropriate matrix size - expects 3x3 or 4x4 matrix"); | ||||
| 		return NULL; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /*****************************************************************************/ | ||||
| /* Python attributes get/set structure:                                      */ | ||||
| @@ -1715,8 +1730,9 @@ static PyObject *Matrix_getIsNegative(MatrixObject *self, void *UNUSED(closure)) | ||||
| static PyGetSetDef Matrix_getseters[] = { | ||||
| 	{(char *)"row_size", (getter)Matrix_getRowSize, (setter)NULL, (char *)"The row size of the matrix (readonly).\n\n:type: int", NULL}, | ||||
| 	{(char *)"col_size", (getter)Matrix_getColSize, (setter)NULL, (char *)"The column size of the matrix (readonly).\n\n:type: int", NULL}, | ||||
| 	{(char *)"median_scale", (getter)Matrix_getMedianScale, (setter)NULL, (char *)"The average scale applied to each axis (readonly).\n\n:type: float", NULL}, | ||||
| 	{(char *)"is_negative", (getter)Matrix_getIsNegative, (setter)NULL, (char *)"True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, | ||||
| 	{(char *)"median_scale", (getter)Matrix_median_scale_get, (setter)NULL, (char *)"The average scale applied to each axis (readonly).\n\n:type: float", NULL}, | ||||
| 	{(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, (char *)"True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, | ||||
| 	{(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, (char *)"True if this matrix is orthogonal, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL}, | ||||
| 	{(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, | ||||
| 	{(char *)"owner",(getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL}, | ||||
| 	{NULL, NULL, NULL, NULL, NULL}  /* Sentinel */ | ||||
|   | ||||
| @@ -497,6 +497,60 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj | ||||
| } | ||||
|  | ||||
|  | ||||
| static char M_Geometry_intersect_line_plane_doc[] = | ||||
| ".. function:: intersect_line_plane(line_a, line_b, plane_co, plane_no, no_flip=False)\n" | ||||
| "\n" | ||||
| "   Takes 2 lines (as 4 vectors) and returns a vector for their point of intersection or None.\n" | ||||
| "\n" | ||||
| "   :arg line_a: First point of the first line\n" | ||||
| "   :type line_a: :class:`mathutils.Vector`\n" | ||||
| "   :arg line_b: Second point of the first line\n" | ||||
| "   :type line_b: :class:`mathutils.Vector`\n" | ||||
| "   :arg plane_co: A point on the plane\n" | ||||
| "   :type plane_co: :class:`mathutils.Vector`\n" | ||||
| "   :arg plane_no: The direction the plane is facing\n" | ||||
| "   :type plane_no: :class:`mathutils.Vector`\n" | ||||
| "   :arg no_flip: Always return an intersection on the directon defined bt line_a -> line_b\n" | ||||
| "   :type no_flip: :boolean\n" | ||||
| "   :return: The point of intersection or None when not found\n" | ||||
| "   :rtype: :class:`mathutils.Vector` or None\n" | ||||
| ; | ||||
| static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObject* args) | ||||
| { | ||||
| 	VectorObject *line_a, *line_b, *plane_co, *plane_no; | ||||
| 	int no_flip= 0; | ||||
| 	float isect[3]; | ||||
| 	if(!PyArg_ParseTuple(args, "O!O!O!O!|i:intersect_line_line_2d", | ||||
| 	  &vector_Type, &line_a, | ||||
| 	  &vector_Type, &line_b, | ||||
| 	  &vector_Type, &plane_co, | ||||
| 	  &vector_Type, &plane_no, | ||||
| 	  &no_flip) | ||||
| 	) { | ||||
| 		return NULL; | ||||
| 	} | ||||
|  | ||||
| 	if(		BaseMath_ReadCallback(line_a) == -1 || | ||||
| 	        BaseMath_ReadCallback(line_b) == -1 || | ||||
| 	        BaseMath_ReadCallback(plane_co) == -1 || | ||||
| 	        BaseMath_ReadCallback(plane_no) == -1 | ||||
| 	) { | ||||
| 		return NULL; | ||||
| 	} | ||||
|  | ||||
| 	if(ELEM4(2, line_a->size, line_b->size, plane_co->size, plane_no->size)) { | ||||
| 		PyErr_SetString(PyExc_RuntimeError, "geometry.intersect_line_plane(...) can't use 2D Vectors"); | ||||
| 		return NULL; | ||||
| 	} | ||||
|  | ||||
| 	if(isect_line_plane_v3(isect, line_a->vec, line_b->vec, plane_co->vec, plane_no->vec, no_flip) == 1) { | ||||
| 		return newVectorObject(isect, 3, Py_NEW, NULL); | ||||
| 	} | ||||
| 	else { | ||||
| 		Py_RETURN_NONE; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static char M_Geometry_intersect_point_line_doc[] = | ||||
| ".. function:: intersect_point_line(pt, line_p1, line_p2)\n" | ||||
| "\n" | ||||
| @@ -860,6 +914,7 @@ static PyMethodDef M_Geometry_methods[]= { | ||||
| 	{"intersect_point_quad_2d", (PyCFunction) M_Geometry_intersect_point_quad_2d, METH_VARARGS, M_Geometry_intersect_point_quad_2d_doc}, | ||||
| 	{"intersect_line_line", (PyCFunction) M_Geometry_intersect_line_line, METH_VARARGS, M_Geometry_intersect_line_line_doc}, | ||||
| 	{"intersect_line_line_2d", (PyCFunction) M_Geometry_intersect_line_line_2d, METH_VARARGS, M_Geometry_intersect_line_line_2d_doc}, | ||||
| 	{"intersect_line_plane", (PyCFunction) M_Geometry_intersect_line_plane, METH_VARARGS, M_Geometry_intersect_line_plane_doc}, | ||||
| 	{"interpolate_bezier", (PyCFunction) M_Geometry_interpolate_bezier, METH_VARARGS, M_Geometry_interpolate_bezier_doc}, | ||||
| 	{"area_tri", (PyCFunction) M_Geometry_area_tri, METH_VARARGS, M_Geometry_area_tri_doc}, | ||||
| 	{"normal", (PyCFunction) M_Geometry_normal, METH_VARARGS, M_Geometry_normal_doc}, | ||||
|   | ||||
| @@ -6040,17 +6040,18 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param | ||||
| 	bpy_context_set(C, &gilstate); | ||||
|  | ||||
| 	if (!is_static) { | ||||
| 		/* exception, operators store their PyObjects for re-use */ | ||||
| 		/* some datatypes (operator, render engine) can store PyObjects for re-use */ | ||||
| 		if(ptr->data) { | ||||
| 			if(RNA_struct_is_a(ptr->type, &RNA_Operator)) { | ||||
| 				wmOperator *op= ptr->data; | ||||
| 				if(op->py_instance) { | ||||
| 					py_class_instance= op->py_instance; | ||||
| 			void **instance = RNA_struct_instance(ptr); | ||||
|  | ||||
| 			if(instance) { | ||||
| 				if(*instance) { | ||||
| 					py_class_instance= *instance; | ||||
| 					Py_INCREF(py_class_instance); | ||||
| 				} | ||||
| 				else { | ||||
| 					/* store the instance here once its created */ | ||||
| 					py_class_instance_store= &op->py_instance; | ||||
| 					py_class_instance_store= instance; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| @@ -6418,7 +6419,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class | ||||
|  | ||||
| 	identifier= ((PyTypeObject*)py_class)->tp_name; | ||||
|  | ||||
| 	srna_new= reg(C, &reports, py_class, identifier, bpy_class_validate, bpy_class_call, bpy_class_free); | ||||
| 	srna_new= reg(CTX_data_main(C), &reports, py_class, identifier, bpy_class_validate, bpy_class_call, bpy_class_free); | ||||
|  | ||||
| 	if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1) | ||||
| 		return NULL; | ||||
| @@ -6568,7 +6569,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla | ||||
| 	C= BPy_GetContext(); | ||||
|  | ||||
| 	/* call unregister */ | ||||
| 	unreg(C, srna); /* calls bpy_class_free, this decref's py_class */ | ||||
| 	unreg(CTX_data_main(C), srna); /* calls bpy_class_free, this decref's py_class */ | ||||
|  | ||||
| 	PyDict_DelItemString(((PyTypeObject *)py_class)->tp_dict, "bl_rna"); | ||||
| 	if(PyErr_Occurred()) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user