[Bf-blender-cvs] [b7cad6914f0] greasepencil-object: Cleanup: rename variables to eval instead of derived

Antonio Vazquez noreply at git.blender.org
Sat Aug 24 16:28:23 CEST 2019


Commit: b7cad6914f0bb12f382505e0c3c9b5990475d093
Author: Antonio Vazquez
Date:   Sat Aug 24 16:25:11 2019 +0200
Branches: greasepencil-object
https://developer.blender.org/rBb7cad6914f0bb12f382505e0c3c9b5990475d093

Cleanup: rename variables to eval instead of derived

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

M	source/blender/editors/gpencil/gpencil_brush.c

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

diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 17e5b80264f..ed43f88208c 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -134,8 +134,8 @@ typedef struct tGP_BrushEditData {
   /* - effect vector (e.g. 2D/3D translation for grab brush) */
   float dvec[3];
 
-  /* rotation for derived data */
-  float rot;
+  /* rotation for evaluated data */
+  float rot_eval;
 
   /* - multiframe falloff factor */
   float mf_falloff;
@@ -314,7 +314,7 @@ static float gp_brush_influence_calc(tGP_BrushEditData *gso, const int radius, c
  * smooth-brush implementation to test the algorithm for stroke smoothing. */
 static bool gp_brush_smooth_apply(tGP_BrushEditData *gso,
                                   bGPDstroke *gps,
-                                  float UNUSED(rot),
+                                  float UNUSED(rot_eval),
                                   int pt_index,
                                   const int radius,
                                   const int co[2])
@@ -353,7 +353,7 @@ static bool gp_brush_smooth_apply(tGP_BrushEditData *gso,
 /* Make lines thicker or thinner by the specified amounts */
 static bool gp_brush_thickness_apply(tGP_BrushEditData *gso,
                                      bGPDstroke *gps,
-                                     float UNUSED(rot),
+                                     float UNUSED(rot_eval),
                                      int pt_index,
                                      const int radius,
                                      const int co[2])
@@ -397,7 +397,7 @@ static bool gp_brush_thickness_apply(tGP_BrushEditData *gso,
 /* Make color more or less transparent by the specified amounts */
 static bool gp_brush_strength_apply(tGP_BrushEditData *gso,
                                     bGPDstroke *gps,
-                                    float UNUSED(rot),
+                                    float UNUSED(rot_eval),
                                     int pt_index,
                                     const int radius,
                                     const int co[2])
@@ -444,7 +444,7 @@ typedef struct tGPSB_Grab_StrokeData {
   /* array of influence weights for each of the included points */
   float *weights;
   /* angles to calc transformation */
-  float *rot;
+  float *rot_eval;
 
   /* capacity of the arrays */
   int capacity;
@@ -472,7 +472,7 @@ static void gp_brush_grab_stroke_init(tGP_BrushEditData *gso, bGPDstroke *gps)
 
     memset(data->points, 0, sizeof(int) * data->capacity);
     memset(data->weights, 0, sizeof(float) * data->capacity);
-    memset(data->rot, 0, sizeof(float) * data->capacity);
+    memset(data->rot_eval, 0, sizeof(float) * data->capacity);
   }
   else {
     /* Create new instance */
@@ -483,7 +483,7 @@ static void gp_brush_grab_stroke_init(tGP_BrushEditData *gso, bGPDstroke *gps)
 
     data->points = MEM_callocN(sizeof(int) * data->capacity, "GP Stroke Grab Indices");
     data->weights = MEM_callocN(sizeof(float) * data->capacity, "GP Stroke Grab Weights");
-    data->rot = MEM_callocN(sizeof(float) * data->capacity, "GP Stroke Grab X");
+    data->rot_eval = MEM_callocN(sizeof(float) * data->capacity, "GP Stroke Grab X");
 
     /* hook up to the cache */
     BLI_ghash_insert(gso->stroke_customdata, gps, data);
@@ -493,7 +493,7 @@ static void gp_brush_grab_stroke_init(tGP_BrushEditData *gso, bGPDstroke *gps)
 /* store references to stroke points in the initial stage */
 static bool gp_brush_grab_store_points(tGP_BrushEditData *gso,
                                        bGPDstroke *gps,
-                                       float rot,
+                                       float rot_eval,
                                        int pt_index,
                                        const int radius,
                                        const int co[2])
@@ -507,7 +507,7 @@ static bool gp_brush_grab_store_points(tGP_BrushEditData *gso,
   /* insert this point into the set of affected points */
   data->points[data->size] = pt_index;
   data->weights[data->size] = inf;
-  data->rot[data->size] = rot;
+  data->rot_eval[data->size] = rot_eval;
   data->size++;
 
   /* done */
@@ -531,10 +531,10 @@ static void gp_brush_grab_calc_dvec(tGP_BrushEditData *gso)
     mval_f[0] = (float)(gso->mval[0] - gso->mval_prev[0]);
     mval_f[1] = (float)(gso->mval[1] - gso->mval_prev[1]);
 
-    /* apply derived data transformation */
-    if (gso->rot != 0.0f) {
-      const float cval = cos(gso->rot);
-      const float sval = sin(gso->rot);
+    /* apply evaluated data transformation */
+    if (gso->rot_eval != 0.0f) {
+      const float cval = cos(gso->rot_eval);
+      const float sval = sin(gso->rot_eval);
       float r[2];
       r[0] = (mval_f[0] * cval) - (mval_f[1] * sval);
       r[1] = (mval_f[0] * sval) + (mval_f[1] * cval);
@@ -565,8 +565,8 @@ static void gp_brush_grab_apply_cached(tGP_BrushEditData *gso,
     bGPDspoint *pt = &gps->points[data->points[i]];
     float delta[3] = {0.0f};
 
-    /* get derived transformation */
-    gso->rot = data->rot[i];
+    /* get evaluated transformation */
+    gso->rot_eval = data->rot_eval[i];
     gp_brush_grab_calc_dvec(gso);
 
     /* adjust the amount of displacement to apply */
@@ -598,7 +598,7 @@ static void gp_brush_grab_stroke_free(void *ptr)
   /* free arrays */
   MEM_SAFE_FREE(data->points);
   MEM_SAFE_FREE(data->weights);
-  MEM_SAFE_FREE(data->rot);
+  MEM_SAFE_FREE(data->rot_eval);
 
   /* ... and this item itself, since it was also allocated */
   MEM_freeN(data);
@@ -609,7 +609,7 @@ static void gp_brush_grab_stroke_free(void *ptr)
 /* NOTE: Depends on gp_brush_grab_calc_dvec() */
 static bool gp_brush_push_apply(tGP_BrushEditData *gso,
                                 bGPDstroke *gps,
-                                float UNUSED(rot),
+                                float rot_eval,
                                 int pt_index,
                                 const int radius,
                                 const int co[2])
@@ -677,7 +677,7 @@ static void gp_brush_calc_midpoint(tGP_BrushEditData *gso)
 /* Shrink distance between midpoint and this point... */
 static bool gp_brush_pinch_apply(tGP_BrushEditData *gso,
                                  bGPDstroke *gps,
-                                 float UNUSED(rot),
+                                 float UNUSED(rot_eval),
                                  int pt_index,
                                  const int radius,
                                  const int co[2])
@@ -736,7 +736,7 @@ static bool gp_brush_pinch_apply(tGP_BrushEditData *gso,
 
 static bool gp_brush_twist_apply(tGP_BrushEditData *gso,
                                  bGPDstroke *gps,
-                                 float UNUSED(rot),
+                                 float UNUSED(rot_eval),
                                  int pt_index,
                                  const int radius,
                                  const int co[2])
@@ -821,7 +821,7 @@ static bool gp_brush_twist_apply(tGP_BrushEditData *gso,
 /* Apply some random jitter to the point */
 static bool gp_brush_randomize_apply(tGP_BrushEditData *gso,
                                      bGPDstroke *gps,
-                                     float UNUSED(rot),
+                                     float UNUSED(rot_eval),
                                      int pt_index,
                                      const int radius,
                                      const int co[2])
@@ -940,7 +940,7 @@ static bool gp_brush_randomize_apply(tGP_BrushEditData *gso,
 /* Change weight paint for vertex groups */
 static bool gp_brush_weight_apply(tGP_BrushEditData *gso,
                                   bGPDstroke *gps,
-                                  float UNUSED(rot),
+                                  float UNUSED(rot_eval),
                                   int pt_index,
                                   const int radius,
                                   const int co[2])
@@ -1176,7 +1176,7 @@ static void gp_brush_clone_adjust(tGP_BrushEditData *gso)
   size_t snum;
 
   /* Compute the amount of movement to apply (overwrites dvec) */
-  gso->rot = 0.0f;
+  gso->rot_eval = 0.0f;
   gp_brush_grab_calc_dvec(gso);
 
   /* For each of the stored strokes, apply the offset to each point */
@@ -1490,35 +1490,38 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso)
 
 /* Apply ----------------------------------------------- */
 
-/* Get angle of the segment relative to the original segment before any transformation */
-static float gpsculpt_transform_rot_get(GP_SpaceConversion *gsc,
-                                        bGPDstroke *gps_derived,
-                                        bGPDspoint *pt_derived,
-                                        int idx_derived)
+/* Get angle of the segment relative to the original segment before any transformation
+ * For strokes with one point only this is impossible to calculate because there isn' a
+ * valid reference point.
+ */
+static float gpsculpt_rotation_eval_get(GP_SpaceConversion *gsc,
+                                        bGPDstroke *gps_eval,
+                                        bGPDspoint *pt_eval,
+                                        int idx_eval)
 {
 
-  bGPDstroke *gps_orig = gps_derived->runtime.gps_orig;
-  bGPDspoint *pt_orig = &gps_orig->points[pt_derived->runtime.idx_orig];
-  bGPDspoint *pt_derived_prev = NULL;
+  bGPDstroke *gps_orig = gps_eval->runtime.gps_orig;
+  bGPDspoint *pt_orig = &gps_orig->points[pt_eval->runtime.idx_orig];
+  bGPDspoint *pt_prev_eval = NULL;
   bGPDspoint *pt_orig_prev = NULL;
-  if (idx_derived != 0) {
-    pt_derived_prev = &gps_derived->points[idx_derived - 1];
+  if (idx_eval != 0) {
+    pt_prev_eval = &gps_eval->points[idx_eval - 1];
   }
   else {
-    if (gps_derived->totpoints > 1) {
-      pt_derived_prev = &gps_derived->points[idx_derived + 1];
+    if (gps_eval->totpoints > 1) {
+      pt_prev_eval = &gps_eval->points[idx_eval + 1];
     }
     else {
       return 0.0f;
     }
   }
 
-  if (pt_derived->runtime.idx_orig != 0) {
-    pt_or

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list