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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-03-30 15:49:07 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-03-30 15:49:07 +0400
commit052cb2afd22b9f54fdb1528066e6e3cba6db6e99 (patch)
tree6e499a7e0ec79fab64dd0467aa2380355f6e9556 /source/blender/makesrna
parent19fb497d139991ec759f3be3db53a27492c62877 (diff)
Rest shape key for cloth option, this makes it possible
to specify different spring lengths. Implementation is quite ugly because the shape key has to be pulled through the modifier stack somehow, need a more flexible data mask system to solve this properly. (commits 27773,27775,27778 by Brecht from render25 branch)
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_cloth.c22
-rw-r--r--source/blender/makesrna/intern/rna_internal.h3
-rw-r--r--source/blender/makesrna/intern/rna_key.c48
3 files changed, 59 insertions, 14 deletions
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 19718a33265..3518044a601 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -140,6 +140,22 @@ static void rna_ClothSettings_bend_vgroup_set(PointerRNA *ptr, const char *value
rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_bend);
}
+static PointerRNA rna_ClothSettings_rest_shape_key_get(PointerRNA *ptr)
+{
+ Object *ob= (Object*)ptr->id.data;
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+
+ return rna_object_shapekey_index_get(ob->data, sim->shapekey_rest);
+}
+
+static void rna_ClothSettings_rest_shape_key_set(PointerRNA *ptr, PointerRNA value)
+{
+ Object *ob= (Object*)ptr->id.data;
+ ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
+
+ sim->shapekey_rest= rna_object_shapekey_index_set(ob->data, value, sim->shapekey_rest);
+}
+
static void rna_ClothSettings_gravity_get(PointerRNA *ptr, float *values)
{
ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
@@ -334,6 +350,12 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Pre Roll", "Simulation starts on this frame");
RNA_def_property_update(prop, 0, "rna_cloth_reset");
+ prop= RNA_def_property(srna, "rest_shape_key", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_struct_type(prop, "ShapeKey");
+ RNA_def_property_pointer_funcs(prop, "rna_ClothSettings_rest_shape_key_get", "rna_ClothSettings_rest_shape_key_set", NULL);
+ RNA_def_property_ui_text(prop, "Rest Shade Key", "Shape key to use the rest spring lengths from");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
/* unused */
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 68a7ca29a1f..433d5ff2904 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -31,6 +31,7 @@
#define RNA_MAGIC ((int)~0)
+struct ID;
struct IDProperty;
struct SDNA;
@@ -200,6 +201,8 @@ void rna_object_vgroup_name_index_set(struct PointerRNA *ptr, const char *value,
void rna_object_vgroup_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen);
void rna_object_uvlayer_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen);
void rna_object_vcollayer_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen);
+PointerRNA rna_object_shapekey_index_get(struct ID *id, int value);
+int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current);
void rna_Object_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
void rna_Object_update_data(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index 8c7e684b422..47accb86d8f 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
+#include "RNA_access.h"
#include "RNA_define.h"
#include "rna_internal.h"
@@ -96,30 +97,49 @@ static void rna_ShapeKey_value_range(PointerRNA *ptr, float *min, float *max)
*max= data->slidermax;
}
-static PointerRNA rna_ShapeKey_relative_key_get(PointerRNA *ptr)
+PointerRNA rna_object_shapekey_index_get(ID *id, int value)
{
- Key *key= rna_ShapeKey_find_key(ptr->id.data);
- KeyBlock *kb= (KeyBlock*)ptr->data, *kbrel;
+ Key *key= rna_ShapeKey_find_key(id);
+ KeyBlock *kb= NULL;
+ PointerRNA ptr;
int a;
- if(key && kb->relative < key->totkey)
- for(a=0, kbrel=key->block.first; kbrel; kbrel=kbrel->next, a++)
- if(a == kb->relative)
- return rna_pointer_inherit_refine(ptr, &RNA_ShapeKey, kbrel);
+ if(key && value < key->totkey)
+ for(a=0, kb=key->block.first; kb; kb=kb->next, a++)
+ if(a == value)
+ break;
+
+ RNA_pointer_create(id, &RNA_ShapeKey, kb, &ptr);
- return rna_pointer_inherit_refine(ptr, NULL, NULL);
+ return ptr;
}
-static void rna_ShapeKey_relative_key_set(PointerRNA *ptr, PointerRNA value)
+int rna_object_shapekey_index_set(ID *id, PointerRNA value, int current)
{
- Key *key= rna_ShapeKey_find_key(ptr->id.data);
- KeyBlock *kb= (KeyBlock*)ptr->data, *kbrel;
+ Key *key= rna_ShapeKey_find_key(id);
+ KeyBlock *kb;
int a;
if(key)
- for(a=0, kbrel=key->block.first; kbrel; kbrel=kbrel->next, a++)
- if(kbrel == value.data)
- kb->relative= a;
+ for(a=0, kb=key->block.first; kb; kb=kb->next, a++)
+ if(kb == value.data)
+ return a;
+
+ return current;
+}
+
+static PointerRNA rna_ShapeKey_relative_key_get(PointerRNA *ptr)
+{
+ KeyBlock *kb= (KeyBlock*)ptr->data;
+
+ return rna_object_shapekey_index_get(ptr->id.data, kb->relative);
+}
+
+static void rna_ShapeKey_relative_key_set(PointerRNA *ptr, PointerRNA value)
+{
+ KeyBlock *kb= (KeyBlock*)ptr->data;
+
+ kb->relative= rna_object_shapekey_index_set(ptr->id.data, value, kb->relative);
}
static void rna_ShapeKeyPoint_co_get(PointerRNA *ptr, float *values)