Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-11-05 07:48:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-11-05 07:48:24 +0300
commita88b9a4e003c57d6cbf0ab2e4ae535e7e6a79c9d (patch)
tree2f9e8151887ce7d1d6e884f63fb12e82c25f007c
parent63f7e698292ae0c4827fd786d7addb7a665ff66b (diff)
parent8d88d9fd339dc2296e17667ad51d6cd1090ede3d (diff)
Merge branch 'blender-v2.91-release'
-rw-r--r--source/blender/editors/transform/transform.h2
-rw-r--r--source/blender/editors/transform/transform_generics.c3
-rw-r--r--source/blender/editors/transform/transform_mode_bend.c2
-rw-r--r--source/blender/editors/transform/transform_mode_tosphere.c70
4 files changed, 59 insertions, 18 deletions
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 17ef9a3034f..275ddb993b2 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -282,8 +282,6 @@ typedef struct TransInfo {
short state;
/** Current context/options for transform. */
int options;
- /** Initial value for some transformations (and rotation angle). */
- float val;
void (*transform)(struct TransInfo *, const int[2]);
/** Transform function pointer. */
eRedrawFlag (*handleEvent)(struct TransInfo *, const struct wmEvent *);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 1b8c9b47c04..60848eb5678 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -270,9 +270,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->data_len_all = 0;
- t->val = 0.0f;
-
- zero_v3(t->vec);
zero_v3(t->center_global);
unit_m3(t->mat);
diff --git a/source/blender/editors/transform/transform_mode_bend.c b/source/blender/editors/transform/transform_mode_bend.c
index 21a6a1ebafc..adf3a0346a0 100644
--- a/source/blender/editors/transform/transform_mode_bend.c
+++ b/source/blender/editors/transform/transform_mode_bend.c
@@ -276,8 +276,6 @@ void initBend(TransInfo *t)
}
calculateCenterLocal(t, t->center_global);
- t->val = 0.0f;
-
data = MEM_callocN(sizeof(*data), __func__);
curs = t->scene->cursor.location;
diff --git a/source/blender/editors/transform/transform_mode_tosphere.c b/source/blender/editors/transform/transform_mode_tosphere.c
index c7a278fe5ea..d50b26d3e5a 100644
--- a/source/blender/editors/transform/transform_mode_tosphere.c
+++ b/source/blender/editors/transform/transform_mode_tosphere.c
@@ -26,6 +26,8 @@
#include "BLI_math.h"
#include "BLI_string.h"
+#include "MEM_guardedalloc.h"
+
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -40,6 +42,53 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
+/** \name To Sphere Utilities
+ * \{ */
+
+struct ToSphereInfo {
+ float prop_size_prev;
+ float radius;
+};
+
+/** Calculate average radius. */
+static void to_sphere_radius_update(TransInfo *t)
+{
+ struct ToSphereInfo *data = t->custom.mode.data;
+ float radius = 0.0f;
+
+ if (t->flag & T_PROP_EDIT_ALL) {
+ int factor_accum = 0.0f;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (int i = 0; i < tc->data_len; i++, td++) {
+ if (td->factor == 0.0f) {
+ continue;
+ }
+ radius += td->factor * len_v3v3(tc->center_local, td->iloc);
+ factor_accum += td->factor;
+ }
+ }
+ if (factor_accum != 0.0f) {
+ radius /= factor_accum;
+ }
+ }
+ else {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (int i = 0; i < tc->data_len; i++, td++) {
+ radius += len_v3v3(tc->center_local, td->iloc);
+ }
+ }
+ radius /= (float)t->data_len_all;
+ }
+
+ data->prop_size_prev = t->prop_size;
+ data->radius = radius;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (ToSphere)
* \{ */
@@ -73,6 +122,11 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), TIP_("To Sphere: %.4f %s"), ratio, t->proptext);
}
+ const struct ToSphereInfo *data = t->custom.mode.data;
+ if (data->prop_size_prev != t->prop_size) {
+ to_sphere_radius_update(t);
+ }
+
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
@@ -87,7 +141,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
tratio = ratio * td->factor;
- mul_v3_fl(vec, radius * (1.0f - tratio) + t->val * tratio);
+ mul_v3_fl(vec, radius * (1.0f - tratio) + data->radius * tratio);
add_v3_v3v3(td->loc, tc->center_local, vec);
}
@@ -100,8 +154,6 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
void initToSphere(TransInfo *t)
{
- int i;
-
t->mode = TFM_TOSPHERE;
t->transform = applyToSphere;
@@ -119,14 +171,10 @@ void initToSphere(TransInfo *t)
t->num.val_flag[0] |= NUM_NULL_ONE | NUM_NO_NEGATIVE;
t->flag |= T_NO_CONSTRAINT;
- /* Calculate average radius */
- FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++) {
- t->val += len_v3v3(tc->center_local, td->iloc);
- }
- }
+ struct ToSphereInfo *data = MEM_callocN(sizeof(*data), __func__);
+ t->custom.mode.data = data;
+ t->custom.mode.use_free = true;
- t->val /= (float)t->data_len_all;
+ to_sphere_radius_update(t);
}
/** \} */