svn merge -r40197:40311 ^/trunk/blender
authorCampbell Barton <ideasman42@gmail.com>
Sun, 18 Sep 2011 02:35:26 +0000 (02:35 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 18 Sep 2011 02:35:26 +0000 (02:35 +0000)
1  2 
source/blender/blenkernel/intern/armature.c
source/blender/editors/armature/editarmature.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_view3d/drawobject.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_scene.c

@@@ -1483,7 -1483,6 +1483,6 @@@ static void pose_proxy_synchronize(Obje
                        pchanw.next= pchan->next;
                        pchanw.parent= pchan->parent;
                        pchanw.child= pchan->child;
-                       pchanw.path= NULL;
                        
                        /* this is freed so copy a copy, else undo crashes */
                        if(pchanw.prop) {
@@@ -2465,32 -2464,3 +2464,32 @@@ void where_is_pose (Scene *scene, Objec
                }
        }
  }
 +
 +/* Jason was here */
 +/* Returns total selected vgroups */
 +int get_selected_defgroups(Object *ob, char *dg_selection, int defbase_len)
 +{
 +      bDeformGroup *defgroup;
 +      unsigned int i;
 +      Object *armob= object_pose_armature_get(ob);
 +      int dg_flags_sel_tot= 0;
 +
 +      if(armob) {
 +              bPose *pose= armob->pose;
 +              for (i= 0, defgroup= ob->defbase.first; i < defbase_len && defgroup; defgroup = defgroup->next, i++) {
 +                      bPoseChannel *pchan= get_pose_channel(pose, defgroup->name);
 +                      if(pchan && (pchan->bone->flag & BONE_SELECTED)) {
 +                              dg_selection[i]= TRUE;
 +                              dg_flags_sel_tot++;
 +                      }
 +                      else {
 +                              dg_selection[i]= FALSE;
 +                      }
 +              }
 +      }
 +      else {
 +              memset(dg_selection, FALSE, sizeof(char) * defbase_len);
 +      }
 +
 +      return dg_flags_sel_tot;
 +}
@@@ -361,7 -361,7 +361,7 @@@ static void fix_bonelist_roll (ListBas
                        print_m4("premat", premat);
                        print_m4("postmat", postmat);
                        print_m4("difmat", difmat);
-                       printf ("Roll = %f\n",  (-atan2(difmat[2][0], difmat[2][2]) * (180.0/M_PI)));
+                       printf ("Roll = %f\n",  RAD2DEGF(-atan2(difmat[2][0], difmat[2][2])));
  #endif
                        curBone->roll = (float)-atan2(difmat[2][0], difmat[2][2]);
                        
@@@ -4276,74 -4276,30 +4276,74 @@@ static int bone_looper(Object *ob, Bon
        
        return count;
  }
 +// Jason
 +Bone* get_other_selected_bone(Object *ob) {
 +      Bone *bone;
 +      int i;
 +      bone = get_indexed_bone(ob, 0);
 +      for(i = 0; bone;){
 +              if(bone->flag & BONE_SELECTED) {
 +                      return bone;
 +              }
 +              i++;
 +              bone = get_indexed_bone(ob, i);
 +      }
  
 +      return NULL;
 +}
  /* called from editview.c, for mode-less pose selection */
  /* assumes scene obact and basact is still on old situation */
  int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend)
  {
        Object *ob= base->object;
        Bone *nearBone;
 -      
 +
        if (!ob || !ob->pose) return 0;
  
        nearBone= get_bone_from_selectbuffer(scene, base, buffer, hits, 1);
 -      
 +
        /* if the bone cannot be affected, don't do anything */
        if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) {
                bArmature *arm= ob->data;
                
                /* since we do unified select, we don't shift+select a bone if the armature object was not active yet */
 -              if (!(extend) || (base != scene->basact)) {
 +              /* Jason was here, I'm doing a select for multibone painting */
 +              if (scene->toolsettings->multipaint && (base != scene->basact)) {//if (!(extend) || (base != scene->basact)) {
 +                      Bone *new_act_bone;
 +                      /* Jason was here */
 +                      /* only deselect all if they aren't using 'shift' */
 +                      if(!extend) {
 +                              ED_pose_deselectall(ob, 0);
 +                              nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
 +                              arm->act_bone= nearBone;
 +                              ED_vgroup_select_by_name(OBACT, nearBone->name);
 +                      }
 +                      else {
 +                              // Jason deselect this bone specifically if it is selected already
 +                              if (nearBone->flag & BONE_SELECTED) {
 +                                      nearBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
 +                                      if(nearBone == arm->act_bone) {
 +                                              // make a different bone the active one if it exists
 +                                              new_act_bone = get_other_selected_bone(ob);
 +                                              if(new_act_bone) {
 +                                                      new_act_bone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
 +                                                      arm->act_bone = new_act_bone;
 +                                                      ED_vgroup_select_by_name(OBACT, new_act_bone->name);
 +                                              }
 +                                      }
 +                              // or select the bone if they are using shift
 +                              } else {
 +                                      nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
 +                                      arm->act_bone= nearBone;
 +                              }
 +                      } 
 +                      DAG_id_tag_update(&OBACT->id, OB_RECALC_DATA);
 +                              // XXX old cruft! use notifiers instead
 +                      //select_actionchannel_by_name(ob->action, nearBone->name, 1);
 +              } else if (!(extend) || (base != scene->basact)) {
                        ED_pose_deselectall(ob, 0);
                        nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
                        arm->act_bone= nearBone;
 -                      
 -                              // XXX old cruft! use notifiers instead
 -                      //select_actionchannel_by_name(ob->action, nearBone->name, 1);
                }
                else {
                        if (nearBone->flag & BONE_SELECTED) {
@@@ -5105,10 -5061,6 +5105,10 @@@ void POSE_OT_select_inverse(wmOperatorT
  static int pose_de_select_all_exec(bContext *C, wmOperator *op)
  {
        int action = RNA_enum_get(op->ptr, "action");
 +      //Jason
 +      Object *ob = NULL;
 +      Scene *scene= CTX_data_scene(C);
 +      int multipaint = scene->toolsettings->multipaint;
  
        if (action == SEL_TOGGLE) {
                action= CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
        CTX_DATA_END;
  
        WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL);
 -      
 +      // Jason
 +      if(multipaint) {
 +              ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
 +              DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 +      }
 +
        return OPERATOR_FINISHED;
  }
  
@@@ -717,7 -717,7 +717,7 @@@ static int project_paint_PickColor(cons
   *  1 : occluded
        2       : occluded with w[3] weights set (need to know in some cases) */
  
- static int project_paint_occlude_ptv(float pt[3], float v1[3], float v2[3], float v3[3], float w[3], int is_ortho)
+ static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], float v3[4], float w[3], int is_ortho)
  {
        /* if all are behind us, return false */
        if(v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2])
  
  static int project_paint_occlude_ptv_clip(
                const ProjPaintState *ps, const MFace *mf,
-               float pt[3], float v1[3], float v2[3], float v3[3],
+               float pt[3], float v1[4], float v2[4], float v3[4],
                const int side )
  {
        float w[3], wco[3];
@@@ -5408,16 -5408,7 +5408,16 @@@ int facemask_paint_poll(bContext *C
  {
        return paint_facesel_test(CTX_data_active_object(C));
  }
 -
 +// Jason
 +int vert_paint_poll(bContext *C)
 +{
 +      return paint_vertsel_test(CTX_data_active_object(C));
 +}
 +// Jason
 +int mask_paint_poll(bContext *C)
 +{
 +      return paint_facesel_test(CTX_data_active_object(C)) || paint_vertsel_test(CTX_data_active_object(C));
 +}
  /* use project paint to re-apply an image */
  static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
  {
@@@ -77,7 -77,6 +77,7 @@@
  #include "BKE_pointcache.h"
  #include "BKE_unit.h"
  
 +
  #include "smoke_API.h"
  
  #include "IMB_imbuf.h"
@@@ -86,7 -85,6 +86,7 @@@
  #include "BIF_gl.h"
  #include "BIF_glutil.h"
  
 +#include "GPU_buffers.h"// Jason
  #include "GPU_draw.h"
  #include "GPU_extensions.h"
  
@@@ -259,7 -257,9 +259,9 @@@ static float cube[8][3] = 
  
  /* ----------------- OpenGL Circle Drawing - Tables for Optimised Drawing Speed ------------------ */
  /* 32 values of sin function (still same result!) */
- static float sinval[32] = {
+ #define CIRCLE_RESOL 32
+ static const float sinval[CIRCLE_RESOL] = {
        0.00000000,
        0.20129852,
        0.39435585,
  };
  
  /* 32 values of cos function (still same result!) */
- static float cosval[32] ={
+ static const float cosval[CIRCLE_RESOL] = {
        1.00000000,
        0.97952994,
        0.91895781,
@@@ -613,28 -613,39 +615,39 @@@ static void draw_empty_image(Object *ob
        glPopMatrix();
  }
  
void drawcircball(int mode, const float cent[3], float rad, float tmat[][4])
static void circball_array_fill(float verts[CIRCLE_RESOL][3], const float cent[3], float rad, float tmat[][4])
  {
-       float vec[3], vx[3], vy[3];
-       int a, tot=32;
+       float vx[3], vy[3];
+       float *viter= (float *)verts;
+       unsigned int a;
  
        mul_v3_v3fl(vx, tmat[0], rad);
        mul_v3_v3fl(vy, tmat[1], rad);
  
-       glBegin(mode);
-       for(a=0; a<tot; a++) {
-               vec[0]= cent[0] + *(sinval+a) * vx[0] + *(cosval+a) * vy[0];
-               vec[1]= cent[1] + *(sinval+a) * vx[1] + *(cosval+a) * vy[1];
-               vec[2]= cent[2] + *(sinval+a) * vx[2] + *(cosval+a) * vy[2];
-               glVertex3fv(vec);
+       for (a=0; a < CIRCLE_RESOL; a++, viter += 3) {
+               viter[0]= cent[0] + sinval[a] * vx[0] + cosval[a] * vy[0];
+               viter[1]= cent[1] + sinval[a] * vx[1] + cosval[a] * vy[1];
+               viter[2]= cent[2] + sinval[a] * vx[2] + cosval[a] * vy[2];
        }
-       glEnd();
+ }
+ void drawcircball(int mode, const float cent[3], float rad, float tmat[][4])
+ {
+       float verts[CIRCLE_RESOL][3];
+       circball_array_fill(verts, cent, rad, tmat);
+       glEnableClientState(GL_VERTEX_ARRAY);
+       glVertexPointer(3, GL_FLOAT, 0, verts);
+       glDrawArrays(mode, 0, CIRCLE_RESOL);
+       glDisableClientState(GL_VERTEX_ARRAY);
  }
  
  /* circle for object centers, special_color is for library or ob users */
  static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, const float co[3], int selstate, int special_color)
  {
        const float size= ED_view3d_pixel_size(rv3d, co) * (float)U.obcenter_dia * 0.5f;
+       float verts[CIRCLE_RESOL][3];
  
        /* using gldepthfunc guarantees that it does write z values, but not checks for it, so centers remain visible independt order of drawing */
        if(v3d->zbuf)  glDepthFunc(GL_ALWAYS);
                else if (selstate == SELECT) UI_ThemeColorShadeAlpha(TH_SELECT, 0, -80);
                else if (selstate == DESELECT) UI_ThemeColorShadeAlpha(TH_TRANSFORM, 0, -80);
        }
-       drawcircball(GL_POLYGON, co, size, rv3d->viewinv);
-       
+       circball_array_fill(verts, co, size, rv3d->viewinv);
+       /* enable vertex array */
+       glEnableClientState(GL_VERTEX_ARRAY);
+       glVertexPointer(3, GL_FLOAT, 0, verts);
+       /* 1. draw filled, blended polygon */
+       glDrawArrays(GL_POLYGON, 0, CIRCLE_RESOL);
+       /* 2. draw outline */
        UI_ThemeColorShadeAlpha(TH_WIRE, 0, -30);
-       drawcircball(GL_LINE_LOOP, co, size, rv3d->viewinv);
-       
+       glDrawArrays(GL_LINE_LOOP, 0, CIRCLE_RESOL);
+       /* finishe up */
+       glDisableClientState(GL_VERTEX_ARRAY);
        glDisable(GL_BLEND);
        if(v3d->zbuf)  glDepthFunc(GL_LEQUAL);
  }
  
@@@ -1715,71 -1739,7 +1741,71 @@@ void mesh_foreachScreenVert(ViewContex
  
        dm->release(dm);
  }
 +/*Jason */
 +static void mesh_obmode_foreachScreenVert__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
 +{
 +      struct { void (*func)(void *userData, MVert *mv, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; } *data = userData;
 +      Mesh *me = data->vc.obact->data;
 +      MVert *mv = me->mvert+index;
 +      //MVert *dmv = CDDM_get_verts(data->vc.obact->derivedFinal)+index;
 +      //MVert *mv = CDDM_get_verts(data->vc.obact->derivedFinal)+index;
 +      if ((mv->flag & ME_HIDE)==0) {
 +              short s[2]= {IS_CLIPPED, 0};
 +
 +              if (data->clipVerts) {
 +                      view3d_project_short_clip(data->vc.ar, co, s, 1);
 +              } else {
 +                      view3d_project_short_noclip(data->vc.ar, co, s);
 +              }
 +
 +              if (s[0]!=IS_CLIPPED)
 +                      data->func(data->userData, mv, s[0], s[1], index);
 +      }
 +}
 +/*Jason*/
 +void mesh_obmode_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, MVert *mv, int x, int y, int index), void *userData, int clipVerts)
 +{
 +      struct { void (*func)(void *userData, MVert *mv, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; } data;
 +      DerivedMesh *dm = mesh_get_derived_final(vc->scene, vc->obact, CD_MASK_BAREMESH);
  
 +      data.vc= *vc;
 +      data.func = func;
 +      data.userData = userData;
 +      data.clipVerts = clipVerts;
 +      
 +      if(clipVerts)
 +              ED_view3d_local_clipping(vc->rv3d, vc->obact->obmat); /* for local clipping lookups */
 +
 +      dm->foreachMappedVert(dm, mesh_obmode_foreachScreenVert__mapFunc, &data);
 +
 +      dm->release(dm);
 +}
 +
 +/* Jason draw callback */
 +static void drawSelectedVertices__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s)
 +{
 +      MVert *mv = userData;
 +      mv+=index;
 +      //printf("%d\n", index);
 +      if(!(mv->flag & ME_HIDE)) {
 +              const char sel= mv->flag & 1;
 +
 +              // TODO define selected color
 +              if(sel) {
 +                      glColor3f(1.0f, 1.0f, 0.0f);
 +              }else {
 +                      glColor3f(0.0f, 0.0f, 0.0f);
 +              }
 +
 +              glVertex3fv(co);
 +      }
 +}
 +/* Jason */
 +static void drawSelectedVertices(DerivedMesh *dm, Mesh *me) {
 +      glBegin(GL_POINTS);
 +      dm->foreachMappedVert(dm, drawSelectedVertices__mapFunc, me->mvert);
 +      glEnd();
 +}
  static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, float *v0co, float *v1co)
  {
        struct { void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ViewContext vc; int clipVerts; } *data = userData;
@@@ -2964,16 -2924,7 +2990,16 @@@ static void draw_mesh_fancy(Scene *scen
                        bglPolygonOffset(rv3d->dist, 0.0);
                }
        }
 -
 +      // Jason
 +      if(paint_vertsel_test(ob)) {
 +              
 +              glColor3f(0.0f, 0.0f, 0.0f);
 +              glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
 +              
 +              drawSelectedVertices(dm, ob->data);
 +              
 +              glPointSize(1.0f);
 +      }
        dm->release(dm);
  }
  
@@@ -4587,16 -4538,22 +4613,22 @@@ static void tekenhandlesN(Nurb *nu, sho
  {
        BezTriple *bezt;
        float *fp;
-       int basecol;
        int a;
-       
        if(nu->hide || hide_handles) return;
  
        glBegin(GL_LINES); 
-       
        if(nu->type == CU_BEZIER) {
-               if(sel) basecol= TH_HANDLE_SEL_FREE;
-               else basecol= TH_HANDLE_FREE;
+ #define TH_HANDLE_COL_TOT ((TH_HANDLE_SEL_FREE - TH_HANDLE_FREE) + 1)
+               /* use MIN2 when indexing to ensure newer files dont read outside the array */
+               unsigned char handle_cols[TH_HANDLE_COL_TOT][3];
+               const int basecol= sel ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
+               for (a=0; a < TH_HANDLE_COL_TOT; a++) {
+                       UI_GetThemeColor3ubv(basecol + a, handle_cols[a]);
+               }
  
                bezt= nu->bezt;
                a= nu->pntsu;
                                if( (bezt->f2 & SELECT)==sel) {
                                        fp= bezt->vec[0];
  
-                                       UI_ThemeColor(basecol + bezt->h1);
+                                       glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT-1)]);
                                        glVertex3fv(fp);
                                        glVertex3fv(fp+3); 
  
-                                       UI_ThemeColor(basecol + bezt->h2);
+                                       glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT-1)]);
                                        glVertex3fv(fp+3); 
                                        glVertex3fv(fp+6); 
                                }
                                else if( (bezt->f1 & SELECT)==sel) {
                                        fp= bezt->vec[0];
  
-                                       UI_ThemeColor(basecol + bezt->h1);
+                                       glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT-1)]);
                                        glVertex3fv(fp); 
                                        glVertex3fv(fp+3); 
                                }
                                else if( (bezt->f3 & SELECT)==sel) {
                                        fp= bezt->vec[1];
  
-                                       UI_ThemeColor(basecol + bezt->h2);
+                                       glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT-1)]);
                                        glVertex3fv(fp); 
                                        glVertex3fv(fp+3); 
                                }
                        }
                        bezt++;
                }
