[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24698] trunk/blender: - dir() now works for collection functions
Campbell Barton
ideasman42 at gmail.com
Fri Nov 20 11:00:55 CET 2009
Revision: 24698
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24698
Author: campbellbarton
Date: 2009-11-20 11:00:54 +0100 (Fri, 20 Nov 2009)
Log Message:
-----------
- dir() now works for collection functions
- group.objects.link/unlink use exceptions rather then return values
- scene.add_object/remove_object --> scene.objects.link/unlink
Modified Paths:
--------------
trunk/blender/release/scripts/io/export_obj.py
trunk/blender/release/scripts/io/import_scene_3ds.py
trunk/blender/release/scripts/io/import_scene_obj.py
trunk/blender/release/scripts/op/add_mesh_torus.py
trunk/blender/source/blender/makesrna/intern/rna_group.c
trunk/blender/source/blender/makesrna/intern/rna_scene.c
trunk/blender/source/blender/makesrna/intern/rna_scene_api.c
trunk/blender/source/blender/python/intern/bpy_rna.c
Modified: trunk/blender/release/scripts/io/export_obj.py
===================================================================
--- trunk/blender/release/scripts/io/export_obj.py 2009-11-20 06:31:49 UTC (rev 24697)
+++ trunk/blender/release/scripts/io/export_obj.py 2009-11-20 10:00:54 UTC (rev 24698)
@@ -485,10 +485,10 @@
newob = bpy.data.add_object('MESH', 'temp_object')
newob.data = me
# if we forget to set Object.data - crash
- scene.add_object(newob)
+ scene.objects.link(newob)
newob.convert_to_triface(scene)
# mesh will still be there
- scene.remove_object(newob)
+ scene.objects.unlink(newob)
'''
# Make our own list so it can be sorted to reduce context switching
Modified: trunk/blender/release/scripts/io/import_scene_3ds.py
===================================================================
--- trunk/blender/release/scripts/io/import_scene_3ds.py 2009-11-20 06:31:49 UTC (rev 24697)
+++ trunk/blender/release/scripts/io/import_scene_3ds.py 2009-11-20 10:00:54 UTC (rev 24698)
@@ -465,7 +465,7 @@
# bmesh.transform(contextMatrix)
ob = bpy.data.add_object("MESH", tempName)
ob.data = bmesh
- SCN.add_object(ob)
+ SCN.objects.link(ob)
# ob = SCN_OBJECTS.new(bmesh, tempName)
'''
if contextMatrix_tx:
@@ -766,7 +766,7 @@
ob = bpy.data.add_object("LAMP", "Lamp")
ob.data = bpy.data.add_lamp("Lamp")
- SCN.add_object(ob)
+ SCN.objects.link(ob)
contextLamp[1]= ob.data
# contextLamp[1]= bpy.data.lamps.new()
Modified: trunk/blender/release/scripts/io/import_scene_obj.py
===================================================================
--- trunk/blender/release/scripts/io/import_scene_obj.py 2009-11-20 06:31:49 UTC (rev 24697)
+++ trunk/blender/release/scripts/io/import_scene_obj.py 2009-11-20 10:00:54 UTC (rev 24698)
@@ -864,7 +864,7 @@
ob= bpy.data.add_object("MESH", "Mesh")
ob.data= me
- scn.add_object(ob)
+ scn.objects.link(ob)
# ob= scn.objects.new(me)
new_objects.append(ob)
Modified: trunk/blender/release/scripts/op/add_mesh_torus.py
===================================================================
--- trunk/blender/release/scripts/op/add_mesh_torus.py 2009-11-20 06:31:49 UTC (rev 24697)
+++ trunk/blender/release/scripts/op/add_mesh_torus.py 2009-11-20 10:00:54 UTC (rev 24698)
@@ -116,7 +116,7 @@
mesh.update()
ob_new = bpy.data.add_object('MESH', "Torus")
ob_new.data = mesh
- scene.add_object(ob_new)
+ scene.objects.link(ob_new)
scene.objects.active = ob_new
ob_new.selected = True
Modified: trunk/blender/source/blender/makesrna/intern/rna_group.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_group.c 2009-11-20 06:31:49 UTC (rev 24697)
+++ trunk/blender/source/blender/makesrna/intern/rna_group.c 2009-11-20 10:00:54 UTC (rev 24698)
@@ -49,16 +49,24 @@
return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((GroupObject*)internal->link)->ob);
}
-static int rna_Group_objects_link(Group *group, bContext *C, Object *object)
+static void rna_Group_objects_link(Group *group, bContext *C, ReportList *reports, Object *object)
{
+ if(!add_to_group(group, object, CTX_data_scene(C), NULL)) {
+ BKE_reportf(reports, RPT_ERROR, "Object \"%s\" already in group \"%s\".", object->id.name+2, group->id.name+2);
+ return;
+ }
+
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id);
- return add_to_group(group, object, CTX_data_scene(C), NULL);
}
-static int rna_Group_objects_unlink(Group *group, bContext *C, Object *object)
+static void rna_Group_objects_unlink(Group *group, bContext *C, ReportList *reports, Object *object)
{
+ if(!rem_from_group(group, object, CTX_data_scene(C), NULL)) {
+ BKE_reportf(reports, RPT_ERROR, "Object \"%s\" not in group \"%s\".", object->id.name+2, group->id.name+2);
+ return;
+ }
+
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id);
- return rem_from_group(group, object, CTX_data_scene(C), NULL);
}
#else
@@ -79,11 +87,8 @@
/* add object */
func= RNA_def_function(srna, "link", "rna_Group_objects_link");
- RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Add this object to a group");
- /* return type */
- parm= RNA_def_boolean(func, "success", 0, "Success", "");
- RNA_def_function_return(func, parm);
/* object to add */
parm= RNA_def_pointer(func, "object", "Object", "", "Object to add.");
RNA_def_property_flag(parm, PROP_REQUIRED);
@@ -91,10 +96,7 @@
/* remove object */
func= RNA_def_function(srna, "unlink", "rna_Group_objects_unlink");
RNA_def_function_ui_description(func, "Remove this object to a group");
- RNA_def_function_flag(func, FUNC_USE_CONTEXT);
- /* return type */
- parm= RNA_def_boolean(func, "success", 0, "Success", "");
- RNA_def_function_return(func, parm);
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
/* object to remove */
parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove.");
RNA_def_property_flag(parm, PROP_REQUIRED);
Modified: trunk/blender/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_scene.c 2009-11-20 06:31:49 UTC (rev 24697)
+++ trunk/blender/source/blender/makesrna/intern/rna_scene.c 2009-11-20 10:00:54 UTC (rev 24698)
@@ -80,6 +80,7 @@
#include "BKE_node.h"
#include "BKE_pointcache.h"
#include "BKE_scene.h"
+#include "BKE_depsgraph.h"
#include "BLI_threads.h"
@@ -97,6 +98,34 @@
return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((Base*)internal->link)->object);
}
+static void rna_Scene_link_object(Scene *sce, ReportList *reports, Object *ob)
+{
+ Base *base= object_in_scene(ob, sce);
+ if (base) {
+ BKE_report(reports, RPT_ERROR, "Object is already in this scene.");
+ return;
+ }
+ base= scene_add_base(sce, ob);
+ ob->id.us++;
+
+ /* this is similar to what object_add_type and add_object do */
+ ob->lay= base->lay= sce->lay;
+ ob->recalc |= OB_RECALC;
+
+ DAG_scene_sort(sce);
+}
+
+static void rna_Scene_unlink_object(Scene *sce, ReportList *reports, Object *ob)
+{
+ Base *base= object_in_scene(ob, sce);
+ if (!base) {
+ BKE_report(reports, RPT_ERROR, "Object is not in this scene.");
+ return;
+ }
+ /* as long as ED_base_object_free_and_unlink calls free_libblock_us, we don't have to decrement ob->id.us */
+ ED_base_object_free_and_unlink(sce, base);
+}
+
static void rna_Scene_skgen_etch_template_set(PointerRNA *ptr, PointerRNA value)
{
ToolSettings *ts = (ToolSettings*)ptr->data;
@@ -2176,37 +2205,25 @@
StructRNA *srna;
PropertyRNA *prop;
-// FunctionRNA *func;
-// PropertyRNA *parm;
+ FunctionRNA *func;
+ PropertyRNA *parm;
RNA_def_property_srna(cprop, "SceneObjects");
srna= RNA_def_struct(brna, "SceneObjects", NULL);
- RNA_def_struct_sdna(srna, "Object");
+ RNA_def_struct_sdna(srna, "Scene");
RNA_def_struct_ui_text(srna, "Scene Objects", "Collection of scene objects.");
-#if 0
- /* add object */
- func= RNA_def_function(srna, "link", "rna_Scene_objects_link");
- RNA_def_function_flag(func, FUNC_USE_CONTEXT);
- RNA_def_function_ui_description(func, "Add this object to this scene");
- /* return type */
- parm= RNA_def_boolean(func, "success", 0, "Success", "");
- RNA_def_function_return(func, parm);
- /* object to add */
- parm= RNA_def_pointer(func, "object", "Object", "", "Object to add.");
+ func= RNA_def_function(srna, "link", "rna_Scene_link_object");
+ RNA_def_function_ui_description(func, "Link object to scene.");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm= RNA_def_pointer(func, "object", "Object", "", "Object to add to scene.");
RNA_def_property_flag(parm, PROP_REQUIRED);
- /* remove object */
- func= RNA_def_function(srna, "unlink", "rna_Scene_objects_unlink");
- RNA_def_function_ui_description(func, "Remove this object to a scene");
- RNA_def_function_flag(func, FUNC_USE_CONTEXT);
- /* return type */
- parm= RNA_def_boolean(func, "success", 0, "Success", "");
- RNA_def_function_return(func, parm);
- /* object to remove */
- parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove.");
+ func= RNA_def_function(srna, "unlink", "rna_Scene_unlink_object");
+ RNA_def_function_ui_description(func, "Unlink object from scene.");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove from scene.");
RNA_def_property_flag(parm, PROP_REQUIRED);
-#endif
prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
Modified: trunk/blender/source/blender/makesrna/intern/rna_scene_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_scene_api.c 2009-11-20 06:31:49 UTC (rev 24697)
+++ trunk/blender/source/blender/makesrna/intern/rna_scene_api.c 2009-11-20 10:00:54 UTC (rev 24698)
@@ -47,34 +47,6 @@
#include "WM_api.h"
-static void rna_Scene_add_object(Scene *sce, ReportList *reports, Object *ob)
-{
- Base *base= object_in_scene(ob, sce);
- if (base) {
- BKE_report(reports, RPT_ERROR, "Object is already in this scene.");
- return;
- }
- base= scene_add_base(sce, ob);
- ob->id.us++;
-
- /* this is similar to what object_add_type and add_object do */
- ob->lay= base->lay= sce->lay;
- ob->recalc |= OB_RECALC;
-
- DAG_scene_sort(sce);
-}
-
-static void rna_Scene_remove_object(Scene *sce, ReportList *reports, Object *ob)
-{
- Base *base= object_in_scene(ob, sce);
- if (!base) {
- BKE_report(reports, RPT_ERROR, "Object is not in this scene.");
- return;
- }
- /* as long as ED_base_object_free_and_unlink calls free_libblock_us, we don't have to decrement ob->id.us */
- ED_base_object_free_and_unlink(sce, base);
-}
-
static void rna_Scene_set_frame(Scene *sce, bContext *C, int frame)
{
sce->r.cfra= frame;
@@ -118,18 +90,6 @@
FunctionRNA *func;
PropertyRNA *parm;
- func= RNA_def_function(srna, "add_object", "rna_Scene_add_object");
- RNA_def_function_ui_description(func, "Add object to scene.");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
- parm= RNA_def_pointer(func, "object", "Object", "", "Object to add to scene.");
- RNA_def_property_flag(parm, PROP_REQUIRED);
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list