Revision: 36897
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36897
Author:   psy-fi
Date:     2011-05-25 15:23:18 +0000 (Wed, 25 May 2011)
Log Message:
-----------
merge to trunk r36896

Revision Links:
--------------
    
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36896

Modified Paths:
--------------
    
branches/soc-2011-onion/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py
    branches/soc-2011-onion/source/blender/editors/armature/editarmature.c
    branches/soc-2011-onion/source/blender/editors/interface/interface_layout.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2011-onion/source/blender/editors/space_graph/graph_select.c
    branches/soc-2011-onion/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2011-onion/source/blender/editors/space_view3d/view3d_draw.c
    branches/soc-2011-onion/source/blender/imbuf/intern/scaling.c
    branches/soc-2011-onion/source/blender/python/generic/bgl.c
    branches/soc-2011-onion/source/blender/python/generic/blf_py_api.c
    branches/soc-2011-onion/source/blender/python/generic/mathutils.c
    branches/soc-2011-onion/source/blender/python/generic/mathutils_Color.c
    branches/soc-2011-onion/source/blender/python/generic/mathutils_Euler.c
    branches/soc-2011-onion/source/blender/python/generic/mathutils_Matrix.c
    branches/soc-2011-onion/source/blender/python/generic/mathutils_Quaternion.c
    branches/soc-2011-onion/source/blender/python/generic/mathutils_Vector.c
    branches/soc-2011-onion/source/blender/python/generic/mathutils_geometry.c
    branches/soc-2011-onion/source/blender/python/generic/noise_py_api.c
    branches/soc-2011-onion/source/blender/python/intern/bpy.c
    branches/soc-2011-onion/source/blender/python/intern/bpy_library.c
    branches/soc-2011-onion/source/blender/python/intern/bpy_props.c
    branches/soc-2011-onion/source/blender/python/intern/bpy_rna.c
    branches/soc-2011-onion/source/blender/windowmanager/intern/wm_operators.c
    branches/soc-2011-onion/source/creator/CMakeLists.txt

Property Changed:
----------------
    branches/soc-2011-onion/


Property changes on: branches/soc-2011-onion
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/blender:36833-36869
   + /trunk/blender:36833-36896

Modified: 
branches/soc-2011-onion/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py
===================================================================
--- 
branches/soc-2011-onion/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py
        2011-05-25 13:10:07 UTC (rev 36896)
+++ 
branches/soc-2011-onion/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py
        2011-05-25 15:23:18 UTC (rev 36897)
@@ -34,6 +34,6 @@
 with bpy.data.libraries.load(filepath) as (data_from, data_to):
     data_to.meshes = data_from.meshes
 # now operate directly on the loaded data
-for mesh in mdata_to.meshes:
+for mesh in data_to.meshes:
     if mesh is not None:
         print(mesh.name)

Modified: branches/soc-2011-onion/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/armature/editarmature.c      
2011-05-25 13:10:07 UTC (rev 36896)
+++ branches/soc-2011-onion/source/blender/editors/armature/editarmature.c      
2011-05-25 15:23:18 UTC (rev 36897)
@@ -2491,14 +2491,12 @@
        Scene *scene;
        ARegion *ar;
        View3D *v3d;
-       RegionView3D *rv3d;
        float *fp = NULL, tvec[3], oldcurs[3], mval_f[2];
        int retv;
 
        scene= CTX_data_scene(C);
        ar= CTX_wm_region(C);
        v3d = CTX_wm_view3d(C);
-       rv3d= CTX_wm_region_view3d(C);
        
        fp= give_cursor(scene, v3d);
        

Modified: 
branches/soc-2011-onion/source/blender/editors/interface/interface_layout.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/interface/interface_layout.c 
2011-05-25 13:10:07 UTC (rev 36896)
+++ branches/soc-2011-onion/source/blender/editors/interface/interface_layout.c 
2011-05-25 15:23:18 UTC (rev 36897)
@@ -729,6 +729,9 @@
        RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
        prop= RNA_struct_find_property(&ptr, propname);
 
