[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20901] branches/soc-2009-kazanbas: Added copy_applied method on Mesh objects.
Arystan Dyussenov
arystan.d at gmail.com
Tue Jun 16 09:16:12 CEST 2009
Hi Joe,
If you mean RNA_api* ones, I'm trying to follow this proposal
http://lists.blender.org/pipermail/bf-taskforce25/2009-March/000544.html
But copy_mesh_applied could go there, but I'm not sure yet if it is needed
at all ;-)
Arystan
On Tue, Jun 16, 2009 at 1:12 AM, joe <joeedh at gmail.com> wrote:
> The stuff you added in editmesh.c looks more like they belong in
> blenkernel (probably mesh.c or DerivedMesh.c).
>
> Joe
>
> On Mon, Jun 15, 2009 at 7:49 AM, Arystanbek
> Dyussenov<arystan.d at gmail.com> wrote:
> > Revision: 20901
> >
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20901
> > Author: kazanbas
> > Date: 2009-06-15 15:49:02 +0200 (Mon, 15 Jun 2009)
> >
> > Log Message:
> > -----------
> > Added copy_applied method on Mesh objects. Uses DerivedMesh funcs to
> > get a mesh with all modifiers applied.
> >
> > Modified Paths:
> > --------------
> > branches/soc-2009-kazanbas/release/io/export_obj.py
> > branches/soc-2009-kazanbas/source/blender/editors/mesh/editmesh.c
> >
> branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_internal.h
> > branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_mesh.c
> >
> > Modified: branches/soc-2009-kazanbas/release/io/export_obj.py
> > ===================================================================
> > --- branches/soc-2009-kazanbas/release/io/export_obj.py 2009-06-15
> 12:18:17 UTC (rev 20900)
> > +++ branches/soc-2009-kazanbas/release/io/export_obj.py 2009-06-15
> 13:49:02 UTC (rev 20901)
> > @@ -1,4 +1,3 @@
> > -
> > import bpy
> >
> > class SCRIPT_OT_export_obj(bpy.types.Operator):
> > @@ -8,24 +7,40 @@
> > # List of operator properties, the attributes will be assigned
> > # to the class instance from the operator settings before calling.
> > __props__ = [
> > - bpy.props["StringProperty"](attr="filename", name="filename",
> default="/tmp")
> > -# FloatProperty(attr="setting_1", name="Example 1",
> default=10.0, min=0, max=10, description="Add info here"),
> > -# StringProperty(attr="filename")
> > + bpy.props["StringProperty"](attr="filename",
> name="filename")
> > ]
> >
> > def debug(self, message):
> > print("{0}: {1}".format(self.__class__.__name__, message))
> >
> > def exec(self, context):
> > -# print(self.setting_1)
> > self.debug("exec")
> > self.debug("filename = " + self.filename)
> > +
> > + self.debug("num selected objects:
> {0}".format(len(context.selected_objects)))
> > +
> > + ob = bpy.data.objects["Cube"]
> > + o = ob.data
> > +
> > + m = bpy.data.add_mesh("tmpmesh")
> > + m.copy_applied(context.scene, ob, True)
> > +
> > + def vert(co):
> > + return "{0}, {1}, {2}".format(co[0], co[1],
> co[2])
> > +
> > + print(" orig: {0} with
> totverts={1}".format(vert(o.verts[0].co), len(o.verts)))
> > + print("applied: {0} with
> totverts={1}".format(vert(m.verts[0].co), len(m.verts)))
> > +
> > + # XXX errors are silenced for some reason
> > +# raise Exception("oops!")
> > +
> > return ('FINISHED',)
> >
> > def invoke(self, context, event):
> > self.debug("invoke")
> > - context.add_fileselect(self.__operator__)
> > - return ('RUNNING_MODAL',) #self.exec(context)
> > +# context.add_fileselect(self.__operator__)
> > +# return ('RUNNING_MODAL',)
> > + return self.exec(context)
> >
> > def poll(self, context): # poll isnt working yet
> > self.debug("poll")
> >
> > Modified:
> branches/soc-2009-kazanbas/source/blender/editors/mesh/editmesh.c
> > ===================================================================
> > --- branches/soc-2009-kazanbas/source/blender/editors/mesh/editmesh.c
> 2009-06-15 12:18:17 UTC (rev 20900)
> > +++ branches/soc-2009-kazanbas/source/blender/editors/mesh/editmesh.c
> 2009-06-15 13:49:02 UTC (rev 20901)
> > @@ -2041,6 +2041,16 @@
> > copy_mesh_data(me, from);
> > }
> >
> > +void RNA_api_mesh_copy_applied(Mesh *me, Scene *sce, Object *ob, int
> apply_obmat)
> > +{
> > + DerivedMesh *dm= mesh_create_derived_view(sce, ob, CD_MASK_MESH);
> > + DM_to_mesh(dm, me);
> > + dm->release(dm);
> > +
> > + if (apply_obmat) {
> > + }
> > +}
> > +
> > void RNA_api_mesh_transform(Mesh *me, float **mat)
> > {
> > }
> > @@ -2048,6 +2058,8 @@
> > /*
> > * This version of copy_mesh doesn't allocate a new mesh,
> > * instead it copies data between two existing meshes.
> > + *
> > + * XXX is this already possible with DerivedMesh?
> > */
> > void copy_mesh_data(Mesh *dest, Mesh *src)
> > {
> > @@ -2078,47 +2090,3 @@
> >
> > mesh_update_customdata_pointers(dest);
> > }
> > -
> > -/*
> > -void RNA_api_mesh_apply_transform(Mesh *me)
> > -{
> > -
> > -}
> > -*/
> > -
> > -/*
> > -void RNA_api_mesh_copy_(Mesh *me, Object *ob, int apply_transform)
> > -{
> > - if (ob->type != OB_MESH) {
> > - return;
> > - }
> > -
> > - Mesh *src= (Mesh*)ob->data;
> > -
> > - CustomData_free(&me->vdata, me->totvert);
> > - CustomData_free(&me->edata, me->totedge);
> > - CustomData_free(&me->fdata, me->totface);
> > -
> > - CustomData_copy(&src->vdata, &me->vdata, CD_MASK_MESH,
> CD_DUPLICATE, me->totvert);
> > - CustomData_copy(&src->edata, &me->edata, CD_MASK_MESH,
> CD_DUPLICATE, me->totedge);
> > - CustomData_copy(&src->fdata, &me->fdata, CD_MASK_MESH,
> CD_DUPLICATE, me->totface);
> > - mesh_update_customdata_pointers(me);
> > -
> > - // ensure indirect linked data becomes lib-extern
> > - for(i=0; i<src->fdata.totlayer; i++) {
> > - if(src->fdata.layers[i].type == CD_MTFACE) {
> > - tface= (MTFace*)src->fdata.layers[i].data;
> > -
> > - for(a=0; a<src->totface; a++, tface++)
> > - if(tface->tpage)
> > - id_lib_extern((ID*)tface->tpage);
> > - }
> > - }
> > -
> > - me->mselect= NULL;
> > - me->bb= src->bb;
> > -
> > - //men->key= copy_key(me->key);
> > - //if(men->key) men->key->from= (ID *)men;
> > -}
> > -*/
> >
> > Modified:
> branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_internal.h
> > ===================================================================
> > ---
> branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_internal.h
> 2009-06-15 12:18:17 UTC (rev 20900)
> > +++
> branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_internal.h
> 2009-06-15 13:49:02 UTC (rev 20901)
> > @@ -188,9 +188,15 @@
> >
> > /* API functions */
> >
> > +struct Main;
> > +struct Scene;
> > +struct Object;
> > +struct Mesh;
> > +
> > void RNA_api_ui_layout(struct StructRNA *srna);
> > struct Mesh *RNA_api_add_mesh(struct Main *main, char *name);
> > void RNA_api_mesh_copy(struct Mesh *me, struct Mesh *from);
> > +void RNA_api_mesh_copy_applied(struct Mesh *me, struct Scene *sce,
> struct Object *ob, int apply_obmat);
> >
> > /* ID Properties */
> >
> >
> > Modified:
> branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_mesh.c
> > ===================================================================
> > --- branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_mesh.c
> 2009-06-15 12:18:17 UTC (rev 20900)
> > +++ branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_mesh.c
> 2009-06-15 13:49:02 UTC (rev 20901)
> > @@ -1132,10 +1132,14 @@
> > RNA_def_function_ui_description(func, "Copy mesh data.");
> > prop= RNA_def_pointer(func, "src", "Mesh", "", "A mesh to copy
> data from.");
> > RNA_def_property_flag(prop, PROP_REQUIRED);
> > - /*
> > - prop= RNA_def_pointer(func, "mesh", "Mesh", "", "A new mesh.");
> > - RNA_def_function_return(func, prop);
> > - */
> > +
> > + func= RNA_def_function(srna, "copy_applied",
> "RNA_api_mesh_copy_applied");
> > + RNA_def_function_ui_description(func, "Copy mesh data from object
> with all modifiers and transformations applied.");
> > + prop= RNA_def_pointer(func, "sce", "Scene", "", "Scene.");
> > + RNA_def_property_flag(prop, PROP_REQUIRED);
> > + prop= RNA_def_pointer(func, "ob", "Object", "", "Object to copy
> data from.");
> > + RNA_def_property_flag(prop, PROP_REQUIRED);
> > + RNA_def_boolean(func, "apply_obmat", 1, "", "Apply object
> matrix.");
> > }
> >
> > void RNA_def_mesh(BlenderRNA *brna)
> >
> >
> > _______________________________________________
> > Bf-blender-cvs mailing list
> > Bf-blender-cvs at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-blender-cvs
> >
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>
More information about the Bf-committers
mailing list