+ #undef TH_HANDLE_COL_TOT
        }
        glEnd();
  }
@@@ -5097,7 -5057,7 +5132,7 @@@ static void curve_draw_speed(Scene *sce
  #endif // XXX old animation system stuff
  
  
- static void draw_textcurs(float textcurs[][2])
+ static void draw_textcurs(float textcurs[4][2])
  {
        cpack(0);
        
  static void drawspiral(const float cent[3], float rad, float tmat[][4], int start)
  {
        float vec[3], vx[3], vy[3];
-       int a, tot=32;
-       char inverse=0;
-               
+       const float tot_inv= (1.0f / (float)CIRCLE_RESOL);
+       int a;
+       char inverse= FALSE;
        if (start < 0) {
-               inverse = 1;
-               start *= -1;
+               inverse = TRUE;
+               start= -start;
        }
  
        mul_v3_v3fl(vx, tmat[0], rad);
        copy_v3_v3(vec, cent);
  
        if (inverse==0) {
-               for(a=0; a<tot; a++) {
+               for(a=0; a<CIRCLE_RESOL; a++) {
                        if (a+start>31)
                                start=-a + 1;
                        glBegin(GL_LINES);                                                      
                        glVertex3fv(vec);
-                       vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)a/(float)tot) + *(cosval+a+start) * (vy[0] * (float)a/(float)tot);
-                       vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)a/(float)tot) + *(cosval+a+start) * (vy[1] * (float)a/(float)tot);
-                       vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)a/(float)tot) + *(cosval+a+start) * (vy[2] * (float)a/(float)tot);
+                       vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)a * tot_inv) + cosval[a+start] * (vy[0] * (float)a * tot_inv);
+                       vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)a * tot_inv) + cosval[a+start] * (vy[1] * (float)a * tot_inv);
+                       vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)a * tot_inv) + cosval[a+start] * (vy[2] * (float)a * tot_inv);
                        glVertex3fv(vec);
                        glEnd();
                }
        }
        else {
                a=0;
-               vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[0] * (float)(-a+31)/(float)tot);
-               vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[1] * (float)(-a+31)/(float)tot);
-               vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[2] * (float)(-a+31)/(float)tot);
-               for(a=0; a<tot; a++) {
+               vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[0] * (float)(-a+31) * tot_inv);
+               vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[1] * (float)(-a+31) * tot_inv);
+               vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[2] * (float)(-a+31) * tot_inv);
+               for(a=0; a<CIRCLE_RESOL; a++) {
                        if (a+start>31)
                                start=-a + 1;
                        glBegin(GL_LINES);                                                      
                        glVertex3fv(vec);
-                       vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[0] * (float)(-a+31)/(float)tot);
-                       vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[1] * (float)(-a+31)/(float)tot);
-                       vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[2] * (float)(-a+31)/(float)tot);
+                       vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[0] * (float)(-a+31) * tot_inv);
+                       vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[1] * (float)(-a+31) * tot_inv);
+                       vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[2] * (float)(-a+31) * tot_inv);
                        glVertex3fv(vec);
                        glEnd();
                }