+       /* don't let bad properties slip through */
+       BLI_assert((prop == NULL) || (RNA_property_type(prop) == PROP_ENUM));
+
        if(prop && RNA_property_type(prop) == PROP_ENUM) {
                EnumPropertyItem *item;
                int totitem, i, free;

Modified: 
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h  
2011-05-25 13:10:07 UTC (rev 36896)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h  
2011-05-25 15:23:18 UTC (rev 36897)
@@ -84,6 +84,8 @@
 void PAINT_OT_weight_paint(struct wmOperatorType *ot);
 void PAINT_OT_weight_set(struct wmOperatorType *ot);
 void PAINT_OT_weight_from_bones(struct wmOperatorType *ot);
+void PAINT_OT_weight_sample(struct wmOperatorType *ot);
+void PAINT_OT_weight_sample_group(struct wmOperatorType *ot);
 
 void PAINT_OT_vertex_paint_toggle(struct wmOperatorType *ot);
 void PAINT_OT_vertex_paint(struct wmOperatorType *ot);

Modified: 
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c     
2011-05-25 13:10:07 UTC (rev 36896)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c     
2011-05-25 15:23:18 UTC (rev 36897)
@@ -370,6 +370,8 @@
        WM_operatortype_append(PAINT_OT_weight_paint);
        WM_operatortype_append(PAINT_OT_weight_set);
        WM_operatortype_append(PAINT_OT_weight_from_bones);
+       WM_operatortype_append(PAINT_OT_weight_sample);
+       WM_operatortype_append(PAINT_OT_weight_sample_group);
 
        /* vertex */
        WM_operatortype_append(PAINT_OT_vertex_paint_toggle);
@@ -589,6 +591,10 @@
 
        WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, 
KM_PRESS, 0, 0);
 
