Commit: dbccccc0a575f7352876fb32f5973615e6761767
Author: Campbell Barton
Date:   Thu Apr 6 12:32:44 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rBdbccccc0a575f7352876fb32f5973615e6761767

Merge branch 'blender2.8' into custom-manipulators

===================================================================



===================================================================

diff --cc source/blender/editors/transform/transform_manipulator.c
index 960d80762bd,4841b136f1d..4390af496c2
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@@ -478,19 -145,13 +478,19 @@@ static void protectflag_to_drawflags(sh
  }
  
  /* for pose mode */
- static void stats_pchan(Scene *scene, Object *ob, RegionView3D *rv3d, 
bPoseChannel *pchan)
 -static void protectflag_to_drawflags_pchan(RegionView3D *rv3d, const 
bPoseChannel *pchan)
++static void protectflag_to_drawflags_pchan(Scene *scene, Object *ob, 
RegionView3D *rv3d, bPoseChannel *pchan)
  {
 -      protectflag_to_drawflags(pchan->protectflag, &rv3d->twdrawflag);
 +      Bone *bone = pchan->bone;
 +      if (bone) {
 +              /* update pose matrix after transform */
 +              BKE_pose_where_is(scene, ob);
 +
 +              protectflag_to_drawflags(pchan->protectflag, &rv3d->twdrawflag);
 +      }
  }
  
  /* for editmode*/