@@@ -5170,9 -5131,9 +5206,9 @@@ static void drawcircle_size(float size
        glBegin(GL_LINE_LOOP);
  
        /* coordinates are: cos(degrees*11.25)=x, sin(degrees*11.25)=y, 0.0f=z */
-       for (degrees=0; degrees<32; degrees++) {
-               x= *(cosval + degrees);
-               y= *(sinval + degrees);
+       for (degrees=0; degrees<CIRCLE_RESOL; degrees++) {
+               x= cosval[degrees];
+               y= sinval[degrees];
                
                glVertex3f(x*size, 0.0f, y*size);
        }
@@@ -5440,8 -5401,7 +5476,7 @@@ static void draw_forcefield(Scene *scen
  
                unit_m4(tmat);
  
-               radius=(pd->flag&PFIELD_USEMAXR)?pd->maxrad:1.0f;
-               radius*=(float)M_PI/180.0f;
+               radius= DEG2RADF((pd->flag&PFIELD_USEMAXR) ? pd->maxrad : 1.0f);
                distance=(pd->flag&PFIELD_USEMAX)?pd->maxdist:0.0f;
  
                if(pd->flag & (PFIELD_USEMAX|PFIELD_USEMAXR)){
                                drawcone(vec, distance * sinf(radius),-distance * cosf(radius),tmat);
                }
  
-               radius=(pd->flag&PFIELD_USEMINR)?pd->minrad:1.0f;
-               radius*=(float)M_PI/180.0f;
+               radius= DEG2RADF((pd->flag&PFIELD_USEMINR) ? pd->minrad : 1.0f);
                distance=(pd->flag&PFIELD_USEMIN)?pd->mindist:0.0f;
  
                if(pd->flag & (PFIELD_USEMIN|PFIELD_USEMINR)){
@@@ -6556,32 -6515,6 +6590,32 @@@ void draw_object(Scene *scene, ARegion 
  }
  
  /* ***************** BACKBUF SEL (BBS) ********* */
 +/* Jason */
 +static void bbs_obmode_mesh_verts__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
 +{
 +      struct {void* offset; MVert *mvert;} *data = userData;
 +      MVert *mv = data->mvert+index;
 +      int offset = (intptr_t) data->offset;
 +
 +      if (!(mv->flag & ME_HIDE)) {
 +              WM_set_framebuffer_index_color(offset+index);
 +              bglVertex3fv(co);
 +      }
 +}
 +/* Jason */
 +static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset)
 +{
 +      struct {void* offset; struct MVert *mvert;} data;
 +      Mesh *me = ob->data;
 +      MVert *mvert = me->mvert;
 +      data.mvert = mvert;
 +      data.offset = (void*)(intptr_t) offset;
 +      glPointSize( UI_GetThemeValuef(TH_VERTEX_SIZE) );
 +      bglBegin(GL_POINTS);
 +      dm->foreachMappedVert(dm, bbs_obmode_mesh_verts__mapFunc, &data);
 +      bglEnd();
 +      glPointSize(1.0);
 +}
  
  static void bbs_mesh_verts__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
  {
@@@ -6680,18 -6613,7 +6714,18 @@@ static int bbs_mesh_solid_hide__setDraw
                return 0;
        }
  }
 +/* Jason */
 +// must have called WM_set_framebuffer_index_color beforehand
 +static int bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index, int *UNUSED(drawSmooth_r))
 +{
 +      Mesh *me = userData;
  
 +      if (!(me->mface[index].flag&ME_HIDE)) {
 +              return 1;
 +      } else {
 +              return 0;
 +      }
 +}
  static void bbs_mesh_solid(Scene *scene, Object *ob)
  {
        DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
@@@ -6750,21 -6672,7 +6784,21 @@@ void draw_object_backbufsel(Scene *scen
                        EM_free_index_arrays();
                }
                else {
 -                      bbs_mesh_solid(scene, ob);
 +                      Mesh *me= ob->data;
 +                      if(me->editflag & ME_EDIT_VERT_SEL) {
 +                              DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
 +                              glColor3ub(0, 0, 0);
 +
 +                              dm->drawMappedFaces(dm, bbs_mesh_solid_hide2__setDrawOpts, me, 0, GPU_enable_material, NULL);
 +
 +                              
 +                              bbs_obmode_mesh_verts(ob, dm, 1);
 +                              em_vertoffs = me->totvert+1;
 +                              dm->release(dm);
 +                      }
 +                      else {
 +                              bbs_mesh_solid(scene, ob);
 +                      }
                }
                break;
        case OB_CURVE:
@@@ -90,24 -90,6 +90,24 @@@ void rna_Mesh_update_draw(Main *UNUSED(
        }
  }
  
 +/* Jason */
 +void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr)
 +{
 +      Mesh* me = ptr->data;
 +      if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) {
 +              me->editflag ^= ME_EDIT_PAINT_MASK;
 +      }
 +      rna_Mesh_update_draw(bmain, scene, ptr);
 +}
 +/* Jason */
 +void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr)
 +{
 +      Mesh* me = ptr->data;
 +      if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) {
 +              me->editflag ^= ME_EDIT_VERT_SEL;
 +      }
 +      rna_Mesh_update_draw(bmain, scene, ptr);
 +}
  static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value)
  {
        MVert *mvert= (MVert*)ptr->data;
@@@ -708,7 -690,7 +708,7 @@@ static void rna_MeshTextureFaceLayer_na
        Mesh *me= (Mesh*)ptr->id.data;
        CustomData *fdata= rna_mesh_fdata(me);
        CustomDataLayer *cdl= (CustomDataLayer*)ptr->data;
-       BLI_strncpy(cdl->name, value, sizeof(cdl->name));
+       BLI_strncpy_utf8(cdl->name, value, sizeof(cdl->name));
        CustomData_set_layer_unique_name(fdata, cdl - fdata->layers);
  }
  