+       /* these keys are from 2.4x but could be changed */
+       WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample", LEFTMOUSE, 
KM_PRESS, KM_CTRL, 0);
+       WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample_group", 
LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
+
        WM_keymap_add_item(keymap,
                        "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
 

Modified: 
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c  
2011-05-25 13:10:07 UTC (rev 36896)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c  
2011-05-25 15:23:18 UTC (rev 36897)
@@ -61,6 +61,7 @@
 
 #include "RNA_access.h"
 #include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_action.h"
@@ -72,6 +73,7 @@
 #include "BKE_modifier.h"
 #include "BKE_object.h"
 #include "BKE_paint.h"
+#include "BKE_report.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -855,145 +857,195 @@
 
 /* ----------------------------------------------------- */
 
-/* used for 3d view, on active object, assumes me->dvert exists */
-/* if mode==1: */
-/*     samples cursor location, and gives menu with vertex groups to activate 
*/
-/* else */
-/*     sets wp->weight to the closest weight value to vertex */
-/*     note: we cant sample frontbuf, weight colors are interpolated too 
unpredictable */
-static void sample_wpaint(Scene *scene, ARegion *ar, View3D *UNUSED(v3d), int 
mode)
+
+/* sets wp->weight to the closest weight value to vertex */
+/* note: we cant sample frontbuf, weight colors are interpolated too 
unpredictable */
+static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        ViewContext vc;
-       ToolSettings *ts= scene->toolsettings;
-       Object *ob= OBACT;
-       Mesh *me= get_mesh(ob);
-       int index;
-       int mval[2] = {0, 0}, sco[2];
-       int vgroup= ob->actdef-1;
+       Mesh *me;
+       short change= FALSE;
 
-       if (!me) return;
-       
-//     getmouseco_areawin(mval);
-       index= view3d_sample_backbuf(&vc, mval[0], mval[1]);
-       
-       if(index && index<=me->totface) {
-               MFace *mface;
-               
-               mface= ((MFace *)me->mface) + index-1;
-               
-               if(mode==1) {   /* sampe which groups are in here */
-                       MDeformVert *dv;
-                       int a, totgroup;
-                       
-                       totgroup= BLI_countlist(&ob->defbase);
-                       if(totgroup) {
-                               int totmenu=0;
-                               int *groups=MEM_callocN(totgroup*sizeof(int), 
"groups");
-                               
-                               dv= me->dvert+mface->v1;
-                               for(a=0; a<dv->totweight; a++) {
-                                       if (dv->dw[a].def_nr<totgroup)
-                                               groups[dv->dw[a].def_nr]= 1;
-                               }
-                               dv= me->dvert+mface->v2;
-                               for(a=0; a<dv->totweight; a++) {
-                                       if (dv->dw[a].def_nr<totgroup)
-                                               groups[dv->dw[a].def_nr]= 1;
-                               }
-                               dv= me->dvert+mface->v3;
-                               for(a=0; a<dv->totweight; a++) {
-                                       if (dv->dw[a].def_nr<totgroup)
-                                               groups[dv->dw[a].def_nr]= 1;
-                               }
-                               if(mface->v4) {
-                                       dv= me->dvert+mface->v4;
-                                       for(a=0; a<dv->totweight; a++) {
-                                               if (dv->dw[a].def_nr<totgroup)
-                                                       
groups[dv->dw[a].def_nr]= 1;
-                                       }
-                               }
-                               for(a=0; a<totgroup; a++)
-                                       if(groups[a]) totmenu++;
-                               
-                               if(totmenu==0) {
-                                       //notice("No Vertex Group Selected");
-                               }
-                               else {
-                                       bDeformGroup *dg;
-                                       short val;
-                                       char item[40], *str= 
MEM_mallocN(40*totmenu+40, "menu");
-                                       
-                                       strcpy(str, "Vertex Groups %t");
-                                       for(a=0, dg=ob->defbase.first; dg && 
a<totgroup; a++, dg= dg->next) {
-                                               if(groups[a]) {
-                                                       sprintf(item, "|%s 
%%x%d", dg->name, a);
-                                                       strcat(str, item);
-                                               }
-                                       }
-                                       
-                                       val= 0; // XXX pupmenu(str);
-                                       if(val>=0) {
-                                               ob->actdef= val+1;
-                                               DAG_id_tag_update(&me->id, 0);
-                                       }
-                                       MEM_freeN(str);
-                               }
-                               MEM_freeN(groups);
-                       }
-//                     else notice("No Vertex Groups in Object");
-               }
-               else {
-                       DerivedMesh *dm;
-                       float w1, w2, w3, w4, co[3], fac;
-                       
-                       dm = mesh_get_derived_final(scene, ob, 
CD_MASK_BAREMESH);
+       view3d_set_viewcontext(C, &vc);
+       me= get_mesh(vc.obact);
+
+       if (me && me->dvert && vc.v3d && vc.rv3d) {
+               int index;
+
+               view3d_operator_needs_opengl(C);
+
+               index= view3d_sample_backbuf(&vc, event->mval[0], 
event->mval[1]);
+
+               if(index && index<=me->totface) {
+                       DerivedMesh *dm= mesh_get_derived_final(vc.scene, 
vc.obact, CD_MASK_BAREMESH);
+
                        if(dm->getVertCo==NULL) {
-                               //notice("Not supported yet");
+                               BKE_report(op->reports, RPT_WARNING, "The 
modifier used does not support deformed locations");
                        }
                        else {
-                               /* calc 3 or 4 corner weights */
-                               dm->getVertCo(dm, mface->v1, co);
-                               project_int_noclip(ar, co, sco);
-                               w1= ((mval[0]-sco[0])*(mval[0]-sco[0]) + 
(mval[1]-sco[1])*(mval[1]-sco[1]));
-                               
-                               dm->getVertCo(dm, mface->v2, co);
-                               project_int_noclip(ar, co, sco);
-                               w2= ((mval[0]-sco[0])*(mval[0]-sco[0]) + 
(mval[1]-sco[1])*(mval[1]-sco[1]));
-                               
-                               dm->getVertCo(dm, mface->v3, co);
-                               project_int_noclip(ar, co, sco);
-                               w3= ((mval[0]-sco[0])*(mval[0]-sco[0]) + 
(mval[1]-sco[1])*(mval[1]-sco[1]));
-                               
-                               if(mface->v4) {
-                                       dm->getVertCo(dm, mface->v4, co);
-                                       project_int_noclip(ar, co, sco);
-                                       w4= ((mval[0]-sco[0])*(mval[0]-sco[0]) 
+ (mval[1]-sco[1])*(mval[1]-sco[1]));
-                               }
-                               else w4= 1.0e10;
-                               
-                               fac= MIN4(w1, w2, w3, w4);
-                               if(w1==fac) {
-                                       ts->vgroup_weight= 
defvert_find_weight(me->dvert+mface->v1, vgroup);
-                               }
-                               else if(w2==fac) {
-                                       ts->vgroup_weight= 
defvert_find_weight(me->dvert+mface->v2, vgroup);
-                               }
-                               else if(w3==fac) {
-                                       ts->vgroup_weight= 
defvert_find_weight(me->dvert+mface->v3, vgroup);
-                               }
-                               else if(w4==fac) {
-                                       if(mface->v4) {
-                                               ts->vgroup_weight= 
defvert_find_weight(me->dvert+mface->v4, vgroup);
+                               MFace *mf= ((MFace *)me->mface) + index-1;
+                               const int vgroup= vc.obact->actdef - 1;
+                               ToolSettings *ts= vc.scene->toolsettings;
+                               float mval_f[2];
+                               int v_idx_best= -1;
+                               int fidx;
+                               float len_best= FLT_MAX;
+
+                               mval_f[0]= (float)event->mval[0];
+                               mval_f[1]= (float)event->mval[1];
+
+                               fidx= mf->v4 ? 3:2;
+                               do {
+                                       float co[3], sco[3], len;
+                                       const int v_idx= (*(&mf->v1 + fidx));
+                                       dm->getVertCo(dm, v_idx, co);
+                                       project_float_noclip(vc.ar, co, sco);
+                                       len= len_squared_v2v2(mval_f, sco);
+                                       if(len < len_best) {
+                                               len_best= len;
+                                               v_idx_best= v_idx;
                                        }
+                               } while (fidx--);
+
+                               if(v_idx_best != -1) { /* should always be 
valid */
+                                       ts->vgroup_weight= 
defvert_find_weight(&me->dvert[v_idx_best], vgroup);
+                                       change= TRUE;
                                }
                        }
                        dm->release(dm);
-               }               
-               
+               }
        }
-       
+

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to