Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2006-08-21 17:52:32 +0400
committerCampbell Barton <ideasman42@gmail.com>2006-08-21 17:52:32 +0400
commit0925d80cfadcd1827d43bf9fd4b00ee99fe4cd81 (patch)
treebd6cdd97c63c214a6680c6a918a8ebb32b813ed2 /source/blender/python/api2_2x/vector.c
parent0dcfab3e3268bac17b37e382bddbbf5169780914 (diff)
removed the unpopular 'ed' functions, and added .copy() to Mathutils vector and matrix
(inverted, normalized, transposed) making an inverted copy of an objects matrix used to be.. (2.42) imat= Mathutils.Matrix(ob.matrixWorld) imat.invert() # inverted.. I added but now removed imat= ob.matrixWorld.inverted() # with copy (current functionality)... imat= ob.matrixWorld.copy().invert()
Diffstat (limited to 'source/blender/python/api2_2x/vector.c')
-rw-r--r--source/blender/python/api2_2x/vector.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/source/blender/python/api2_2x/vector.c b/source/blender/python/api2_2x/vector.c
index cebe00169f2..d7497a88cbd 100644
--- a/source/blender/python/api2_2x/vector.c
+++ b/source/blender/python/api2_2x/vector.c
@@ -39,24 +39,25 @@
/*-------------------------DOC STRINGS ---------------------------*/
char Vector_Zero_doc[] = "() - set all values in the vector to 0";
char Vector_Normalize_doc[] = "() - normalize the vector";
-char Vector_Normalized_doc[] = "() - return a normalized copy of the vector";
char Vector_Negate_doc[] = "() - changes vector to it's additive inverse";
char Vector_Resize2D_doc[] = "() - resize a vector to [x,y]";
char Vector_Resize3D_doc[] = "() - resize a vector to [x,y,z]";
char Vector_Resize4D_doc[] = "() - resize a vector to [x,y,z,w]";
char Vector_toPoint_doc[] = "() - create a new Point Object from this vector";
char Vector_ToTrackQuat_doc[] = "(track, up) - extract a quaternion from the vector and the track and up axis";
+char Vector_copy_doc[] = "() - return a copy of the vector";
/*-----------------------METHOD DEFINITIONS ----------------------*/
struct PyMethodDef Vector_methods[] = {
{"zero", (PyCFunction) Vector_Zero, METH_NOARGS, Vector_Zero_doc},
{"normalize", (PyCFunction) Vector_Normalize, METH_NOARGS, Vector_Normalize_doc},
- {"normalized", (PyCFunction) Vector_Normalized, METH_NOARGS, Vector_Normalized_doc},
{"negate", (PyCFunction) Vector_Negate, METH_NOARGS, Vector_Negate_doc},
{"resize2D", (PyCFunction) Vector_Resize2D, METH_NOARGS, Vector_Resize2D_doc},
{"resize3D", (PyCFunction) Vector_Resize3D, METH_NOARGS, Vector_Resize2D_doc},
{"resize4D", (PyCFunction) Vector_Resize4D, METH_NOARGS, Vector_Resize2D_doc},
{"toPoint", (PyCFunction) Vector_toPoint, METH_NOARGS, Vector_toPoint_doc},
{"toTrackQuat", ( PyCFunction ) Vector_ToTrackQuat, METH_VARARGS, Vector_ToTrackQuat_doc},
+ {"copy", (PyCFunction) Vector_copy, METH_NOARGS, Vector_copy_doc},
+ {"__copy__", (PyCFunction) Vector_copy, METH_NOARGS, Vector_copy_doc},
{NULL, NULL, 0, NULL}
};
/*-----------------------------METHODS----------------------------
@@ -101,16 +102,7 @@ PyObject *Vector_Normalize(VectorObject * self)
for(x = 0; x < self->size; x++) {
self->vec[x] /= norm;
}
- Py_RETURN_NONE;
-}
-
-/*----------------------------Vector.normalized() -----------------
- return a normalized copy*/
-PyObject *Vector_Normalized(VectorObject * self)
-{
- VectorObject *vec= (VectorObject*)newVectorObject(self->vec, self->size, Py_NEW);
- Vector_Normalize(vec);
- return (PyObject*)vec;
+ return EXPP_incr_ret((PyObject*)self);
}
@@ -289,6 +281,16 @@ PyObject *Vector_ToTrackQuat( VectorObject * self, PyObject * args )
return newQuaternionObject(vectoquat(vec, track, up), Py_NEW);
}
+
+
+
+/*----------------------------Vector.copy() --------------------------------------
+ return a copy of the vector */
+PyObject *Vector_copy(VectorObject * self)
+{
+ return newVectorObject(self->vec, self->size, Py_NEW);
+}
+
/*----------------------------dealloc()(internal) ----------------
free the py_object */
static void Vector_dealloc(VectorObject * self)
@@ -704,11 +706,12 @@ static PyObject *Vector_div(PyObject * v1, PyObject * v2)
static PyObject *Vector_neg(VectorObject *self)
{
int x;
+ float vec[4];
for(x = 0; x < self->size; x++){
- self->vec[x] = -self->vec[x];
+ vec[x] = -self->vec[x];
}
- return EXPP_incr_ret((PyObject *)self);
+ return newVectorObject(vec, self->size, Py_NEW);
}
/*------------------------coerce(obj, obj)-----------------------
coercion of unknown types to type VectorObject for numeric protocols
@@ -969,7 +972,7 @@ PyObject *Vector_Negate(VectorObject * self)
for(x = 0; x < self->size; x++) {
self->vec[x] = -(self->vec[x]);
}
- printf("Vector.negate(): Deprecated: use -vector instead\n");
+ /*printf("Vector.negate(): Deprecated: use -vector instead\n");*/
return EXPP_incr_ret((PyObject*)self);
}
/*###################################################################