@@@ -820,7 -802,7 +820,7 @@@ static void rna_MeshColorLayer_name_set
        Mesh *me= (Mesh*)ptr->id.data;
        CustomData *fdata= rna_mesh_fdata(me);
        CustomDataLayer *cdl= (CustomDataLayer*)ptr->data;
-       BLI_strncpy(cdl->name, value, sizeof(cdl->name));
+       BLI_strncpy_utf8(cdl->name, value, sizeof(cdl->name));
        CustomData_set_layer_unique_name(fdata, cdl - fdata->layers);
  }
  
@@@ -2093,14 -2075,8 +2093,14 @@@ static void rna_def_mesh(BlenderRNA *br
        RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_PAINT_MASK);
        RNA_def_property_ui_text(prop, "Paint Mask", "Face selection masking for painting");
        RNA_def_property_ui_icon(prop, ICON_FACESEL_HLT, 0);
 -      RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
 -
 +      RNA_def_property_update(prop, 0, "rna_Mesh_update_facemask");
 +
 +      /* Jason */
 +      prop= RNA_def_property(srna, "use_paint_mask_vertex", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_VERT_SEL);
 +      RNA_def_property_ui_text(prop, "Vertex Selection", "Vertex selection masking for painting (weight paint only)");
 +      RNA_def_property_ui_icon(prop, ICON_VERTEXSEL, 0);
 +      RNA_def_property_update(prop, 0, "rna_Mesh_update_vertmask");
  
        /* readonly editmesh info - use for extrude menu */
        prop= RNA_def_property(srna, "total_vert_sel", PROP_INT, PROP_UNSIGNED);
