diff options
24 files changed, 148 insertions, 71 deletions
diff --git a/release/scripts/op/io_anim_bvh/import_bvh.py b/release/scripts/op/io_anim_bvh/import_bvh.py index befd6cdbe89..5f9de6cbd90 100644 --- a/release/scripts/op/io_anim_bvh/import_bvh.py +++ b/release/scripts/op/io_anim_bvh/import_bvh.py @@ -351,7 +351,7 @@ def bvh_node_dict2armature(context, bvh_nodes, ROT_MODE='XYZ', IMPORT_START_FRAM for ob in scn.objects: ob.select = False - scn.set_frame(IMPORT_START_FRAME) + scn.frame_set(IMPORT_START_FRAME) arm_data = bpy.data.armatures.new("MyBVH") arm_ob = bpy.data.objects.new("MyBVH", arm_data) diff --git a/release/scripts/op/io_scene_3ds/import_3ds.py b/release/scripts/op/io_scene_3ds/import_3ds.py index 5ea705f15f7..1f34d3738bd 100644 --- a/release/scripts/op/io_scene_3ds/import_3ds.py +++ b/release/scripts/op/io_scene_3ds/import_3ds.py @@ -240,7 +240,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH): bmat = MATDICT[matName][1] img = TEXTURE_DICT.get(bmat.name) - bmesh.materials.link(bmat) # can be None + bmesh.materials.append(bmat) # can be None if uv_faces and img: for fidx in faces: diff --git a/release/scripts/op/io_scene_fbx/export_fbx.py b/release/scripts/op/io_scene_fbx/export_fbx.py index ec13decc026..51a5f86a5e4 100644 --- a/release/scripts/op/io_scene_fbx/export_fbx.py +++ b/release/scripts/op/io_scene_fbx/export_fbx.py @@ -1965,7 +1965,7 @@ def save(operator, context, filepath="", \ ob_base.update(scene) # This causes the makeDisplayList command to effect the mesh - scene.set_frame(scene.frame_current) + scene.frame_set(scene.frame_current) # Blender.Set('curframe', Blender.Get('curframe')) @@ -2138,7 +2138,7 @@ def save(operator, context, filepath="", \ if ob_base.type == 'ARMATURE': ob_base.update(scene) # This causes the makeDisplayList command to effect the mesh - scene.set_frame(scene.frame_current) + scene.frame_set(scene.frame_current) # Blender.Set('curframe', Blender.Get('curframe')) del tmp_ob_type, tmp_objects @@ -2758,7 +2758,7 @@ Takes: {''') ''' i = act_start while i <= act_end: - scene.set_frame(i) + scene.frame_set(i) # Blender.Set('curframe', i) for ob_generic in ob_anim_lists: for my_ob in ob_generic: @@ -2898,8 +2898,7 @@ Takes: {''') file.write('\n}') - scene.set_frame(frame_orig) -# Blender.Set('curframe', frame_orig) + scene.frame_set(frame_orig) else: # no animation diff --git a/release/scripts/op/io_scene_obj/import_obj.py b/release/scripts/op/io_scene_obj/import_obj.py index b21db8ae615..73b5484ff3a 100644 --- a/release/scripts/op/io_scene_obj/import_obj.py +++ b/release/scripts/op/io_scene_obj/import_obj.py @@ -593,7 +593,7 @@ def create_mesh(new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc, v # make sure the list isnt too big for material in materials: - me.materials.link(material) + me.materials.append(material) me.vertices.add(len(verts_loc)) me.faces.add(len(faces)) diff --git a/release/scripts/op/io_shape_mdd/export_mdd.py b/release/scripts/op/io_shape_mdd/export_mdd.py index 1f0a5d94320..3c57ae5afa0 100644 --- a/release/scripts/op/io_shape_mdd/export_mdd.py +++ b/release/scripts/op/io_shape_mdd/export_mdd.py @@ -69,7 +69,7 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25): bpy.ops.object.mode_set(mode='OBJECT') orig_frame = scene.frame_current - scene.set_frame(frame_start) + scene.frame_set(frame_start) me = obj.create_mesh(scene, True, 'PREVIEW') #Flip y and z @@ -108,7 +108,7 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25): me_tmp.getFromObject(obj.name) """ - scene.set_frame(frame) + scene.frame_set(frame) me = obj.create_mesh(scene, True, 'PREVIEW') check_vertcount(me, numverts) me.transform(mat_flip * obj.matrix_world) @@ -126,6 +126,6 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25): Blender.Window.WaitCursor(0) Blender.Set('curframe', orig_frame) """ - scene.set_frame(orig_frame) + scene.frame_set(orig_frame) return {'FINISHED'} diff --git a/release/scripts/op/nla.py b/release/scripts/op/nla.py index cc48d39188a..27fd83c4482 100644 --- a/release/scripts/op/nla.py +++ b/release/scripts/op/nla.py @@ -87,7 +87,7 @@ def bake(frame_start, frame_end, step=1, only_selected=False): # could spped this up by applying steps here too... for f in frame_range: - scene.set_frame(f) + scene.frame_set(f) info = pose_info() info_ls.append(info) diff --git a/release/scripts/ui/properties_object.py b/release/scripts/ui/properties_object.py index 35037b10216..66189f62dbf 100644 --- a/release/scripts/ui/properties_object.py +++ b/release/scripts/ui/properties_object.py @@ -142,7 +142,7 @@ class OBJECT_PT_groups(ObjectButtonsPanel, bpy.types.Panel): if ob.name in group.objects: col = layout.column(align=True) - col.set_context_pointer("group", group) + col.context_pointer_set("group", group) row = col.box().row() row.prop(group, "name", text="") diff --git a/release/scripts/ui/properties_physics_cloth.py b/release/scripts/ui/properties_physics_cloth.py index 4fd7fc97418..2e50babfcfd 100644 --- a/release/scripts/ui/properties_physics_cloth.py +++ b/release/scripts/ui/properties_physics_cloth.py @@ -63,7 +63,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, bpy.types.Panel): if md: # remove modifier + settings - split.set_context_pointer("modifier", md) + split.context_pointer_set("modifier", md) split.operator("object.modifier_remove", text="Remove") row = split.row(align=True) diff --git a/release/scripts/ui/properties_physics_common.py b/release/scripts/ui/properties_physics_common.py index c4692635ee7..68b93386099 100644 --- a/release/scripts/ui/properties_physics_common.py +++ b/release/scripts/ui/properties_physics_common.py @@ -26,7 +26,7 @@ import bpy def point_cache_ui(self, context, cache, enabled, cachetype): layout = self.layout - layout.set_context_pointer("point_cache", cache) + layout.context_pointer_set("point_cache", cache) row = layout.row() row.template_list(cache, "point_caches", cache.point_caches, "active_index", rows=2) diff --git a/release/scripts/ui/properties_physics_field.py b/release/scripts/ui/properties_physics_field.py index 07d748e8c28..a72103f5132 100644 --- a/release/scripts/ui/properties_physics_field.py +++ b/release/scripts/ui/properties_physics_field.py @@ -175,7 +175,7 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, bpy.types.Panel): if md: # remove modifier + settings - split.set_context_pointer("modifier", md) + split.context_pointer_set("modifier", md) split.operator("object.modifier_remove", text="Remove") col = split.column() diff --git a/release/scripts/ui/properties_physics_fluid.py b/release/scripts/ui/properties_physics_fluid.py index 18c0204f993..dcdb2de8b52 100644 --- a/release/scripts/ui/properties_physics_fluid.py +++ b/release/scripts/ui/properties_physics_fluid.py @@ -44,7 +44,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, bpy.types.Panel): if md: # remove modifier + settings - split.set_context_pointer("modifier", md) + split.context_pointer_set("modifier", md) split.operator("object.modifier_remove", text="Remove") row = split.row(align=True) diff --git a/release/scripts/ui/properties_physics_smoke.py b/release/scripts/ui/properties_physics_smoke.py index cf91705318e..1db6785f36f 100644 --- a/release/scripts/ui/properties_physics_smoke.py +++ b/release/scripts/ui/properties_physics_smoke.py @@ -49,7 +49,7 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel, bpy.types.Panel): if md: # remove modifier + settings - split.set_context_pointer("modifier", md) + split.context_pointer_set("modifier", md) split.operator("object.modifier_remove", text="Remove") row = split.row(align=True) diff --git a/release/scripts/ui/properties_physics_softbody.py b/release/scripts/ui/properties_physics_softbody.py index b9c4c87c78d..08abf048c50 100644 --- a/release/scripts/ui/properties_physics_softbody.py +++ b/release/scripts/ui/properties_physics_softbody.py @@ -55,7 +55,7 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel, bpy.types.Panel): if md: # remove modifier + settings - split.set_context_pointer("modifier", md) + split.context_pointer_set("modifier", md) split.operator("object.modifier_remove", text="Remove") row = split.row(align=True) diff --git a/release/scripts/ui/space_userpref_keymap.py b/release/scripts/ui/space_userpref_keymap.py index 3d76c014694..d77acabd66b 100644 --- a/release/scripts/ui/space_userpref_keymap.py +++ b/release/scripts/ui/space_userpref_keymap.py @@ -161,7 +161,7 @@ class InputKeyMapPanel(bpy.types.Panel): def draw_km(self, display_keymaps, kc, km, children, layout, level): km = km.active() - layout.set_context_pointer("keymap", km) + layout.context_pointer_set("keymap", km) col = self.indented_layout(layout, level) @@ -315,12 +315,12 @@ class InputKeyMapPanel(bpy.types.Panel): kmm = kc.keymaps.find_modal(kmi.idname) if kmm: self.draw_km(display_keymaps, kc, kmm, None, layout, level + 1) - layout.set_context_pointer("keymap", km) + layout.context_pointer_set("keymap", km) def draw_filtered(self, display_keymaps, filter_text, layout): for km, kc in display_keymaps: km = km.active() - layout.set_context_pointer("keymap", km) + layout.context_pointer_set("keymap", km) filtered_items = [kmi for kmi in km.items if filter_text in kmi.name.lower()] @@ -364,7 +364,7 @@ class InputKeyMapPanel(bpy.types.Panel): row = subcol.row() row.prop_search(wm.keyconfigs, "active", wm, "keyconfigs", text="Key Config:") - layout.set_context_pointer("keyconfig", wm.keyconfigs.active) + layout.context_pointer_set("keyconfig", wm.keyconfigs.active) row.operator("wm.keyconfig_remove", text="", icon='X') row.prop(context.space_data, "filter_text", icon="VIEWZOOM") diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index a220153523e..40d98394a8e 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -57,6 +57,9 @@ void automatname(struct Material *); struct Material ***give_matarar(struct Object *ob); short *give_totcolp(struct Object *ob); +struct Material ***give_matarar_id(struct ID *id); /* same but for ID's */ +short *give_totcolp_id(struct ID *id); + struct Material *give_current_material(struct Object *ob, int act); struct ID *material_from(struct Object *ob, int act); void assign_material(struct Object *ob, struct Material *ma, int act); @@ -67,6 +70,10 @@ int find_material_index(struct Object *ob, struct Material *ma); int object_add_material_slot(struct Object *ob); int object_remove_material_slot(struct Object *ob); +/* rna api */ +void material_append_id(struct ID *id, struct Material *ma); +struct Material *material_pop_id(struct ID *id, int index); + /* rendering */ void init_render_material(struct Material *, int, float *); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index e6cf0beb861..beffd542427 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -434,6 +434,90 @@ short *give_totcolp(Object *ob) return NULL; } +/* same as above but for ID's */ +Material ***give_matarar_id(ID *id) +{ + switch(GS(id->name)) { + case ID_ME: + return &(((Mesh *)id)->mat); + break; + case ID_CU: + return &(((Curve *)id)->mat); + break; + case ID_MB: + return &(((Curve *)id)->mat); + break; + } + return NULL; +} + +short *give_totcolp_id(ID *id) +{ + switch(GS(id->name)) { + case ID_ME: + return &(((Mesh *)id)->totcol); + break; + case ID_CU: + return &(((Curve *)id)->totcol); + break; + case ID_MB: + return &(((Curve *)id)->totcol); + break; + } + return NULL; +} + +void material_append_id(ID *id, Material *ma) +{ + Material ***matar; + if((matar= give_matarar_id(id))) { + short *totcol= give_totcolp_id(id); + Material **mat= MEM_callocN(sizeof(void *) * (*totcol) + 1, "newmatar"); + if(*totcol) memcpy(mat, *matar, sizeof(void *) * (*totcol)); + if(*matar) MEM_freeN(*matar); + + *matar= mat; + (*matar)[(*totcol)++]= ma; + + id_us_plus((ID *)ma); + test_object_materials(id); + } +} + +Material *material_pop_id(ID *id, int index) +{ + Material *ret= NULL; + Material ***matar; + if((matar= give_matarar_id(id))) { + short *totcol= give_totcolp_id(id); + if(index >= 0 && index < (*totcol)) { + ret= (*matar)[index]; + if(*totcol <= 1) { + *totcol= 0; + MEM_freeN(*matar); + *matar= NULL; + } + else { + Material **mat; + + if(index + 1 != (*totcol)) + memmove((*matar), (*matar) + 1, (*totcol) - (index + 1)); + + (*totcol)--; + + mat= MEM_callocN(sizeof(void *) * (*totcol), "newmatar"); + memcpy(mat, *matar, sizeof(void *) * (*totcol)); + MEM_freeN(*matar); + + *matar= mat; + test_object_materials(id); + } + } + } + + return ret; +} + Material *give_current_material(Object *ob, int act) { Material ***matarar, *ma; diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 35cb9f02b64..d1c6ff4c4ae 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -772,24 +772,3 @@ void ED_mesh_calc_normals(Mesh *me) { mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL); } - -/* always adds the material even if its linked alredy - * for pradictable material indicies */ -void ED_mesh_material_link(Mesh *me, Material *ma) -{ - int totcol = me->totcol + 1; - Material **mat; - - mat= MEM_callocN(sizeof(void*)*totcol, "newmatar"); - - if(me->totcol) memcpy(mat, me->mat, sizeof(void*) * me->totcol); - if(me->mat) MEM_freeN(me->mat); - - me->mat = mat; - me->mat[me->totcol++] = ma; - if(ma) - ma->id.us++; - - test_object_materials((ID*)me); -} - diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 4133afffeed..7a2d659755a 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -972,6 +972,8 @@ int make_structDNA(char *baseDirectory, FILE *file) dna_write(file, str, 4); len= nr_names; dna_write(file, &len, 4); + printf("LEEEN %d\n", len); + /* calculate size of datablock with strings */ cp= names[nr_names-1]; diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index a8b7fb1540b..b9ef92cdca1 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -71,6 +71,7 @@ EnumPropertyItem id_type_items[] = { #include "BKE_idprop.h" #include "BKE_library.h" #include "BKE_animsys.h" +#include "BKE_material.h" /* name functions that ignore the first two ID characters */ void rna_ID_name_get(PointerRNA *ptr, char *value) @@ -331,6 +332,31 @@ static void rna_def_ID_properties(BlenderRNA *brna) RNA_def_struct_name_property(srna, prop); } + +static void rna_def_ID_materials(BlenderRNA *brna) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + /* for mesh/mball/curve materials */ + srna= RNA_def_struct(brna, "IDMaterials", NULL); + RNA_def_struct_sdna(srna, "ID"); + RNA_def_struct_ui_text(srna, "ID Materials", "Collection of materials"); + + func= RNA_def_function(srna, "append", "material_append_id"); + RNA_def_function_ui_description(func, "Add a new material to Mesh."); + parm= RNA_def_pointer(func, "material", "Material", "", "Material to add."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "pop", "material_pop_id"); + RNA_def_function_ui_description(func, "Add a new material to Mesh."); + parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "", "Frame number to set.", 0, INT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "material", "Material", "", "Material to add."); + RNA_def_function_return(func, parm); +} + static void rna_def_ID(BlenderRNA *brna) { StructRNA *srna; @@ -422,6 +448,7 @@ void RNA_def_ID(BlenderRNA *brna) rna_def_ID(brna); rna_def_ID_properties(brna); + rna_def_ID_materials(brna); rna_def_library(brna); } diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index fb6da576811..e28212470c3 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -1261,6 +1261,7 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); RNA_def_property_struct_type(prop, "Material"); RNA_def_property_ui_text(prop, "Materials", ""); + RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */ } static void rna_def_curve_nurb(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 741b5cbab81..db5a2062359 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1781,29 +1781,6 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); } -/* mesh.materials */ -static void rna_def_mesh_materials(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; - // PropertyRNA *prop; - - FunctionRNA *func; - PropertyRNA *parm; - - RNA_def_property_srna(cprop, "MeshMaterials"); - srna= RNA_def_struct(brna, "MeshMaterials", NULL); - RNA_def_struct_sdna(srna, "Mesh"); - RNA_def_struct_ui_text(srna, "Mesh Materials", "Collection of materials"); - - func= RNA_def_function(srna, "link", "ED_mesh_material_link"); - RNA_def_function_ui_description(func, "Add a new material to Mesh."); - parm= RNA_def_pointer(func, "material", "Material", "", "Material to add."); - RNA_def_property_flag(parm, PROP_REQUIRED); - - /* TODO, unlink? */ -} - - static void rna_def_mesh(BlenderRNA *brna) { StructRNA *srna; @@ -1951,7 +1928,7 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); RNA_def_property_struct_type(prop, "Material"); RNA_def_property_ui_text(prop, "Materials", ""); - rna_def_mesh_materials(brna, prop); + RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */ /* Mesh Draw Options for Edit Mode*/ diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 9bb25ac2cda..18dfd05b971 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -325,6 +325,7 @@ static void rna_def_metaball(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); RNA_def_property_struct_type(prop, "Material"); RNA_def_property_ui_text(prop, "Materials", ""); + RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */ /* anim */ rna_def_animdata_common(srna); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 04fbae894d0..f6a6453c703 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -47,7 +47,7 @@ -static void rna_Scene_set_frame(Scene *scene, int frame, float subframe) +static void rna_Scene_frame_set(Scene *scene, int frame, float subframe) { scene->r.cfra= frame; scene->r.subframe= subframe; @@ -78,7 +78,7 @@ void RNA_api_scene(StructRNA *srna) FunctionRNA *func; PropertyRNA *parm; - func= RNA_def_function(srna, "set_frame", "rna_Scene_set_frame"); + func= RNA_def_function(srna, "frame_set", "rna_Scene_frame_set"); RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately."); parm= RNA_def_int(func, "frame", 0, MINAFRAME, MAXFRAME, "", "Frame number to set.", MINAFRAME, MAXFRAME); RNA_def_property_flag(parm, PROP_REQUIRED); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 4f5c8094c14..1d86faa5e53 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -259,7 +259,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_function_ui_description(func, "Item. Inserts empty space into the layout between items."); /* context */ - func= RNA_def_function(srna, "set_context_pointer", "uiLayoutSetContextPointer"); + func= RNA_def_function(srna, "context_pointer_set", "uiLayoutSetContextPointer"); parm= RNA_def_string(func, "name", "", 0, "Name", "Name of entry in the context."); RNA_def_property_flag(parm, PROP_REQUIRED); parm= RNA_def_pointer(func, "data", "AnyType", "", "Pointer to put in context."); |