added __copy__ to mesh and object types, fixed a monor bug in setTexMesh and made Mesh.c use G.totMesh properly.
This commit is contained in:
		@@ -6437,6 +6437,29 @@ static PyObject *Mesh_fill( BPy_Mesh * self )
 | 
			
		||||
	return Mesh_Tools( self, MESH_TOOL_FILL, NULL );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * "__copy__" return a copy of the mesh
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static PyObject *Mesh_copy( BPy_Mesh * self )
 | 
			
		||||
{
 | 
			
		||||
	BPy_Mesh *obj;
 | 
			
		||||
 | 
			
		||||
	obj = (BPy_Mesh *)PyObject_NEW( BPy_Mesh, &Mesh_Type );
 | 
			
		||||
 | 
			
		||||
	if( !obj )
 | 
			
		||||
		return EXPP_ReturnPyObjError( PyExc_RuntimeError,
 | 
			
		||||
				       "PyObject_New() failed" );
 | 
			
		||||
	
 | 
			
		||||
	obj->mesh = copy_mesh( self->mesh );
 | 
			
		||||
	obj->mesh->id.us= 0;
 | 
			
		||||
	obj->object = NULL;
 | 
			
		||||
	obj->new = 1;
 | 
			
		||||
	return (PyObject *)obj;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static struct PyMethodDef BPy_Mesh_methods[] = {
 | 
			
		||||
	{"calcNormals", (PyCFunction)Mesh_calcNormals, METH_NOARGS,
 | 
			
		||||
		"all recalculate vertex normals"},
 | 
			
		||||
@@ -6486,6 +6509,10 @@ static struct PyMethodDef BPy_Mesh_methods[] = {
 | 
			
		||||
		"Removes duplicates from selected vertices (experimental)"},
 | 
			
		||||
	{"recalcNormals", (PyCFunction)Mesh_recalcNormals, METH_VARARGS,
 | 
			
		||||
		"Recalculates inside or outside normals (experimental)"},
 | 
			
		||||
	
 | 
			
		||||
	/* python standard class functions */
 | 
			
		||||
	{"__copy__", (PyCFunction)Mesh_copy, METH_NOARGS,
 | 
			
		||||
		"Return a copy of the mesh"},
 | 
			
		||||
	{NULL, NULL, 0, NULL}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -6976,7 +7003,7 @@ static int Mesh_setTexMesh( BPy_Mesh * self, PyObject * arg )
 | 
			
		||||
		/*This is a mesh so it needs to be added */
 | 
			
		||||
		self->mesh->texcomesh= blen_obj->mesh;
 | 
			
		||||
		self->mesh->texcomesh->id.us++;
 | 
			
		||||
		blen_obj->new==0;
 | 
			
		||||
		blen_obj->new= 0;
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -7296,7 +7323,6 @@ static PyObject *M_Mesh_New( PyObject * self_unused, PyObject * args )
 | 
			
		||||
				       "FATAL: could not create mesh object" );
 | 
			
		||||
	}
 | 
			
		||||
	mesh->id.us = 0;
 | 
			
		||||
	G.totmesh++;
 | 
			
		||||
 | 
			
		||||
	PyOS_snprintf( buf, sizeof( buf ), "%s", name );
 | 
			
		||||
	rename_id( &mesh->id, buf );
 | 
			
		||||
@@ -7563,6 +7589,7 @@ PyObject *Mesh_CreatePyObject( Mesh * me, Object *obj )
 | 
			
		||||
	nmesh->mesh = me;
 | 
			
		||||
	nmesh->object = obj;
 | 
			
		||||
	nmesh->new = 0;
 | 
			
		||||
	G.totmesh++;
 | 
			
		||||
 | 
			
		||||
	return ( PyObject * ) nmesh;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -323,6 +323,7 @@ static PyObject *Object_setSBStiffQuads( BPy_Object * self, PyObject * args );
 | 
			
		||||
static PyObject *Object_insertShapeKey(BPy_Object * self);
 | 
			
		||||
static PyObject *Object_copyNLA( BPy_Object * self, PyObject * args );
 | 
			
		||||
static PyObject *Object_convertActionToStrip( BPy_Object * self );
 | 
			
		||||
static PyObject *Object_copy(BPy_Object * self); /* __copy__ */
 | 
			
		||||
 | 
			
		||||
/*****************************************************************************/
 | 
			
		||||
/* Python BPy_Object methods table:					   */
 | 
			
		||||
@@ -645,8 +646,10 @@ works only if self and the object specified are of the same type."},
 | 
			
		||||
	 METH_VARARGS,
 | 
			
		||||
	 "() - Delete all scriptlinks from this object.\n"
 | 
			
		||||
	 "([s1<,s2,s3...>]) - Delete specified scriptlinks from this object."},
 | 
			
		||||
	{"insertShapeKey", ( PyCFunction ) Object_insertShapeKey,
 | 
			
		||||
	 METH_NOARGS, "() - Insert a Shape Key in the current object"},
 | 
			
		||||
	{"insertShapeKey", ( PyCFunction ) Object_insertShapeKey, METH_NOARGS,
 | 
			
		||||
	 "() - Insert a Shape Key in the current object"},
 | 
			
		||||
	{"__copy__", ( PyCFunction ) Object_copy, METH_NOARGS,
 | 
			
		||||
	 "() - Return a copy of this object."},
 | 
			
		||||
	{NULL, NULL, 0, NULL}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -3397,6 +3400,22 @@ static  PyObject *Object_insertShapeKey(BPy_Object * self)
 | 
			
		||||
	return Py_None;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* __copy__() */
 | 
			
		||||
static  PyObject *Object_copy(BPy_Object * self)
 | 
			
		||||
{
 | 
			
		||||
	/* copy_object never returns NULL */
 | 
			
		||||
	struct Object *object= copy_object( self->object );
 | 
			
		||||
	object->id.us= 0; /*is 1 by default, not sure why */
 | 
			
		||||
	
 | 
			
		||||
	/* Create a Python object from it. */
 | 
			
		||||
	return Object_CreatePyObject( object );
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*****************************************************************************/
 | 
			
		||||
/* Function:	Object_CreatePyObject					 */
 | 
			
		||||
/* Description: This function will create a new BlenObject from an existing  */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user