@@@ -466,7 -466,7 +466,7 @@@ void rna_VertexGroup_name_set(PointerRN
  {
        Object *ob= (Object *)ptr->id.data;
        bDeformGroup *dg= (bDeformGroup *)ptr->data;
-       BLI_strncpy(dg->name, value, sizeof(dg->name));
+       BLI_strncpy_utf8(dg->name, value, sizeof(dg->name));
        defgroup_unique_name(dg, ob);
  }
  
@@@ -512,7 -512,7 +512,7 @@@ void rna_object_vgroup_name_index_get(P
        dg= BLI_findlink(&ob->defbase, index-1);
  
        if(dg) BLI_strncpy(value, dg->name, sizeof(dg->name));
-       else BLI_strncpy(value, "", sizeof(dg->name));
+       else value[0]= '\0';
  }
  
  int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index)
@@@ -535,7 -535,7 +535,7 @@@ void rna_object_vgroup_name_set(Pointer
        Object *ob= (Object*)ptr->id.data;
        bDeformGroup *dg= defgroup_find_name(ob, value);
        if(dg) {
-               BLI_strncpy(result, value, maxlen);
+               BLI_strncpy(result, value, maxlen); /* no need for BLI_strncpy_utf8, since this matches an existing group */
                return;
        }
  
@@@ -562,7 -562,7 +562,7 @@@ void rna_object_uvlayer_name_set(Pointe
                }
        }
  
