Remove slurph shape-key feature

This is an old option which wasn't working in over a year without complaint.
This commit is contained in:
Campbell Barton 2015-01-07 02:02:55 +11:00
parent 0527183090
commit 8e73b770d4
13 changed files with 78 additions and 194 deletions

View File

@ -220,7 +220,6 @@ class SpellChecker():
"polycount",
"polygonization", "polygonalization", # yuck!
"selectability",
"slurph",
"stitchable",
"symmetrize",
"trackability",

View File

@ -317,7 +317,6 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
row = layout.column()
row.active = enable_edit_value
row.prop(key, "eval_time")
row.prop(key, "slurph")
class DATA_PT_uv_texture(MeshButtonsPanel, Panel):

View File

@ -60,9 +60,11 @@ void key_curve_position_weights(float t, float data[4], int type);
void key_curve_tangent_weights(float t, float data[4], int type);
void key_curve_normal_weights(float t, float data[4], int type);
float *BKE_key_evaluate_object_ex(struct Scene *scene, struct Object *ob, int *r_totelem,
float *arr, size_t arr_size);
float *BKE_key_evaluate_object(struct Scene *scene, struct Object *ob, int *r_totelem);
float *BKE_key_evaluate_object_ex(
struct Object *ob, int *r_totelem,
float *arr, size_t arr_size);
float *BKE_key_evaluate_object(
struct Object *ob, int *r_totelem);
struct Key *BKE_key_from_object(struct Object *ob);
struct KeyBlock *BKE_keyblock_from_object(struct Object *ob);
@ -111,9 +113,6 @@ bool BKE_keyblock_move(struct Object *ob, int org_index, int new_index);
bool BKE_keyblock_is_basis(struct Key *key, const int index);
/* key.c */
extern int slurph_opt;
#ifdef __cplusplus
};
#endif

View File