- static void stats_editbone(RegionView3D *rv3d, EditBone *ebo)
 -static void protectflag_to_drawflags_ebone(RegionView3D *rv3d, const EditBone 
*ebo)
++static void protectflag_to_drawflags_ebone(RegionView3D *rv3d, EditBone *ebo)
  {
        if (ebo->flag & BONE_EDITMODE_LOCKED) {
                protectflag_to_drawflags(OB_LOCK_LOC | OB_LOCK_ROT | 
OB_LOCK_SCALE, &rv3d->twdrawflag);
@@@ -867,7 -528,7 +867,7 @@@ static int calc_manipulator_stats(cons
                        Bone *bone = pchan->bone;
                        if (bone) {
                                calc_tw_center(scene, pchan->pose_head);
-                               stats_pchan(scene, ob, rv3d, pchan);
 -                              protectflag_to_drawflags_pchan(rv3d, pchan);
++                              protectflag_to_drawflags_pchan(scene, ob, rv3d, 
pchan);
                                totsel = 1;
                                ok = true;
                        }
@@@ -881,7 -542,7 +881,7 @@@
                                        Bone *bone = pchan->bone;
                                        if (bone && (bone->flag & 
BONE_TRANSFORM)) {
                                                calc_tw_center(scene, 
pchan->pose_head);
-                                               stats_pchan(scene, ob, rv3d, 
pchan);
 -                                              
protectflag_to_drawflags_pchan(rv3d, pchan);
++                                              
protectflag_to_drawflags_pchan(scene, ob, rv3d, pchan);
                                        }
                                }
                                ok = true;
@@@ -1041,60 -699,101 +1041,60 @@@ static void drawflags_posemode(Object *
        }
  }
  
 -
 -/* ******************** DRAWING STUFFIES *********** */
 -
 -static float screen_aligned(RegionView3D *rv3d, float mat[4][4])
 +static void drawflags_editmode(Object *obedit, View3D *v3d, RegionView3D 
*rv3d)
  {
 -      gpuTranslate3fv(mat[3]);
 -
 -      /* sets view screen aligned */
 -      gpuRotate3f(-360.0f * saacos(rv3d->viewquat[0]) / (float)M_PI, 
rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]);
 -
 -      return len_v3(mat[0]); /* draw scale */
 -}
 -
 +      if ((obedit->lay & v3d->lay) == 0)
 +              return;
  
 -/* radring = radius of doughnut rings
 - * radhole = radius hole
 - * start = starting segment (based on nrings)
 - * end   = end segment
 - * nsides = amount of points in ring
 - * nrigns = amount of rings
 - */
 -static void partial_doughnut(unsigned int pos, float radring, float radhole, 
int start, int end, int nsides, int nrings)
 -{
 -      float theta, phi, theta1;
 -      float cos_theta, sin_theta;
 -      float cos_theta1, sin_theta1;
 -      float ring_delta, side_delta;
 -      int i, j, do_caps = true;
 -
 -      if (start == 0 && end == nrings) do_caps = false;
 -
 -      ring_delta = 2.0f * (float)M_PI / (float)nrings;
 -      side_delta = 2.0f * (float)M_PI / (float)nsides;
 -
 -      theta = (float)M_PI + 0.5f * ring_delta;
 -      cos_theta = cosf(theta);
 -      sin_theta = sinf(theta);
 -
 -      for (i = nrings - 1; i >= 0; i--) {
 -              theta1 = theta + ring_delta;
 -              cos_theta1 = cosf(theta1);
 -              sin_theta1 = sinf(theta1);
 -
 -              if (do_caps && i == start) {  // cap
 -                      immBegin(GL_TRIANGLE_FAN, nsides+1);
 -                      phi = 0.0;
 -                      for (j = nsides; j >= 0; j--) {
 -                              float cos_phi, sin_phi, dist;
 -
 -                              phi += side_delta;
 -                              cos_phi = cosf(phi);
 -                              sin_phi = sinf(phi);
 -                              dist = radhole + radring * cos_phi;
 -
 -                              immVertex3f(pos, cos_theta1 * dist, -sin_theta1 
* dist,  radring * sin_phi);
 -                      }
 -                      immEnd();
 +      if (obedit->type == OB_ARMATURE) {
 +              const bArmature *arm = obedit->data;
 +              EditBone *ebo;
 +              if ((v3d->around == V3D_AROUND_ACTIVE) && (ebo = 
arm->act_edbone)) {
-                       stats_editbone(rv3d, ebo);
++                      protectflag_to_drawflags_ebone(rv3d, ebo);
                }
 -              if (i >= start && i <= end) {
 -                      immBegin(GL_TRIANGLE_STRIP, (nsides+1) * 2);
 -                      phi = 0.0;
 -                      for (j = nsides; j >= 0; j--) {
 -                              float cos_phi, sin_phi, dist;
 -
 -                              phi += side_delta;
 -                              cos_phi = cosf(phi);
 -                              sin_phi = sinf(phi);
 -                              dist = radhole + radring * cos_phi;
 -
 -                              immVertex3f(pos, cos_theta1 * dist, -sin_theta1 
* dist, radring * sin_phi);
 -                              immVertex3f(pos, cos_theta * dist, -sin_theta * 
dist,  radring * sin_phi);
 +              else {
 +                      for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
 +                              if (EBONE_VISIBLE(arm, ebo)) {
 +                                      if (ebo->flag & BONE_SELECTED) {
-                                               stats_editbone(rv3d, ebo);
++                                              
protectflag_to_drawflags_ebone(rv3d, ebo);
 +                                      }
 +                              }
                        }
 -                      immEnd();
                }
 +      }
 +}
  
 -              if (do_caps && i == end) {    // cap
 -                      immBegin(GL_TRIANGLE_FAN, nsides+1);
 -                      phi = 0.0;
 -                      for (j = nsides; j >= 0; j--) {
 -                              float cos_phi, sin_phi, dist;
 +/**
 + * Refresh RegionView3D.twdrawflag based on protect-flags.
 + */
 +static void manipulator_drawflags_refresh(const bContext *C, View3D *v3d, 
RegionView3D *rv3d)
 +{
 +      SceneLayer *sl = CTX_data_scene_layer(C);
 +      Object *ob = OBACT_NEW, *obedit = CTX_data_edit_object(C);
 +      bGPdata *gpd = CTX_data_gpencil_data(C);
 +      const bool is_gp_edit = ((gpd) && (gpd->flag & 
GP_DATA_STROKE_EDITMODE));
  
 -                              phi -= side_delta;
 -                              cos_phi = cosf(phi);
 -                              sin_phi = sinf(phi);
 -                              dist = radhole + radring * cos_phi;
 +      /* all enabled */
 +      rv3d->twdrawflag = 0xFFFF;
  
 -                              immVertex3f(pos, cos_theta * dist, -sin_theta * 
dist,  radring * sin_phi);
 +      if (is_gp_edit) {
 +              /* pass */
 +      }
 +      else if (obedit) {
 +              drawflags_editmode(obedit, v3d, rv3d);
 +      }
 +      else if (ob && (ob->mode & OB_MODE_POSE)) {
 +              drawflags_posemode(ob, v3d, rv3d);
 +      }
 +      else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) {
 +              /* pass */
 +      }
 +      else {
 +              for (Base *base = sl->object_bases.first; base; base = 
base->next) {
 +                      if (TESTBASELIB_NEW(base)) {
 +                              
protectflag_to_drawflags(base->object->protectflag, &rv3d->twdrawflag);
                        }
 -                      immEnd();
                }
 -
 -
 -              theta = theta1;
 -              cos_theta = cos_theta1;
 -              sin_theta = sin_theta1;
        }
  }

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

Reply via email to