-       BLI_strncpy(result, "", maxlen);
+       result[0]= '\0';
  }
  
  void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
                }
        }
  
-       BLI_strncpy(result, "", maxlen);
+       result[0]= '\0';
  }
  
  static int rna_Object_active_material_index_get(PointerRNA *ptr)
@@@ -836,7 -836,7 +836,7 @@@ static void rna_MaterialSlot_name_get(P
        if(ma)
                strcpy(str, ma->id.name+2);
        else
-               strcpy(str, "");
+               str[0]= '\0';
  }
  
  static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr)
@@@ -1265,11 -1265,6 +1265,11 @@@ static void rna_def_vertex_group(Blende
        RNA_def_struct_name_property(srna, prop);
        RNA_def_property_string_funcs(prop, NULL, NULL, "rna_VertexGroup_name_set");
        RNA_def_property_update(prop, NC_GEOM|ND_DATA|NA_RENAME, "rna_Object_internal_update_data"); /* update data because modifiers may use [#24761] */
 +      /* Jason was here */
 +      prop= RNA_def_property(srna, "lock_weight", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_ui_text(prop, "", "Maintain the relative weights for the group");
 +      RNA_def_property_boolean_sdna(prop, NULL, "flag", 0);
 +      RNA_def_property_update(prop, NC_GEOM|ND_DATA|NA_RENAME, "rna_Object_internal_update_data"); /* update data because modifiers may use [#24761] */
  
        prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@@ -737,7 -737,7 +737,7 @@@ static void rna_RenderSettings_engine_s
        RenderEngineType *type= BLI_findlink(&R_engines, value);
  
        if(type)
-               BLI_strncpy(rd->engine, type->idname, sizeof(rd->engine));
+               BLI_strncpy_utf8(rd->engine, type->idname, sizeof(rd->engine));
  }
  
  static EnumPropertyItem *rna_RenderSettings_engine_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
@@@ -810,7 -810,7 +810,7 @@@ static void rna_SceneRenderLayer_name_s
        Scene *scene= (Scene*)ptr->id.data;
        SceneRenderLayer *rl= (SceneRenderLayer*)ptr->data;
  
-       BLI_strncpy(rl->name, value, sizeof(rl->name));
+       BLI_strncpy_utf8(rl->name, value, sizeof(rl->name));
  
        if(scene->nodetree) {
                bNode *node;
@@@ -1011,7 -1011,7 +1011,7 @@@ static TimeMarker *rna_TimeLine_add(Sce
        TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
        marker->flag= SELECT;
        marker->frame= 1;
-       BLI_strncpy(marker->name, name, sizeof(marker->name));
+       BLI_strncpy_utf8(marker->name, name, sizeof(marker->name));
        BLI_addtail(&scene->markers, marker);
        return marker;
  }
@@@ -1120,14 -1120,6 +1120,14 @@@ static void rna_def_tool_settings(Blend
        RNA_def_property_ui_text(prop, "WPaint Auto-Normalize", 
                "Ensure all bone-deforming vertex groups add up to 1.0 while "
                 "weight painting");
 +      RNA_def_property_update(prop, NC_GEOM|ND_DATA, 0);
 +
 +      prop = RNA_def_property(srna, "use_multipaint", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "multipaint", 1);
 +      RNA_def_property_ui_text(prop, "WPaint Multi-Paint", 
 +              "Paint across all selected bones while "
 +               "weight painting");
 +      RNA_def_property_update(prop, NC_GEOM|ND_DATA, 0);
  
        prop= RNA_def_property(srna, "vertex_paint", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "vpaint");
@@@ -1819,8 -1811,8 +1819,8 @@@ static void rna_def_scene_game_data(Ble
  
        static EnumPropertyItem obstacle_simulation_items[] = {
                {OBSTSIMULATION_NONE, "NONE", 0, "None", ""},
-               {OBSTSIMULATION_TOI_rays, "RVO (rays)", 0, "RVO (rays)", ""},
-               {OBSTSIMULATION_TOI_cells, "RVO (cells)", 0, "RVO (cells)", ""},
+               {OBSTSIMULATION_TOI_rays, "RVO_RAYS", 0, "RVO (rays)", ""},
+               {OBSTSIMULATION_TOI_cells, "RVO_CELLS", 0, "RVO (cells)", ""},
                {0, NULL, 0, NULL, NULL}};
  
        srna= RNA_def_struct(brna, "SceneGameData", NULL);