diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2010-05-27 11:37:09 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2010-05-27 11:37:09 +0400 |
commit | 8872cba7e956a9d9a840e55e5323945497524795 (patch) | |
tree | 6aaf3e97a13cc5b6fccbb1e2ad3bed27a8e3d2d8 /source | |
parent | 0db16ff434b4fb4ac35dd8d4525ee85c738528d1 (diff) |
Logic Editor: removing usercount for existent datablocks
Using custom setfuncs to avoid increase/decrease of usercount.
That way nothing stops you from removing a material that is used by a
sensor, or a mesh, an action ... (this is how 2.49 works too)
* also some general code cleaning/fix (adding static casts, replacing libaddr_us by lib_addr for dome text (I had no idea how user count worked back then)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_actuator.c | 23 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sensor.c | 16 |
3 files changed, 37 insertions, 5 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 4000669c30e..e4a3a128ef4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4213,8 +4213,7 @@ static void lib_link_scene(FileData *fd, Main *main) srl->light_override= newlibadr_us(fd, sce->id.lib, srl->light_override); } /*Game Settings: Dome Warp Text*/ -// sce->r.dometext= newlibadr_us(fd, sce->id.lib, sce->r.dometext); // XXX deprecated since 2.5 - sce->gm.dome.warptext= newlibadr_us(fd, sce->id.lib, sce->gm.dome.warptext); + sce->gm.dome.warptext= newlibadr(fd, sce->id.lib, sce->gm.dome.warptext); sce->id.flag -= LIB_NEEDLINK; } diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index e9da96e0960..8bad6957b1b 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -422,6 +422,23 @@ static void rna_Actuator_Armature_update(Main *bmain, Scene *scene, PointerRNA * constraint[0] = 0; } +/* note: the following set functions exists only to avoid id refcounting */ +static void rna_Actuator_editobject_mesh_set(PointerRNA *ptr, PointerRNA value) +{ + bActuator *act = (bActuator *)ptr->data; + bEditObjectActuator *eoa = (bEditObjectActuator *) act->data; + + eoa->me = value.data; +} + +static void rna_Actuator_action_action_set(PointerRNA *ptr, PointerRNA value) +{ + bActuator *act = (bActuator *)ptr->data; + bActionActuator *aa = (bActionActuator *) act->data; + + aa->me = value.data; +} + #else void rna_def_actuator(BlenderRNA *brna) @@ -481,6 +498,8 @@ static void rna_def_action_actuator(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Action"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Action", ""); + /* note: custom set function is ONLY to avoid rna setting a user for this. */ + RNA_def_property_pointer_funcs(prop, NULL, "rna_Actuator_action_action_set", NULL); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "continue_last_frame", PROP_BOOLEAN, PROP_NONE); @@ -1222,6 +1241,8 @@ static void rna_def_edit_object_actuator(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "me"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Mesh", "Replace the existing, when left blank 'Phys' will remake the existing physics mesh"); + /* note: custom set function is ONLY to avoid rna setting a user for this. */ + RNA_def_property_pointer_funcs(prop, NULL, "rna_Actuator_editobject_mesh_set", NULL); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "time", PROP_INT, PROP_NONE); @@ -1688,6 +1709,8 @@ static void rna_def_shape_action_actuator(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Action"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Action", ""); + /* note: custom set function is ONLY to avoid rna setting a user for this. */ + RNA_def_property_pointer_funcs(prop, NULL, "rna_Actuator_action_action_set", NULL); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "continue_last_frame", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index b206384dbc4..31fa8f018dc 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -152,7 +152,7 @@ EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, int *free) static void rna_Sensor_keyboard_key_set(struct PointerRNA *ptr, int value) { bSensor *sens= (bSensor *)ptr->data; - bKeyboardSensor *ks = sens->data; + bKeyboardSensor *ks = (bKeyboardSensor *)sens->data; if (ISKEYBOARD(value)) ks->key = value; @@ -161,7 +161,7 @@ static void rna_Sensor_keyboard_key_set(struct PointerRNA *ptr, int value) static void rna_Sensor_keyboard_modifier_set(struct PointerRNA *ptr, int value) { bSensor *sens= (bSensor *)ptr->data; - bKeyboardSensor *ks = sens->data; + bKeyboardSensor *ks = (bKeyboardSensor *)sens->data; if (ISKEYBOARD(value)) ks->qual = value; @@ -170,7 +170,7 @@ static void rna_Sensor_keyboard_modifier_set(struct PointerRNA *ptr, int value) static void rna_Sensor_keyboard_modifier2_set(struct PointerRNA *ptr, int value) { bSensor *sens= (bSensor *)ptr->data; - bKeyboardSensor *ks = sens->data; + bKeyboardSensor *ks = (bKeyboardSensor *)sens->data; if (ISKEYBOARD(value)) ks->qual2 = value; @@ -228,6 +228,14 @@ static void rna_Sensor_Armature_update(Main *bmain, Scene *scene, PointerRNA *pt constraint[0] = 0; } +/* note: the following set functions exists only to avoid id refcounting */ +static void rna_Sensor_touch_material_set(PointerRNA *ptr, PointerRNA value) +{ + bSensor *sens = (bSensor *)ptr->data; + bTouchSensor *ts = (bTouchSensor *) sens->data; + + ts->ma = value.data; +} #else static void rna_def_sensor(BlenderRNA *brna) @@ -365,6 +373,8 @@ static void rna_def_touch_sensor(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "ma"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material"); + /* note: custom set function is ONLY to avoid rna setting a user for this. */ + RNA_def_property_pointer_funcs(prop, NULL, "rna_Sensor_touch_material_set", NULL); RNA_def_property_update(prop, NC_LOGIC, NULL); } |