Revision: 20936
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20936
Author:   kazanbas
Date:     2009-06-16 20:02:38 +0200 (Tue, 16 Jun 2009)

Log Message:
-----------
RNA_property_collection_add should work now for non-ID properties.
Since it's very limited, and has a doubtful interface, I need help on 
how improve and use it. I'll ask on ML.

Modified Paths:
--------------
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_access.c
    
branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_internal_types.h
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_mesh.c

Modified: branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_access.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_access.c      
2009-06-16 16:15:19 UTC (rev 20935)
+++ branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_access.c      
2009-06-16 18:02:38 UTC (rev 20936)
@@ -1314,6 +1314,7 @@
 void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, 
PointerRNA *r_ptr)
 {
        IDProperty *idprop;
+       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
 
        if((idprop=rna_idproperty_check(&prop, ptr))) {
                IDPropertyTemplate val = {0};
@@ -1339,11 +1340,12 @@
                        MEM_freeN(item);
                }
        }
+       else if(cprop->add){
+               cprop->add(ptr, r_ptr);
+       }
        else
-               printf("RNA_property_collection_add %s.%s: only supported for 
id properties.\n", ptr->type->identifier, prop->identifier);
+               printf("RNA_property_collection_add %s.%s: not implemented for 
this property.\n", ptr->type->identifier, prop->identifier);
 
-       /* TODO: call cprop->add on non-ID props here */
-
        if(r_ptr) {
                if(idprop) {
                        CollectionPropertyRNA *cprop= 
(CollectionPropertyRNA*)prop;

Modified: 
branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_internal_types.h
===================================================================
--- 
branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_internal_types.h  
    2009-06-16 16:15:19 UTC (rev 20935)
+++ 
branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_internal_types.h  
    2009-06-16 18:02:38 UTC (rev 20936)
@@ -78,7 +78,7 @@
 typedef int (*PropCollectionLengthFunc)(struct PointerRNA *ptr);
 typedef PointerRNA (*PropCollectionLookupIntFunc)(struct PointerRNA *ptr, int 
key);
 typedef PointerRNA (*PropCollectionLookupStringFunc)(struct PointerRNA *ptr, 
const char *key);
-typedef void (*PropCollectionAddFunc)(PointerRNA *ptr, PointerRNA *item);
+typedef void (*PropCollectionAddFunc)(PointerRNA *ptr, PointerRNA *ptr_item);
 
 /* Container - generic abstracted container of RNA properties */
 typedef struct ContainerRNA {

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-16 16:15:19 UTC (rev 20935)
+++ branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_mesh.c        
2009-06-16 18:02:38 UTC (rev 20936)
@@ -484,6 +484,33 @@
        tf->tpage= (struct Image*)id;
 }
 
+static void rna_Mesh_verts_begin(CollectionPropertyIterator *iter, PointerRNA 
*ptr)
+{
+       Mesh *me= (Mesh*)ptr->data;
+       rna_iterator_array_begin(iter, me->mvert, sizeof(MVert), me->totvert, 
NULL);
+}
+
+/* extern struct EditVert *addvertlist(EditMesh *em, float *vec, struct 
EditVert *example); */
+
+static void rna_Mesh_verts_add(PointerRNA *ptr, PointerRNA *ptr_item)
+{
+       Mesh *me= (Mesh*)ptr->data;
+
+       /*
+       // XXX if item is not MVert we fail silently
+       if (item->type == RNA_MeshVertex)
+               return;
+
+       // XXX this must be slow...
+       EditMesh *em= BKE_mesh_get_editmesh(me);
+
+       MVert *v = (MVert*)ptr_item->ptr->data;
+       addvertlist(em, v->co, NULL);
+
+       BKE_mesh_end_editmesh(me, em);
+       */
+}
+
 /* path construction */
 
 static char *rna_VertexGroupElement_path(PointerRNA *ptr)
@@ -1054,6 +1081,7 @@
        RNA_def_property_collection_sdna(prop, NULL, "mvert", "totvert");
        RNA_def_property_struct_type(prop, "MeshVertex");
        RNA_def_property_ui_text(prop, "Vertices", "Vertices of the mesh.");
+       RNA_def_property_collection_funcs(prop, "rna_Mesh_verts_begin", 0, 0, 
0, 0, 0, 0, "rna_Mesh_verts_add");
 
        prop= RNA_def_property(srna, "edges", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_collection_sdna(prop, NULL, "medge", "totedge");


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to