@ -181,7 +181,7 @@ int BKE_object_obdata_texspace_get(struct Object *ob, short **r_texflag, float *
int BKE_object_insert_ptcache(struct Object *ob);
void BKE_object_delete_ptcache(struct Object *ob, int index);
struct KeyBlock *BKE_object_insert_shape_key(struct Scene *scene, struct Object *ob, const char *name, const bool from_mix);
struct KeyBlock *BKE_object_insert_shape_key(struct Object *ob, const char *name, const bool from_mix);
bool BKE_object_is_child_recursive(struct Object *ob_parent, struct Object *ob_child);
bool BKE_object_is_animated(struct Scene *scene, struct Object *ob);

View File

@ -813,7 +813,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, ListBase *nurb,
required_mode |= eModifierMode_Editmode;
if (cu->editnurb == NULL) {
keyVerts = BKE_key_evaluate_object(scene, ob, &numVerts);
keyVerts = BKE_key_evaluate_object(ob, &numVerts);
if (keyVerts) {
/* split coords from key data, the latter also includes

View File

@ -73,10 +73,6 @@
#define IPO_BEZTRIPLE 100
#define IPO_BPOINT 101
/* extern, not threadsafe */
int slurph_opt = 1;
void BKE_key_free(Key *key)
{
KeyBlock *kb;
@ -607,7 +603,7 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
k1 = key_block_get_data(key, actkb, kb, &freek1);
kref = key_block_get_data(key, actkb, key->refkey, &freekref);
/* this exception is needed for slurphing */
/* this exception is needed curves with multiple splines */
if (start != 0) {
poin += poinsize * start;
@ -891,7 +887,7 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
}
}
/* this exception needed for slurphing */
/* this exception is needed for curves with multiple splines */
if (start != 0) {
poin += poinsize * start;
@ -1168,53 +1164,29 @@ void BKE_keyblock_free_per_block_weights(Key *key, float **per_keyblock_weights,
MEM_freeN(per_keyblock_weights);
}
static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int tot)
static void do_mesh_key(Object *ob, Key *key, char *out, const int tot)
{
KeyBlock *k[4], *actkb = BKE_keyblock_from_object(ob);
float t[4];
int flag = 0;
if (key->slurph && key->type != KEY_RELATIVE) {
const float ctime_scaled = key->ctime / 100.0f;
float delta = (float)key->slurph / tot;
float cfra = BKE_scene_frame_get(scene);
int step, a;
if (tot > 100 && slurph_opt) {
step = tot / 50;
delta *= step;
/* in do_key and cp_key the case a>tot is handled */
}
else {
step = 1;
}
for (a = 0; a < tot; a += step, cfra += delta) {
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
if (flag == 0)
do_key(a, a + step, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
else
cp_key(a, a + step, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY);
}
if (key->type == KEY_RELATIVE) {
WeightsArrayCache cache = {0, NULL};
float **per_keyblock_weights;
per_keyblock_weights = BKE_keyblock_get_per_block_weights(ob, key, &cache);
BKE_key_evaluate_relative(0, tot, tot, (char *)out, key, actkb, per_keyblock_weights, KEY_MODE_DUMMY);
BKE_keyblock_free_per_block_weights(key, per_keyblock_weights, &cache);
}
else {
if (key->type == KEY_RELATIVE) {
WeightsArrayCache cache = {0, NULL};
float **per_keyblock_weights;
per_keyblock_weights = BKE_keyblock_get_per_block_weights(ob, key, &cache);
BKE_key_evaluate_relative(0, tot, tot, (char *)out, key, actkb, per_keyblock_weights, KEY_MODE_DUMMY);
BKE_keyblock_free_per_block_weights(key, per_keyblock_weights, &cache);
const float ctime_scaled = key->ctime / 100.0f;
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
if (flag == 0) {
do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
}
else {
const float ctime_scaled = key->ctime / 100.0f;
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
if (flag == 0)
do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
else
cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY);
cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY);
}
}
}
@ -1259,135 +1231,63 @@ static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, char *out, const
}
}
static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const int tot)
static void do_curve_key(Object *ob, Key *key, char *out, const int tot)
{
Curve *cu = ob->data;
KeyBlock *k[4], *actkb = BKE_keyblock_from_object(ob);
float t[4];
int flag = 0;
if (key->slurph && key->type != KEY_RELATIVE) {
const float ctime_scaled = key->ctime / 100.0f;
float delta = (float)key->slurph / tot;
float cfra = BKE_scene_frame_get(scene);
Nurb *nu;
int i = 0, remain = 0;
int step, a;
if (tot > 100 && slurph_opt) {
step = tot / 50;
delta *= step;
/* in do_key and cp_key the case a>tot has been handled */
}
else {
step = 1;
}
for (nu = cu->nurb.first; nu; nu = nu->next) {
int estep, mode;
if (nu->bp) {
mode = KEY_MODE_BPOINT;
estep = nu->pntsu * nu->pntsv;
}
else if (nu->bezt) {
mode = KEY_MODE_BEZTRIPLE;
estep = 3 * nu->pntsu;
}
else {
mode = 0;
estep = 0;
}
a = 0;
while (a < estep) {
int count;
if (remain <= 0) {
cfra += delta;
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
remain = step;
}
count = min_ii(remain, estep);
if (mode == KEY_MODE_BEZTRIPLE) {
count += 3 - count % 3;
}
if (flag == 0)
do_key(i, i + count, tot, (char *)out, key, actkb, k, t, mode);
else
cp_key(i, i + count, tot, (char *)out, key, actkb, k[2], NULL, mode);
a += count;
i += count;
remain -= count;
}
}
if (key->type == KEY_RELATIVE) {
do_rel_cu_key(cu, cu->key, actkb, out, tot);
}
else {
if (key->type == KEY_RELATIVE) {
do_rel_cu_key(cu, cu->key, actkb, out, tot);
const float ctime_scaled = key->ctime / 100.0f;
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
if (flag == 0) {
do_cu_key(cu, key, actkb, k, t, out, tot);
}
else {
const float ctime_scaled = key->ctime / 100.0f;
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
if (flag == 0) do_cu_key(cu, key, actkb, k, t, out, tot);
else cp_cu_key(cu, key, actkb, k[2], 0, tot, out, tot);
cp_cu_key(cu, key, actkb, k[2], 0, tot, out, tot);
}
}
}
static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int tot)
static void do_latt_key(Object *ob, Key *key, char *out, const int tot)
{
Lattice *lt = ob->data;
KeyBlock *k[4], *actkb = BKE_keyblock_from_object(ob);
float t[4];
int flag;
if (key->slurph && key->type != KEY_RELATIVE) {
const float ctime_scaled = key->ctime / 100.0f;
float delta = (float)key->slurph / tot;
float cfra = BKE_scene_frame_get(scene);
int a;
for (a = 0; a < tot; a++, cfra += delta) {
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
if (flag == 0)
do_key(a, a + 1, tot, out, key, actkb, k, t, KEY_MODE_DUMMY);
else
cp_key(a, a + 1, tot, out, key, actkb, k[2], NULL, KEY_MODE_DUMMY);
}
if (key->type == KEY_RELATIVE) {
float **per_keyblock_weights;
per_keyblock_weights = BKE_keyblock_get_per_block_weights(ob, key, NULL);
BKE_key_evaluate_relative(0, tot, tot, (char *)out, key, actkb, per_keyblock_weights, KEY_MODE_DUMMY);
BKE_keyblock_free_per_block_weights(key, per_keyblock_weights, NULL);
}
else {
if (key->type == KEY_RELATIVE) {
float **per_keyblock_weights;
per_keyblock_weights = BKE_keyblock_get_per_block_weights(ob, key, NULL);
BKE_key_evaluate_relative(0, tot, tot, (char *)out, key, actkb, per_keyblock_weights, KEY_MODE_DUMMY);
BKE_keyblock_free_per_block_weights(key, per_keyblock_weights, NULL);
const float ctime_scaled = key->ctime / 100.0f;
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
if (flag == 0) {
do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
}
else {
const float ctime_scaled = key->ctime / 100.0f;
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
if (flag == 0)
do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
else
cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY);
cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY);
}
}
if (lt->flag & LT_OUTSIDE) outside_lattice(lt);
}
/* returns key coordinates (+ tilt) when key applied, NULL otherwise */
float *BKE_key_evaluate_object_ex(Scene *scene, Object *ob, int *r_totelem,
float *arr, size_t arr_size)
float *BKE_key_evaluate_object_ex(
Object *ob, int *r_totelem,
float *arr, size_t arr_size)
{
Key *key = BKE_key_from_object(ob);
KeyBlock *actkb = BKE_keyblock_from_object(ob);
@ -1469,10 +1369,10 @@ float *BKE_key_evaluate_object_ex(Scene *scene, Object *ob, int *r_totelem,
}
else {
if (ob->type == OB_MESH) do_mesh_key(scene, ob, key, out, tot);
else if (ob->type == OB_LATTICE) do_latt_key(scene, ob, key, out, tot);
else if (ob->type == OB_CURVE) do_curve_key(scene, ob, key, out, tot);
else if (ob->type == OB_SURF) do_curve_key(scene, ob, key, out, tot);
if (ob->type == OB_MESH) do_mesh_key(ob, key, out, tot);
else if (ob->type == OB_LATTICE) do_latt_key(ob, key, out, tot);
else if (ob->type == OB_CURVE) do_curve_key(ob, key, out, tot);
else if (ob->type == OB_SURF) do_curve_key(ob, key, out, tot);
}
if (r_totelem) {
@ -1481,9 +1381,9 @@ float *BKE_key_evaluate_object_ex(Scene *scene, Object *ob, int *r_totelem,
return (float *)out;
}
float *BKE_key_evaluate_object(Scene *scene, Object *ob, int *r_totelem)
float *BKE_key_evaluate_object(Object *ob, int *r_totelem)
{
return BKE_key_evaluate_object_ex(scene, ob, r_totelem, NULL, 0);
return BKE_key_evaluate_object_ex(ob, r_totelem, NULL, 0);
}
Key *BKE_key_from_object(Object *ob)

View File

@ -3347,7 +3347,7 @@ void BKE_object_delete_ptcache(Object *ob, int index)
/* shape key utility function */
/************************* Mesh ************************/
static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, const bool from_mix)
static KeyBlock *insert_meshkey(Object *ob, const char *name, const bool from_mix)
{
Mesh *me = ob->data;
Key *key = me->key;
@ -3368,7 +3368,7 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, cons
else {
/* copy from current values */
int totelem;
float *data = BKE_key_evaluate_object(scene, ob, &totelem);
float *data = BKE_key_evaluate_object(ob, &totelem);
/* create new block with prepared data */
kb = BKE_keyblock_add_ctime(key, name, false);
@ -3379,7 +3379,7 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, cons
return kb;
}
/************************* Lattice ************************/
static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, const bool from_mix)
static KeyBlock *insert_lattkey(Object *ob, const char *name, const bool from_mix)
{
Lattice *lt = ob->data;
Key *key = lt->key;
@ -3406,7 +3406,7 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, cons
else {
/* copy from current values */
int totelem;
float *data = BKE_key_evaluate_object(scene, ob, &totelem);
float *data = BKE_key_evaluate_object(ob, &totelem);
/* create new block with prepared data */
kb = BKE_keyblock_add_ctime(key, name, false);
@ -3417,7 +3417,7 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, cons
return kb;
}
/************************* Curve ************************/
static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, const bool from_mix)
static KeyBlock *insert_curvekey(Object *ob, const char *name, const bool from_mix)
{
Curve *cu = ob->data;
Key *key = cu->key;
@ -3446,7 +3446,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, con
else {
/* copy from current values */
int totelem;
float *data = BKE_key_evaluate_object(scene, ob, &totelem);
float *data = BKE_key_evaluate_object(ob, &totelem);
/* create new block with prepared data */
kb = BKE_keyblock_add_ctime(key, name, false);
@ -3457,16 +3457,16 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, con
return kb;
}
KeyBlock *BKE_object_insert_shape_key(Scene *scene, Object *ob, const char *name, const bool from_mix)
KeyBlock *BKE_object_insert_shape_key(Object *ob, const char *name, const bool from_mix)
{
switch (ob->type) {
case OB_MESH:
return insert_meshkey(scene, ob, name, from_mix);
return insert_meshkey(ob, name, from_mix);
case OB_CURVE:
case OB_SURF:
return insert_curvekey(scene, ob, name, from_mix);
return insert_curvekey(ob, name, from_mix);
case OB_LATTICE:
return insert_lattkey(scene, ob, name, from_mix);
return insert_lattkey(ob, name, from_mix);
default:
return NULL;
}

View File

@ -75,10 +75,10 @@
/*********************** add shape key ***********************/
static void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob, const bool from_mix)
static void ED_object_shape_key_add(bContext *C, Object *ob, const bool from_mix)
{
KeyBlock *kb;
if ((kb = BKE_object_insert_shape_key(scene, ob, NULL, from_mix))) {
if ((kb = BKE_object_insert_shape_key(ob, NULL, from_mix))) {
Key *key = BKE_key_from_object(ob);
/* for absolute shape keys, new keys may not be added last */
ob->shapenr = BLI_findindex(&key->block, kb) + 1;
@ -320,11 +320,10 @@ static int shape_key_poll(bContext *C)
static int shape_key_add_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_context(C);
const bool from_mix = RNA_boolean_get(op->ptr, "from_mix");
ED_object_shape_key_add(C, scene, ob, from_mix);
ED_object_shape_key_add(C, ob, from_mix);
return OPERATOR_FINISHED;
}

View File

@ -91,10 +91,10 @@ typedef struct Key {
ID *from;
short type; /* absolute or relative shape key */
short totkey; /* (totkey == BLI_listbase_count(&key->block)) */
short slurph; /* quaint feature to delay moving points based on their order (Key->type == KEY_NORMAL) only */
int totkey; /* (totkey == BLI_listbase_count(&key->block)) */
short flag;
char type; /* absolute or relative shape key */
char pad2;
/* only used when (Key->type == KEY_NORMAL), this value is used as a time slider,
* rather then using the scenes time, this value can be animated to give greater control */

View File

@ -675,13 +675,6 @@ static void rna_def_key(BlenderRNA *brna)
RNA_def_property_range(prop, MINFRAME, MAXFRAME);
RNA_def_property_ui_text(prop, "Evaluation Time", "Evaluation time for absolute shape keys");
RNA_def_property_update(prop, 0, "rna_Key_update_data");
prop = RNA_def_property(srna, "slurph", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "slurph");
RNA_def_property_range(prop, -500, 500);
RNA_def_property_ui_text(prop, "Slurph",
"Create a delay (in frames) in applying key positions, first vertex goes first");
RNA_def_property_update(prop, 0, "rna_Key_update_data");
}
void RNA_def_key(BlenderRNA *brna)

View File

@ -225,10 +225,9 @@ static void rna_Object_free_duplilist(Object *ob)
static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *reports,
const char *name, int from_mix)
{
Scene *scene = CTX_data_scene(C);
KeyBlock *kb = NULL;
if ((kb = BKE_object_insert_shape_key(scene, ob, name, from_mix))) {
if ((kb = BKE_object_insert_shape_key(ob, name, from_mix))) {
PointerRNA keyptr;
RNA_pointer_create((ID *)ob->data, &RNA_ShapeKey, kb, &keyptr);

View File

@ -44,7 +44,7 @@
#include "MOD_modifiertypes.h"
static void deformVerts(ModifierData *md, Object *ob,
static void deformVerts(ModifierData *UNUSED(md), Object *ob,
DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
int numVerts,
@ -54,8 +54,9 @@ static void deformVerts(ModifierData *md, Object *ob,
if (key && key->block.first) {
int deformedVerts_tot;
BKE_key_evaluate_object_ex(md->scene, ob, &deformedVerts_tot,
(float *)vertexCos, sizeof(*vertexCos) * numVerts);
BKE_key_evaluate_object_ex(
ob, &deformedVerts_tot,
(float *)vertexCos, sizeof(*vertexCos) * numVerts);
}
}

View File

@ -5134,8 +5134,7 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l
re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
re->lights.first= re->lights.last= NULL;
re->lampren.first= re->lampren.last= NULL;
slurph_opt= 0;
re->i.partsdone = false; /* signal now in use for previewrender */
/* in localview, lamps are using normal layers, objects only local bits */
@ -5197,8 +5196,6 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l
re->i.totlamp= re->totlamp;
re->stats_draw(re->sdh, &re->i);
}
slurph_opt= 1;
}
void RE_Database_Preprocess(Render *re)
@ -5316,8 +5313,6 @@ static void database_fromscene_vectors(Render *re, Scene *scene, unsigned int la
re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
re->i.totface=re->i.totvert=re->i.totstrand=re->i.totlamp=re->i.tothalo= 0;
re->lights.first= re->lights.last= NULL;
slurph_opt= 0;
/* in localview, lamps are using normal layers, objects only local bits */
if (re->lay & 0xFF000000)