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>2008-12-03 02:45:11 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-12-03 02:45:11 +0300
commit8f1847e4c33f4276c6aaf123e658f9d2043f7dcb (patch)
tree76fc524250b9a54069931c3d50e8c379fc6b982f /source/blender/makesrna/intern/rna_property.c
parentd27c9f9d76752bffdcdf60812ee05f48482bccfc (diff)
RNA: review of commits in the past days, check the diffs for the
many small changes, but the two bigger ones are: * Sensors and controllers now use inheritance, rather than pointing to the data in a separate struct. Had to add some new RNA define functionality to support this better. * DNA_meta_types.h was marked as done but still missing many things, now completed.
Diffstat (limited to 'source/blender/makesrna/intern/rna_property.c')
-rw-r--r--source/blender/makesrna/intern/rna_property.c75
1 files changed, 56 insertions, 19 deletions
diff --git a/source/blender/makesrna/intern/rna_property.c b/source/blender/makesrna/intern/rna_property.c
index 94a16eaf9b9..626bf0bf43d 100644
--- a/source/blender/makesrna/intern/rna_property.c
+++ b/source/blender/makesrna/intern/rna_property.c
@@ -34,6 +34,40 @@
#ifdef RNA_RUNTIME
+static StructRNA* rna_GameProperty_refine(struct PointerRNA *ptr)
+{
+ bProperty *property= (bProperty*)ptr->data;
+
+ switch(property->type){
+ case PROP_BOOL:
+ return &RNA_GameBooleanProperty;
+ case PROP_INT:
+ return &RNA_GameIntProperty;
+ case PROP_FLOAT:
+ return &RNA_GameFloatProperty;
+ case PROP_STRING:
+ return &RNA_GameStringProperty;
+ case PROP_TIME:
+ return &RNA_GameTimeProperty;
+ default:
+ return &RNA_GameProperty;
+ }
+}
+
+/* for both float and timer */
+static float rna_GameFloatProperty_value_get(PointerRNA *ptr)
+{
+ bProperty *prop= (bProperty*)(ptr->data);
+ return *(float*)(&prop->data);
+}
+
+static void rna_GameFloatProperty_value_set(PointerRNA *ptr, float value)
+{
+ bProperty *prop= (bProperty*)(ptr->data);
+ CLAMP(value, -10000.0f, 10000.0f);
+ *(float*)(&prop->data)= value;
+}
+
#else
void RNA_def_gameproperty(BlenderRNA *brna)
@@ -41,7 +75,7 @@ void RNA_def_gameproperty(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static EnumPropertyItem gameproperty_types_items[] ={
+ static EnumPropertyItem gameproperty_type_items[] ={
{PROP_BOOL, "BOOL", "Boolean", ""},
{PROP_INT, "INT", "Integer", ""},
{PROP_FLOAT, "FLOAT", "Float", ""},
@@ -50,25 +84,26 @@ void RNA_def_gameproperty(BlenderRNA *brna)
{0, NULL, NULL, NULL}};
/* Base Struct for GameProperty */
- srna= RNA_def_struct(brna, "GameProperty", NULL , "GameProperty");
+ srna= RNA_def_struct(brna, "GameProperty", NULL , "Game Property");
RNA_def_struct_sdna(srna, "bProperty");
+ RNA_def_struct_funcs(srna, NULL, "rna_GameProperty_refine");
- prop= RNA_def_property(srna, "gameproperty_name", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_string_maxlength(prop, 31);
- RNA_def_property_ui_text(prop, "Name", "Game Property name.");
+ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE); /* must be unique */
+ RNA_def_property_ui_text(prop, "Name", "Available as as GameObject attributes in the game engines python api");
+ RNA_def_struct_name_property(srna, prop);
prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
- RNA_def_property_enum_items(prop, gameproperty_types_items);
- RNA_def_property_ui_text(prop, "Game Property Types", "Game Property types.");
+ RNA_def_property_enum_items(prop, gameproperty_type_items);
+ RNA_def_property_ui_text(prop, "Type", "");
prop= RNA_def_property(srna, "debug", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PROP_DEBUG);
- RNA_def_property_ui_text(prop, "Debug", "Show debug information for this property.");
+ RNA_def_property_ui_text(prop, "Debug", "Print debug information for this property.");
/* GameBooleanProperty */
- srna= RNA_def_struct(brna, "GameBooleanProperty", "GameProperty" , "GameBooleanProperty");
+ srna= RNA_def_struct(brna, "GameBooleanProperty", "GameProperty" , "Game Boolean Property");
RNA_def_struct_sdna(srna, "bProperty");
prop= RNA_def_property(srna, "boolean_value", PROP_BOOLEAN, PROP_NONE);
@@ -76,39 +111,41 @@ void RNA_def_gameproperty(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Value", "Property value.");
/* GameIntProperty */
- srna= RNA_def_struct(brna, "GameIntProperty", "GameProperty" , "GameIntProperty");
+ srna= RNA_def_struct(brna, "GameIntProperty", "GameProperty" , "Game Integer Property");
RNA_def_struct_sdna(srna, "bProperty");
- prop= RNA_def_property(srna, "int_value", PROP_INT, PROP_NONE);
+ prop= RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "data");
RNA_def_property_ui_text(prop, "Value", "Property value.");
RNA_def_property_range(prop, -10000, 10000);
/* GameFloatProperty */
- srna= RNA_def_struct(brna, "GameFloatProperty", "GameProperty" , "GameFloatProperty");
+ srna= RNA_def_struct(brna, "GameFloatProperty", "GameProperty" , "Game Float Property");
RNA_def_struct_sdna(srna, "bProperty");
- prop= RNA_def_property(srna, "float_value", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "data");
RNA_def_property_ui_text(prop, "Value", "Property value.");
RNA_def_property_range(prop, -10000, 10000);
+ RNA_def_property_float_funcs(prop, "rna_GameFloatProperty_value_get", "rna_GameFloatProperty_value_set", NULL);
/* GameTimerProperty */
- srna= RNA_def_struct(brna, "GameTimeProperty", "GameProperty" , "GameTimeProperty");
+ srna= RNA_def_struct(brna, "GameTimeProperty", "GameProperty" , "Game Time Property");
RNA_def_struct_sdna(srna, "bProperty");
- prop= RNA_def_property(srna, "timer_value", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "data");
RNA_def_property_ui_text(prop, "Value", "Property value.");
RNA_def_property_range(prop, -10000, 10000);
+ RNA_def_property_float_funcs(prop, "rna_GameFloatProperty_value_get", "rna_GameFloatProperty_value_set", NULL);
/* GameStringProperty */
- srna= RNA_def_struct(brna, "GameStringProperty", "GameProperty" , "GameStringProperty");
+ srna= RNA_def_struct(brna, "GameStringProperty", "GameProperty" , "Game String Property");
RNA_def_struct_sdna(srna, "bProperty");
- prop= RNA_def_property(srna, "string_value", PROP_STRING, PROP_NONE);
+ prop= RNA_def_property(srna, "value", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "poin");
- RNA_def_property_string_maxlength(prop, MAX_PROPSTRING-1);
+ RNA_def_property_string_maxlength(prop, MAX_PROPSTRING);
RNA_def_property_ui_text(prop, "Value", "Property value.");
}