From e11327b9c9ed791acbd9b449e45c692bafd5ac70 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 14:40:37 +0000 Subject: [PATCH 001/202] workaround for a problem with rna collection type definitions. setting the type for a collection does not work if its set before the type is defined. --- source/blender/makesrna/intern/rna_main.c | 80 +++++++++++-------- source/blender/makesrna/intern/rna_main_api.c | 14 ++-- 2 files changed, 52 insertions(+), 42 deletions(-) diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 4b5a404b268..b47a2d5c907 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -235,42 +235,52 @@ static PointerRNA rna_Test_test_get(PointerRNA *ptr) #else -typedef void (*CollectionDefFunc)(struct BlenderRNA *brna, struct PropertyRNA *cprop); +/* local convenience types */ +typedef void (CollectionDefFunc)(struct BlenderRNA *brna, struct PropertyRNA *cprop); + +typedef struct MainCollectionDef { + const char *identifier; + const char *type; + const char *iter_begin; + const char *name; + const char *description; + CollectionDefFunc *func; +} MainCollectionDef; void RNA_def_main(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - CollectionDefFunc func; + CollectionDefFunc *func; - const char *lists[][6]= { - {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks.", (char *)RNA_def_main_cameras}, - {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks.", (char *)RNA_def_main_scenes}, - {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks.", (char *)RNA_def_main_objects}, - {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks.", (char *)RNA_def_main_materials}, - {"node_groups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks.", (char *)RNA_def_main_node_groups}, - {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks.", (char *)RNA_def_main_meshes}, - {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks.", (char *)RNA_def_main_lamps}, - {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks.", (char *)RNA_def_main_libraries}, - {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks.", (char *)RNA_def_main_screens}, - {"window_managers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks.", (char *)RNA_def_main_window_managers}, - {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks.", (char *)RNA_def_main_images}, - {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks.", (char *)RNA_def_main_lattices}, - {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks.", (char *)RNA_def_main_curves} , - {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks.", (char *)RNA_def_main_metaballs}, - {"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks.", (char *)RNA_def_main_vfonts}, - {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks.", (char *)RNA_def_main_textures}, - {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks.", (char *)RNA_def_main_brushes}, - {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks.", (char *)RNA_def_main_worlds}, - {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks.", (char *)RNA_def_main_groups}, + MainCollectionDef lists[]= { + {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks.", RNA_def_main_cameras}, + {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks.", RNA_def_main_scenes}, + {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks.", RNA_def_main_objects}, + {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks.", RNA_def_main_materials}, + {"node_groups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks.", RNA_def_main_node_groups}, + {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks.", RNA_def_main_meshes}, + {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks.", RNA_def_main_lamps}, + {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks.", RNA_def_main_libraries}, + {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks.", RNA_def_main_screens}, + {"window_managers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks.", RNA_def_main_window_managers}, + {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks.", RNA_def_main_images}, + {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks.", RNA_def_main_lattices}, + {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks.", RNA_def_main_curves} , + {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks.", RNA_def_main_metaballs}, + {"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks.", RNA_def_main_vfonts}, + {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks.", RNA_def_main_textures}, + {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks.", RNA_def_main_brushes}, + {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks.", RNA_def_main_worlds}, + {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks.", RNA_def_main_groups}, /* {"keys", "Key", "rna_Main_key_begin", "Keys", "Key datablocks.", NULL}, */ - {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks (DEPRECATED).", (char *)NULL}, - {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks.", (char *)RNA_def_main_texts}, - {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks.", (char *)RNA_def_main_sounds}, - {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks.", (char *)RNA_def_main_armatures}, - {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks.", (char *)RNA_def_main_actions}, - {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks.", (char *)RNA_def_main_particles}, - {"gpencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks.", (char *)RNA_def_main_gpencil}, + {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks (DEPRECATED).", NULL}, + {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks.", RNA_def_main_texts}, + {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks.", RNA_def_main_sounds}, + {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks.", RNA_def_main_armatures}, + {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks.", RNA_def_main_actions}, + {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks.", RNA_def_main_particles}, + {"gpencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks.", RNA_def_main_gpencil}, {NULL, NULL, NULL, NULL, NULL, NULL}}; int i; @@ -285,15 +295,15 @@ void RNA_def_main(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Filename", "Path to the .blend file."); - for(i=0; lists[i][0]; i++) + for(i=0; lists[i].name; i++) { - prop= RNA_def_property(srna, lists[i][0], PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, lists[i][1]); - RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); - RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]); + prop= RNA_def_property(srna, lists[i].identifier, PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, lists[i].type); + RNA_def_property_collection_funcs(prop, lists[i].iter_begin, "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); + RNA_def_property_ui_text(prop, lists[i].name, lists[i].description); /* collection functions */ - func= (CollectionDefFunc *)lists[i][5]; + func= lists[i].func; if(func) func(brna, prop); } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index ecaf6f813da..09c92751087 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -212,7 +212,7 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainCameras"); srna= RNA_def_struct(brna, "MainCameras", NULL); - RNA_def_struct_sdna(srna, "Camera"); +// RNA_def_struct_sdna(srna, "Camera"); RNA_def_struct_ui_text(srna, "Main Cameras", "Collection of cameras."); func= RNA_def_function(srna, "new", "rna_Main_cameras_new"); @@ -239,7 +239,7 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainScenes"); srna= RNA_def_struct(brna, "MainScenes", NULL); - RNA_def_struct_sdna(srna, "Scene"); +// RNA_def_struct_sdna(srna, "Scene"); RNA_def_struct_ui_text(srna, "Main Scenes", "Collection of scenes."); func= RNA_def_function(srna, "new", "rna_Main_scenes_new"); @@ -267,7 +267,7 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainObjects"); srna= RNA_def_struct(brna, "MainObjects", NULL); - RNA_def_struct_sdna(srna, "Object"); +// RNA_def_struct_sdna(srna, "Object"); RNA_def_struct_ui_text(srna, "Main Objects", "Collection of objects."); func= RNA_def_function(srna, "new", "rna_Main_objects_new"); @@ -297,7 +297,7 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainMaterials"); srna= RNA_def_struct(brna, "MainMaterials", NULL); - RNA_def_struct_sdna(srna, "Material"); +// RNA_def_struct_sdna(srna, "Material"); RNA_def_struct_ui_text(srna, "Main Material", "Collection of materials."); func= RNA_def_function(srna, "new", "rna_Main_materials_new"); @@ -327,7 +327,7 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainMeshes"); srna= RNA_def_struct(brna, "MainMeshes", NULL); - RNA_def_struct_sdna(srna, "Mesh"); +// RNA_def_struct_sdna(srna, "Mesh"); RNA_def_struct_ui_text(srna, "Main Meshes", "Collection of meshes."); func= RNA_def_function(srna, "new", "rna_Main_meshes_new"); @@ -353,7 +353,7 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainLamps"); srna= RNA_def_struct(brna, "MainLamps", NULL); - RNA_def_struct_sdna(srna, "Lamp"); +// RNA_def_struct_sdna(srna, "Lamp"); RNA_def_struct_ui_text(srna, "Main Lamps", "Collection of lamps."); func= RNA_def_function(srna, "new", "rna_Main_lamps_new"); @@ -435,7 +435,7 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainArmatures"); srna= RNA_def_struct(brna, "MainArmatures", NULL); - RNA_def_struct_sdna(srna, "Armature"); +// RNA_def_struct_sdna(srna, "Armature"); RNA_def_struct_ui_text(srna, "Main Armatures", "Collection of armatures."); func= RNA_def_function(srna, "new", "rna_Main_armatures_new"); From 3b03984294176abfe1205edc25ee05dc6211055f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 15:20:22 +0000 Subject: [PATCH 002/202] Change how 'Main' collection type definitons work so that 'self' can be used without overriding the srna type. --- source/blender/makesrna/RNA_types.h | 10 +++ source/blender/makesrna/intern/rna_main_api.c | 63 +++++++------------ 2 files changed, 33 insertions(+), 40 deletions(-) diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 4e60fb413db..841f8708aa2 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -323,6 +323,16 @@ typedef struct ExtensionRNA { void (*free)(void *data); } ExtensionRNA; +/* fake struct definitions, needed otherwise collections end up owning the C + * structs like 'Object' when defined first */ +#define MainCameras Main +#define MainScenes Main +#define MainArmatures Main +#define MainMaterials Main +#define MainMeshes Main +#define MainLamps Main +#define MainObjects Main + #ifdef __cplusplus } #endif diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 09c92751087..f1fe24418e9 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -52,25 +52,24 @@ #include "DNA_mesh_types.h" #include "DNA_object_types.h" -static Tex *rna_Main_add_texture(Main *bmain, char *name) +Tex *rna_Main_add_texture(Main *bmain, char *name) { return add_texture(name); } /* TODO: remove texture? */ -static Image *rna_Main_add_image(Main *bmain, char *filename) +Image *rna_Main_add_image(Main *bmain, char *filename) { return BKE_add_image_file(filename, 0); } -static Camera *rna_Main_cameras_new(bContext *C, char* name) +Camera *rna_Main_cameras_new(Main *bmain, char* name) { return add_camera(name); } -static void rna_Main_cameras_remove(bContext *C, ReportList *reports, struct Camera *camera) +void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera) { - Main *bmain= CTX_data_main(C); if(camera->id.us == 0) free_libblock(&bmain->camera, camera); else @@ -79,23 +78,22 @@ static void rna_Main_cameras_remove(bContext *C, ReportList *reports, struct Cam /* XXX python now has invalid pointer? */ } -static Scene *rna_Main_scenes_new(bContext *C, char* name) +Scene *rna_Main_scenes_new(Main *bmain, char* name) { return add_scene(name); } -static void rna_Main_scenes_remove(bContext *C, ReportList *reports, struct Scene *scene) +void rna_Main_scenes_remove(Main *bmain, ReportList *reports, struct Scene *scene) { - Main *bmain= CTX_data_main(C); free_libblock(&bmain->scene, scene); } -static Object *rna_Main_objects_new(bContext *C, char* name, int type) +Object *rna_Main_objects_new(Main *bmain, char* name, int type) { Object *ob= add_only_object(type, name); ob->id.us--; return ob; } -static void rna_Main_objects_remove(bContext *C, ReportList *reports, struct Object *object) +void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object) { /* NOTE: the following example shows when this function should _not_ be called @@ -109,20 +107,18 @@ static void rna_Main_objects_remove(bContext *C, ReportList *reports, struct Obj # don't do this since ob is already freed! bpy.data.remove_object(ob) */ - Main *bmain= CTX_data_main(C); if(object->id.us == 0) free_libblock(&bmain->object, object); else BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d.", object->id.name+2, object->id.us); } -static Material *rna_Main_materials_new(bContext *C, char* name) +struct Material *rna_Main_materials_new(Main *bmain, char* name) { return add_material(name); } -static void rna_Main_materials_remove(bContext *C, ReportList *reports, struct Material *material) +void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material) { - Main *bmain= CTX_data_main(C); if(material->id.us == 0) free_libblock(&bmain->mat, material); else @@ -131,15 +127,14 @@ static void rna_Main_materials_remove(bContext *C, ReportList *reports, struct M /* XXX python now has invalid pointer? */ } -static Mesh *rna_Main_meshes_new(bContext *C, char* name) +Mesh *rna_Main_meshes_new(Main *bmain, char* name) { Mesh *me= add_mesh(name); me->id.us--; return me; } -static void rna_Main_meshes_remove(bContext *C, ReportList *reports, Mesh *mesh) +void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) { - Main *bmain= CTX_data_main(C); if(mesh->id.us == 0) free_libblock(&bmain->mesh, mesh); else @@ -148,15 +143,14 @@ static void rna_Main_meshes_remove(bContext *C, ReportList *reports, Mesh *mesh) /* XXX python now has invalid pointer? */ } -static Lamp *rna_Main_lamps_new(bContext *C, char* name) +Lamp *rna_Main_lamps_new(Main *bmain, char* name) { Lamp *lamp= add_lamp(name); lamp->id.us--; return lamp; } -static void rna_Main_lamps_remove(bContext *C, ReportList *reports, Lamp *lamp) +void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) { - Main *bmain= CTX_data_main(C); if(lamp->id.us == 0) free_libblock(&bmain->lamp, lamp); else @@ -165,15 +159,14 @@ static void rna_Main_lamps_remove(bContext *C, ReportList *reports, Lamp *lamp) /* XXX python now has invalid pointer? */ } -static bArmature *rna_Main_armatures_new(bContext *C, char* name) +bArmature *rna_Main_armatures_new(Main *bmain, char* name) { bArmature *arm= add_armature(name); arm->id.us--; return arm; } -static void rna_Main_armatures_remove(bContext *C, ReportList *reports, bArmature *arm) +void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm) { - Main *bmain= CTX_data_main(C); if(arm->id.us == 0) free_libblock(&bmain->armature, arm); else @@ -212,11 +205,9 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainCameras"); srna= RNA_def_struct(brna, "MainCameras", NULL); -// RNA_def_struct_sdna(srna, "Camera"); RNA_def_struct_ui_text(srna, "Main Cameras", "Collection of cameras."); func= RNA_def_function(srna, "new", "rna_Main_cameras_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new camera to the main database"); parm= RNA_def_string(func, "name", "Camera", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -225,7 +216,7 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_cameras_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a camera from the current blendfile."); parm= RNA_def_pointer(func, "camera", "Camera", "", "Camera to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -239,11 +230,9 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainScenes"); srna= RNA_def_struct(brna, "MainScenes", NULL); -// RNA_def_struct_sdna(srna, "Scene"); RNA_def_struct_ui_text(srna, "Main Scenes", "Collection of scenes."); func= RNA_def_function(srna, "new", "rna_Main_scenes_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new scene to the main database"); parm= RNA_def_string(func, "name", "Scene", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -252,7 +241,7 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_scenes_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_function_ui_description(func, "Remove a scene from the current blendfile."); @@ -271,7 +260,6 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Main Objects", "Collection of objects."); func= RNA_def_function(srna, "new", "rna_Main_objects_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new object to the main database"); parm= RNA_def_string(func, "name", "Object", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -283,7 +271,7 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_objects_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_function_ui_description(func, "Remove a object from the current blendfile."); @@ -301,7 +289,6 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Main Material", "Collection of materials."); func= RNA_def_function(srna, "new", "rna_Main_materials_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new material to the main database"); parm= RNA_def_string(func, "name", "Material", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -310,7 +297,7 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_materials_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a material from the current blendfile."); parm= RNA_def_pointer(func, "material", "Material", "", "Material to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -331,7 +318,6 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Main Meshes", "Collection of meshes."); func= RNA_def_function(srna, "new", "rna_Main_meshes_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new mesh to the main database"); parm= RNA_def_string(func, "name", "Mesh", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -340,7 +326,7 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_meshes_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a mesh from the current blendfile."); parm= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -357,7 +343,6 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Main Lamps", "Collection of lamps."); func= RNA_def_function(srna, "new", "rna_Main_lamps_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new lamp to the main database"); parm= RNA_def_string(func, "name", "Lamp", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -366,7 +351,7 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_lamps_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a lamp from the current blendfile."); parm= RNA_def_pointer(func, "lamp", "Lamp", "", "Lamp to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -435,11 +420,9 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainArmatures"); srna= RNA_def_struct(brna, "MainArmatures", NULL); -// RNA_def_struct_sdna(srna, "Armature"); RNA_def_struct_ui_text(srna, "Main Armatures", "Collection of armatures."); func= RNA_def_function(srna, "new", "rna_Main_armatures_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new armature to the main database"); parm= RNA_def_string(func, "name", "Armature", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -448,7 +431,7 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_armatures_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a armature from the current blendfile."); parm= RNA_def_pointer(func, "armature", "Armature", "", "Armature to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); From 83e5edf5cb8fdaa0b08743756665f8a0ab8fc066 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 15:44:42 +0000 Subject: [PATCH 003/202] linked scenes were not animating. this needs fixing properly but for now we need linked data to be animated by its linked actions. --- source/blender/makesrna/intern/rna_access.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index ce06bc8f6c4..6932d775da7 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1060,7 +1060,9 @@ int RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop) id= ptr->id.data; - return (flag & PROP_EDITABLE) && (!id || !id->lib || (flag & PROP_LIB_EXCEPTION)); + /* with this, libdata is not animated by its own library fcurves, FIXME */ +// return (flag & PROP_EDITABLE) && (!id || !id->lib || (flag & PROP_LIB_EXCEPTION)); + return (flag & PROP_EDITABLE) ? 1:0; } /* same as RNA_property_editable(), except this checks individual items in an array */ @@ -1079,8 +1081,9 @@ int RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index) flag= prop->itemeditable(ptr, index); id= ptr->id.data; - - return (flag & PROP_EDITABLE) && (!id || !id->lib || (flag & PROP_LIB_EXCEPTION)); + /* with this, libdata is not animated by its own library fcurves, FIXME */ +// return (flag & PROP_EDITABLE) && (!id || !id->lib || (flag & PROP_LIB_EXCEPTION)); + return (flag & PROP_EDITABLE) ? 1:0; } int RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop) From c8966e53732a43b00516b7680c59586b874b5f1e Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 10 Jan 2010 16:29:53 +0000 Subject: [PATCH 004/202] * make sure build info is enabled for BF_BUILDINFO (this is enabled by default, and can be set in your user-config.py or other custom config). --- source/blender/windowmanager/SConscript | 3 +++ source/creator/SConscript | 1 + 2 files changed, 4 insertions(+) diff --git a/source/blender/windowmanager/SConscript b/source/blender/windowmanager/SConscript index beae5b721cc..0a86133e614 100644 --- a/source/blender/windowmanager/SConscript +++ b/source/blender/windowmanager/SConscript @@ -32,4 +32,7 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): if env['WITH_GHOST_COCOA']: sources.remove('intern/wm_apple.c') +if env['BF_BUILDINFO']: + defs.append('NAN_BUILDINFO') + env.BlenderLib ( 'bf_windowmanager', sources, Split(incs), defs, libtype=['core'], priority=[5] ) diff --git a/source/creator/SConscript b/source/creator/SConscript index 6c95f25a0b2..8c71e0e8566 100644 --- a/source/creator/SConscript +++ b/source/creator/SConscript @@ -38,5 +38,6 @@ if env['WITH_BF_FHS']: # /usr -> /usr/share/blender/2.5 if env['BF_BUILDINFO']: defs.append('BUILD_DATE') + defs.append('NAN_BUILDINFO') env.BlenderLib ( libname = 'bf_creator', sources = Split(sources), includes = Split(incs), defines = defs, libtype='core', priority = 0 ) From 57e96e4472464f4bc091ba9e7e8130bca7334b3f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 18:53:15 +0000 Subject: [PATCH 005/202] patch from Cessen, update to metarigs and some changes to the rigging main loop. - property names dont need the bone type prefix anymore - always add a root bone that all non parented bones are parented to - x/y/z axis properties for bones. --- release/scripts/modules/bpy_types.py | 19 ++++++ release/scripts/modules/rigify/__init__.py | 58 ++++++++++++------- .../modules/rigify/arm_biped_generic.py | 41 ++++++------- release/scripts/modules/rigify/copy.py | 25 +++++--- release/scripts/modules/rigify/finger_curl.py | 16 +++-- .../modules/rigify/leg_biped_generic.py | 46 ++++++++++----- .../modules/rigify/leg_quadruped_generic.py | 21 +++++-- release/scripts/modules/rigify/neck_flex.py | 23 ++++++-- release/scripts/modules/rigify/palm_curl.py | 3 +- .../modules/rigify/spine_pivot_flex.py | 26 ++++++--- release/scripts/modules/rigify_utils.py | 1 + 11 files changed, 186 insertions(+), 93 deletions(-) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 2a757f83208..a535673051c 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -19,6 +19,7 @@ # from _bpy import types as bpy_types +from Mathutils import Vector StructRNA = bpy_types.Struct.__bases__[0] # StructRNA = bpy_types.Struct @@ -88,6 +89,24 @@ class _GenericBone: i += 1 return 0 + + @property + def x_axis(self): + """ Vector pointing down the x-axis of the bone. + """ + return self.matrix.rotationPart() * Vector(1,0,0) + + @property + def y_axis(self): + """ Vector pointing down the x-axis of the bone. + """ + return self.matrix.rotationPart() * Vector(0,1,0) + + @property + def z_axis(self): + """ Vector pointing down the x-axis of the bone. + """ + return self.matrix.rotationPart() * Vector(0,0,1) @property def basename(self): diff --git a/release/scripts/modules/rigify/__init__.py b/release/scripts/modules/rigify/__init__.py index 6857d7e8f6d..262508c9a84 100644 --- a/release/scripts/modules/rigify/__init__.py +++ b/release/scripts/modules/rigify/__init__.py @@ -28,8 +28,14 @@ LAYER_TYPES = "main", "extra", "ik", "fk" ORG_LAYERS = [n==31 for n in range(0,32)] MCH_LAYERS = [n==30 for n in range(0,32)] -DEF_LAYERS = [n==29 for n in range(0,32)] +DEF_LAYERS = [n==29 for n in range(0,32)] +ROOT_LAYERS = [n==28 for n in range(0,32)] +ORG_PREFIX = "ORG-" +MCH_PREFIX = "MCH-" +DEF_PREFIX = "DEF-" + +WGT_PREFIX = "WGT-" @@ -79,11 +85,15 @@ def get_bone_type_options(pbone, type_name): options = {} bone_name = pbone.name for key, value in pbone.items(): - key_pair = key.split(".") + key_pair = key.rsplit(".") + # get all bone properties + """" if key_pair[0] == type_name: if len(key_pair) != 2: raise RigifyError("option error for bone '%s', property name was not a pair '%s'" % (bone_name, key_pair)) options[key_pair[1]] = value + """ + options[key] = value return options @@ -174,18 +184,22 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): arm = obj.data - # original name mapping + # prepend the ORG prefix to the bones, and create the base_names mapping base_names = {} - - # add all new parentless children to this bone - root_bone = None - bpy.ops.object.mode_set(mode='EDIT') for bone in arm.edit_bones: bone_name = bone.name - if obj.pose.bones[bone_name].get("type", "") != "root": - bone.name = prefix + bone_name - base_names[bone.name] = bone_name # new -> old mapping + bone.name = ORG_PREFIX + bone_name + base_names[bone.name] = bone_name + + # create root_bone + bpy.ops.object.mode_set(mode='EDIT') + edit_bone = obj.data.edit_bones.new("root") + root_bone = edit_bone.name + edit_bone.head = (0.0, 0.0, 0.0) + edit_bone.tail = (0.0, 1.0, 0.0) + edit_bone.roll = 0.0 + edit_bone.layer = ROOT_LAYERS bpy.ops.object.mode_set(mode='OBJECT') # key: bone name @@ -218,12 +232,6 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): else: bone_type_list = [] - if bone_type_list == ["root"]: # special case! - if root_bone: - raise RigifyError("cant have more then 1 root bone, found '%s' and '%s' to have type==root" % (root_bone, bone_name)) - root_bone = bone_name - bone_type_list[:] = [] - for bone_type in bone_type_list: type_name, submod, type_func = submodule_func_from_type(bone_type) reload(submod) @@ -292,9 +300,11 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): # need a reverse lookup on bone_genesis so as to know immediately # where a bone comes from bone_genesis_reverse = {} + ''' for bone_name, bone_children in bone_genesis.items(): for bone_child_name in bone_children: bone_genesis_reverse[bone_child_name] = bone_name + ''' if root_bone: @@ -304,6 +314,9 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): root_ebone = arm.edit_bones[root_bone] for ebone in arm.edit_bones: bone_name = ebone.name + if ebone.parent is None: + ebone.parent = root_ebone + ''' if ebone.parent is None and bone_name not in base_names: # check for override bone_creator = bone_genesis_reverse[bone_name] @@ -317,6 +330,7 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): ebone.connected = False ebone.parent = root_ebone_tmp + ''' bpy.ops.object.mode_set(mode='OBJECT') @@ -348,18 +362,22 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): for bone_name, bone in arm.bones.items(): bone.deform = False # Non DEF bones shouldn't deform - if bone_name.startswith(prefix): + if bone_name.startswith(ORG_PREFIX): bone.layer = ORG_LAYERS - elif bone_name.startswith("MCH-"): # XXX fixme + elif bone_name.startswith(MCH_PREFIX): # XXX fixme bone.layer = MCH_LAYERS - elif bone_name.startswith("DEF-"): # XXX fixme + elif bone_name.startswith(DEF_PREFIX): # XXX fixme bone.layer = DEF_LAYERS bone.deform = True + else: + # Assign bone appearance if there is a widget for it + obj.pose.bones[bone_name].custom_shape = context.scene.objects.get(WGT_PREFIX+bone_name) layer_tot[:] = [max(lay) for lay in zip(layer_tot, bone.layer)] # Only for demo'ing - arm.layer = layer_tot + layer_show = [a and not (b or c or d) for a,b,c,d in zip(layer_tot, ORG_LAYERS, MCH_LAYERS, DEF_LAYERS)] + arm.layer = layer_show # obj.restrict_view = True diff --git a/release/scripts/modules/rigify/arm_biped_generic.py b/release/scripts/modules/rigify/arm_biped_generic.py index 0974b1b8010..52e6c3e3355 100644 --- a/release/scripts/modules/rigify/arm_biped_generic.py +++ b/release/scripts/modules/rigify/arm_biped_generic.py @@ -20,7 +20,7 @@ import bpy from math import radians -from rigify import RigifyError, get_layer_dict +from rigify import RigifyError, get_layer_dict, ORG_PREFIX from rigify_utils import bone_class_instance, copy_bone_simple, add_pole_target_bone, add_stretch_to, blend_bone_list, get_side_name, get_base_name from rna_prop_ui import rna_idprop_ui_prop_get from Mathutils import Vector @@ -126,7 +126,7 @@ def ik(obj, definitions, base_names, options): if elbow_parent_name: try: - elbow_parent_e = arm.edit_bones[elbow_parent_name] + elbow_parent_e = arm.edit_bones[ORG_PREFIX + elbow_parent_name] except: # TODO, old/new parent mapping raise RigifyError("parent bone from property 'arm_biped_generic.elbow_parent' not found '%s'" % elbow_parent_name) @@ -165,13 +165,14 @@ def ik(obj, definitions, base_names, options): con.pole_angle = -90.0 # XXX, RAD2DEG # last step setup layers - layers = get_layer_dict(options) - lay = layers["ik"] - for attr in ik_chain.attr_names: - getattr(ik_chain, attr + "_b").layer = lay - for attr in ik.attr_names: - getattr(ik, attr + "_b").layer = lay - + if "ik_layer" in options: + layer = [n==options["ik_layer"] for n in range(0,32)] + else: + layer = list(mt.arm_b.layer) + ik_chain.hand_b.layer = layer + ik.hand_vis_b.layer = layer + ik.pole_b.layer = layer + ik.pole_vis_b.layer = layer bpy.ops.object.mode_set(mode='EDIT') # don't blend the shoulder @@ -200,9 +201,9 @@ def fk(obj, definitions, base_names, options): ex.socket_e.parent = mt.shoulder_e ex.socket_e.length *= 0.5 - # insert the 'DLT-hand', between the forearm and the hand + # insert the 'MCH-delta_hand', between the forearm and the hand # copies forarm rotation - ex.hand_delta_e = copy_bone_simple(arm, fk_chain.hand, "DLT-%s" % base_names[mt.hand], parent=True) + ex.hand_delta_e = copy_bone_simple(arm, fk_chain.hand, "MCH-delta_%s" % base_names[mt.hand], parent=True) ex.hand_delta = ex.hand_delta_e.name ex.hand_delta_e.length *= 0.5 ex.hand_delta_e.connected = False @@ -267,17 +268,14 @@ def fk(obj, definitions, base_names, options): hinge_setup() - # last step setup layers - layers = get_layer_dict(options) - lay = layers["fk"] - for attr in fk_chain.attr_names: - getattr(fk_chain, attr + "_b").layer = lay - - lay = layers["extra"] - for attr in ex.attr_names: - getattr(ex, attr + "_b").layer = lay - + if "fk_layer" in options: + layer = [n==options["fk_layer"] for n in range(0,32)] + else: + layer = list(mt.arm_b.layer) + fk_chain.arm_b.layer = layer + fk_chain.forearm_b.layer = layer + fk_chain.hand_b.layer = layer bpy.ops.object.mode_set(mode='EDIT') return None, fk_chain.arm, fk_chain.forearm, fk_chain.hand @@ -378,4 +376,3 @@ def main(obj, bone_definition, base_names, options): bpy.ops.object.mode_set(mode='OBJECT') blend_bone_list(obj, bone_definition, bones_fk, bones_ik, target_bone=bones_ik[3], target_prop="ik", blend_default=0.0) - diff --git a/release/scripts/modules/rigify/copy.py b/release/scripts/modules/rigify/copy.py index a84487e8e21..c0192af7d18 100644 --- a/release/scripts/modules/rigify/copy.py +++ b/release/scripts/modules/rigify/copy.py @@ -69,10 +69,12 @@ def deform(obj, definitions, base_names, options): return (bone_name,) -def main(obj, bone_definition, base_names, options): +def control(obj, definitions, base_names, options): + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data mt = bone_class_instance(obj, METARIG_NAMES) - mt.cpy = bone_definition[0] + mt.cpy = definitions[0] mt.update() cp = bone_class_instance(obj, ["cpy"]) cp.cpy_e = copy_bone_simple(arm, mt.cpy, base_names[mt.cpy], parent=True) @@ -96,12 +98,17 @@ def main(obj, bone_definition, base_names, options): cp.cpy_p.lock_rotation_w = mt.cpy_p.lock_rotation_w cp.cpy_p.lock_scale = tuple(mt.cpy_p.lock_scale) - # Create deform bone - deform_bone = deform(obj, bone_definition, base_names, options)[0] - - # setup layers last - layers = get_layer_dict(options) - cp.cpy_b.layer = layers["main"] - + # Layers + cp.cpy_b.layer = list(mt.cpy_b.layer) + return (mt.cpy,) + +def main(obj, bone_definition, base_names, options): + # Create control bone + cpy = control(obj, bone_definition, base_names, options)[0] + # Create deform bone + deform(obj, bone_definition, base_names, options) + + return (cpy,) + diff --git a/release/scripts/modules/rigify/finger_curl.py b/release/scripts/modules/rigify/finger_curl.py index 4c00f134e19..085eba180fd 100644 --- a/release/scripts/modules/rigify/finger_curl.py +++ b/release/scripts/modules/rigify/finger_curl.py @@ -209,6 +209,8 @@ def main(obj, bone_definition, base_names, options): orig_pbone = obj.pose.bones[bone_definition[0]] control_pbone = obj.pose.bones[control_bone_name] + control_bbone = arm.bones[control_bone_name] + control_pbone.rotation_mode = obj.pose.bones[bone_definition[0]].rotation_mode # only allow Y scale @@ -279,13 +281,15 @@ def main(obj, bone_definition, base_names, options): # last step setup layers - layers = get_layer_dict(options) - lay = layers["extra"] + if "ex_layer" in options: + layer = [n==options["ex_layer"] for n in range(0,32)] + else: + layer = list(arm.bones[bone_definition[0]].layer) for child_bone_name, driver_bone_name in driver_bone_pairs: - arm.bones[driver_bone_name].layer = lay - - lay = layers["main"] - arm.bones[control_bone_name].layer = lay + arm.bones[driver_bone_name].layer = layer + + layer = list(arm.bones[bone_definition[0]].layer) + control_bbone.layer = layer # no blending the result of this return None diff --git a/release/scripts/modules/rigify/leg_biped_generic.py b/release/scripts/modules/rigify/leg_biped_generic.py index 2bf53ddc1ce..d0fbba83a0c 100644 --- a/release/scripts/modules/rigify/leg_biped_generic.py +++ b/release/scripts/modules/rigify/leg_biped_generic.py @@ -150,16 +150,15 @@ def ik(obj, bone_definition, base_names, options): # ik foot: no parents base_foot_name = get_base_name(base_names[mt_chain.foot]) - ik.foot_e = copy_bone_simple(arm, mt_chain.foot, base_foot_name + "_ik" + get_side_name(base_names[mt_chain.foot])) + ik.foot_e = copy_bone_simple(arm, mt.heel, base_foot_name + "_ik" + get_side_name(base_names[mt_chain.foot])) ik.foot = ik.foot_e.name - ik.foot_e.tail.z = ik.foot_e.head.z - ik.foot_e.roll = 0.0 + ik.foot_e.translate(mt_chain.foot_e.head - ik.foot_e.head) ik.foot_e.local_location = False # foot roll: heel pointing backwards, half length ik.foot_roll_e = copy_bone_simple(arm, mt.heel, base_foot_name + "_roll" + get_side_name(base_names[mt_chain.foot])) ik.foot_roll = ik.foot_roll_e.name - ik.foot_roll_e.tail = ik.foot_roll_e.head + ik.foot_roll_e.vector / 2.0 + ik.foot_roll_e.tail = ik.foot_roll_e.head - ik.foot_roll_e.vector / 2.0 ik.foot_roll_e.parent = ik.foot_e # heel is disconnected # heel pointing forwards to the toe base, parent of the following 2 bones @@ -189,7 +188,7 @@ def ik(obj, bone_definition, base_names, options): # knee target is the heel moved up and forward on its local axis - ik.knee_target_e = copy_bone_simple(arm, mt.heel, "knee_target") + ik.knee_target_e = copy_bone_simple(arm, mt.heel, "knee_target" + get_side_name(mt.heel)) ik.knee_target = ik.knee_target_e.name offset = ik.knee_target_e.tail - ik.knee_target_e.head offset.z = 0 @@ -262,12 +261,14 @@ def ik(obj, bone_definition, base_names, options): # last step setup layers - layers = get_layer_dict(options) - lay = layers["ik"] + if "ik_layer" in options: + layer = [n==options["ik_layer"] for n in range(0,32)] + else: + layer = list(mt_chain.thigh_b.layer) for attr in ik_chain.attr_names: - getattr(ik_chain, attr + "_b").layer = lay + getattr(ik_chain, attr + "_b").layer = layer for attr in ik.attr_names: - getattr(ik, attr + "_b").layer = lay + getattr(ik, attr + "_b").layer = layer bpy.ops.object.mode_set(mode='EDIT') @@ -300,6 +301,17 @@ def fk(obj, bone_definition, base_names, options): ex.thigh_hinge = ex.thigh_hinge_e.name fk_chain = mt_chain.copy(base_names=base_names) # fk has no prefix! + fk_chain.foot_e.name = "MCH-" + fk_chain.foot + fk_chain.foot = fk_chain.foot_e.name + + # Set up fk foot control + foot_e = copy_bone_simple(arm, mt.heel, base_names[mt_chain.foot]) + foot = foot_e.name + foot_e.translate(mt_chain.foot_e.head - foot_e.head) + foot_e.parent = fk_chain.shin_e + foot_e.connected = fk_chain.foot_e.connected + fk_chain.foot_e.connected = False + fk_chain.foot_e.parent = foot_e fk_chain.thigh_e.connected = False fk_chain.thigh_e.parent = ex.thigh_hinge_e @@ -309,11 +321,12 @@ def fk(obj, bone_definition, base_names, options): ex.update() mt_chain.update() fk_chain.update() + foot_p = obj.pose.bones[foot] # Set rotation modes and axis locks fk_chain.shin_p.rotation_mode = 'XYZ' fk_chain.shin_p.lock_rotation = False, True, True - fk_chain.foot_p.rotation_mode = 'YXZ' + foot_p.rotation_mode = 'YXZ' fk_chain.toe_p.rotation_mode = 'YXZ' fk_chain.toe_p.lock_rotation = False, True, True @@ -350,14 +363,15 @@ def fk(obj, bone_definition, base_names, options): # last step setup layers - layers = get_layer_dict(options) - lay = layers["fk"] + if "fk_layer" in options: + layer = [n==options["fk_layer"] for n in range(0,32)] + else: + layer = list(mt_chain.thigh_b.layer) for attr in fk_chain.attr_names: - getattr(fk_chain, attr + "_b").layer = lay - - lay = layers["extra"] + getattr(fk_chain, attr + "_b").layer = layer for attr in ex.attr_names: - getattr(ex, attr + "_b").layer = lay + getattr(ex, attr + "_b").layer = layer + arm.bones[foot].layer = layer bpy.ops.object.mode_set(mode='EDIT') diff --git a/release/scripts/modules/rigify/leg_quadruped_generic.py b/release/scripts/modules/rigify/leg_quadruped_generic.py index 36481d91676..99a09955572 100644 --- a/release/scripts/modules/rigify/leg_quadruped_generic.py +++ b/release/scripts/modules/rigify/leg_quadruped_generic.py @@ -20,7 +20,7 @@ import bpy from rigify import RigifyError -from rigify_utils import bone_class_instance, copy_bone_simple, add_pole_target_bone, get_base_name, get_side_name +from rigify_utils import bone_class_instance, copy_bone_simple, add_pole_target_bone, get_side_name, get_base_name from Mathutils import Vector METARIG_NAMES = "hips", "thigh", "shin", "foot", "toe" @@ -105,6 +105,7 @@ def metarig_definition(obj, orig_bone_name): def ik(obj, bone_definition, base_names, options): arm = obj.data + bpy.ops.object.mode_set(mode='EDIT') # setup the existing bones, use names from METARIG_NAMES mt = bone_class_instance(obj, ["hips"]) @@ -128,7 +129,7 @@ def ik(obj, bone_definition, base_names, options): ik_chain.foot_e.align_orientation(mt_chain.toe_e) # children of ik_foot - ik = bone_class_instance(obj, ["foot", "foot_roll", "foot_roll_01", "foot_roll_02", "knee_target", "foot_target"]) + ik = bone_class_instance(obj, ["foot_roll", "foot_roll_01", "foot_roll_02", "knee_target", "foot_target"]) ik.knee_target = add_pole_target_bone(obj, mt_chain.shin, "knee_target" + get_side_name(base_names[mt_chain.foot])) #XXX - pick a better name ik.update() @@ -153,7 +154,7 @@ def ik(obj, bone_definition, base_names, options): ik.foot_roll_01_e.roll = ik.foot_roll_e.roll # ik_target, child of MCH-foot - ik.foot_target_e = copy_bone_simple(arm, mt_chain.foot, base_names[mt_chain.foot] + "_ik_target") + ik.foot_target_e = copy_bone_simple(arm, mt_chain.foot, "MCH-" + base_names[mt_chain.foot] + "_ik_target") ik.foot_target = ik.foot_target_e.name ik.foot_target_e.parent = ik.foot_roll_01_e ik.foot_target_e.align_orientation(ik_chain.foot_e) @@ -213,8 +214,20 @@ def ik(obj, bone_definition, base_names, options): con.pole_target = obj con.pole_subtarget = ik.knee_target + ik.update() + ik_chain.update() + + # Set layers of the bones. + if "ik_layer" in options: + layer = [n==options["ik_layer"] for n in range(0,32)] + else: + layer = list(mt_chain.thigh_b.layer) + for attr in ik_chain.attr_names: + obj.data.bones[getattr(ik_chain, attr)].layer = layer + for attr in ik.attr_names: + obj.data.bones[getattr(ik, attr)].layer = layer + - bpy.ops.object.mode_set(mode='EDIT') return None, ik_chain.thigh, ik_chain.shin, ik_chain.foot, ik_chain.toe diff --git a/release/scripts/modules/rigify/neck_flex.py b/release/scripts/modules/rigify/neck_flex.py index a56c7dcb4e3..f9b7a9ae99d 100644 --- a/release/scripts/modules/rigify/neck_flex.py +++ b/release/scripts/modules/rigify/neck_flex.py @@ -155,7 +155,7 @@ def main(obj, bone_definition, base_names, options): # Copy the head bone and offset - ex.head_e = copy_bone_simple(arm, mt.head, "MCH_%s" % base_names[mt.head], parent=True) + ex.head_e = copy_bone_simple(arm, mt.head, "MCH-%s" % base_names[mt.head], parent=True) ex.head_e.connected = False ex.head = ex.head_e.name # offset @@ -164,7 +164,7 @@ def main(obj, bone_definition, base_names, options): ex.head_e.tail.y += head_length / 2.0 # Yes, use the body bone but call it a head hinge - ex.head_hinge_e = copy_bone_simple(arm, mt.body, "MCH_%s_hinge" % base_names[mt.head], parent=False) + ex.head_hinge_e = copy_bone_simple(arm, mt.body, "MCH-%s_hinge" % base_names[mt.head], parent=False) ex.head_hinge_e.connected = False ex.head_hinge = ex.head_hinge_e.name ex.head_hinge_e.head.y += head_length / 4.0 @@ -320,16 +320,27 @@ def main(obj, bone_definition, base_names, options): con = orig_neck_p.constraints.new('COPY_ROTATION') con.target = obj con.subtarget = neck_p.name + + + # Set the head control's custom shape to use the last + # org neck bone for its transform + ex.head_ctrl_p.custom_shape_transform = obj.pose.bones[bone_definition[len(bone_definition)-1]] # last step setup layers - layers = get_layer_dict(options) - lay = layers["extra"] + if "ex_layer" in options: + layer = [n==options["ex_layer"] for n in range(0,32)] + else: + layer = list(arm.bones[bone_definition[1]].layer) for attr in ex_chain.attr_names: - getattr(ex_chain, attr + "_b").layer = lay + getattr(ex_chain, attr + "_b").layer = layer for attr in ex.attr_names: - getattr(ex, attr + "_b").layer = lay + getattr(ex, attr + "_b").layer = layer + + layer = list(arm.bones[bone_definition[1]].layer) + ex.head_ctrl_b.layer = layer # no blending the result of this return None + diff --git a/release/scripts/modules/rigify/palm_curl.py b/release/scripts/modules/rigify/palm_curl.py index 548c311f823..9e60bc9dc22 100644 --- a/release/scripts/modules/rigify/palm_curl.py +++ b/release/scripts/modules/rigify/palm_curl.py @@ -261,8 +261,7 @@ def main(obj, bone_definition, base_names, options): # last step setup layers - layers = get_layer_dict(options) - arm.bones[control_name].layer = layers["extra"] + arm.bones[control_name].layer = list(arm.bones[bone_definition[1]].layer) # no blending the result of this diff --git a/release/scripts/modules/rigify/spine_pivot_flex.py b/release/scripts/modules/rigify/spine_pivot_flex.py index c6a5fa67390..6d01e0263eb 100644 --- a/release/scripts/modules/rigify/spine_pivot_flex.py +++ b/release/scripts/modules/rigify/spine_pivot_flex.py @@ -520,21 +520,31 @@ def main(obj, bone_definition, base_names, options): mod.poly_order = 1 mod.coefficients[0] = - (i - 1) mod.coefficients[1] = spine_chain_len + + + # Set pelvis and ribcage controls to use the first and last bone in the + # spine respectively for their custom shape transform + ex.ribcage_copy_p.custom_shape_transform = obj.pose.bones[bone_definition[len(bone_definition)-1]] + ex.pelvis_copy_p.custom_shape_transform = obj.pose.bones[bone_definition[2]] # last step setup layers - layers = get_layer_dict(options) - lay = layers["extra"] + if "ex_layer" in options: + layer = [n==options["ex_layer"] for n in range(0,32)] + else: + layer = list(arm.bones[bone_definition[1]].layer) for attr in ex.attr_names: - getattr(ex, attr + "_b").layer = lay + getattr(ex, attr + "_b").layer = layer for attr in ex_chain.attr_names: - getattr(ex_chain, attr + "_b").layer = lay - - lay = layers["main"] + getattr(ex_chain, attr + "_b").layer = layer for attr in df.attr_names: - getattr(df, attr + "_b").layer = lay + getattr(df, attr + "_b").layer = layer for attr in rv_chain.attr_names: - getattr(rv_chain, attr + "_b").layer = lay + getattr(rv_chain, attr + "_b").layer = layer + + layer = list(arm.bones[bone_definition[1]].layer) + arm.bones[ex.pelvis_copy].layer = layer + arm.bones[ex.ribcage_copy].layer = layer # no support for blending chains return None diff --git a/release/scripts/modules/rigify_utils.py b/release/scripts/modules/rigify_utils.py index b453ef77d4f..2a1c92534a0 100644 --- a/release/scripts/modules/rigify_utils.py +++ b/release/scripts/modules/rigify_utils.py @@ -87,6 +87,7 @@ def copy_bone_simple(arm, from_bone, name, parent=False): ebone_new.head = ebone.head ebone_new.tail = ebone.tail ebone_new.roll = ebone.roll + ebone_new.layer = list(ebone.layer) return ebone_new From c723251cc0c2f836420040b6571b398396367b9b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 18:59:32 +0000 Subject: [PATCH 006/202] rename rig types not to have generic in the name (Cessens decission) --- .../{arm_biped_generic.py => arm_biped.py} | 2 +- .../{leg_biped_generic.py => leg_biped.py} | 2 +- ...g_quadruped_generic.py => leg_quadruped.py} | 2 +- release/scripts/op/add_armature_human.py | 18 ++++-------------- 4 files changed, 7 insertions(+), 17 deletions(-) rename release/scripts/modules/rigify/{arm_biped_generic.py => arm_biped.py} (99%) rename release/scripts/modules/rigify/{leg_biped_generic.py => leg_biped.py} (99%) rename release/scripts/modules/rigify/{leg_quadruped_generic.py => leg_quadruped.py} (99%) diff --git a/release/scripts/modules/rigify/arm_biped_generic.py b/release/scripts/modules/rigify/arm_biped.py similarity index 99% rename from release/scripts/modules/rigify/arm_biped_generic.py rename to release/scripts/modules/rigify/arm_biped.py index 52e6c3e3355..26b56164b37 100644 --- a/release/scripts/modules/rigify/arm_biped_generic.py +++ b/release/scripts/modules/rigify/arm_biped.py @@ -59,7 +59,7 @@ def metarig_template(): bpy.ops.object.mode_set(mode='OBJECT') pbone = obj.pose.bones['upper_arm'] - pbone['type'] = 'arm_biped_generic' + pbone['type'] = 'arm_biped' def metarig_definition(obj, orig_bone_name): diff --git a/release/scripts/modules/rigify/leg_biped_generic.py b/release/scripts/modules/rigify/leg_biped.py similarity index 99% rename from release/scripts/modules/rigify/leg_biped_generic.py rename to release/scripts/modules/rigify/leg_biped.py index d0fbba83a0c..70be980d7b2 100644 --- a/release/scripts/modules/rigify/leg_biped_generic.py +++ b/release/scripts/modules/rigify/leg_biped.py @@ -69,7 +69,7 @@ def metarig_template(): bpy.ops.object.mode_set(mode='OBJECT') pbone = obj.pose.bones['thigh'] - pbone['type'] = 'leg_biped_generic' + pbone['type'] = 'leg_biped' def metarig_definition(obj, orig_bone_name): diff --git a/release/scripts/modules/rigify/leg_quadruped_generic.py b/release/scripts/modules/rigify/leg_quadruped.py similarity index 99% rename from release/scripts/modules/rigify/leg_quadruped_generic.py rename to release/scripts/modules/rigify/leg_quadruped.py index 99a09955572..49a404aef33 100644 --- a/release/scripts/modules/rigify/leg_quadruped_generic.py +++ b/release/scripts/modules/rigify/leg_quadruped.py @@ -63,7 +63,7 @@ def metarig_template(): bpy.ops.object.mode_set(mode='OBJECT') pbone = obj.pose.bones['thigh'] - pbone['type'] = 'leg_quadruped_generic' + pbone['type'] = 'leg_quadruped' def metarig_definition(obj, orig_bone_name): diff --git a/release/scripts/op/add_armature_human.py b/release/scripts/op/add_armature_human.py index afc3c8bd065..573c894350b 100644 --- a/release/scripts/op/add_armature_human.py +++ b/release/scripts/op/add_armature_human.py @@ -29,17 +29,11 @@ def metarig_template(): bpy.ops.object.mode_set(mode='EDIT') obj = bpy.context.active_object arm = obj.data - bone = arm.edit_bones.new('root') - bone.head[:] = 0.0000, 0.0000, 0.0000 - bone.tail[:] = 0.0000, 0.4000, 0.0000 - bone.roll = 0.0000 - bone.connected = False bone = arm.edit_bones.new('pelvis') bone.head[:] = -0.0000, -0.0145, 1.1263 bone.tail[:] = -0.0000, -0.0145, 0.9563 bone.roll = 3.1416 bone.connected = False - bone.parent = arm.edit_bones['root'] bone = arm.edit_bones.new('torso') bone.head[:] = -0.0000, -0.0145, 1.1263 bone.tail[:] = -0.0000, -0.0145, 1.2863 @@ -462,10 +456,6 @@ def metarig_template(): bone.parent = arm.edit_bones['finger_index.02.R'] bpy.ops.object.mode_set(mode='OBJECT') - pbone = obj.pose.bones['root'] - pbone['type'] = 'root' - pbone = obj.pose.bones['root'] - pbone['root.layer'] = 16 pbone = obj.pose.bones['torso'] pbone['type'] = 'spine_pivot_flex' pbone = obj.pose.bones['torso'] @@ -473,13 +463,13 @@ def metarig_template(): pbone = obj.pose.bones['torso'] pbone['spine_pivot_flex.layer_extra'] = 2 pbone = obj.pose.bones['thigh.L'] - pbone['type'] = 'leg_biped_generic' + pbone['type'] = 'leg_biped' pbone = obj.pose.bones['thigh.L'] pbone['leg_biped_generic.layer_ik'] = 12 pbone = obj.pose.bones['thigh.L'] pbone['leg_biped_generic.layer_fk'] = 11 pbone = obj.pose.bones['thigh.R'] - pbone['type'] = 'leg_biped_generic' + pbone['type'] = 'leg_biped' pbone = obj.pose.bones['thigh.R'] pbone['leg_biped_generic.layer_ik'] = 14 pbone = obj.pose.bones['thigh.R'] @@ -507,7 +497,7 @@ def metarig_template(): pbone = obj.pose.bones['DLT-upper_arm.R'] pbone['type'] = 'delta' pbone = obj.pose.bones['upper_arm.L'] - pbone['type'] = 'arm_biped_generic' + pbone['type'] = 'arm_biped' pbone = obj.pose.bones['upper_arm.L'] pbone['arm_biped_generic.elbow_parent'] = 'spine.04' pbone = obj.pose.bones['upper_arm.L'] @@ -515,7 +505,7 @@ def metarig_template(): pbone = obj.pose.bones['upper_arm.L'] pbone['arm_biped_generic.layer_ik'] = 8 pbone = obj.pose.bones['upper_arm.R'] - pbone['type'] = 'arm_biped_generic' + pbone['type'] = 'arm_biped' pbone = obj.pose.bones['upper_arm.R'] pbone['arm_biped_generic.layer_fk'] = 9 pbone = obj.pose.bones['upper_arm.R'] From 8fedb7d65f8076ae713529fe93dcd447ec2746a0 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sun, 10 Jan 2010 19:19:22 +0000 Subject: [PATCH 007/202] Bug [#20572] Crash Blender - Gkey in Video Sequence Editor Missing null check in durian fcurve hack (always enabled for some reasons) --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 926f7fde14d..36c6e074d4e 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3652,7 +3652,7 @@ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs) char str[32]; FCurve *fcu; - if(scene->adt==NULL || ofs==0) + if(scene->adt==NULL || ofs==0 || scene->adt->action==NULL) return; sprintf(str, "[\"%s\"]", seq->name+2); From 20df075e38efe9f1cbf538b3e5b5791aac01a483 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 19:20:48 +0000 Subject: [PATCH 008/202] new rig types from Cessen --- release/scripts/modules/rigify/mouth.py | 468 ++++++++++++++++++ release/scripts/modules/rigify/stretch.py | 111 +++++ .../scripts/modules/rigify/stretch_twist.py | 152 ++++++ release/scripts/modules/rigify/track_dual.py | 113 +++++ .../scripts/modules/rigify/track_reverse.py | 101 ++++ 5 files changed, 945 insertions(+) create mode 100644 release/scripts/modules/rigify/mouth.py create mode 100644 release/scripts/modules/rigify/stretch.py create mode 100644 release/scripts/modules/rigify/stretch_twist.py create mode 100644 release/scripts/modules/rigify/track_dual.py create mode 100644 release/scripts/modules/rigify/track_reverse.py diff --git a/release/scripts/modules/rigify/mouth.py b/release/scripts/modules/rigify/mouth.py new file mode 100644 index 00000000000..b22df918675 --- /dev/null +++ b/release/scripts/modules/rigify/mouth.py @@ -0,0 +1,468 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# + +import bpy +from math import acos +from Mathutils import Vector +from rigify import get_layer_dict +from rigify_utils import bone_class_instance, copy_bone_simple + +#METARIG_NAMES = ("cpy",) +RIG_TYPE = "mouth" + + +def metarig_template(): + # generated by rigify.write_meta_rig + bpy.ops.object.mode_set(mode='EDIT') + obj = bpy.context.active_object + arm = obj.data + bone = arm.edit_bones.new('Bone') + bone.head[:] = 0.0000, 0.0000, 0.0000 + bone.tail[:] = 0.0000, 0.0000, 1.0000 + bone.roll = 0.0000 + bone.connected = False + + bpy.ops.object.mode_set(mode='OBJECT') + pbone = obj.pose.bones['Bone'] + pbone['type'] = 'copy' + + +def metarig_definition(obj, orig_bone_name): + bone = obj.data.bones[orig_bone_name] + chain = [] + + try: + chain += [bone.parent.name, bone.parent.parent.name, bone.name] + except AttributeError: + raise RigifyError("'%s' rig type requires a chain of two parents (bone: %s)" % (RIG_TYPE, base_names[0])) + + chain += [child.name for child in bone.children_recursive_basename] + + if len(chain) < 10: + raise RigifyError("'%s' rig type requires a chain of 8 bones (bone: %s)" % (RIG_TYPE, base_names[0])) + + return chain[:10] + + +def deform(obj, definitions, base_names, options): + bpy.ops.object.mode_set(mode='EDIT') + + eb = obj.data.edit_bones + pb = obj.pose.bones + + # Upper lip MCH + lip1 = make_lip_stretch_bone(obj, "MCH-lip", definitions[2], definitions[3], 1.0) + lip2 = make_lip_stretch_bone(obj, "MCH-lip", definitions[3], definitions[4], 1.0) + lip22 = make_lip_stretch_bone(obj, "MCH-lip", definitions[4], definitions[5], 1.0) + lip33 = make_lip_stretch_bone(obj, "MCH-lip", definitions[4], definitions[3], 1.0) + lip3 = make_lip_stretch_bone(obj, "MCH-lip", definitions[5], definitions[4], 1.0) + lip4 = make_lip_stretch_bone(obj, "MCH-lip", definitions[6], definitions[5], 1.0) + + dlip22 = copy_bone_simple(obj.data, lip22, "MCH-lip", parent=True).name + dlip33 = copy_bone_simple(obj.data, lip33, "MCH-lip", parent=True).name + eb[dlip22].bbone_segments = 8 + eb[dlip33].bbone_segments = 8 + + eb[lip1].parent = eb[definitions[2]] + eb[lip2].parent = eb[definitions[3]] + eb[lip22].parent = eb[definitions[4]] + eb[lip33].parent = eb[definitions[4]] + eb[lip3].parent = eb[definitions[5]] + eb[lip4].parent = eb[definitions[6]] + + # Lower lip MCH + lip5 = make_lip_stretch_bone(obj, "MCH-lip", definitions[6], definitions[7], 1.0) + lip6 = make_lip_stretch_bone(obj, "MCH-lip", definitions[7], definitions[8], 1.0) + lip66 = make_lip_stretch_bone(obj, "MCH-lip", definitions[8], definitions[9], 1.0) + lip77 = make_lip_stretch_bone(obj, "MCH-lip", definitions[8], definitions[7], 1.0) + lip7 = make_lip_stretch_bone(obj, "MCH-lip", definitions[9], definitions[8], 1.0) + lip8 = make_lip_stretch_bone(obj, "MCH-lip", definitions[2], definitions[9], 1.0) + + dlip66 = copy_bone_simple(obj.data, lip66, "MCH-lip", parent=True).name + dlip77 = copy_bone_simple(obj.data, lip77, "MCH-lip", parent=True).name + eb[dlip66].bbone_segments = 8 + eb[dlip77].bbone_segments = 8 + + eb[lip5].parent = eb[definitions[6]] + eb[lip6].parent = eb[definitions[7]] + eb[lip66].parent = eb[definitions[8]] + eb[lip77].parent = eb[definitions[8]] + eb[lip7].parent = eb[definitions[9]] + eb[lip8].parent = eb[definitions[2]] + + # Upper lip DEF + dlip1 = copy_bone_simple(obj.data, lip1, "DEF-lip", parent=True).name + dlip2 = copy_bone_simple(obj.data, lip2, "DEF-lip", parent=True).name + dlip3 = copy_bone_simple(obj.data, lip3, "DEF-lip", parent=True).name + dlip4 = copy_bone_simple(obj.data, lip4, "DEF-lip", parent=True).name + + eb[dlip2].parent = eb[dlip1] + eb[dlip22].parent = eb[dlip2] + + eb[dlip3].parent = eb[dlip4] + eb[dlip33].parent = eb[dlip3] + + eb[dlip2].connected = True + eb[dlip22].connected = True + eb[dlip3].connected = True + eb[dlip33].connected = True + + eb[dlip1].bbone_segments = 8 + eb[dlip2].bbone_segments = 8 + eb[dlip3].bbone_segments = 8 + eb[dlip4].bbone_segments = 8 + + # Lower lip DEF + dlip5 = copy_bone_simple(obj.data, lip5, "DEF-lip", parent=True).name + dlip6 = copy_bone_simple(obj.data, lip6, "DEF-lip", parent=True).name + dlip7 = copy_bone_simple(obj.data, lip7, "DEF-lip", parent=True).name + dlip8 = copy_bone_simple(obj.data, lip8, "DEF-lip", parent=True).name + + eb[dlip6].parent = eb[dlip5] + eb[dlip66].parent = eb[dlip6] + + eb[dlip7].parent = eb[dlip8] + eb[dlip77].parent = eb[dlip7] + + eb[dlip6].connected = True + eb[dlip66].connected = True + eb[dlip7].connected = True + eb[dlip77].connected = True + + eb[dlip5].bbone_segments = 8 + eb[dlip6].bbone_segments = 8 + eb[dlip7].bbone_segments = 8 + eb[dlip8].bbone_segments = 8 + + + bpy.ops.object.mode_set(mode='OBJECT') + + # Constraints + con = pb[dlip1].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = lip1 + + con = pb[dlip22].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = lip22 + + con = pb[dlip33].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = lip33 + + con = pb[dlip2].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = lip2 + + con = pb[dlip3].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = lip3 + + con = pb[dlip4].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = lip4 + + con = pb[dlip5].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = lip5 + + con = pb[dlip6].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = lip6 + + con = pb[dlip66].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = lip66 + + con = pb[dlip77].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = lip77 + + con = pb[dlip7].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = lip7 + + con = pb[dlip8].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = lip8 + + return (None,) + + + + +def control(obj, definitions, base_names, options): + bpy.ops.object.mode_set(mode='EDIT') + + eb = obj.data.edit_bones + bb = obj.data.bones + pb = obj.pose.bones + + head_e = eb[definitions[0]] + jaw_e = eb[definitions[1]] + + # Head lips + hlip1 = copy_bone_simple(obj.data, definitions[2], "MCH-"+base_names[definitions[2]]+".head").name + hlip2 = copy_bone_simple(obj.data, definitions[3], "MCH-"+base_names[definitions[3]]+".head").name + hlip3 = copy_bone_simple(obj.data, definitions[4], "MCH-"+base_names[definitions[4]]+".head").name + hlip4 = copy_bone_simple(obj.data, definitions[5], "MCH-"+base_names[definitions[5]]+".head").name + hlip5 = copy_bone_simple(obj.data, definitions[6], "MCH-"+base_names[definitions[6]]+".head").name + hlip6 = copy_bone_simple(obj.data, definitions[7], "MCH-"+base_names[definitions[7]]+".head").name + hlip7 = copy_bone_simple(obj.data, definitions[8], "MCH-"+base_names[definitions[8]]+".head").name + hlip8 = copy_bone_simple(obj.data, definitions[9], "MCH-"+base_names[definitions[9]]+".head").name + + eb[hlip1].parent = head_e + eb[hlip2].parent = head_e + eb[hlip3].parent = head_e + eb[hlip4].parent = head_e + eb[hlip5].parent = head_e + eb[hlip6].parent = head_e + eb[hlip7].parent = head_e + eb[hlip8].parent = head_e + + # Jaw lips + jlip1 = copy_bone_simple(obj.data, definitions[2], "MCH-"+base_names[definitions[2]]+".jaw").name + jlip2 = copy_bone_simple(obj.data, definitions[3], "MCH-"+base_names[definitions[3]]+".jaw").name + jlip3 = copy_bone_simple(obj.data, definitions[4], "MCH-"+base_names[definitions[4]]+".jaw").name + jlip4 = copy_bone_simple(obj.data, definitions[5], "MCH-"+base_names[definitions[5]]+".jaw").name + jlip5 = copy_bone_simple(obj.data, definitions[6], "MCH-"+base_names[definitions[6]]+".jaw").name + jlip6 = copy_bone_simple(obj.data, definitions[7], "MCH-"+base_names[definitions[7]]+".jaw").name + jlip7 = copy_bone_simple(obj.data, definitions[8], "MCH-"+base_names[definitions[8]]+".jaw").name + jlip8 = copy_bone_simple(obj.data, definitions[9], "MCH-"+base_names[definitions[9]]+".jaw").name + + eb[jlip1].parent = jaw_e + eb[jlip2].parent = jaw_e + eb[jlip3].parent = jaw_e + eb[jlip4].parent = jaw_e + eb[jlip5].parent = jaw_e + eb[jlip6].parent = jaw_e + eb[jlip7].parent = jaw_e + eb[jlip8].parent = jaw_e + + # Control lips + lip1 = copy_bone_simple(obj.data, definitions[2], base_names[definitions[2]]).name + lip2 = copy_bone_simple(obj.data, definitions[3], base_names[definitions[3]]).name + lip3 = copy_bone_simple(obj.data, definitions[4], base_names[definitions[4]]).name + lip4 = copy_bone_simple(obj.data, definitions[5], base_names[definitions[5]]).name + lip5 = copy_bone_simple(obj.data, definitions[6], base_names[definitions[6]]).name + lip6 = copy_bone_simple(obj.data, definitions[7], base_names[definitions[7]]).name + lip7 = copy_bone_simple(obj.data, definitions[8], base_names[definitions[8]]).name + lip8 = copy_bone_simple(obj.data, definitions[9], base_names[definitions[9]]).name + + size = eb[lip1].length + eb[lip1].tail = eb[lip1].head + Vector(0,size,0) + eb[lip2].tail = eb[lip2].head + Vector(0,size,0) + eb[lip3].tail = eb[lip3].head + Vector(0,size,0) + eb[lip4].tail = eb[lip4].head + Vector(0,size,0) + eb[lip5].tail = eb[lip5].head + Vector(0,size,0) + eb[lip6].tail = eb[lip6].head + Vector(0,size,0) + eb[lip7].tail = eb[lip7].head + Vector(0,size,0) + eb[lip8].tail = eb[lip8].head + Vector(0,size,0) + + eb[lip1].roll = 0 + eb[lip2].roll = 0 + eb[lip3].roll = 0 + eb[lip4].roll = 0 + eb[lip5].roll = 0 + eb[lip6].roll = 0 + eb[lip7].roll = 0 + eb[lip8].roll = 0 + + eb[lip1].parent = eb[jlip1] + eb[lip2].parent = eb[jlip2] + eb[lip3].parent = eb[jlip3] + eb[lip4].parent = eb[jlip4] + eb[lip5].parent = eb[jlip5] + eb[lip6].parent = eb[jlip6] + eb[lip7].parent = eb[jlip7] + eb[lip8].parent = eb[jlip8] + + # Link lips + llip1 = copy_bone_simple(obj.data, definitions[2], "MCH-"+base_names[definitions[2]]+".link").name + llip2 = copy_bone_simple(obj.data, definitions[3], "MCH-"+base_names[definitions[3]]+".link").name + llip3 = copy_bone_simple(obj.data, definitions[4], "MCH-"+base_names[definitions[4]]+".link").name + llip4 = copy_bone_simple(obj.data, definitions[5], "MCH-"+base_names[definitions[5]]+".link").name + llip5 = copy_bone_simple(obj.data, definitions[6], "MCH-"+base_names[definitions[6]]+".link").name + llip6 = copy_bone_simple(obj.data, definitions[7], "MCH-"+base_names[definitions[7]]+".link").name + llip7 = copy_bone_simple(obj.data, definitions[8], "MCH-"+base_names[definitions[8]]+".link").name + llip8 = copy_bone_simple(obj.data, definitions[9], "MCH-"+base_names[definitions[9]]+".link").name + + eb[llip1].parent = eb[lip1] + eb[llip2].parent = eb[lip2] + eb[llip3].parent = eb[lip3] + eb[llip4].parent = eb[lip4] + eb[llip5].parent = eb[lip5] + eb[llip6].parent = eb[lip6] + eb[llip7].parent = eb[lip7] + eb[llip8].parent = eb[lip8] + + + bpy.ops.object.mode_set(mode='OBJECT') + + # Constraints + + # Jaw lips to head lips + influence = [0.0, 0.1, 0.5] + + con = pb[jlip1].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = hlip1 + con.influence = influence[2] + + con = pb[jlip2].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = hlip2 + con.influence = influence[1] + + con = pb[jlip3].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = hlip3 + con.influence = influence[0] + + con = pb[jlip4].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = hlip4 + con.influence = influence[1] + + con = pb[jlip5].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = hlip5 + con.influence = influence[2] + + con = pb[jlip6].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = hlip6 + con.influence = 1.0 - influence[1] + + con = pb[jlip7].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = hlip7 + con.influence = 1.0 - influence[0] + + con = pb[jlip8].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = hlip8 + con.influence = 1.0 - influence[1] + + # ORG bones to link lips + con = pb[definitions[2]].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = llip1 + + con = pb[definitions[3]].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = llip2 + + con = pb[definitions[4]].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = llip3 + + con = pb[definitions[5]].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = llip4 + + con = pb[definitions[6]].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = llip5 + + con = pb[definitions[7]].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = llip6 + + con = pb[definitions[8]].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = llip7 + + con = pb[definitions[9]].constraints.new('COPY_TRANSFORMS') + con.target = obj + con.subtarget = llip8 + + + # Set layers + layer = list(bb[definitions[2]].layer) + bb[lip1].layer = layer + bb[lip2].layer = layer + bb[lip3].layer = layer + bb[lip4].layer = layer + bb[lip5].layer = layer + bb[lip6].layer = layer + bb[lip7].layer = layer + bb[lip8].layer = layer + + + return (None,) + + + + +def main(obj, bone_definition, base_names, options): + # Create control rig + control(obj, bone_definition, base_names, options) + # Create deform rig + deform(obj, bone_definition, base_names, options) + + return (None,) + + + + +def make_lip_stretch_bone(obj, name, bone1, bone2, roll_alpha): + eb = obj.data.edit_bones + pb = obj.pose.bones + + # Create the bone, pointing from bone1 to bone2 + bone_e = copy_bone_simple(obj.data, bone1, name, parent=True) + bone_e.connected = False + bone_e.tail = eb[bone2].head + bone = bone_e.name + + # Align the bone roll with the average direction of bone1 and bone2 + vec = bone_e.y_axis.cross(((1.0-roll_alpha)*eb[bone1].y_axis) + (roll_alpha*eb[bone2].y_axis)).normalize() + + ang = acos(vec * bone_e.x_axis) + + bone_e.roll += ang + c1 = vec * bone_e.x_axis + bone_e.roll -= (ang*2) + c2 = vec * bone_e.x_axis + + if c1 > c2: + bone_e.roll += (ang*2) + + bpy.ops.object.mode_set(mode='OBJECT') + bone_p = pb[bone] + + # Constrains + con = bone_p.constraints.new('COPY_LOCATION') + con.target = obj + con.subtarget = bone1 + + con = bone_p.constraints.new('DAMPED_TRACK') + con.target = obj + con.subtarget = bone2 + + con = bone_p.constraints.new('STRETCH_TO') + con.target = obj + con.subtarget = bone2 + con.volume = 'NO_VOLUME' + + bpy.ops.object.mode_set(mode='EDIT') + + return bone diff --git a/release/scripts/modules/rigify/stretch.py b/release/scripts/modules/rigify/stretch.py new file mode 100644 index 00000000000..373a934ac74 --- /dev/null +++ b/release/scripts/modules/rigify/stretch.py @@ -0,0 +1,111 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# + +import bpy +from rigify import get_layer_dict, RigifyError +from rigify_utils import bone_class_instance, copy_bone_simple + +METARIG_NAMES = tuple() +RIG_TYPE = "stretch" + +# TODO +#def metarig_template(): +# # generated by rigify.write_meta_rig +# bpy.ops.object.mode_set(mode='EDIT') +# obj = bpy.context.active_object +# arm = obj.data +# bone = arm.edit_bones.new('Bone') +# bone.head[:] = 0.0000, 0.0000, 0.0000 +# bone.tail[:] = 0.0000, 0.0000, 1.0000 +# bone.roll = 0.0000 +# bone.connected = False +# +# bpy.ops.object.mode_set(mode='OBJECT') +# pbone = obj.pose.bones['Bone'] +# pbone['type'] = 'copy' + +bool_map = {0:False, 1:True, + 0.0:False, 1.0:True, + "false":False, "true":True, + "False":False, "True":True, + "no":False, "yes":True, + "No":False, "Yes":True} + +def metarig_definition(obj, orig_bone_name): + return (orig_bone_name,) + + + + +def main(obj, bone_definition, base_names, options): + """ A stretchy bone from one bone to another. + Deformation only (no controls). + """ + # Verify required parameter + if "to" not in options: + raise RigifyError("'%s' rig type requires a 'to' parameter (bone: %s)" % (RIG_TYPE, base_names[bone_definition[0]])) + if type(options["to"]) is not str: + raise RigifyError("'%s' rig type 'to' parameter must be a string (bone: %s)" % (RIG_TYPE, base_names[bone_definition[0]])) + if ("ORG-" + options["to"]) not in obj.data.bones: + raise RigifyError("'%s' rig type 'to' parameter must name a bone in the metarig (bone: %s)" % (RIG_TYPE, base_names[bone_definition[0]])) + + preserve_volume = None + # Check optional parameter + if "preserve_volume" in options: + try: + preserve_volume = bool_map[options["preserve_volume"]] + except KeyError: + preserve_volume = False + + eb = obj.data.edit_bones + bb = obj.data.bones + pb = obj.pose.bones + + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data + + mbone1 = bone_definition[0] + mbone2 = "ORG-" + options["to"] + + bone_e = copy_bone_simple(obj.data, mbone1, "DEF-%s" % base_names[bone_definition[0]]) + bone_e.connected = False + bone_e.parent = eb[mbone1] + bone_e.tail = eb[mbone2].head + bone = bone_e.name + + + bpy.ops.object.mode_set(mode='OBJECT') + + # Constraints + con = pb[bone].constraints.new('DAMPED_TRACK') + con.target = obj + con.subtarget = mbone2 + + con = pb[bone].constraints.new('STRETCH_TO') + con.target = obj + con.subtarget = mbone2 + con.original_length = bb[bone].length + if preserve_volume: + con.volume = 'VOLUME_XZX' + else: + con.volume = 'NO_VOLUME' + + return tuple() + diff --git a/release/scripts/modules/rigify/stretch_twist.py b/release/scripts/modules/rigify/stretch_twist.py new file mode 100644 index 00000000000..6e5891b5e0a --- /dev/null +++ b/release/scripts/modules/rigify/stretch_twist.py @@ -0,0 +1,152 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# + +import bpy +from rigify import get_layer_dict +from rigify_utils import bone_class_instance, copy_bone_simple + +METARIG_NAMES = tuple() +RIG_TYPE = "stretch_twist" + +# TODO +#def metarig_template(): +# # generated by rigify.write_meta_rig +# bpy.ops.object.mode_set(mode='EDIT') +# obj = bpy.context.active_object +# arm = obj.data +# bone = arm.edit_bones.new('Bone') +# bone.head[:] = 0.0000, 0.0000, 0.0000 +# bone.tail[:] = 0.0000, 0.0000, 1.0000 +# bone.roll = 0.0000 +# bone.connected = False +# +# bpy.ops.object.mode_set(mode='OBJECT') +# pbone = obj.pose.bones['Bone'] +# pbone['type'] = 'copy' + +bool_map = {0:False, 1:True, + 0.0:False, 1.0:True, + "false":False, "true":True, + "False":False, "True":True, + "no":False, "yes":True, + "No":False, "Yes":True} + +def metarig_definition(obj, orig_bone_name): + return (orig_bone_name,) + + + + +def main(obj, bone_definition, base_names, options): + """ A dual-bone stretchy bone setup. Each half follows the twist of the + bone on its side. + Deformation only (no controls). + """ + # Verify required parameter + if "to" not in options: + raise RigifyError("'%s' rig type requires a 'to' parameter (bone: %s)" % (RIG_TYPE, base_names[0])) + if type(options["to"]) is not str: + raise RigifyError("'%s' rig type 'to' parameter must be a string (bone: %s)" % (RIG_TYPE, base_names[0])) + if ("ORG-" + options["to"]) not in obj.data.bones: + raise RigifyError("'%s' rig type 'to' parameter must name a bone in the metarig (bone: %s)" % (RIG_TYPE, base_names[0])) + + preserve_volume = None + # Check optional parameter + if "preserve_volume" in options: + try: + preserve_volume = bool_map[options["preserve_volume"]] + except KeyError: + preserve_volume = False + + eb = obj.data.edit_bones + bb = obj.data.bones + pb = obj.pose.bones + + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data + + mbone1 = bone_definition[0] + mbone2 = "ORG-" + options["to"] + + bone_e = copy_bone_simple(obj.data, mbone1, "MCH-%s" % base_names[bone_definition[0]]) + bone_e.connected = False + bone_e.parent = None + bone_e.head = (eb[mbone1].head + eb[mbone2].head) / 2 + bone_e.tail = (bone_e.head[0], bone_e.head[1], bone_e.head[2]+0.1) + mid_bone = bone_e.name + + bone_e = copy_bone_simple(obj.data, mbone1, "DEF-%s.01" % base_names[bone_definition[0]]) + bone_e.connected = False + bone_e.parent = eb[mbone1] + bone_e.tail = eb[mid_bone].head + bone1 = bone_e.name + + bone_e = copy_bone_simple(obj.data, mbone2, "DEF-%s.02" % base_names[bone_definition[0]]) + bone_e.connected = False + bone_e.parent = eb[mbone2] + bone_e.tail = eb[mid_bone].head + bone2 = bone_e.name + + + + bpy.ops.object.mode_set(mode='OBJECT') + + # Constraints + + # Mid bone + con = pb[mid_bone].constraints.new('COPY_LOCATION') + con.target = obj + con.subtarget = mbone1 + + con = pb[mid_bone].constraints.new('COPY_LOCATION') + con.target = obj + con.subtarget = mbone2 + con.influence = 0.5 + + # Bone 1 + con = pb[bone1].constraints.new('DAMPED_TRACK') + con.target = obj + con.subtarget = mid_bone + + con = pb[bone1].constraints.new('STRETCH_TO') + con.target = obj + con.subtarget = mid_bone + con.original_length = bb[bone1].length + if preserve_volume: + con.volume = 'VOLUME_XZX' + else: + con.volume = 'NO_VOLUME' + + # Bone 2 + con = pb[bone2].constraints.new('DAMPED_TRACK') + con.target = obj + con.subtarget = mid_bone + + con = pb[bone2].constraints.new('STRETCH_TO') + con.target = obj + con.subtarget = mid_bone + con.original_length = bb[bone2].length + if preserve_volume: + con.volume = 'VOLUME_XZX' + else: + con.volume = 'NO_VOLUME' + + return tuple() + diff --git a/release/scripts/modules/rigify/track_dual.py b/release/scripts/modules/rigify/track_dual.py new file mode 100644 index 00000000000..3a1197b95bf --- /dev/null +++ b/release/scripts/modules/rigify/track_dual.py @@ -0,0 +1,113 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# + +import bpy +from rigify import get_layer_dict +from rigify_utils import bone_class_instance, copy_bone_simple + +METARIG_NAMES = tuple() +RIG_TYPE = "track_dual" + +# TODO +#def metarig_template(): +# # generated by rigify.write_meta_rig +# bpy.ops.object.mode_set(mode='EDIT') +# obj = bpy.context.active_object +# arm = obj.data +# bone = arm.edit_bones.new('Bone') +# bone.head[:] = 0.0000, 0.0000, 0.0000 +# bone.tail[:] = 0.0000, 0.0000, 1.0000 +# bone.roll = 0.0000 +# bone.connected = False +# +# bpy.ops.object.mode_set(mode='OBJECT') +# pbone = obj.pose.bones['Bone'] +# pbone['type'] = 'copy' + +bool_map = {0:False, 1:True, + 0.0:False, 1.0:True, + "false":False, "true":True, + "False":False, "True":True, + "no":False, "yes":True, + "No":False, "Yes":True} + +def metarig_definition(obj, orig_bone_name): + return (orig_bone_name,) + + + + +def main(obj, bone_definition, base_names, options): + """ A dual-bone track setup. + Deformation only (no controls). + """ + # Verify required parameter + if "to" not in options: + raise RigifyError("'%s' rig type requires a 'to' parameter (bone: %s)" % (RIG_TYPE, base_names[0])) + if type(options["to"]) is not str: + raise RigifyError("'%s' rig type 'to' parameter must be a string (bone: %s)" % (RIG_TYPE, base_names[0])) + if ("ORG-" + options["to"]) not in obj.data.bones: + raise RigifyError("'%s' rig type 'to' parameter must name a bone in the metarig (bone: %s)" % (RIG_TYPE, base_names[0])) + + eb = obj.data.edit_bones + bb = obj.data.bones + pb = obj.pose.bones + + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data + + mbone1 = bone_definition[0] + mbone2 = "ORG-" + options["to"] + + bone_e = copy_bone_simple(obj.data, mbone1, "DEF-%s.01" % base_names[bone_definition[0]]) + bone_e.connected = False + bone_e.parent = eb[mbone1] + bone_e.tail = (eb[mbone1].head + eb[mbone2].head) / 2 + bone1 = bone_e.name + + bone_e = copy_bone_simple(obj.data, mbone2, "DEF-%s.02" % base_names[bone_definition[0]]) + bone_e.connected = False + bone_e.parent = eb[mbone1] + bone_e.tail = (eb[mbone1].head + eb[mbone2].head) / 2 + bone2 = bone_e.name + + + + bpy.ops.object.mode_set(mode='OBJECT') + + # Constraints + # Bone 1 + con = pb[bone1].constraints.new('DAMPED_TRACK') + con.target = obj + con.subtarget = mbone2 + + + # Bone 2 + con = pb[bone2].constraints.new('COPY_LOCATION') + con.target = obj + con.subtarget = mbone2 + + con = pb[bone2].constraints.new('DAMPED_TRACK') + con.target = obj + con.subtarget = mbone1 + + + return tuple() + diff --git a/release/scripts/modules/rigify/track_reverse.py b/release/scripts/modules/rigify/track_reverse.py new file mode 100644 index 00000000000..38f7b6182f9 --- /dev/null +++ b/release/scripts/modules/rigify/track_reverse.py @@ -0,0 +1,101 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# + +import bpy +from rigify import get_layer_dict +from rigify_utils import bone_class_instance, copy_bone_simple + +METARIG_NAMES = tuple() +RIG_TYPE = "track_reverse" + +# TODO +#def metarig_template(): +# # generated by rigify.write_meta_rig +# bpy.ops.object.mode_set(mode='EDIT') +# obj = bpy.context.active_object +# arm = obj.data +# bone = arm.edit_bones.new('Bone') +# bone.head[:] = 0.0000, 0.0000, 0.0000 +# bone.tail[:] = 0.0000, 0.0000, 1.0000 +# bone.roll = 0.0000 +# bone.connected = False +# +# bpy.ops.object.mode_set(mode='OBJECT') +# pbone = obj.pose.bones['Bone'] +# pbone['type'] = 'copy' + +bool_map = {0:False, 1:True, + 0.0:False, 1.0:True, + "false":False, "true":True, + "False":False, "True":True, + "no":False, "yes":True, + "No":False, "Yes":True} + +def metarig_definition(obj, orig_bone_name): + return (orig_bone_name,) + + + + +def main(obj, bone_definition, base_names, options): + """ A bone that tracks bakwards towards its parent, while copying the + location of it's target. + Deformation only (no controls). + """ + # Verify required parameter + if "to" not in options: + raise RigifyError("'%s' rig type requires a 'to' parameter (bone: %s)" % (RIG_TYPE, base_names[0])) + if type(options["to"]) is not str: + raise RigifyError("'%s' rig type 'to' parameter must be a string (bone: %s)" % (RIG_TYPE, base_names[0])) + if ("ORG-" + options["to"]) not in obj.data.bones: + raise RigifyError("'%s' rig type 'to' parameter must name a bone in the metarig (bone: %s)" % (RIG_TYPE, base_names[0])) + + eb = obj.data.edit_bones + bb = obj.data.bones + pb = obj.pose.bones + + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data + + mbone1 = bone_definition[0] + mbone2 = "ORG-" + options["to"] + + bone_e = copy_bone_simple(obj.data, mbone2, "DEF-%s.02" % base_names[bone_definition[0]]) + bone_e.connected = False + bone_e.parent = eb[mbone1] + bone_e.tail = eb[mbone1].head + bone = bone_e.name + + + + bpy.ops.object.mode_set(mode='OBJECT') + + # Constraints + con = pb[bone].constraints.new('COPY_LOCATION') + con.target = obj + con.subtarget = mbone2 + + con = pb[bone].constraints.new('DAMPED_TRACK') + con.target = obj + con.subtarget = mbone1 + + + return tuple() + From 6b4a8c5d722f13576cf486b2f8b9a190c7970781 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 19:21:46 +0000 Subject: [PATCH 009/202] attemp to fix [#20610] GHOST_WindowX11.cpp:202: X11 glXChooseVisual() failed, verify working openGL system! cant test but should work. --- intern/ghost/intern/GHOST_WindowX11.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 4afaa09b3f1..c500055c280 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -169,7 +169,7 @@ GHOST_WindowX11( // Set up the minimum atrributes that we require and see if // X can find us a visual matching those requirements. - int attributes[40], i = 0; + int attributes[40], i = 0, i_pre_aa; Atom atoms[2]; int natom; int glxVersionMajor, glxVersionMinor; // As in GLX major.minor @@ -188,6 +188,7 @@ GHOST_WindowX11( attributes[i++] = GLX_BLUE_SIZE; attributes[i++] = 1; attributes[i++] = GLX_GREEN_SIZE; attributes[i++] = 1; attributes[i++] = GLX_DEPTH_SIZE; attributes[i++] = 1; + i_pre_aa= i; /* GLX 1.4+, multi-sample */ if(m_numOfAASamples && (glxVersionMajor >= 1) && (glxVersionMinor >= 4)) { attributes[i++] = GLX_SAMPLE_BUFFERS; attributes[i++] = 1; @@ -198,9 +199,17 @@ GHOST_WindowX11( m_visual = glXChooseVisual(m_display, DefaultScreen(m_display), attributes); if (m_visual == NULL) { - // barf : no visual meeting these requirements could be found. - printf("%s:%d: X11 glXChooseVisual() failed, verify working openGL system!\n", __FILE__, __LINE__); - return; + /* possibly the X Server does not support GLX_SAMPLE_BUFFERS */ + attributes[i_pre_aa] = None; + m_visual = glXChooseVisual(m_display, DefaultScreen(m_display), attributes); + + if (m_visual == NULL) { + // barf : no visual meeting these requirements could be found. + printf("%s:%d: X11 glXChooseVisual() failed, verify working openGL system!\n", __FILE__, __LINE__); + return; + } else { + printf("%s:%d: X11 glXChooseVisual() multi-sample failed, continue with multisample disabled\n", __FILE__, __LINE__); + } } memset(&m_xtablet, 0, sizeof(m_xtablet)); From 580345394eb58748fa6df527a095671ed3edc396 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sun, 10 Jan 2010 19:35:42 +0000 Subject: [PATCH 010/202] BGE API_DOC: VideoTexture and PhysicsConstraints templates (need the functions to be filled with their description). PhysicsConstraints is documented in the Game Kit Book: http://download.blender.org/documentation/gamekit1/ VideoTexture is documented in the wiki: http://wiki.blender.org/index.php/Dev:Source/GameEngine/2.49/VideoTexture I don't think I will have time to fill the documentation. But I hope this commit helps someone interested in helping it. Therefore volunteers to document those modules are highly welcome !!! (let's give to BGE the documentation it deserves)! * + added GameLogic.Lave/LoadGlobalDict + some typo fixes --- source/gameengine/PyDoc/API_intro.py | 6 +- source/gameengine/PyDoc/GameLogic.py | 9 +- source/gameengine/PyDoc/GameTypes.py | 4 +- source/gameengine/PyDoc/PhysicsConstraints.py | 126 +++++++++++++++++ source/gameengine/PyDoc/VideoTexture.py | 133 ++++++++++++++++++ 5 files changed, 272 insertions(+), 6 deletions(-) create mode 100644 source/gameengine/PyDoc/PhysicsConstraints.py create mode 100644 source/gameengine/PyDoc/VideoTexture.py diff --git a/source/gameengine/PyDoc/API_intro.py b/source/gameengine/PyDoc/API_intro.py index 0a687088627..abc8c83855b 100644 --- a/source/gameengine/PyDoc/API_intro.py +++ b/source/gameengine/PyDoc/API_intro.py @@ -16,10 +16,10 @@ The Blender Game Engine Python API Reference - L{Rasterizer} display and rendering. - L{GameTypes} contains all the python types spesific to the GameEngine. - Undocumented modules: + Modules with documentation in progress: --------------------- - - VideoTexture - - PhysicsConstraints + - L{VideoTexture} + - L{PhysicsConstraints} Additional Modules: ------------------- diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py index d22b1690e74..3cf15636892 100644 --- a/source/gameengine/PyDoc/GameLogic.py +++ b/source/gameengine/PyDoc/GameLogic.py @@ -313,7 +313,6 @@ Documentation for the GameLogic Module. import GameTypes # TODO -# globalDict # error def getCurrentController(): @@ -446,6 +445,14 @@ def setPhysicsTicRate(ticrate): @param ticrate: The new update frequency (in Hz). @type ticrate: float """ +def saveGlobalDict(): + """ + Saves GameLogic.globalDict to a file. + """ +def loadGlobalDict(): + """ + Loads GameLogic.globalDict from a file. + """ #{ Utility functions def getAverageFrameRate(): diff --git a/source/gameengine/PyDoc/GameTypes.py b/source/gameengine/PyDoc/GameTypes.py index ba22dbd4e8f..e6d51e85af6 100644 --- a/source/gameengine/PyDoc/GameTypes.py +++ b/source/gameengine/PyDoc/GameTypes.py @@ -1581,7 +1581,7 @@ class KX_GameObject(SCA_IObject): """ def endObject(): """ - Delete this object, can be used inpace of the EndObject Actuator. + Delete this object, can be used in place of the EndObject Actuator. The actual removal of the object from the scene is delayed. """ def replaceMesh(mesh, useDisplayMesh=True, usePhysicsMesh=False): @@ -1682,7 +1682,7 @@ class KX_GameObject(SCA_IObject): def getAxisVect(vect): """ Returns the axis vector rotates by the objects worldspace orientation. - This is the equivalent if multiplying the vector by the orientation matrix. + This is the equivalent of multiplying the vector by the orientation matrix. @type vect: 3d vector. @param vect: a vector to align the axis. diff --git a/source/gameengine/PyDoc/PhysicsConstraints.py b/source/gameengine/PyDoc/PhysicsConstraints.py new file mode 100644 index 00000000000..d78a32f4f79 --- /dev/null +++ b/source/gameengine/PyDoc/PhysicsConstraints.py @@ -0,0 +1,126 @@ +# $Id$ +""" +Documentation for the PhysicsConstraints module. + +Example: + import PhysicsConstraints + import GameLogic + +""" +# TODO +# error + +def createConstraint(): + """ + Does something + + @rtype: + """ +def getAppliedImpulse(): + """ + Does something + + @rtype: + """ +def getVehicleConstraint(): + """ + Does something + + @rtype: + """ +def removeConstraint(): + """ + Does something + + @rtype: + """ +def setCcdMode(): + """ + Does something + + @rtype: + """ +def setContactBreakingTreshold(): + """ + Does something + + @rtype: + """ +def setDeactivationAngularTreshold(): + """ + Does something + + @rtype: + """ +def setDeactivationLinearTreshold(): + """ + Does something + + @rtype: + """ +def setDeactivationTime(): + """ + Does something + + @rtype: + """ +def setDebugMode(): + """ + Does something + + @rtype: + """ +def setGravity(): + """ + Does something + + @rtype: + """ +def setLinearAirDamping(): + """ + Does something + + @rtype: + """ +def setNumIterations(): + """ + Does something + + @rtype: + """ +def setNumTimeSubSteps(): + """ + Does something + + @rtype: + """ +def setSolverDamping(): + """ + Does something + + @rtype: + """ +def setSolverTau(): + """ + Does something + + @rtype: + """ +def setSolverType(): + """ + Does something + + @rtype: + """ +def setSorConstant(): + """ + Does something + + @rtype: + """ +def setUseEpa(): + """ + Does something + + @rtype: + """ \ No newline at end of file diff --git a/source/gameengine/PyDoc/VideoTexture.py b/source/gameengine/PyDoc/VideoTexture.py new file mode 100644 index 00000000000..cbcd28fb24c --- /dev/null +++ b/source/gameengine/PyDoc/VideoTexture.py @@ -0,0 +1,133 @@ +# $Id$ +""" +Documentation for the VideoTexture module. + +Example: + import VideoTexture + import GameLogic + +""" +def getLastError(): + """ + Does something + + @rtype: + """ +def imageToArray(image): + """ + Does something + + @param image: Image ID + @type image: integer + @rtype: array + """ +def materialID(material): + """ + Gets the ID of a material + + @param material: the name of the material + @type material: string + @rtype: + """ +def setLogFile(): + """ + Does something + + @rtype: + """ +def FilterBGR24(): + """ + Does something + + @rtype: + """ +def FilterBlueScreen(): + """ + Does something + + @rtype: + """ +def FilterColor(): + """ + Does something + + @rtype: + """ +def FilterGray(): + """ + Does something + + @rtype: + """ +def FilterLevel(): + """ + Does something + + @rtype: + """ +def FilterNormal(): + """ + Does something + + @rtype: + """ +def FilterRGB24(): + """ + Does something + + @rtype: + """ +def FilterRGBA32(): + """ + Does something + + @rtype: + """ +def ImageBuff(): + """ + Does something + + @rtype: + """ +def ImageFFmpeg(): + """ + Does something + + @rtype: + """ +def ImageMirror(): + """ + Does something + + @rtype: + """ +def ImageMix(): + """ + Does something + + @rtype: + """ +def ImageRender(): + """ + Does something + + @rtype: + """ +def ImageViewport(): + """ + Does something + + @rtype: + """ +def Texture(): + """ + Does something + + @rtype: + """ +def VideoFFmpeg(): + """ + Does something + + @rtype: + """ \ No newline at end of file From 0bd98195a1d67ce741145a39147cf8272708f5a2 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sun, 10 Jan 2010 19:56:22 +0000 Subject: [PATCH 011/202] Bug [#20539] Pink Opengl line should disapear Reset edge loop data when there are no edge near (it doesn't cut when there's no edge near anyway, so the display was missleading) Also don't do any display setup when there's nothing to display. --- source/blender/editors/mesh/loopcut.c | 33 ++++++++++++++++----------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/mesh/loopcut.c b/source/blender/editors/mesh/loopcut.c index 9fea0d08e70..9510e40c6ac 100644 --- a/source/blender/editors/mesh/loopcut.c +++ b/source/blender/editors/mesh/loopcut.c @@ -103,21 +103,23 @@ static void ringsel_draw(const bContext *C, ARegion *ar, void *arg) int i; tringselOpData *lcd = arg; - glDisable(GL_DEPTH_TEST); + if (lcd->totedge > 0) { + glDisable(GL_DEPTH_TEST); - glPushMatrix(); - glMultMatrixf(lcd->ob->obmat); + glPushMatrix(); + glMultMatrixf(lcd->ob->obmat); - glColor3ub(255, 0, 255); - glBegin(GL_LINES); - for (i=0; itotedge; i++) { - glVertex3fv(lcd->edges[i][0]); - glVertex3fv(lcd->edges[i][1]); + glColor3ub(255, 0, 255); + glBegin(GL_LINES); + for (i=0; itotedge; i++) { + glVertex3fv(lcd->edges[i][0]); + glVertex3fv(lcd->edges[i][1]); + } + glEnd(); + + glPopMatrix(); + glEnable(GL_DEPTH_TEST); } - glEnd(); - - glPopMatrix(); - glEnable(GL_DEPTH_TEST); } static void edgering_sel(tringselOpData *lcd, int previewlines, int select) @@ -252,8 +254,13 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select) static void ringsel_find_edge(tringselOpData *lcd, const bContext *C, ARegion *ar, int cuts) { - if (lcd->eed) + if (lcd->eed) { edgering_sel(lcd, cuts, 0); + } else { + MEM_freeN(lcd->edges); + lcd->edges = NULL; + lcd->totedge = 0; + } } static void ringsel_finish(bContext *C, wmOperator *op) From b36a05bb7e794335e3415594c41d3986cdc815e8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 20:01:13 +0000 Subject: [PATCH 012/202] - fix for crash if drivers were used in the .B.blend - fix for problem where proxy objects could enter editmode but not exit --- source/blender/editors/object/object_edit.c | 4 ++++ source/blender/python/intern/bpy_interface.c | 5 +++++ source/blender/windowmanager/WM_api.h | 2 +- .../blender/windowmanager/intern/wm_init_exit.c | 15 ++++++++++++--- source/creator/creator.c | 15 ++------------- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 9ef1fafff82..54fa3f51eb6 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -499,6 +499,10 @@ static int editmode_toggle_poll(bContext *C) { Object *ob = CTX_data_active_object(C); + /* covers proxies too */ + if(ob->data==NULL || ((ID *)ob->data)->lib) + return 0; + return ob && (ob->type == OB_MESH || ob->type == OB_ARMATURE || ob->type == OB_FONT || ob->type == OB_MBALL || ob->type == OB_LATTICE || ob->type == OB_SURF || diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 2fcb36f6d5b..2c1edc965e9 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -698,8 +698,13 @@ int BPY_button_eval(bContext *C, char *expr, double *value) void BPY_load_user_modules(bContext *C) { PyGILState_STATE gilstate; + Main *bmain= CTX_data_main(C); Text *text; + /* can happen on file load */ + if(bmain==NULL) + return; + bpy_context_set(C, &gilstate); for(text=CTX_data_main(C)->text.first; text; text= text->id.next) { diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index d2b67142eb5..94cd6ed85a0 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -50,7 +50,7 @@ typedef struct wmJob wmJob; /* general API */ void WM_setprefsize (int stax, int stay, int sizx, int sizy); -void WM_init (struct bContext *C); +void WM_init (struct bContext *C, int argc, char **argv); void WM_exit (struct bContext *C); void WM_main (struct bContext *C); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 6997bcaf309..a83b6c3609a 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -106,9 +106,9 @@ static void wm_free_reports(bContext *C) /* only called once, for startup */ -void WM_init(bContext *C) +void WM_init(bContext *C, int argc, char **argv) { - + if (!G.background) { wm_ghost_init(C); /* note: it assigns C to ghost! */ wm_init_cursor_data(); @@ -129,9 +129,18 @@ void WM_init(bContext *C) init_builtin_keyingsets(); /* editors/animation/keyframing.c */ + /* python needs initializing before loading the .B.blend + * because it may contain PyDrivers. It also needs to be after + * initializing space types and other internal data */ +#ifndef DISABLE_PYTHON + BPY_set_context(C); /* necessary evil */ + BPY_start_python(argc, argv); + BPY_load_user_modules(C); +#endif + /* get the default database, plus a wm */ WM_read_homefile(C, NULL); - + wm_init_reports(C); /* reports cant be initialized before the wm */ if (!G.background) { diff --git a/source/creator/creator.c b/source/creator/creator.c index cad79395b76..87662e0b7a5 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -493,13 +493,7 @@ int main(int argc, char **argv) } } - WM_init(C); - -#ifndef DISABLE_PYTHON - BPY_set_context(C); /* necessary evil */ - BPY_start_python(argc, argv); - BPY_load_user_modules(C); -#endif + WM_init(C, argc, argv); // XXX BRECHT SOLVE BLI_where_is_temp( btempdir, 1 ); /* call after loading the .B.blend so we can read U.tempdir */ @@ -539,13 +533,8 @@ int main(int argc, char **argv) } } - WM_init(C); + WM_init(C, argc, argv); -#ifndef DISABLE_PYTHON - BPY_set_context(C); /* necessary evil */ - BPY_start_python(argc, argv); - BPY_load_user_modules(C); -#endif BLI_where_is_temp( btempdir, 0 ); /* call after loading the .B.blend so we can read U.tempdir */ } #ifndef DISABLE_PYTHON From 6a15ac70b6558873dc15aa2172024477362fc33f Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sun, 10 Jan 2010 20:16:56 +0000 Subject: [PATCH 013/202] [#20581] Lasso tool ends unexpectedly Don't limit lasso to 1024 points, just realloc array with increased size when current limit is reached. Also silence two stupid warnings. --- source/blender/windowmanager/WM_types.h | 1 + .../blender/windowmanager/intern/wm_gesture.c | 3 ++- .../windowmanager/intern/wm_operators.c | 20 ++++++++++++------- source/blender/windowmanager/wm.h | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 9f52cde27e1..442177ef7ba 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -286,6 +286,7 @@ typedef struct wmGesture { int type; /* gesture type define */ int swinid; /* initial subwindow id where it started */ int points; /* optional, amount of points stored */ + int size; /* optional, maximum amount of points stored */ void *customdata; /* customdata for border is a recti */ diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index a57421560a6..80d6869067a 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -91,10 +91,11 @@ wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type) } else if (ELEM(type, WM_GESTURE_LINES, WM_GESTURE_LASSO)) { short *lasso; - gesture->customdata= lasso= MEM_callocN(2*sizeof(short)*WM_LASSO_MAX_POINTS, "lasso points"); + gesture->customdata= lasso= MEM_callocN(2*sizeof(short)*WM_LASSO_MIN_POINTS, "lasso points"); lasso[0] = event->x - sx; lasso[1] = event->y - sy; gesture->points= 1; + gesture->size = WM_LASSO_MIN_POINTS; } return gesture; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1d4e4eb2d39..69b3cbc51ab 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -962,7 +962,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unuse ver_width = BLF_width(version_str); rev_width = BLF_width(revision_str); -#endif NAN_BUILDINFO +#endif //NAN_BUILDINFO block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1); @@ -973,7 +973,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unuse #ifdef NAN_BUILDINFO uiDefBut(block, LABEL, 0, version_str, 500-ver_width, 282-24, ver_width, 20, NULL, 0, 0, 0, 0, NULL); uiDefBut(block, LABEL, 0, revision_str, 500-rev_width, 282-36, rev_width, 20, NULL, 0, 0, 0, 0, NULL); -#endif NAN_BUILDINFO +#endif //NAN_BUILDINFO uiBlockSetEmboss(block, UI_EMBOSSP); @@ -2152,17 +2152,23 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event) wm_gesture_tag_redraw(C); wm_subwindow_getorigin(CTX_wm_window(C), gesture->swinid, &sx, &sy); - if(gesture->points < WM_LASSO_MAX_POINTS) { + + if(gesture->points == gesture->size) { + short *old_lasso = gesture->customdata; + gesture->customdata= MEM_callocN(2*sizeof(short)*(gesture->size + WM_LASSO_MIN_POINTS), "lasso points"); + memcpy(gesture->customdata, old_lasso, 2*sizeof(short)*gesture->size); + gesture->size = gesture->size + WM_LASSO_MIN_POINTS; + MEM_freeN(old_lasso); + printf("realloc\n"); + } + + { short *lasso= gesture->customdata; lasso += 2 * gesture->points; lasso[0] = event->x - sx; lasso[1] = event->y - sy; gesture->points++; } - else { - gesture_lasso_apply(C, op, event->type); - return OPERATOR_FINISHED; - } break; case LEFTMOUSE: diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index 9b888a0e347..14483915083 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -59,7 +59,7 @@ void wm_window_keymap(wmKeyConfig *keyconf); void wm_tweakevent_test(bContext *C, wmEvent *event, int action); /* wm_gesture.c */ -#define WM_LASSO_MAX_POINTS 1024 +#define WM_LASSO_MIN_POINTS 1024 void wm_gesture_draw(struct wmWindow *win); int wm_gesture_evaluate(bContext *C, wmGesture *gesture); void wm_gesture_tag_redraw(bContext *C); From 0185e248619b883aa818d136ee1b8bd4bfa9f8ef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 20:23:59 +0000 Subject: [PATCH 014/202] Make linked animdata working again, copies NLA too, as well as ObData animdata where types match --- source/blender/blenkernel/BKE_animsys.h | 3 +++ source/blender/blenkernel/intern/anim_sys.c | 20 +++++++++++++++++++ .../blender/editors/object/object_relations.c | 10 ++-------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index 045095567bc..ad89d3bbd53 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -55,6 +55,9 @@ void BKE_free_animdata(struct ID *id); /* Copy AnimData */ struct AnimData *BKE_copy_animdata(struct AnimData *adt); +/* Copy AnimData */ +int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from); + /* Make Local */ void BKE_animdata_make_local(struct AnimData *adt); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 8b86f6a5d1f..2a5a12cc513 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -203,6 +203,26 @@ AnimData *BKE_copy_animdata (AnimData *adt) return dadt; } +int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from) +{ + AnimData *adt; + + if((id_to && id_from) && (GS(id_to->name) != GS(id_from->name))) + return 0; + + BKE_free_animdata(id_to); + + adt = BKE_animdata_from_id(id_from); + if (adt) { + IdAdtTemplate *iat = (IdAdtTemplate *)id_to; + iat->adt= BKE_copy_animdata(adt); + } + + return 1; +} + + + /* Make Local -------------------------------------------- */ static void make_local_strips(ListBase *strips) diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index d4bf721e14e..237498f15fd 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1219,14 +1219,8 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } break; case MAKE_LINKS_ANIMDATA: -#if 0 // XXX old animation system - if(obt->ipo) obt->ipo->id.us--; - obt->ipo= ob->ipo; - if(obt->ipo) { - id_us_plus((ID *)obt->ipo); - do_ob_ipo(scene, obt); - } -#endif // XXX old animation system + BKE_copy_animdata_id((ID *)obt, (ID *)ob); + BKE_copy_animdata_id((ID *)obt->data, (ID *)ob->data); break; case MAKE_LINKS_DUPLIGROUP: if(ob->dup_group) ob->dup_group->id.us--; From 0f4741050963e5f2928fc537818890de1a206525 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sun, 10 Jan 2010 20:31:23 +0000 Subject: [PATCH 015/202] [#20522] alt+b in object mode has an offset depending on the selected object's origin View clipping doesn't need object matrix in view transformation (permit NULL object pointer to get global transformation). --- source/blender/editors/space_view3d/view3d_edit.c | 2 +- source/blender/editors/space_view3d/view3d_select.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 74362d29e40..1e23d27fe77 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2075,7 +2075,7 @@ static int view3d_clipping_exec(bContext *C, wmOperator *op) view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); - view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats); + view3d_get_transformation(vc.ar, vc.rv3d, NULL, &mats); /* NULL because we don't want it in object space */ view3d_calculate_clipping(rv3d->clipbb, rv3d->clip, &mats, &rect); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 0ed7f4c0d0a..331d3c4fefe 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -124,12 +124,19 @@ void view3d_get_view_aligned_coordinate(ViewContext *vc, float *fp, short mval[2 } } +/* + * ob == NULL if you want global matrices + * */ void view3d_get_transformation(ARegion *ar, RegionView3D *rv3d, Object *ob, bglMats *mats) { float cpy[4][4]; int i, j; - mul_m4_m4m4(cpy, ob->obmat, rv3d->viewmat); + if (ob) { + mul_m4_m4m4(cpy, ob->obmat, rv3d->viewmat); + } else { + copy_m4_m4(cpy, rv3d->viewmat); + } for(i = 0; i < 4; ++i) { for(j = 0; j < 4; ++j) { From 3a858e84bdb5aa0e51e09f1848ab3995035bd86a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 21:33:41 +0000 Subject: [PATCH 016/202] blenderplayer building with cmake --- source/blenderplayer/CMakeLists.txt | 7 +++++-- source/blenderplayer/bad_level_call_stubs/stubs.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 62064e31d59..e111d804bbe 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -80,8 +80,11 @@ IF(UNIX) bf_rasterizer bf_oglrasterizer bf_expressions - bf_scenegraph - bf_IK + bf_scenegraph + bf_ikplugin + bf_ITASC + bf_IK + bf_smoke bf_moto bf_kernel bf_nodes diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index eddd85c6444..6c2d0b1a25b 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -220,7 +220,7 @@ void uiTemplateHeader3D(struct uiLayout *layout, struct bContext *C){} void uiTemplateTextureImage(struct uiLayout *layout, struct bContext *C, struct Tex *tex){} void uiTemplateImage(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, struct PointerRNA *userptr, int compact){} void uiTemplateDopeSheetFilter(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr){} - +void uiTemplateColorWheel(struct uiLayout *layout, struct PointerRNA *ptr, char *propname, int value_slider){} /* rna render */ struct RenderResult *RE_engine_begin_result(struct RenderEngine *engine, int x, int y, int w, int h){return (struct RenderResult *) NULL;} struct RenderResult *RE_AcquireResultRead(struct Render *re){return (struct RenderResult *) NULL;} From 34794eafe495586761af883b292c16a939d17df8 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Sun, 10 Jan 2010 21:58:40 +0000 Subject: [PATCH 017/202] SVN maintenance. --- source/blender/collada/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/collada/Makefile b/source/blender/collada/Makefile index 29a731dbcb2..f2fed004a25 100644 --- a/source/blender/collada/Makefile +++ b/source/blender/collada/Makefile @@ -1,5 +1,5 @@ # -# $Id: +# $Id$ # # ***** BEGIN GPL LICENSE BLOCK ***** # From affe84a4536c6b7966aee227ae01edbf0861c60b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 22:03:26 +0000 Subject: [PATCH 018/202] get rid of annoying duplicate python initialization code, added setupGamePython() which initializes modules --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 36 ++++--------------- .../GamePlayer/ghost/GPG_Application.cpp | 20 +++-------- source/gameengine/Ketsji/KX_PythonInit.cpp | 32 +++++++++++++++++ source/gameengine/Ketsji/KX_PythonInit.h | 2 ++ 4 files changed, 46 insertions(+), 44 deletions(-) diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 83a6bbb2fe1..254d0c7262d 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -391,22 +391,8 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c #ifndef DISABLE_PYTHON // some python things - PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest, blenderdata); - ketsjiengine->SetPyNamespace(dictionaryobject); - initRasterizer(rasterizer, canvas); - PyObject *gameLogic = initGameLogic(ketsjiengine, startscene); - PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. - PyObject *gameLogic_keys = PyDict_Keys(PyModule_GetDict(gameLogic)); - PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module. - - initGameKeys(); - initPythonConstraintBinding(); - initMathutils(); - initGeometry(); - initBGL(); -#ifdef WITH_FFMPEG - initVideoTexture(); -#endif + PyObject *gameLogic, *gameLogic_keys; + setupGamePython(ketsjiengine, startscene, blenderdata, pyGlobalDict, &gameLogic, &gameLogic_keys, 0, NULL); #endif // DISABLE_PYTHON //initialize Dome Settings @@ -622,6 +608,7 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, // Acquire Python's GIL (global interpreter lock) // so we can safely run Python code and API calls PyGILState_STATE gilstate = PyGILState_Ensure(); + PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */ #endif bgl::InitExtensions(true); @@ -722,19 +709,8 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, #ifndef DISABLE_PYTHON // some python things - PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest, blenderdata); - ketsjiengine->SetPyNamespace(dictionaryobject); - initRasterizer(rasterizer, canvas); - PyObject *gameLogic = initGameLogic(ketsjiengine, startscene); - PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module - initGameKeys(); - initPythonConstraintBinding(); - initMathutils(); - initGeometry(); - initBGL(); -#ifdef WITH_FFMPEG - initVideoTexture(); -#endif + PyObject *gameLogic, *gameLogic_keys; + setupGamePython(ketsjiengine, startscene, blenderdata, pyGlobalDict, &gameLogic, &gameLogic_keys, 0, NULL); #endif // DISABLE_PYTHON if (sceneconverter) @@ -820,6 +796,8 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); #ifndef DISABLE_PYTHON + Py_DECREF(pyGlobalDict); + // Release Python's GIL PyGILState_Release(gilstate); #endif diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index c6952a68a58..323e88187bd 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -679,21 +679,11 @@ bool GPG_Application::startEngine(void) startscenename, m_startScene); - - // some python things - PyObject* dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest, m_maggie, m_argc, m_argv); - m_ketsjiengine->SetPyNamespace(dictionaryobject); - initRasterizer(m_rasterizer, m_canvas); - PyObject *gameLogic = initGameLogic(m_ketsjiengine, startscene); - PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module - initGameKeys(); - initPythonConstraintBinding(); - initMathutils(); - initGeometry(); - initBGL(); -#ifdef WITH_FFMPEG - initVideoTexture(); -#endif +#ifndef DISABLE_PYTHON + // some python things + PyObject *gameLogic, *gameLogic_keys; + setupGamePython(m_ketsjiengine, startscene, m_maggie, NULL, &gameLogic, &gameLogic_keys, m_argc, m_argv); +#endif // DISABLE_PYTHON //initialize Dome Settings if(m_startScene->gm.stereoflag == STEREO_DOME) diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index ed422b81ec6..cd0bcefff3b 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1926,6 +1926,38 @@ void exitGamePythonScripting() PyObjectPlus::ClearDeprecationWarning(); } +/* similar to the above functions except it sets up the namespace + * and other more general things */ +void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene* startscene, Main *blenderdata, PyObject * pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char** argv) +{ + PyObject* dictionaryobject; + + if(argv) /* player only */ + dictionaryobject= initGamePlayerPythonScripting("Ketsji", psl_Lowest, blenderdata, argc, argv); + else + dictionaryobject= initGamePythonScripting("Ketsji", psl_Lowest, blenderdata); + + ketsjiengine->SetPyNamespace(dictionaryobject); + initRasterizer(ketsjiengine->GetRasterizer(), ketsjiengine->GetCanvas()); + *gameLogic = initGameLogic(ketsjiengine, startscene); + + /* is set in initGameLogic so only set here if we want it to persist between scenes */ + if(pyGlobalDict) + PyDict_SetItemString(PyModule_GetDict(*gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. + + *gameLogic_keys = PyDict_Keys(PyModule_GetDict(*gameLogic)); + PyDict_SetItemString(dictionaryobject, "GameLogic", *gameLogic); // Same as importing the module. + + initGameKeys(); + initPythonConstraintBinding(); + initMathutils(); + initGeometry(); + initBGL(); + +#ifdef WITH_FFMPEG + initVideoTexture(); +#endif +} static struct PyModuleDef Rasterizer_module_def = { {}, /* m_base */ diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index ad3cd15ab4a..442c32a0a82 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -52,6 +52,8 @@ void exitGamePlayerPythonScripting(); PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level, struct Main *maggie); void exitGamePythonScripting(); +void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene* startscene, Main *blenderdata, PyObject *pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char** argv); + void setGamePythonPath(char *path); void resetGamePythonPath(); void pathGamePythonConfig( char *path ); From 1cb013f8771990542dc5ab72bcc285e5942605b6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 22:15:29 +0000 Subject: [PATCH 019/202] evil 1 liner to get bge.logic, bge.render, bge.keys etc.. may eventually replace GameLogic, GameKeys module names. --- source/gameengine/Ketsji/KX_PythonInit.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index cd0bcefff3b..5e109770fee 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1957,6 +1957,9 @@ void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene* startscene, Main * #ifdef WITH_FFMPEG initVideoTexture(); #endif + + /* could be done a lot more nicely, but for now a quick way to get bge.* working */ + PyRun_SimpleString("__import__('sys').modules['bge']=[mod for mod in (type(__builtins__)('bge'), ) if mod.__dict__.update({'logic':__import__('GameLogic'), 'render':__import__('Rasterizer'), 'keys':__import__('GameKeys'), 'constraints':__import__('PhysicsConstraints'), 'types':__import__('GameTypes')}) is None][0]"); } static struct PyModuleDef Rasterizer_module_def = { From 5074a4c30748d281d04f8c54ccfc43ae2360e764 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Sun, 10 Jan 2010 22:52:40 +0000 Subject: [PATCH 020/202] Request different OpenGL oversampling levels before giving up. --- intern/ghost/intern/GHOST_WindowX11.cpp | 55 ++++++++++++++----------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index c500055c280..efde9005fe4 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -169,7 +169,7 @@ GHOST_WindowX11( // Set up the minimum atrributes that we require and see if // X can find us a visual matching those requirements. - int attributes[40], i = 0, i_pre_aa; + int attributes[40], i, samples; Atom atoms[2]; int natom; int glxVersionMajor, glxVersionMinor; // As in GLX major.minor @@ -179,39 +179,44 @@ GHOST_WindowX11( return; } - if(m_stereoVisual) - attributes[i++] = GLX_STEREO; + /* Find the display with highest samples, starting at level requested */ + for (samples = m_numOfAASamples; samples >= 0; samples--) { + i = 0; /* Reusing attributes array, so reset counter */ - attributes[i++] = GLX_RGBA; - attributes[i++] = GLX_DOUBLEBUFFER; - attributes[i++] = GLX_RED_SIZE; attributes[i++] = 1; - attributes[i++] = GLX_BLUE_SIZE; attributes[i++] = 1; - attributes[i++] = GLX_GREEN_SIZE; attributes[i++] = 1; - attributes[i++] = GLX_DEPTH_SIZE; attributes[i++] = 1; - i_pre_aa= i; - /* GLX 1.4+, multi-sample */ - if(m_numOfAASamples && (glxVersionMajor >= 1) && (glxVersionMinor >= 4)) { - attributes[i++] = GLX_SAMPLE_BUFFERS; attributes[i++] = 1; - attributes[i++] = GLX_SAMPLES; attributes[i++] = m_numOfAASamples; - } - attributes[i] = None; + if(m_stereoVisual) + attributes[i++] = GLX_STEREO; - m_visual = glXChooseVisual(m_display, DefaultScreen(m_display), attributes); + attributes[i++] = GLX_RGBA; + attributes[i++] = GLX_DOUBLEBUFFER; + attributes[i++] = GLX_RED_SIZE; attributes[i++] = 1; + attributes[i++] = GLX_BLUE_SIZE; attributes[i++] = 1; + attributes[i++] = GLX_GREEN_SIZE; attributes[i++] = 1; + attributes[i++] = GLX_DEPTH_SIZE; attributes[i++] = 1; + /* GLX >= 1.4 required for multi-sample */ + if(samples && (glxVersionMajor >= 1) && (glxVersionMinor >= 4)) { + attributes[i++] = GLX_SAMPLE_BUFFERS; attributes[i++] = 1; + attributes[i++] = GLX_SAMPLES; attributes[i++] = samples; + } + attributes[i] = None; - if (m_visual == NULL) { - /* possibly the X Server does not support GLX_SAMPLE_BUFFERS */ - attributes[i_pre_aa] = None; m_visual = glXChooseVisual(m_display, DefaultScreen(m_display), attributes); + /* Any sample level or even zero, which means oversampling disabled, is good + but we need a valid visual to continue */ if (m_visual == NULL) { - // barf : no visual meeting these requirements could be found. - printf("%s:%d: X11 glXChooseVisual() failed, verify working openGL system!\n", __FILE__, __LINE__); - return; + if (samples == 0) { + /* All options exhausted, cannot continue */ + printf("%s:%d: X11 glXChooseVisual() failed, verify working openGL system!\n", __FILE__, __LINE__); + return; + } } else { - printf("%s:%d: X11 glXChooseVisual() multi-sample failed, continue with multisample disabled\n", __FILE__, __LINE__); + if (m_numOfAASamples && (m_numOfAASamples > samples)) { + printf("%s:%d: oversampling requested %i but using %i samples\n", __FILE__, __LINE__, m_numOfAASamples, samples); + } + break; } } - + memset(&m_xtablet, 0, sizeof(m_xtablet)); // Create a bunch of attributes needed to create an X window. From e9d9602bab1c68db42a94127a5e2af6e03f742b2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Jan 2010 23:18:09 +0000 Subject: [PATCH 021/202] change the defaults for solidify since users are getting unexpected spikes because of the 'Even Thickness' option. For buildings this is nice but for cloth and random mesh input it ends up giving ugly spikes. --- source/blender/blenkernel/intern/modifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index fd152c118ae..89ca48977ba 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5917,7 +5917,7 @@ static void solidifyModifier_initData(ModifierData *md) { SolidifyModifierData *smd = (SolidifyModifierData*) md; smd->offset = 0.01f; - smd->flag = MOD_SOLIDIFY_EVEN | MOD_SOLIDIFY_RIM | MOD_SOLIDIFY_NORMAL_CALC; + smd->flag = MOD_SOLIDIFY_RIM; } static void solidifyModifier_copyData(ModifierData *md, ModifierData *target) From b6a1bc575bf683cac8048c9e9f76028466fb3b07 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Jan 2010 00:41:31 +0000 Subject: [PATCH 022/202] rna/py api bpy.data.scenes.remove(scene) # now works without crashing bpy.data.texts.new(name)/remove(text)/load(path) # added --- release/scripts/ui/space_info.py | 6 +- source/blender/makesrna/RNA_types.h | 1 + source/blender/makesrna/intern/rna_main_api.c | 79 +++++++++++++++++-- 3 files changed, 75 insertions(+), 11 deletions(-) diff --git a/release/scripts/ui/space_info.py b/release/scripts/ui/space_info.py index b15315b8668..ae21ecd0693 100644 --- a/release/scripts/ui/space_info.py +++ b/release/scripts/ui/space_info.py @@ -384,12 +384,10 @@ class HELP_OT_operator_cheat_sheet(bpy.types.Operator): op_strings.append('') - bpy.ops.text.new() # XXX - assumes new text is always at the end! - textblock = bpy.data.texts[-1] + textblock = bpy.data.texts.new("OperatorList.txt") textblock.write('# %d Operators\n\n' % tot) textblock.write('\n'.join(op_strings)) - textblock.name = "OperatorList.txt" - print("See OperatorList.txt textblock") + self.report({'INFO'}, "See OperatorList.txt textblock") return {'FINISHED'} bpy.types.register(HELP_OT_manual) diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 841f8708aa2..5ec2320e2dc 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -332,6 +332,7 @@ typedef struct ExtensionRNA { #define MainMeshes Main #define MainLamps Main #define MainObjects Main +#define MainTexts Main #ifdef __cplusplus } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index f1fe24418e9..737f570df67 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -33,6 +33,8 @@ #include "RNA_types.h" #include "RNA_enum_types.h" +#include "BKE_utildefines.h" + #ifdef RNA_RUNTIME #include "BKE_main.h" @@ -44,6 +46,7 @@ #include "BKE_image.h" #include "BKE_texture.h" #include "BKE_scene.h" +#include "BKE_text.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" @@ -51,6 +54,9 @@ #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" +#include "DNA_text_types.h" + +#include "ED_screen.h" Tex *rna_Main_add_texture(Main *bmain, char *name) { @@ -82,9 +88,23 @@ Scene *rna_Main_scenes_new(Main *bmain, char* name) { return add_scene(name); } -void rna_Main_scenes_remove(Main *bmain, ReportList *reports, struct Scene *scene) +void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struct Scene *scene) { - free_libblock(&bmain->scene, scene); + /* dont call free_libblock(...) directly */ + Scene *newscene; + + if(scene->id.prev) + newscene= scene->id.prev; + else if(scene->id.next) + newscene= scene->id.next; + else { + BKE_reportf(reports, RPT_ERROR, "Scene \"%s\" is the last, cant ve removed.", scene->id.name+2); + return; + } + + ED_screen_set_scene(C, newscene); + + unlink_scene(bmain, scene, newscene); } Object *rna_Main_objects_new(Main *bmain, char* name, int type) @@ -159,6 +179,25 @@ void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) /* XXX python now has invalid pointer? */ } +Text *rna_Main_texts_new(Main *bmain, char* name) +{ + return add_empty_text(name); +} +void rna_Main_texts_remove(Main *bmain, ReportList *reports, Text *text) +{ + unlink_text(bmain, text); + free_libblock(&bmain->text, text); + /* XXX python now has invalid pointer? */ +} +Text *rna_Main_texts_load(Main *bmain, ReportList *reports, char* path) +{ + Text *txt= add_text(path, bmain->name); + if(txt==NULL) + BKE_reportf(reports, RPT_ERROR, "Couldn't load text from path \"%s\".", path); + + return txt; +} + bArmature *rna_Main_armatures_new(Main *bmain, char* name) { bArmature *arm= add_armature(name); @@ -241,7 +280,7 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_scenes_remove"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_function_ui_description(func, "Remove a scene from the current blendfile."); @@ -256,7 +295,6 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainObjects"); srna= RNA_def_struct(brna, "MainObjects", NULL); -// RNA_def_struct_sdna(srna, "Object"); RNA_def_struct_ui_text(srna, "Main Objects", "Collection of objects."); func= RNA_def_function(srna, "new", "rna_Main_objects_new"); @@ -285,7 +323,6 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainMaterials"); srna= RNA_def_struct(brna, "MainMaterials", NULL); -// RNA_def_struct_sdna(srna, "Material"); RNA_def_struct_ui_text(srna, "Main Material", "Collection of materials."); func= RNA_def_function(srna, "new", "rna_Main_materials_new"); @@ -314,7 +351,6 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainMeshes"); srna= RNA_def_struct(brna, "MainMeshes", NULL); -// RNA_def_struct_sdna(srna, "Mesh"); RNA_def_struct_ui_text(srna, "Main Meshes", "Collection of meshes."); func= RNA_def_function(srna, "new", "rna_Main_meshes_new"); @@ -339,7 +375,6 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainLamps"); srna= RNA_def_struct(brna, "MainLamps", NULL); -// RNA_def_struct_sdna(srna, "Lamp"); RNA_def_struct_ui_text(srna, "Main Lamps", "Collection of lamps."); func= RNA_def_function(srna, "new", "rna_Main_lamps_new"); @@ -406,7 +441,37 @@ void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) } void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) { + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + RNA_def_property_srna(cprop, "MainTexts"); + srna= RNA_def_struct(brna, "MainTexts", NULL); + RNA_def_struct_ui_text(srna, "Main Texts", "Collection of texts."); + + func= RNA_def_function(srna, "new", "rna_Main_texts_new"); + RNA_def_function_ui_description(func, "Add a new text to the main database"); + parm= RNA_def_string(func, "name", "Text", 0, "", "New name for the datablock."); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm= RNA_def_pointer(func, "text", "Text", "", "New text datablock."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "rna_Main_texts_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a text from the current blendfile."); + parm= RNA_def_pointer(func, "text", "Text", "", "Text to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + /* load func */ + func= RNA_def_function(srna, "load", "rna_Main_texts_load"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Add a new text to the main database from a file"); + parm= RNA_def_string(func, "path", "Path", FILE_MAXDIR + FILE_MAXFILE, "", "path for the datablock."); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm= RNA_def_pointer(func, "text", "Text", "", "New text datablock."); + RNA_def_function_return(func, parm); } void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop) { From 9d67c720d5328f1918cc01d86a326c0aca3e0d06 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 11 Jan 2010 01:26:16 +0000 Subject: [PATCH 023/202] * Tweak for splash screen rev. info - dalai, does this look ok on your machine? * Added very feint separator lines in menus --- .../editors/interface/interface_widgets.c | 18 ++++++++++++++++++ .../windowmanager/intern/wm_operators.c | 9 +++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 82c79c32c6c..418773cbe25 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1791,6 +1791,23 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) } +/* ************ separator, for menus etc ***************** */ +static void ui_draw_separator(uiBut *but, rcti *rect, uiWidgetColors *wcol) +{ + int y = rect->ymin + (rect->ymax - rect->ymin)/2 - 1; + unsigned char col[3]; + + col[0] = wcol->text[0]; + col[1] = wcol->text[1]; + col[2] = wcol->text[2]; + col[3] = 7; + + glEnable(GL_BLEND); + glColor4ubv(col); + sdrawline(rect->xmin, y, rect->xmax, y); + glDisable(GL_BLEND); +} + /* ************ button callbacks, draw ***************** */ static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) @@ -2508,6 +2525,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect); break; case SEPR: + ui_draw_separator(but, rect, &tui->wcol_menu_item); break; default: diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 69b3cbc51ab..1d9687a2d94 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -960,8 +960,9 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unuse *cp = 0; } - ver_width = BLF_width(version_str); - rev_width = BLF_width(revision_str); + BLF_size(style->widgetlabel.points, U.dpi); + ver_width = BLF_width(version_str)+5; + rev_width = BLF_width(revision_str)+5; #endif //NAN_BUILDINFO block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); @@ -990,7 +991,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unuse uiItemO(col, NULL, ICON_URL, "HELP_OT_blender_website"); uiItemO(col, NULL, ICON_URL, "HELP_OT_user_community"); uiItemO(col, NULL, ICON_URL, "HELP_OT_python_api"); - uiItemS(col); + uiItemL(col, "", 0); col = uiLayoutColumn(split, 0); uiItemL(col, "Recent", 0); @@ -1001,7 +1002,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unuse uiItemStringO(col, display_name, ICON_FILE_BLEND, "WM_OT_open_mainfile", "path", recent->filename); } - uiItemS(col); + uiItemL(col, "", 0); uiCenteredBoundsBlock(block, 0.0f); uiEndBlock(C, block); From e0dd3fe5872ba37ff188e292b80b46fcf8df413c Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 11 Jan 2010 05:10:57 +0000 Subject: [PATCH 024/202] * Restored font selection functionality with open font and unlink font operators, so you can change the font of 3D text objects. --- release/scripts/ui/properties_data_curve.py | 10 +- source/blender/blenkernel/intern/font.c | 6 +- source/blender/blenlib/intern/freetypefont.c | 2 +- source/blender/editors/curve/curve_intern.h | 3 + source/blender/editors/curve/curve_ops.c | 3 + source/blender/editors/curve/editfont.c | 167 +++++++++++++++++- .../editors/space_view3d/space_view3d.c | 5 + source/blender/makesrna/intern/rna_ID.c | 13 ++ source/blender/makesrna/intern/rna_curve.c | 3 +- source/blender/makesrna/intern/rna_vfont.c | 2 +- 10 files changed, 205 insertions(+), 9 deletions(-) diff --git a/release/scripts/ui/properties_data_curve.py b/release/scripts/ui/properties_data_curve.py index 442590b8946..4071c7b0412 100644 --- a/release/scripts/ui/properties_data_curve.py +++ b/release/scripts/ui/properties_data_curve.py @@ -282,10 +282,12 @@ class DATA_PT_font(DataButtonsPanel): char = context.curve.edit_format wide_ui = context.region.width > narrowui - if wide_ui: - layout.prop(text, "font") - else: - layout.prop(text, "font", text="") + layout.template_ID(text, "font", open="font.open", unlink="font.unlink") + + #if wide_ui: + # layout.prop(text, "font") + #else: + # layout.prop(text, "font", text="") split = layout.split() diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 1a63f97e310..41e5178d6cb 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -398,7 +398,11 @@ VFont *load_vfont(char *name) if (vfd) { vfont = alloc_libblock(&G.main->vfont, ID_VF, filename); vfont->data = vfd; - + + /* if there's a font name, use it for the ID name */ + if (strcmp(vfd->name, "")!=0) { + BLI_strncpy(vfont->id.name+2, vfd->name, 21); + } BLI_strncpy(vfont->name, name, sizeof(vfont->name)); // if autopack is on store the packedfile in de font structure diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index f2727f6f259..35b9c86892a 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -359,7 +359,7 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile * pf) // get the name fontname = FT_Get_Postscript_Name(face); - strcpy(vfd->name, (fontname == NULL) ? "Fontname not available" : fontname); + strcpy(vfd->name, (fontname == NULL) ? "" : fontname); // Extract the first 256 character from TTF lcode= charcode= FT_Get_First_Char(face, &glyph_index); diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h index 6c477bd011a..ca5aa213d36 100644 --- a/source/blender/editors/curve/curve_intern.h +++ b/source/blender/editors/curve/curve_intern.h @@ -63,6 +63,9 @@ void FONT_OT_delete(struct wmOperatorType *ot); void FONT_OT_change_character(struct wmOperatorType *ot); void FONT_OT_change_spacing(struct wmOperatorType *ot); +void FONT_OT_open(struct wmOperatorType *ot); +void FONT_OT_unlink(struct wmOperatorType *ot); + /* editcurve.c */ void CURVE_OT_hide(struct wmOperatorType *ot); void CURVE_OT_reveal(struct wmOperatorType *ot); diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 660db2f0951..a3b620ef7b5 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -87,6 +87,9 @@ void ED_operatortypes_curve(void) WM_operatortype_append(FONT_OT_change_character); WM_operatortype_append(FONT_OT_change_spacing); + + WM_operatortype_append(FONT_OT_open); + WM_operatortype_append(FONT_OT_unlink); WM_operatortype_append(CURVE_OT_hide); WM_operatortype_append(CURVE_OT_reveal); diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index da794eb1c25..101f0e2074c 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -54,6 +54,7 @@ #include "BKE_depsgraph.h" #include "BKE_font.h" #include "BKE_global.h" +#include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" #include "BKE_report.h" @@ -70,6 +71,8 @@ #include "ED_screen.h" #include "ED_util.h" +#include "UI_interface.h" + #include "curve_intern.h" #define MAXTEXT 32766 @@ -1538,6 +1541,169 @@ void FONT_OT_case_toggle(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/* **************** Open Font ************** */ + +static void open_init(bContext *C, wmOperator *op) +{ + PropertyPointerRNA *pprop; + + op->customdata= pprop= MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); + uiIDContextProperty(C, &pprop->ptr, &pprop->prop); +} + +static int open_cancel(bContext *C, wmOperator *op) +{ + MEM_freeN(op->customdata); + op->customdata= NULL; + return OPERATOR_CANCELLED; +} + +static int open_exec(bContext *C, wmOperator *op) +{ + Object *ob = CTX_data_active_object(C); + Curve *cu; + VFont *font; + PropertyPointerRNA *pprop; + PointerRNA idptr; + char str[FILE_MAX]; + + RNA_string_get(op->ptr, "path", str); + + font = load_vfont(str); + + if(!font) { + if(op->customdata) MEM_freeN(op->customdata); + return OPERATOR_CANCELLED; + } + + if(!op->customdata) + open_init(C, op); + + /* hook into UI */ + pprop= op->customdata; + + if(pprop->prop) { + /* when creating new ID blocks, use is already 1, but RNA + * pointer se also increases user, so this compensates it */ + font->id.us--; + + RNA_id_pointer_create(&font->id, &idptr); + RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr); + RNA_property_update(C, &pprop->ptr, pprop->prop); + } else if(ob && ob->type == OB_FONT) { + cu = ob->data; + id_us_min(&cu->vfont->id); + cu->vfont = font; + } + + DAG_id_flush_update(ob->data, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_GEOM|ND_DATA|NA_EDITED, ob->data); + + MEM_freeN(op->customdata); + + return OPERATOR_FINISHED; +} + +static int open_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + Object *ob = CTX_data_active_object(C); + Curve *cu; + VFont *font=NULL; + char *path; + if (ob && ob->type == OB_FONT) { + cu = ob->data; + font = cu->vfont; + } + path = (font && font->name)? font->name: U.fontdir; + + if(RNA_property_is_set(op->ptr, "path")) + return open_exec(C, op); + + open_init(C, op); + + RNA_string_set(op->ptr, "path", path); + WM_event_add_fileselect(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +void FONT_OT_open(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Open"; + ot->idname= "FONT_OT_open"; + + /* api callbacks */ + ot->exec= open_exec; + ot->invoke= open_invoke; + ot->cancel= open_cancel; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL); +} + +/******************* delete operator *********************/ +static int font_unlink_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + Curve *cu; + + if (!ED_operator_object_active_editable(C) ) return 0; + if (ob->type != OB_FONT) return 0; + + cu = ob->data; + if (cu && strcmp(cu->vfont->name, "")==0) return 0; + return 1; +} + +static int font_unlink_exec(bContext *C, wmOperator *op) +{ + Object *ob = CTX_data_active_object(C); + Curve *cu; + VFont *font, *builtin_font; + + cu = ob->data; + font = cu->vfont; + + if (!font) { + BKE_report(op->reports, RPT_ERROR, "No font datablock available to unlink."); + return OPERATOR_CANCELLED; + } + + if (strcmp(font->name, "")==0) { + BKE_report(op->reports, RPT_WARNING, "Can't unlink the default builtin font."); + return OPERATOR_FINISHED; + } + + /* revert back to builtin font */ + builtin_font = get_builtin_font(); + + cu->vfont = builtin_font; + id_us_plus(&cu->vfont->id); + id_us_min(&font->id); + + DAG_id_flush_update(ob->data, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_GEOM|ND_DATA|NA_EDITED, ob->data); + + return OPERATOR_FINISHED; +} + +void FONT_OT_unlink(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Unlink"; + ot->idname= "FONT_OT_unlink"; + ot->description= "Unlink active font data block."; + + /* api callbacks */ + ot->exec= font_unlink_exec; + ot->poll= font_unlink_poll; +} + + /* **************** undo for font object ************** */ static void undoFont_to_editFont(void *strv, void *ecu) @@ -1595,4 +1761,3 @@ void undo_push_font(bContext *C, char *name) { undo_editmode_push(C, name, get_undoFont, free_undoFont, undoFont_to_editFont, editFont_to_undoFont, NULL); } - diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 6ee0e341849..31c02be6621 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -483,6 +483,11 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; } + switch(wmn->action) { + case NA_EDITED: + ED_region_tag_redraw(ar); + break; + } break; case NC_GROUP: /* all group ops for now */ diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index e931f08c3a3..ac354366c25 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -93,6 +93,18 @@ void rna_ID_name_set(PointerRNA *ptr, const char *value) test_idbutton(id->name+2); } +static int rna_ID_name_editable(PointerRNA *ptr) +{ + ID *id= (ID*)ptr->data; + + if (GS(id->name) == ID_VF) { + if (strcmp(id->name+2, "")==0) + return 0; + } + + return 1; +} + short RNA_type_to_ID_code(StructRNA *type) { if(RNA_struct_is_a(type, &RNA_Action)) return ID_AC; @@ -365,6 +377,7 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Name", "Unique datablock ID name."); RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set"); RNA_def_property_string_maxlength(prop, sizeof(((ID*)NULL)->name)-2); + RNA_def_property_editable_func(prop, "rna_ID_name_editable"); RNA_def_property_update(prop, NC_ID|NA_RENAME, NULL); RNA_def_struct_name_property(srna, prop); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index d3a56661813..98c2963a110 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -73,7 +73,7 @@ static StructRNA *rna_Curve_refine(PointerRNA *ptr) { Curve *cu= (Curve*)ptr->data; short obtype= curve_type(cu); - + if(obtype == OB_FONT) return &RNA_TextCurve; else if(obtype == OB_SURF) return &RNA_SurfaceCurve; else return &RNA_Curve; @@ -634,6 +634,7 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "font", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "vfont"); RNA_def_property_ui_text(prop, "Font", ""); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "edit_format", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_vfont.c b/source/blender/makesrna/intern/rna_vfont.c index aa2aaaf6342..db576207eae 100644 --- a/source/blender/makesrna/intern/rna_vfont.c +++ b/source/blender/makesrna/intern/rna_vfont.c @@ -43,7 +43,7 @@ void RNA_def_vfont(BlenderRNA *brna) srna= RNA_def_struct(brna, "VectorFont", "ID"); RNA_def_struct_ui_text(srna, "Vector Font", "Vector font for Text objects."); RNA_def_struct_sdna(srna, "VFont"); - RNA_def_struct_ui_icon(srna, ICON_FONT_DATA); + RNA_def_struct_ui_icon(srna, ICON_FILE_FONT); prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); RNA_def_property_clear_flag(prop, PROP_EDITABLE); From 7bbf4f660507b95711ccd67bdc36bc5e1ee8c26f Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 11 Jan 2010 05:32:01 +0000 Subject: [PATCH 025/202] * Removed popups from curve select random and Nth, also edited select random code to use the same logic as select random for meshes (with extend property as well) --- source/blender/editors/curve/editcurve.c | 92 +++++++++--------------- 1 file changed, 32 insertions(+), 60 deletions(-) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index a109e9149cf..40edac0ffce 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4146,35 +4146,35 @@ void CURVE_OT_select_less(wmOperatorType *ot) /********************** select random *********************/ -/* this function could be moved elsewhere as it can be reused in other parts of the source needing randomized list */ -/* returns list containing -1 in indices that have been left out of the list. otherwise index contains reference */ -/* to next index. basically *list contains a linked list */ -static void generate_pickable_list(int *list, int size, int pickamount) +static void selectrandom_curve(ListBase *editnurb, float randfac) { - int i, j, removable; + Nurb *nu; + BezTriple *bezt; + BPoint *bp; + int a; BLI_srand( BLI_rand() ); /* random seed */ - - /* generate list in form 0->1, 1->2, 2->3, ... i-2->i-1, i->0 */ - for(i=0; ifirst; nu; nu= nu->next) { + if(nu->type == CU_BEZIER) { + bezt= nu->bezt; + a= nu->pntsu; + while(a--) { + if (BLI_frand() < randfac) + select_beztriple(bezt, SELECT, 1, VISIBLE); + bezt++; + } } - - /* pick unwanted item out of the list */ - list[list[removable]]= -1; /* mark former last as invalid */ - - if(list[removable] == size-1) list[removable]= 0; - else list[removable]= list[removable]+1; + else { + bp= nu->bp; + a= nu->pntsu*nu->pntsv; + + while(a--) { + if (BLI_frand() < randfac) + select_bpoint(bp, SELECT, 1, VISIBLE); + bp++; + } + } } } @@ -4185,44 +4185,17 @@ static int select_random_exec(bContext *C, wmOperator *op) Nurb *nu; BezTriple *bezt; BPoint *bp; - float percent= RNA_float_get(op->ptr, "percent"); int amounttoselect, amountofcps, a, i, k= 0; int *itemstobeselected; + float percent; - if(percent == 0.0f) - return OPERATOR_CANCELLED; + if(!RNA_boolean_get(op->ptr, "extend")) + CU_deselect_all(obedit); - amountofcps= count_curveverts_without_handles(editnurb); - itemstobeselected= MEM_callocN(sizeof(int) * amountofcps, "selectitems"); - amounttoselect= floor(percent * amountofcps + 0.5); - generate_pickable_list(itemstobeselected, amountofcps, amounttoselect); + selectrandom_curve(editnurb, RNA_float_get(op->ptr, "percent")/100.0f); - /* select elements */ - for(i=1, nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; - while(a--) { - if(itemstobeselected[k] != -1) select_beztriple(bezt, SELECT, 1, VISIBLE); - k++; - bezt++; - } - } - else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; - while(a--) { - if(itemstobeselected[k] != -1) select_bpoint(bp, SELECT, 1, VISIBLE); - k++; - bp++; - } - } - } - - MEM_freeN(itemstobeselected); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); - + return OPERATOR_FINISHED; } @@ -4234,14 +4207,14 @@ void CURVE_OT_select_random(wmOperatorType *ot) /* api callbacks */ ot->exec= select_random_exec; - ot->invoke= WM_operator_props_popup; ot->poll= ED_operator_editsurfcurve; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_float_percentage(ot->srna, "percent", 0.5f, 0.0f, 1.0f, "Percent", "Percentage of vertices to select randomly.", 0.0001f, 1.0f); + RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of elements to select randomly.", 0.f, 100.0f); + RNA_def_boolean(ot->srna, "extend", FALSE, "Extend Selection", "Extend selection instead of deselecting everything first."); } /********************** select every nth *********************/ @@ -4268,7 +4241,6 @@ void CURVE_OT_select_every_nth(wmOperatorType *ot) /* api callbacks */ ot->exec= select_every_nth_exec; - ot->invoke= WM_operator_props_popup; ot->poll= ED_operator_editsurfcurve; /* flags */ From 1f12e8c59f9bcdcef8b632b2a93d1b1875209b27 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 11 Jan 2010 05:55:34 +0000 Subject: [PATCH 026/202] * Restored vertex parent The operator was already there and written, just didn't have a hotkey assigned. Gave it an icky popup menu like object mode parent until we get a nice non-blocking report viewer. --- source/blender/editors/curve/curve_ops.c | 2 ++ source/blender/editors/curve/editcurve.c | 6 ------ source/blender/editors/mesh/mesh_ops.c | 2 ++ source/blender/editors/object/object_ops.c | 2 ++ source/blender/editors/object/object_relations.c | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index a3b620ef7b5..76f08bb3a9b 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -218,6 +218,8 @@ void ED_keymap_curve(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CURVE_OT_hide", HKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_hide", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "unselected", 1); + WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_curve_specials", WKEY, KM_PRESS, 0, 0); /* menus */ diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 40edac0ffce..20aece9a5fc 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4182,12 +4182,6 @@ static int select_random_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); ListBase *editnurb= curve_get_editcurve(obedit); - Nurb *nu; - BezTriple *bezt; - BPoint *bp; - int amounttoselect, amountofcps, a, i, k= 0; - int *itemstobeselected; - float percent; if(!RNA_boolean_get(op->ptr, "extend")) CU_deselect_all(obedit); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 8537d39fbd8..32141005c7c 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -287,6 +287,8 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_fgon_clear", FKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0); WM_keymap_add_item(keymap, "MESH_OT_knife_cut", LEFTMOUSE, KM_PRESS, 0, KKEY); + + WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); /* menus */ WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_specials", WKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index eb2086fe95d..a1889b97169 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -330,6 +330,8 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "LATTICE_OT_select_all", AKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); + /* menus */ WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 237498f15fd..95fbcdd4223 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -251,6 +251,7 @@ void OBJECT_OT_vertex_parent_set(wmOperatorType *ot) ot->idname= "OBJECT_OT_vertex_parent_set"; /* api callbacks */ + ot->invoke= WM_operator_confirm; ot->poll= vertex_parent_set_poll; ot->exec= vertex_parent_set_exec; From 1afb01876c8b35fb2b72ca89d6e12d844a811cf2 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 11 Jan 2010 06:32:05 +0000 Subject: [PATCH 027/202] Graph Editor: Snapping + Cursor Added buttons beside the numeric inputs for cursor location to make it more obvious how the cursor can be used for numeric manipulation of selected keyframes. --- source/blender/editors/space_graph/graph_buttons.c | 14 +++++++++----- source/blender/editors/space_graph/graph_edit.c | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index a866ebd75e2..7dfb11a9827 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -147,7 +147,7 @@ static void graph_panel_view(const bContext *C, Panel *pa) SpaceIpo *sipo= CTX_wm_space_graph(C); Scene *scene= CTX_data_scene(C); PointerRNA spaceptr, sceneptr; - uiLayout *col, *subcol; + uiLayout *col, *subcol, *row; /* get RNA pointers for use when creating the UI elements */ RNA_id_pointer_create(&scene->id, &sceneptr); @@ -159,12 +159,16 @@ static void graph_panel_view(const bContext *C, Panel *pa) subcol= uiLayoutColumn(col, 1); uiLayoutSetActive(subcol, RNA_boolean_get(&spaceptr, "show_cursor")); - uiItemR(subcol, "Cursor X", 0, &sceneptr, "current_frame", 0); - uiItemR(subcol, "Cursor Y", 0, &spaceptr, "cursor_value", 0); - + uiItemO(subcol, "Cursor from Selection", 0, "GRAPH_OT_frame_jump"); + subcol= uiLayoutColumn(col, 1); uiLayoutSetActive(subcol, RNA_boolean_get(&spaceptr, "show_cursor")); - uiItemO(subcol, "Cursor from Selection", 0, "GRAPH_OT_frame_jump"); + row= uiLayoutSplit(subcol, 0.7, 1); + uiItemR(row, "Cursor X", 0, &sceneptr, "current_frame", 0); + uiItemEnumO(row, "To Keys", 0, "GRAPH_OT_snap", "type", GRAPHKEYS_SNAP_CFRA); + row= uiLayoutSplit(subcol, 0.7, 1); + uiItemR(row, "Cursor Y", 0, &spaceptr, "cursor_value", 0); + uiItemEnumO(row, "To Keys", 0, "GRAPH_OT_snap", "type", GRAPHKEYS_SNAP_VALUE); } /* ******************* active F-Curve ************** */ diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index ffc450b5368..2adf783b338 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1686,7 +1686,7 @@ void GRAPH_OT_snap (wmOperatorType *ot) /* identifiers */ ot->name= "Snap Keys"; ot->idname= "GRAPH_OT_snap"; - ot->description= "Snap selected keyframes to the times specified."; + ot->description= "Snap selected keyframes to the chosen times/values."; /* api callbacks */ ot->invoke= WM_menu_invoke; From 9565322d3254eb1ea0a2e3ea3bb42b6b0f5962af Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 11 Jan 2010 06:57:41 +0000 Subject: [PATCH 028/202] Fix [#20600] First added camera is not made active Also forced view align on when adding cameras --- release/scripts/ui/space_info.py | 2 +- source/blender/editors/object/object_add.c | 50 +++++++++++++++++++ source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/release/scripts/ui/space_info.py b/release/scripts/ui/space_info.py index ae21ecd0693..fc0c2e460e6 100644 --- a/release/scripts/ui/space_info.py +++ b/release/scripts/ui/space_info.py @@ -214,7 +214,7 @@ class INFO_MT_add(bpy.types.Menu): layout.operator("object.add", text="Empty", icon='OUTLINER_OB_EMPTY').type = 'EMPTY' layout.separator() - layout.operator("object.add", text="Camera", icon='OUTLINER_OB_CAMERA').type = 'CAMERA' + layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA') layout.operator_context = 'EXEC_SCREEN' layout.operator_menu_enum("object.lamp_add", "type", 'LAMP', text="Lamp", icon='OUTLINER_OB_LAMP') layout.separator() diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index abc182ef7ae..7af66d98df4 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -298,6 +298,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) int enter_editmode; float loc[3], rot[3]; + object_add_generic_invoke_options(C, op); ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); if(type==PFIELD_GUIDE) { @@ -357,6 +358,54 @@ void OBJECT_OT_effector_add(wmOperatorType *ot) ED_object_add_generic_props(ot, TRUE); } +/* ***************** Add Camera *************** */ + +static int object_camera_add_exec(bContext *C, wmOperator *op) +{ + View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d= CTX_wm_region_view3d(C); + Scene *scene= CTX_data_scene(C); + Object *ob; + int enter_editmode; + float loc[3], rot[3]; + + /* force view align for cameras */ + RNA_boolean_set(op->ptr, "view_align", 1); + + object_add_generic_invoke_options(C, op); + ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); + + ob= ED_object_add_type(C, OB_CAMERA, loc, rot, FALSE); + + if (v3d) { + if (v3d->camera == NULL) + v3d->camera = ob; + if (v3d->scenelock && scene->camera==NULL) { + scene->camera = ob; + } + } + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_camera_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Camera"; + ot->description = "Add a camera object to the scene."; + ot->idname= "OBJECT_OT_camera_add"; + + /* api callbacks */ + ot->exec= object_camera_add_exec; + ot->poll= ED_operator_scene_editable; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + ED_object_add_generic_props(ot, TRUE); +} + + /* ***************** add primitives *************** */ static EnumPropertyItem prop_curve_types[] = { @@ -583,6 +632,7 @@ void OBJECT_OT_metaball_add(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", prop_metaball_types, 0, "Primitive", ""); ED_object_add_generic_props(ot, TRUE); } + static int object_add_text_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index d47cecb762b..861b2cc0a6e 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -100,6 +100,7 @@ void OBJECT_OT_text_add(struct wmOperatorType *ot); void OBJECT_OT_armature_add(struct wmOperatorType *ot); void OBJECT_OT_lamp_add(struct wmOperatorType *ot); void OBJECT_OT_effector_add(struct wmOperatorType *ot); +void OBJECT_OT_camera_add(struct wmOperatorType *ot); void OBJECT_OT_group_instance_add(struct wmOperatorType *ot); void OBJECT_OT_duplicates_make_real(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index a1889b97169..5d6636f68d0 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -117,6 +117,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_surface_add); WM_operatortype_append(OBJECT_OT_armature_add); WM_operatortype_append(OBJECT_OT_lamp_add); + WM_operatortype_append(OBJECT_OT_camera_add); WM_operatortype_append(OBJECT_OT_add); WM_operatortype_append(OBJECT_OT_effector_add); WM_operatortype_append(OBJECT_OT_group_instance_add); From 49fc1f9860b5fe3ba628f761a00615a24e054a14 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 11 Jan 2010 10:22:24 +0000 Subject: [PATCH 029/202] Fix #20619: subsurf + explode modifier crash. --- source/blender/blenkernel/intern/modifier.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 89ca48977ba..2985eb7774b 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -7869,7 +7869,7 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, DerivedMesh *to_explode) { DerivedMesh *explode, *dm=to_explode; - MFace *mf=0; + MFace *mf=0, *mface; ParticleSettings *part=psmd->psys->part; ParticleSimulationData sim = {scene, ob, psmd->psys, psmd}; ParticleData *pa=NULL, *pars=psmd->psys->particles; @@ -7885,6 +7885,7 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, totface= dm->getNumFaces(dm); totvert= dm->getNumVerts(dm); + mface= dm->getFaceArray(dm); totpart= psmd->psys->totpart; timestep= psys_get_timestep(&sim); @@ -7905,7 +7906,7 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, else mindex = totvert+facepa[i]; - mf=CDDM_get_face(dm,i); + mf= &mface[i]; /* set face vertices to exist in particle group */ BLI_edgehash_insert(vertpahash, mf->v1, mindex, NULL); @@ -8013,8 +8014,6 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, test_index_face(mf, &explode->faceData, i, (orig_v4 ? 4 : 3)); } - MEM_printmemlist_stats(); - /* cleanup */ BLI_edgehash_free(vertpahash, NULL); From a3e461ce1b863b783219c5488182a4aa66b3e9f7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Jan 2010 10:48:41 +0000 Subject: [PATCH 030/202] - player building again - fix for compiler warnigns - bpath reporting was incorrect --- source/blender/blenkernel/intern/colortools.c | 3 +-- source/blender/blenlib/intern/bpath.c | 5 +++-- source/blender/editors/interface/interface_templates.c | 1 - source/blender/editors/object/object_add.c | 1 - source/blender/imbuf/intern/divers.c | 3 +-- source/blender/windowmanager/intern/wm_operators.c | 7 ++++--- source/blenderplayer/bad_level_call_stubs/stubs.c | 1 + 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index d8975c16cc8..09c65f4b21d 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -768,7 +768,6 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) { ImBuf *tmpbuf; int pixel; - char *tmpcbuf; float *pix_in; float col[3]; int stride= 4; @@ -816,7 +815,7 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) } IMB_rect_from_float(tmpbuf); - SWAP(char *, tmpbuf->rect, ibuf->rect); + SWAP(unsigned int *, tmpbuf->rect, ibuf->rect); IMB_freeImBuf(tmpbuf); diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 626c6ee8443..e448f6a4083 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -62,6 +62,7 @@ #include "BKE_main.h" /* so we can access G.main->*.first */ #include "BKE_sequencer.h" #include "BKE_utildefines.h" +#include "BKE_report.h" //XXX #include "BIF_screen.h" /* only for wait cursor */ // @@ -448,8 +449,8 @@ static void bpath_as_report(struct BPathIterator *bpi, const char *message, Repo BLI_bpathIterator_getPathExpanded(bpi, path_expanded); if(reports) { - if (name) BKE_reportf("%s \"%s\", \"%s\": %s", prefix, name, path_expanded, message); - else BKE_reportf("%s \"%s\": %s", prefix, path_expanded, message); + if (name) BKE_reportf(reports, RPT_INFO, "%s \"%s\", \"%s\": %s", prefix, name, path_expanded, message); + else BKE_reportf(reports, RPT_INFO, "%s \"%s\": %s", prefix, path_expanded, message); } } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 5852f8f8873..0cb916d7448 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1869,7 +1869,6 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, char *propname, int PropertyRNA *prop= RNA_struct_find_property(ptr, propname); uiBlock *block= uiLayoutGetBlock(layout); uiLayout *col, *row; - uiBut *but; if (!prop) { printf("uiTemplateColorWheel: property not found: %s\n", propname); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 7af66d98df4..28ddf07fe8e 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -363,7 +363,6 @@ void OBJECT_OT_effector_add(wmOperatorType *ot) static int object_camera_add_exec(bContext *C, wmOperator *op) { View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); Scene *scene= CTX_data_scene(C); Object *ob; int enter_editmode; diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index bcf913e6caf..93bfec823e9 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -180,7 +180,7 @@ void IMB_rect_from_float(struct ImBuf *ibuf) { /* quick method to convert floatbuf to byte */ float *tof = (float *)ibuf->rect_float; - int do_dither = ibuf->dither != 0.f; +// int do_dither = ibuf->dither != 0.f; float dither= ibuf->dither / 255.0; float srgb[4]; int i, channels= ibuf->channels; @@ -241,7 +241,6 @@ void IMB_rect_from_float(struct ImBuf *ibuf) } else { if (dither != 0.f) { - float col[3]; for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof+=4) { const float d = (BLI_frand()-0.5)*dither; const float col[4] = {d+tof[0], d+tof[1], d+tof[2], d+tof[3]}; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1d9687a2d94..88ac8986936 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -934,11 +934,12 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unuse uiLayout *layout, *split, *col; uiStyle *style= U.uistyles.first; struct RecentFile *recent; - int i, ver_width, rev_width; + int i; + +#ifdef NAN_BUILDINFO + int ver_width, rev_width; char *version_str = NULL; char *revision_str = NULL; - -#ifdef NAN_BUILDINFO char version_buf[128]; char revision_buf[128]; extern char * build_rev; diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 6c2d0b1a25b..190b64781e2 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -102,6 +102,7 @@ int ED_space_image_show_render(struct SpaceImage *sima){return 0;} int ED_space_image_show_paint(struct SpaceImage *sima){return 0;} void ED_space_image_set(struct bContext *C, struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima){} struct ImBuf *ED_space_image_buffer(struct SpaceImage *sima){return (struct ImBuf *) NULL;} +void ED_screen_set_scene(struct bContext *C, struct Scene *scene){} struct PTCacheEdit *PE_get_current(struct Scene *scene, struct Object *ob){return (struct PTCacheEdit *) NULL;} void PE_current_changed(struct Scene *scene, struct Object *ob){} From ebb9286fd65d3cb1aae001080dbdb7102e7b49bf Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 11 Jan 2010 11:11:21 +0000 Subject: [PATCH 031/202] Fix for cmake + windows debug build crash on startup, PYTHONPATH needs to be set, Py_SetPythonHome seems insufficient. Not sure why this is needed or if there is a better solution, but couldn't find another one. --- source/blender/python/intern/bpy_interface.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 2c1edc965e9..611521073ef 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -299,9 +299,20 @@ void BPY_start_python_path(void) \nThis may make python import function fail\n"); #endif -#if 0 - BLI_setenv("PYTHONHOME", py_path_bundle); - BLI_setenv("PYTHONPATH", py_path_bundle); +#ifdef _WIN32 + /* cmake/MSVC debug build crashes without this, why only + in this case is unknown.. */ + { + char *envpath = getenv("PYTHONPATH"); + + if(envpath && envpath[0]) { + char *newenvpath = BLI_sprintfN("%s;%s", py_path_bundle, envpath); + BLI_setenv("PYTHONPATH", newenvpath); + MEM_freeN(newenvpath); + } + else + BLI_setenv("PYTHONPATH", py_path_bundle); + } #endif { From 4a011a99cb9f45e0d76b134d72c2c2ab150ba006 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Mon, 11 Jan 2010 11:14:36 +0000 Subject: [PATCH 032/202] Multitouch trackpad 2 fingers gestures implementation - 2 fingers scroll (MOUSEPAN / GHOST_kTrackpadEventScroll event) pans/scrolls the view - 2 fingers pinch (MOUSEZOOM / GHOST_kTrackpadEventMagnify event) zooms the view And in 3D view: - alt + 2 fingers scroll rotates the view - 2 fingers rotation (MOUSEROTATE / GHOST_kTrackpadEventRotate) orbits the view. The implementation uses a new GHOST event type: GHOST_kEventTrackpad, that is then dispatched as Blender MOUSEPAN, MOUSEZOOM or MOUSEROTATE events. This is currently fully implemented for OSX (GHOST Cocoa fires the new events), with auto-detection of the source peripheral, so that a regular mouse still sends MOUSEWHEEL events. --- intern/ghost/GHOST_Types.h | 23 +++++ intern/ghost/intern/GHOST_EventTrackpad.h | 71 +++++++++++++++ intern/ghost/intern/GHOST_SystemCocoa.mm | 80 ++++++++++++++--- source/blender/editors/interface/view2d_ops.c | 35 ++++++++ .../blender/editors/space_image/image_ops.c | 35 +++++++- .../blender/editors/space_image/space_image.c | 2 + .../blender/editors/space_outliner/outliner.c | 3 + .../blender/editors/space_text/space_text.c | 1 + source/blender/editors/space_text/text_ops.c | 53 +++++++---- .../editors/space_view3d/view3d_edit.c | 88 +++++++++++++++---- .../blender/editors/space_view3d/view3d_ops.c | 5 ++ source/blender/makesrna/intern/rna_wm.c | 6 ++ .../windowmanager/intern/wm_event_system.c | 34 +++++++ source/blender/windowmanager/wm_event_types.h | 10 ++- 14 files changed, 389 insertions(+), 57 deletions(-) create mode 100644 intern/ghost/intern/GHOST_EventTrackpad.h diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 5c888e218d8..e26013c1ecd 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -151,6 +151,7 @@ typedef enum { GHOST_kEventButtonDown, /// Mouse button event GHOST_kEventButtonUp, /// Mouse button event GHOST_kEventWheel, /// Mouse wheel event + GHOST_kEventTrackpad, /// Trackpad event GHOST_kEventNDOFMotion, /// N degree of freedom device motion event GHOST_kEventNDOFButton, /// N degree of freedom device button event @@ -373,6 +374,28 @@ typedef struct { GHOST_TInt32 z; } GHOST_TEventWheelData; +typedef enum { + GHOST_kTrackpadEventUnknown =0, + GHOST_kTrackpadEventScroll, + GHOST_kTrackpadEventRotate, + GHOST_kTrackpadEventSwipe, /* Reserved, not used for now */ + GHOST_kTrackpadEventMagnify +} GHOST_TTrackpadEventSubTypes; + + +typedef struct { + /** The event subtype */ + GHOST_TTrackpadEventSubTypes subtype; + /** The x-location of the trackpad event */ + GHOST_TInt32 x; + /** The y-location of the trackpad event */ + GHOST_TInt32 y; + /** The x-delta or value of the trackpad event */ + GHOST_TInt32 deltaX; + /** The y-delta (currently only for scroll subtype) of the trackpad event */ + GHOST_TInt32 deltaY; +} GHOST_TEventTrackpadData; + typedef enum { GHOST_kDragnDropTypeUnknown =0, diff --git a/intern/ghost/intern/GHOST_EventTrackpad.h b/intern/ghost/intern/GHOST_EventTrackpad.h new file mode 100644 index 00000000000..c2332d8e920 --- /dev/null +++ b/intern/ghost/intern/GHOST_EventTrackpad.h @@ -0,0 +1,71 @@ +/** + * $Id$ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): James Deery 11/2009 + * Damien Plisson 12/2009 + * + * ***** END GPL LICENSE BLOCK ***** + */ +/** + * @file GHOST_EventTrackpad.h + * Declaration of GHOST_EventTrackpad class. + */ + +#ifndef _GHOST_EVENT_TRACKPAD_H_ +#define _GHOST_EVENT_TRACKPAD_H_ + +#include "GHOST_Event.h" + +/** + * Trackpad (scroll, magnify, rotate, ...) event. + */ +class GHOST_EventTrackpad : public GHOST_Event +{ +public: + /** + * Constructor. + * @param msec The time this event was generated. + * @param type The type of this event. + * @param subtype The subtype of the event. + * @param x The x-delta of the pan event. + * @param y The y-delta of the pan event. + */ + GHOST_EventTrackpad(GHOST_TUns64 msec, GHOST_IWindow* window, GHOST_TTrackpadEventSubTypes subtype, GHOST_TInt32 x, GHOST_TInt32 y, GHOST_TInt32 deltaX, GHOST_TInt32 deltaY) + : GHOST_Event(msec, GHOST_kEventTrackpad, window) + { + m_trackpadEventData.subtype = subtype; + m_trackpadEventData.x = x; + m_trackpadEventData.y = y; + m_trackpadEventData.deltaX = deltaX; + m_trackpadEventData.deltaY = deltaY; + m_data = &m_trackpadEventData; + } + +protected: + /** The mouse pan data */ + GHOST_TEventTrackpadData m_trackpadEventData; +}; + + +#endif // _GHOST_EVENT_PAN_H_ + diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 1ba20315512..735efcda395 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -41,6 +41,7 @@ #include "GHOST_EventCursor.h" #include "GHOST_EventWheel.h" #include "GHOST_EventNDOF.h" +#include "GHOST_EventTrackpad.h" #include "GHOST_EventDragnDrop.h" #include "GHOST_TimerManager.h" @@ -376,6 +377,24 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar) #pragma mark defines for 10.6 api not documented in 10.5 #ifndef MAC_OS_X_VERSION_10_6 +enum { + /* The following event types are available on some hardware on 10.5.2 and later */ + NSEventTypeGesture = 29, + NSEventTypeMagnify = 30, + NSEventTypeSwipe = 31, + NSEventTypeRotate = 18, + NSEventTypeBeginGesture = 19, + NSEventTypeEndGesture = 20 +}; + +@interface NSEvent(GestureEvents) +/* This message is valid for events of type NSEventTypeMagnify, on 10.5.2 or later */ +#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 +- (float)magnification; // change in magnification. +#else +- (CGFloat)magnification; // change in magnification. +#endif +@end @interface NSEvent(SnowLeopardEvents) /* modifier keys currently down. This returns the state of devices combined @@ -596,7 +615,7 @@ GHOST_TSuccess GHOST_SystemCocoa::init() } [NSApp finishLaunching]; - + [pool drain]; } return success; @@ -846,7 +865,9 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent) case NSScrollWheel: case NSOtherMouseDown: case NSOtherMouseUp: - case NSOtherMouseDragged: + case NSOtherMouseDragged: + case NSEventTypeMagnify: + case NSEventTypeRotate: handleMouseEvent(event); break; @@ -855,11 +876,9 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent) handleTabletEvent(event,[event type]); break; - /* Trackpad features, will need OS X 10.6 for implementation + /* Trackpad features, fired only from OS X 10.5.2 case NSEventTypeGesture: - case NSEventTypeMagnify: case NSEventTypeSwipe: - case NSEventTypeRotate: case NSEventTypeBeginGesture: case NSEventTypeEndGesture: break; */ @@ -1316,16 +1335,53 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) case NSScrollWheel: { - GHOST_TInt32 delta; - - double deltaF = [event deltaY]; - if (deltaF == 0.0) break; //discard trackpad delta=0 events - - delta = deltaF > 0.0 ? 1 : -1; - pushEvent(new GHOST_EventWheel([event timestamp]*1000, window, delta)); + /* Send Wheel event if sent from the mouse, trackpad event otherwise */ + if ([event subtype] == NSMouseEventSubtype) { + GHOST_TInt32 delta; + + double deltaF = [event deltaY]; + if (deltaF == 0.0) break; //discard trackpad delta=0 events + + delta = deltaF > 0.0 ? 1 : -1; + pushEvent(new GHOST_EventWheel([event timestamp]*1000, window, delta)); + } + else { + NSPoint mousePos = [event locationInWindow]; + double dx = [event deltaX]; + double dy = -[event deltaY]; + + const double deltaMax = 50.0; + + if ((dx == 0) && (dy == 0)) break; + + /* Quadratic acceleration */ + dx = dx*(fabs(dx)+0.5); + if (dx<0.0) dx-=0.5; else dx+=0.5; + if (dx< -deltaMax) dx= -deltaMax; else if (dx>deltaMax) dx=deltaMax; + + dy = dy*(fabs(dy)+0.5); + if (dy<0.0) dy-=0.5; else dy+=0.5; + if (dy< -deltaMax) dy= -deltaMax; else if (dy>deltaMax) dy=deltaMax; + + pushEvent(new GHOST_EventTrackpad([event timestamp]*1000, window, GHOST_kTrackpadEventScroll, mousePos.x, mousePos.y, dx, dy)); + } } break; + case NSEventTypeMagnify: + { + NSPoint mousePos = [event locationInWindow]; + pushEvent(new GHOST_EventTrackpad([event timestamp]*1000, window, GHOST_kTrackpadEventMagnify, mousePos.x, mousePos.y, + [event magnification]*250.0 + 0.1, 0)); + } + break; + + case NSEventTypeRotate: + { + NSPoint mousePos = [event locationInWindow]; + pushEvent(new GHOST_EventTrackpad([event timestamp]*1000, window, GHOST_kTrackpadEventRotate, mousePos.x, mousePos.y, + -[event rotation] * 5.0, 0)); + } default: return GHOST_kFailure; break; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 57882b7dd0d..bd325eb79eb 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -199,6 +199,16 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) /* set initial settings */ vpd->startx= vpd->lastx= event->x; vpd->starty= vpd->lasty= event->y; + + if (event->type == MOUSEPAN) { + RNA_int_set(op->ptr, "deltax", event->prevx - event->x); + RNA_int_set(op->ptr, "deltay", event->prevy - event->y); + + view_pan_apply(C, op); + view_pan_exit(C, op); + return OPERATOR_FINISHED; + } + RNA_int_set(op->ptr, "deltax", 0); RNA_int_set(op->ptr, "deltay", 0); @@ -789,6 +799,26 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) vzd= op->customdata; v2d= vzd->v2d; + if (event->type == MOUSEZOOM) { + float dx, dy, fac; + + vzd->lastx= event->prevx; + vzd->lasty= event->prevy; + + /* As we have only 1D information (magnify value), feed both axes + with magnify information that is stored in x axis */ + fac= 0.01f * (event->x - event->prevx); + dx= fac * (v2d->cur.xmax - v2d->cur.xmin) / 10.0f; + dy= fac * (v2d->cur.ymax - v2d->cur.ymin) / 10.0f; + + RNA_float_set(op->ptr, "deltax", dx); + RNA_float_set(op->ptr, "deltay", dy); + + view_zoomdrag_apply(C, op); + view_zoomdrag_exit(C, op); + return OPERATOR_FINISHED; + } + /* set initial settings */ vzd->lastx= event->x; vzd->lasty= event->y; @@ -1467,6 +1497,8 @@ void UI_view2d_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MOUSEPAN, 0, 0, 0); + WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_right", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_left", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0); @@ -1489,6 +1521,7 @@ void UI_view2d_keymap(wmKeyConfig *keyconf) /* zoom - drag */ WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEZOOM, 0, 0, 0); /* borderzoom - drag */ WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0); @@ -1499,9 +1532,11 @@ void UI_view2d_keymap(wmKeyConfig *keyconf) /* Alternative keymap for buttons listview */ keymap= WM_keymap_find(keyconf, "View2D Buttons List", 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MOUSEPAN, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", WHEELUPMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEZOOM, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_out", PADMINUS, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_reset", HOMEKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 827b2ddeac2..cef92153725 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -214,8 +214,21 @@ static int view_pan_exec(bContext *C, wmOperator *op) static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) { - view_pan_init(C, op, event); - return OPERATOR_RUNNING_MODAL; + if (event->type == MOUSEPAN) { + SpaceImage *sima= CTX_wm_space_image(C); + float offset[2]; + + offset[0]= (event->x - event->prevx)/sima->zoom; + offset[1]= (event->y - event->prevy)/sima->zoom; + RNA_float_set_array(op->ptr, "offset", offset); + + view_pan_exec(C, op); + return OPERATOR_FINISHED; + } + else { + view_pan_init(C, op, event); + return OPERATOR_RUNNING_MODAL; + } } static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) @@ -331,8 +344,22 @@ static int view_zoom_exec(bContext *C, wmOperator *op) static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event) { - view_zoom_init(C, op, event); - return OPERATOR_RUNNING_MODAL; + if (event->type == MOUSEZOOM) { + SpaceImage *sima= CTX_wm_space_image(C); + ARegion *ar= CTX_wm_region(C); + float factor; + + factor= 1.0 + (event->x-event->prevx+event->y-event->prevy)/300.0f; + RNA_float_set(op->ptr, "factor", factor); + sima_zoom_set(sima, ar, sima->zoom*factor); + ED_area_tag_redraw(CTX_wm_area(C)); + + return OPERATOR_FINISHED; + } + else { + view_zoom_init(C, op, event); + return OPERATOR_RUNNING_MODAL; + } } static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 4622962bac5..6c325d9722f 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -219,12 +219,14 @@ void image_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "IMAGE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MIDDLEMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MOUSEPAN, 0, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_in", WHEELINMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_out", WHEELOUTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_out", PADMINUS, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom", MOUSEZOOM, 0, 0, 0); RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f); RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f); diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 93b32086614..79a16a50544 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -5104,6 +5104,9 @@ static char *keymap_mouse_menu(void) str += sprintf(str, formatstr, "Wheel Down", WHEELDOWNMOUSE); str += sprintf(str, formatstr, "Wheel In", WHEELINMOUSE); str += sprintf(str, formatstr, "Wheel Out", WHEELOUTMOUSE); + str += sprintf(str, formatstr, "Mouse/Trackpad Pan", MOUSEPAN); + str += sprintf(str, formatstr, "Mouse/Trackpad Zoom", MOUSEZOOM); + str += sprintf(str, formatstr, "Mouse/Trackpad Rotate", MOUSEROTATE); return string; } diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 292249bb0e8..c7601ef692e 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -313,6 +313,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_overwrite_toggle", INSERTKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_scroll", MIDDLEMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "TEXT_OT_scroll", MOUSEPAN, 0, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_scroll_bar", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_cursor_set", LEFTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "TEXT_OT_cursor_set", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select", 1); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 0504db51a72..e5a1e772523 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1720,25 +1720,6 @@ static int scroll_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int scroll_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - SpaceText *st= CTX_wm_space_text(C); - TextScroll *tsc; - - if(RNA_property_is_set(op->ptr, "lines")) - return scroll_exec(C, op); - - tsc= MEM_callocN(sizeof(TextScroll), "TextScroll"); - tsc->first= 1; - op->customdata= tsc; - - st->flags|= ST_SCROLL_SELECT; - - WM_event_add_modal_handler(C, op); - - return OPERATOR_RUNNING_MODAL; -} - static void scroll_apply(bContext *C, wmOperator *op, wmEvent *event) { SpaceText *st= CTX_wm_space_text(C); @@ -1816,6 +1797,40 @@ static int scroll_cancel(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } +static int scroll_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + SpaceText *st= CTX_wm_space_text(C); + TextScroll *tsc; + + if(RNA_property_is_set(op->ptr, "lines")) + return scroll_exec(C, op); + + tsc= MEM_callocN(sizeof(TextScroll), "TextScroll"); + tsc->first= 1; + op->customdata= tsc; + + st->flags|= ST_SCROLL_SELECT; + + if (event->type == MOUSEPAN) { + text_update_character_width(st); + + tsc->hold[0] = event->prevx; + tsc->hold[1] = event->prevy; + /* Sensitivity of scroll set to 4pix per line/char */ + event->mval[0] = event->prevx + (event->x - event->prevx)*st->cwidth/4; + event->mval[1] = event->prevy + (event->y - event->prevy)*st->lheight/4; + tsc->first = 0; + tsc->scrollbar = 0; + scroll_apply(C, op, event); + scroll_exit(C, op); + return OPERATOR_FINISHED; + } + + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; +} + void TEXT_OT_scroll(wmOperatorType *ot) { /* identifiers */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 1e23d27fe77..288918c3c1e 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -554,7 +554,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) invert_m3_m3(m_inv,m); /* Determine the direction of the x vector (for rotating up and down) */ - /* This can likely be compuated directly from the quaternion. */ + /* This can likely be computed directly from the quaternion. */ mul_m3_v3(m_inv,xvec); /* Perform the up/down rotation */ @@ -690,11 +690,30 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event) vod->rv3d->persp= RV3D_PERSP; ED_region_tag_redraw(vod->ar); } + + if (event->type == MOUSEPAN) { + viewrotate_apply(vod, event->prevx, event->prevy); + request_depth_update(CTX_wm_region_view3d(C)); + + viewops_data_free(C, op); + + return OPERATOR_FINISHED; + } + else if (event->type == MOUSEROTATE) { + /* MOUSEROTATE performs orbital rotation, so y axis delta is set to 0 */ + viewrotate_apply(vod, event->prevx, event->y); + request_depth_update(CTX_wm_region_view3d(C)); + + viewops_data_free(C, op); + + return OPERATOR_FINISHED; + } + else { + /* add temp handler */ + WM_event_add_modal_handler(C, op); - /* add temp handler */ - WM_event_add_modal_handler(C, op); - - return OPERATOR_RUNNING_MODAL; + return OPERATOR_RUNNING_MODAL; + } } static int ED_operator_view3d_rotate(bContext *C) @@ -838,13 +857,23 @@ static int viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) /* makes op->customdata */ viewops_data_create(C, op, event); - /* add temp handler */ - WM_event_add_modal_handler(C, op); + if (event->type == MOUSEPAN) { + ViewOpsData *vod= op->customdata; + viewmove_apply(vod, event->prevx, event->prevy); + request_depth_update(CTX_wm_region_view3d(C)); + + viewops_data_free(C, op); + + return OPERATOR_FINISHED; + } + else { + /* add temp handler */ + WM_event_add_modal_handler(C, op); - return OPERATOR_RUNNING_MODAL; + return OPERATOR_RUNNING_MODAL; + } } - void VIEW3D_OT_move(wmOperatorType *ot) { @@ -940,11 +969,11 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my) } -static void viewzoom_apply(ViewOpsData *vod, int x, int y) +static void viewzoom_apply(ViewOpsData *vod, int x, int y, short viewzoom) { float zfac=1.0; - if(U.viewzoom==USER_ZOOM_CONT) { + if(viewzoom==USER_ZOOM_CONT) { double time= PIL_check_seconds_timer(); float time_step= (float)(time - vod->timer_lastdraw); @@ -952,7 +981,7 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y) zfac = 1.0f + (((float)(vod->origx - x + vod->origy - y)/20.0) * time_step); vod->timer_lastdraw= time; } - else if(U.viewzoom==USER_ZOOM_SCALE) { + else if(viewzoom==USER_ZOOM_SCALE) { int ctr[2], len1, len2; // method which zooms based on how far you move the mouse @@ -986,7 +1015,7 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y) view_zoom_mouseloc(vod->ar, zfac, vod->oldx, vod->oldy); - if ((U.uiflag & USER_ORBIT_ZBUF) && (U.viewzoom==USER_ZOOM_CONT) && (vod->rv3d->persp==RV3D_PERSP)) { + if ((U.uiflag & USER_ORBIT_ZBUF) && (viewzoom==USER_ZOOM_CONT) && (vod->rv3d->persp==RV3D_PERSP)) { float upvec[3], mat[3][3]; /* Secret apricot feature, translate the view when in continues mode */ @@ -1043,7 +1072,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, wmEvent *event) } if(event_code==VIEW_APPLY) { - viewzoom_apply(vod, event->x, event->y); + viewzoom_apply(vod, event->x, event->y, U.viewzoom); } else if (event_code==VIEW_CONFIRM) { request_depth_update(CTX_wm_region_view3d(C)); @@ -1114,13 +1143,34 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) vod= op->customdata; - vod->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f); - vod->timer_lastdraw= PIL_check_seconds_timer(); + if (event->type == MOUSEZOOM) { + if (U.uiflag & USER_ZOOM_INVERT) /* Bypass Zoom invert flag */ + SWAP(int, event->x, event->prevx); - /* add temp handler */ - WM_event_add_modal_handler(C, op); + if (U.uiflag & USER_ZOOM_DOLLY_HORIZ) { + vod->origx = vod->oldx = event->x; + viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY); + } + else { + + /* Set y move = x move as MOUSEZOOM uses only x axis to pass magnification value */ + vod->origy = vod->oldy = event->x; + viewzoom_apply(vod, event->x, event->prevx, USER_ZOOM_DOLLY); + } + request_depth_update(CTX_wm_region_view3d(C)); + + viewops_data_free(C, op); + return OPERATOR_FINISHED; + } + else { + vod->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f); + vod->timer_lastdraw= PIL_check_seconds_timer(); - return OPERATOR_RUNNING_MODAL; + /* add temp handler */ + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; + } } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 2bcd78b3d3d..2e134da7e02 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -133,6 +133,11 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "VIEW3D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEPAN, 0, KM_ALT, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEROTATE, 0, 0, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_move", MOUSEPAN, 0, 0, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MOUSEZOOM, 0, 0, 0); + RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADMINUS, KM_PRESS, 0, 0)->ptr, "delta", -1); RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELINMOUSE, KM_PRESS, 0, 0)->ptr, "delta", 1); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 513f2f8f0ec..a3a2bc35dc1 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -85,6 +85,9 @@ EnumPropertyItem event_mouse_type_items[]= { {SELECTMOUSE, "SELECTMOUSE", 0, "Select", ""}, {0, "", 0, NULL, NULL}, {MOUSEMOVE, "MOUSEMOVE", 0, "Move", ""}, + {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""}, + {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""}, + {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""}, {0, "", 0, NULL, NULL}, {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""}, {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""}, @@ -112,6 +115,9 @@ EnumPropertyItem event_type_items[] = { {SELECTMOUSE, "SELECTMOUSE", 0, "Select Mouse", ""}, {0, "", 0, NULL, NULL}, {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", ""}, + {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""}, + {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""}, + {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""}, {0, "", 0, NULL, NULL}, {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""}, {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""}, diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index aff843dc1cb..f513488eca8 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1760,6 +1760,40 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata) } break; } + case GHOST_kEventTrackpad: { + if (win->active) { + GHOST_TEventTrackpadData * pd = customdata; + switch (pd->subtype) { + case GHOST_kTrackpadEventMagnify: + event.type = MOUSEZOOM; + break; + case GHOST_kTrackpadEventRotate: + event.type = MOUSEROTATE; + break; + case GHOST_kTrackpadEventScroll: + default: + event.type= MOUSEPAN; + break; + } +#if defined(__APPLE__) && defined(GHOST_COCOA) + //Cocoa already uses coordinates with y=0 at bottom, and returns inwindow coordinates on mouse moved event + event.x= evt->x = pd->x; + event.y = evt->y = pd->y; +#else + int cx, cy; + GHOST_ScreenToClient(win->ghostwin, pd->x, pd->y, &cx, &cy); + event.x= evt->x= cx; + event.y= evt->y= (win->sizey-1) - cy; +#endif + // Use prevx/prevy so we can calculate the delta later + event.prevx= event.x - pd->deltaX; + event.prevy= event.y - pd->deltaY; + + update_tablet_data(win, &event); + wm_event_add(win, &event); + } + break; + } /* mouse button */ case GHOST_kEventButtonDown: case GHOST_kEventButtonUp: { diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 8179154fc98..a90eb702069 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -56,9 +56,13 @@ /* only use if you want user option switch possible */ #define ACTIONMOUSE 0x005 #define SELECTMOUSE 0x006 -/* Extra mouse buttons */ + /* Extra mouse buttons */ #define BUTTON4MOUSE 0x007 #define BUTTON5MOUSE 0x008 + /* Extra trackpad gestures */ +#define MOUSEPAN 0x00e +#define MOUSEZOOM 0x00f +#define MOUSEROTATE 0x010 /* defaults from ghost */ #define WHEELUPMOUSE 0x00a #define WHEELDOWNMOUSE 0x00b @@ -67,7 +71,7 @@ #define WHEELOUTMOUSE 0x00d -/* SYSTEM : 0x01x */ +/* SYSTEM : 0x01xx */ #define INPUTCHANGE 0x0103 /* input connected or disconnected */ #define WINDEACTIVATE 0x0104 /* window is deactivated, focus lost */ @@ -202,7 +206,7 @@ #define ISKEYBOARD(event) (event >=' ' && event <=320) /* test whether the event is a mouse button */ -#define ISMOUSE(event) (event >= LEFTMOUSE && event <= WHEELOUTMOUSE) +#define ISMOUSE(event) (event >= LEFTMOUSE && event <= MOUSEROTATE) /* test whether the event is timer event */ #define ISTIMER(event) (event >= TIMER && event <= TIMERAUTOSAVE) From d5f5e0cd75ca61fdd9106c21f02b883f7d402b44 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Jan 2010 11:59:14 +0000 Subject: [PATCH 033/202] report errors with library linking errors. uses a hack to set the window for the popup for the menu, which is nasty but artists need to know when their files should not be resaved :( --- source/blender/blenloader/intern/readfile.c | 10 +++++++--- .../editors/interface/interface_regions.c | 4 +++- .../windowmanager/intern/wm_event_system.c | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 7b30ba603ac..5711db97d93 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11947,10 +11947,12 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) FileData *fd= mainptr->curlib->filedata; if(fd==NULL) { - ReportList reports; + /* printf and reports for now... its important users know this */ printf("read library: lib %s\n", mainptr->curlib->name); - fd= blo_openblenderfile(mainptr->curlib->filename, &reports); + BKE_reportf(basefd->reports, RPT_INFO, "read library: lib %s\n", mainptr->curlib->name); + + fd= blo_openblenderfile(mainptr->curlib->filename, basefd->reports); if (fd) { fd->reports= basefd->reports; @@ -11968,8 +11970,10 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) } else mainptr->curlib->filedata= NULL; - if (fd==NULL) + if (fd==NULL) { printf("ERROR: can't find lib %s \n", mainptr->curlib->filename); + BKE_reportf(basefd->reports, RPT_ERROR, "Can't find lib %s (CAREFUL, DON'T RE-SAVE\n", mainptr->curlib->filename); + } } if(fd) { doit= 1; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 6bc4e7b0b65..3a02b1f7e0c 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2229,7 +2229,9 @@ void uiPupMenuReports(bContext *C, ReportList *reports) ds= BLI_dynstr_new(); for(report=reports->list.first; report; report=report->next) { - if(report->type >= RPT_ERROR) + if(report->type <= reports->printlevel) + ; /* pass */ + else if(report->type >= RPT_ERROR) BLI_dynstr_appendf(ds, "Error %%i%d%%t|%s", ICON_ERROR, report->message); else if(report->type >= RPT_WARNING) BLI_dynstr_appendf(ds, "Warning %%i%d%%t|%s", ICON_ERROR, report->message); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index f513488eca8..5f864a97d3b 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1060,6 +1060,8 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa wm_handler_op_context(C, handler); + /* needed for uiPupMenuReports */ + if(event->val==EVT_FILESELECT_EXEC) { /* a bit weak, might become arg for WM_event_fileselect? */ /* XXX also extension code in image-save doesnt work for this yet */ @@ -1074,6 +1076,21 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa if(G.f & G_DEBUG) wm_operator_print(handler->op); + if(handler->op->reports->list.first) { + + /* FIXME, temp setting window, this is really bad! + * only have because lib linking errors need to be seen by users :( + * it can be removed without breaking anything but then no linking errors - campbell */ + wmWindow *win_prev= CTX_wm_window(C); + if(win_prev==NULL) + CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); + + handler->op->reports->printlevel = RPT_WARNING; + uiPupMenuReports(C, handler->op->reports); + + CTX_wm_window_set(C, win_prev); + } + WM_operator_free(handler->op); } } From 276f60536fa5f38a1929ab341c2a02200f3db37f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Jan 2010 12:24:08 +0000 Subject: [PATCH 034/202] better reporting for lib linking problems note that errors are displayed upside down --- source/blender/blenloader/intern/readfile.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5711db97d93..6bf347e9bd5 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4236,6 +4236,7 @@ static void lib_link_scene(FileData *fd, Main *main) if(base->object==NULL) { printf("LIB ERROR: base removed\n"); + BKE_reportf(fd->reports, RPT_ERROR, "LIB ERROR: Object lost from scene:'%s\'\n", sce->id.name+2); BLI_remlink(&sce->base, base); if(base==sce->basact) sce->basact= 0; MEM_freeN(base); @@ -11949,8 +11950,8 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) if(fd==NULL) { /* printf and reports for now... its important users know this */ - printf("read library: lib %s\n", mainptr->curlib->name); - BKE_reportf(basefd->reports, RPT_INFO, "read library: lib %s\n", mainptr->curlib->name); + printf("read library: %s\n", mainptr->curlib->name); + BKE_reportf(basefd->reports, RPT_INFO, "read library: '%s'\n", mainptr->curlib->name); fd= blo_openblenderfile(mainptr->curlib->filename, basefd->reports); @@ -11972,7 +11973,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) if (fd==NULL) { printf("ERROR: can't find lib %s \n", mainptr->curlib->filename); - BKE_reportf(basefd->reports, RPT_ERROR, "Can't find lib %s (CAREFUL, DON'T RE-SAVE\n", mainptr->curlib->filename); + BKE_reportf(basefd->reports, RPT_ERROR, "Can't find lib '%s'\n", mainptr->curlib->filename); } } if(fd) { @@ -11988,8 +11989,10 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) BLI_remlink(lbarray[a], id); append_id_part(fd, mainptr, id, &realid); - if (!realid) + if (!realid) { printf("LIB ERROR: can't find %s\n", id->name); + BKE_reportf(fd->reports, RPT_ERROR, "LIB ERROR: %s:'%s' missing from '%s'\n", BLO_idcode_to_name(GS(id->name)), id->name+2, mainptr->curlib->filename); + } change_idid_adr(mainlist, basefd, id, realid); @@ -12025,6 +12028,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) BLI_remlink(lbarray[a], id); printf("LIB ERROR: can't find %s\n", id->name); + BKE_reportf(basefd->reports, RPT_ERROR, "LIB ERROR: %s:'%s' missing from '%s'\n", BLO_idcode_to_name(GS(id->name)), id->name+2, mainptr->curlib->filename); change_idid_adr(mainlist, basefd, id, NULL); MEM_freeN(id); From 42afb591844d71335eda0327d6e7c21342328482 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Jan 2010 13:54:00 +0000 Subject: [PATCH 035/202] remove operators PARTICLE_OT_brush_set and PARTICLE_OT_edit_type_set, rna data access and menu's can replace --- .../blender/editors/physics/particle_edit.c | 73 ------------------- .../blender/editors/physics/physics_intern.h | 1 - source/blender/editors/physics/physics_ops.c | 1 - .../makesrna/intern/rna_sculpt_paint.c | 2 +- 4 files changed, 1 insertion(+), 76 deletions(-) diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 8a73dc0e050..c510a28b7ad 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2695,79 +2695,6 @@ void PARTICLE_OT_mirror(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/*********************** set brush operator **********************/ - -static EnumPropertyItem brush_type_items[]= { - {PE_BRUSH_NONE, "NONE", 0, "None", ""}, - {PE_BRUSH_COMB, "COMB", 0, "Comb", ""}, - {PE_BRUSH_SMOOTH, "SMOOTH", 0, "Smooth", ""}, - {PE_BRUSH_ADD, "ADD", 0, "Add", ""}, - {PE_BRUSH_LENGTH, "LENGTH", 0, "Length", ""}, - {PE_BRUSH_PUFF, "PUFF", 0, "Puff", ""}, - {PE_BRUSH_CUT, "CUT", 0, "Cut", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static int set_brush_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - ParticleEditSettings *pset= PE_settings(scene); - - pset->brushtype= RNA_enum_get(op->ptr, "type"); - - return OPERATOR_FINISHED; -} - -void PARTICLE_OT_brush_set(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Set Brush"; - ot->idname= "PARTICLE_OT_brush_set"; - - /* api callbacks */ - ot->exec= set_brush_exec; - ot->invoke= WM_menu_invoke; - ot->poll= PE_poll; - - /* properties */ - RNA_def_enum(ot->srna, "type", brush_type_items, PE_BRUSH_NONE, "Type", "Brush type to select for editing."); -} - - -/*********************** set mode operator **********************/ - -static EnumPropertyItem edit_type_items[]= { - {PE_TYPE_PARTICLES, "PARTICLES", 0, "Particles", ""}, - {PE_TYPE_SOFTBODY, "SOFTBODY", 0, "Soft body", ""}, - {PE_TYPE_CLOTH, "CLOTH", 0, "Cloth", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static int set_edit_mode_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - ParticleEditSettings *pset= PE_settings(scene); - - pset->edittype= RNA_enum_get(op->ptr, "type"); - - return OPERATOR_FINISHED; -} - -void PARTICLE_OT_edit_type_set(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Set Edit Type"; - ot->idname= "PARTICLE_OT_edit_type_set"; - - /* api callbacks */ - ot->exec= set_edit_mode_exec; - ot->invoke= WM_menu_invoke; - ot->poll= PE_poll; - - /* properties */ - RNA_def_enum(ot->srna, "type", edit_type_items, PE_TYPE_PARTICLES, "Type", "Edit type to select for editing."); -} - /************************* brush edit callbacks ********************/ static void brush_comb(PEData *data, float mat[][4], float imat[][4], int point_index, int key_index, PTCacheEditKey *key) diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index e1b1a8b90a8..cc0a288f8be 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -53,7 +53,6 @@ void PARTICLE_OT_remove_doubles(struct wmOperatorType *ot); void PARTICLE_OT_delete(struct wmOperatorType *ot); void PARTICLE_OT_mirror(struct wmOperatorType *ot); -void PARTICLE_OT_brush_set(struct wmOperatorType *ot); void PARTICLE_OT_brush_edit(struct wmOperatorType *ot); void PARTICLE_OT_brush_radial_control(struct wmOperatorType *ot); diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 24b3881d6b8..5cb8230e463 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -60,7 +60,6 @@ static void operatortypes_particle(void) WM_operatortype_append(PARTICLE_OT_delete); WM_operatortype_append(PARTICLE_OT_mirror); - WM_operatortype_append(PARTICLE_OT_brush_set); WM_operatortype_append(PARTICLE_OT_brush_edit); WM_operatortype_append(PARTICLE_OT_brush_radial_control); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 99bee9413cd..528d61271f5 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -36,7 +36,7 @@ #include "WM_types.h" -static EnumPropertyItem particle_edit_hair_brush_items[] = { +EnumPropertyItem particle_edit_hair_brush_items[] = { {PE_BRUSH_NONE, "NONE", 0, "None", "Don't use any brush."}, {PE_BRUSH_COMB, "COMB", 0, "Comb", "Comb hairs."}, {PE_BRUSH_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth hairs."}, From 1adab3451594d22d8dbeb41401e75a5f29a4e610 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 11 Jan 2010 14:23:16 +0000 Subject: [PATCH 036/202] Compile Fix for recent multi touch commit. --- source/blender/windowmanager/intern/wm_event_system.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 5f864a97d3b..9a6d02790e5 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1797,10 +1797,12 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata) event.x= evt->x = pd->x; event.y = evt->y = pd->y; #else + { int cx, cy; GHOST_ScreenToClient(win->ghostwin, pd->x, pd->y, &cx, &cy); event.x= evt->x= cx; event.y= evt->y= (win->sizey-1) - cy; + } #endif // Use prevx/prevy so we can calculate the delta later event.prevx= event.x - pd->deltaX; From 9df5bfe404b9c827ebf2e36453e000d72bafc9d4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 11 Jan 2010 15:28:00 +0000 Subject: [PATCH 037/202] Fix wrong icons in shape key panel, not sure why these were specified, they're already defined in RNA. --- release/scripts/ui/properties_data_mesh.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/ui/properties_data_mesh.py b/release/scripts/ui/properties_data_mesh.py index a03d8d55005..2748c5e4c31 100644 --- a/release/scripts/ui/properties_data_mesh.py +++ b/release/scripts/ui/properties_data_mesh.py @@ -207,8 +207,8 @@ class DATA_PT_shape_keys(DataButtonsPanel): sub = row.row(align=True) subsub = sub.row(align=True) subsub.active = enable_edit_value - subsub.prop(ob, "shape_key_lock", icon='PINNED' if ob.shape_key_lock else 'UNPINNED', text="") - subsub.prop(kb, "mute", icon='MUTE_IPO_ON' if kb.mute else 'MUTE_IPO_OFF', text="") + subsub.prop(ob, "shape_key_lock", text="") + subsub.prop(kb, "mute", text="") sub.prop(ob, "shape_key_edit_mode", text="") sub = row.row(align=True) From 491e365514654e14df3afe7e070f6574bf0e8d6e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Jan 2010 18:10:13 +0000 Subject: [PATCH 038/202] - draw mesh wire faded into the 3D view background color when in particle mode, the mesh and particle selection colors conflict too much making it hard to see particles. - show proportional editmode button in particle editmode. --- release/scripts/ui/space_view3d.py | 2 +- .../blender/editors/space_view3d/drawobject.c | 31 +++++++++++++------ .../makesrna/intern/rna_sculpt_paint.c | 2 +- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 8c430d39aa3..30ea8e34710 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -65,7 +65,7 @@ class VIEW3D_HT_header(bpy.types.Header): row.prop(view, "occlude_geometry", text="") # Proportional editing - if obj and obj.mode in ('OBJECT', 'EDIT'): + if obj and obj.mode in ('OBJECT', 'EDIT', 'PARTICLE_EDIT'): row = layout.row(align=True) row.prop(toolsettings, "proportional_editing", text="", icon_only=True) if toolsettings.proportional_editing != 'DISABLED': diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 77d8ed0f24d..3fca79cd2f0 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2489,15 +2489,28 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } if (draw_wire) { - /* If drawing wire and drawtype is not OB_WIRE then we are - * overlaying the wires. - * - * UPDATE bug #10290 - With this wire-only objects can draw - * behind other objects depending on their order in the scene. 2x if 0's below. undo'ing zr's commit: r4059 - * - * if draw wire is 1 then just drawing wire, no need for depth buffer stuff, - * otherwise this wire is to overlay solid mode faces so do some depth buffer tricks. - */ + + /* When using wireframe object traw in particle edit mode + * the mesh gets in the way of seeing the particles, fade the wire color + * with the background. */ + if(ob==OBACT && (ob->mode & OB_MODE_PARTICLE_EDIT)) { + float col_wire[4], col_bg[4], col[3]; + + UI_GetThemeColor3fv(TH_BACK, col_bg); + glGetFloatv(GL_CURRENT_COLOR, col_wire); + interp_v3_v3v3(col, col_bg, col_wire, 0.15); + glColor3fv(col); + } + + /* If drawing wire and drawtype is not OB_WIRE then we are + * overlaying the wires. + * + * UPDATE bug #10290 - With this wire-only objects can draw + * behind other objects depending on their order in the scene. 2x if 0's below. undo'ing zr's commit: r4059 + * + * if draw wire is 1 then just drawing wire, no need for depth buffer stuff, + * otherwise this wire is to overlay solid mode faces so do some depth buffer tricks. + */ if (dt!=OB_WIRE && draw_wire==2) { bglPolygonOffset(rv3d->dist, 1.0); glDepthMask(0); // disable write in zbuffer, selected edge wires show better diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 528d61271f5..99bee9413cd 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -36,7 +36,7 @@ #include "WM_types.h" -EnumPropertyItem particle_edit_hair_brush_items[] = { +static EnumPropertyItem particle_edit_hair_brush_items[] = { {PE_BRUSH_NONE, "NONE", 0, "None", "Don't use any brush."}, {PE_BRUSH_COMB, "COMB", 0, "Comb", "Comb hairs."}, {PE_BRUSH_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth hairs."}, From 393f53fc920e6a99cbe7e4efe51daa8a90ef2384 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Mon, 11 Jan 2010 19:52:03 +0000 Subject: [PATCH 039/202] [#20640] Border/lasso selection zone "translated" when occlude geometry is on Box select for mesh wrongly applied the transformation matrix (it wasn't done for Circle select and that worked correctly). I've just commented and explained the removal, since comments in the matrix setting function seems to indicate that this should be needed (with the call removed, the situations that are noted as problematic still work fine). --- source/blender/editors/space_view3d/view3d_select.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 331d3c4fefe..06f257cbb78 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1361,7 +1361,10 @@ static void do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exte EM_deselect_all(vc->em); } - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ + /* XXX Don't think we need this, it break selection of transformed objects. + * Also, it's not done by Circle select and that works fine + */ + //ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ bbsel= EM_init_backbuf_border(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax); if(ts->selectmode & SCE_SELECT_VERTEX) { @@ -1423,7 +1426,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) rect.xmax= RNA_int_get(op->ptr, "xmax"); rect.ymax= RNA_int_get(op->ptr, "ymax"); extend = RNA_boolean_get(op->ptr, "extend"); - + if(obedit==NULL && (paint_facesel_test(OBACT))) { face_borderselect(C, obact, &rect, selecting, extend); return OPERATOR_FINISHED; From 3b1585b1722efcf06ef9aa8f9d673047e68a7b9d Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Mon, 11 Jan 2010 20:27:52 +0000 Subject: [PATCH 040/202] Apply previous fix to lasso too. --- source/blender/editors/space_view3d/view3d_select.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 06f257cbb78..5d9919ea4c0 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -470,7 +470,8 @@ static void do_lasso_select_mesh(ViewContext *vc, short mcords[][2], short moves /* workaround: init mats first, EM_mask_init_backbuf_border can change view matrix to pixel space, breaking edge select with backbuf .. */ - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ + // XXX not needed anymore, check here if selection is broken + //ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ bbsel= EM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); if(ts->selectmode & SCE_SELECT_VERTEX) { From 689450a8f17c39708e90944555f73aa2f8bb8f17 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Jan 2010 23:40:01 +0000 Subject: [PATCH 041/202] rna/py api bpy.data.groups.new()/remove() bpy.data.actions.new()/remove() --- source/blender/makesrna/RNA_types.h | 2 + source/blender/makesrna/intern/rna_main_api.c | 73 +++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 5ec2320e2dc..b5f3abf8b25 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -333,6 +333,8 @@ typedef struct ExtensionRNA { #define MainLamps Main #define MainObjects Main #define MainTexts Main +#define MainActions Main +#define MainGroups Main #ifdef __cplusplus } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 737f570df67..a1cc8bbabc8 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -47,6 +47,8 @@ #include "BKE_texture.h" #include "BKE_scene.h" #include "BKE_text.h" +#include "BKE_action.h" +#include "BKE_group.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" @@ -55,6 +57,7 @@ #include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_text_types.h" +#include "DNA_group_types.h" #include "ED_screen.h" @@ -179,6 +182,19 @@ void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) /* XXX python now has invalid pointer? */ } +Group *rna_Main_groups_new(Main *bmain, char* name) +{ + return add_group(name); +} +void rna_Main_groups_remove(Main *bmain, ReportList *reports, Group *group) +{ + free_group(group); + unlink_group(group); + group->id.us= 0; + free_libblock(&bmain->group, group); + /* XXX python now has invalid pointer? */ +} + Text *rna_Main_texts_new(Main *bmain, char* name) { return add_empty_text(name); @@ -214,6 +230,23 @@ void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm) /* XXX python now has invalid pointer? */ } +bAction *rna_Main_actions_new(Main *bmain, char* name) +{ + bAction *act= add_empty_action(name); + act->id.us--; + act->id.flag &= ~LIB_FAKEUSER; + return act; +} +void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act) +{ + if(act->id.us == 0) + free_libblock(&bmain->action, act); + else + BKE_reportf(reports, RPT_ERROR, "Action \"%s\" must have zero users to be removed, found %d.", act->id.name+2, act->id.us); + + /* XXX python now has invalid pointer? */ +} + #else void RNA_api_main(StructRNA *srna) @@ -437,7 +470,27 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) } void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) { + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + RNA_def_property_srna(cprop, "MainGroups"); + srna= RNA_def_struct(brna, "MainGroups", NULL); + RNA_def_struct_ui_text(srna, "Main Groups", "Collection of groups."); + + func= RNA_def_function(srna, "new", "rna_Main_groups_new"); + RNA_def_function_ui_description(func, "Add a new group to the main database"); + parm= RNA_def_string(func, "name", "Group", 0, "", "New name for the datablock."); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm= RNA_def_pointer(func, "group", "Group", "", "New group datablock."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "rna_Main_groups_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a group from the current blendfile."); + parm= RNA_def_pointer(func, "group", "Group", "", "Group to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) { @@ -503,7 +556,27 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) } void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop) { + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + RNA_def_property_srna(cprop, "MainActions"); + srna= RNA_def_struct(brna, "MainActions", NULL); + RNA_def_struct_ui_text(srna, "Main Actions", "Collection of actions."); + + func= RNA_def_function(srna, "new", "rna_Main_actions_new"); + RNA_def_function_ui_description(func, "Add a new action to the main database"); + parm= RNA_def_string(func, "name", "Action", 0, "", "New name for the datablock."); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm= RNA_def_pointer(func, "action", "Action", "", "New action datablock."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "rna_Main_actions_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a action from the current blendfile."); + parm= RNA_def_pointer(func, "action", "Action", "", "Action to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) { From 44068d96aa16f7561dfec224776bb16b7f694551 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Tue, 12 Jan 2010 00:26:11 +0000 Subject: [PATCH 042/202] Fixed bug #20155, "When Displaying the mesh angles one of the angles always displays in the middle not at the angle location" --- source/blender/editors/space_view3d/drawobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 3fca79cd2f0..8e269d98014 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2039,7 +2039,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E /* Vec 1 */ sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v4, v1, v2))); interp_v3_v3v3(fvec, efa->cent, efa->v1->co, 0.8f); - view3d_cached_text_draw_add(efa->cent[0], efa->cent[1], efa->cent[2], val, 0); + view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0); } if( (e1->f & e2->f & SELECT) || (G.moving && (efa->v2->f & SELECT)) ) { /* Vec 2 */ From e6c61acb68927519d869d150444e1a58798976d3 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 12 Jan 2010 01:50:34 +0000 Subject: [PATCH 043/202] Fix [#20644] new curve sets itself to the origin, but the pivot to the cursor + Cleaned up the nurbs spin operator and gave it properties rather than relying on context --- source/blender/editors/curve/editcurve.c | 173 +++++++------------ source/blender/editors/include/ED_curve.h | 2 +- source/blender/editors/include/ED_mball.h | 2 +- source/blender/editors/include/ED_object.h | 1 + source/blender/editors/mesh/editmesh_add.c | 32 +--- source/blender/editors/metaball/mball_edit.c | 37 +--- source/blender/editors/object/object_add.c | 49 +++++- 7 files changed, 118 insertions(+), 178 deletions(-) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 20aece9a5fc..f61596f397f 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -3202,45 +3202,25 @@ int mouse_nurb(bContext *C, short mval[2], int extend) * orientation of the global 3d view (yuck yuck!) mode==1 does the same, but doesn't bridge up * up the new geometry, mode==2 now does the same as 0, but aligned to world axes, not the view. */ -static int spin_nurb(bContext *C, Scene *scene, Object *obedit, float *dvec, short mode) +static int spin_nurb(bContext *C, Scene *scene, Object *obedit, float *dvec, float *cent, short mode) { ListBase *editnurb= curve_get_editcurve(obedit); - View3D *v3d= CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); Nurb *nu; - float *curs, si,phi,n[3],q[4],cmat[3][3],tmat[3][3],imat[3][3]; - float cent[3],bmat[3][3], rotmat[3][3], scalemat1[3][3], scalemat2[3][3]; + float si,phi,n[3],q[4],cmat[3][3],tmat[3][3],imat[3][3]; + float bmat[3][3], rotmat[3][3], scalemat1[3][3], scalemat2[3][3]; float persmat[3][3], persinv[3][3]; short a,ok, changed= 0; - if(mode != 2 && rv3d) copy_m3_m4(persmat, rv3d->viewmat); - else unit_m3(persmat); + unit_m3(persmat); invert_m3_m3(persinv, persmat); /* imat and center and size */ copy_m3_m4(bmat, obedit->obmat); invert_m3_m3(imat, bmat); - if(v3d) { - curs= give_cursor(scene, v3d); - VECCOPY(cent, curs); - } - else - cent[0]= cent[1]= cent[2]= 0.0f; - - sub_v3_v3v3(cent, cent, obedit->obmat[3]); - mul_m3_v3(imat,cent); - - if(dvec || mode==2 || !rv3d) { - n[0]=n[1]= 0.0; - n[2]= 1.0; - } else { - n[0]= rv3d->viewinv[2][0]; - n[1]= rv3d->viewinv[2][1]; - n[2]= rv3d->viewinv[2][2]; - normalize_v3(n); - } - + n[0]=n[1]= 0.0; + n[2]= 1.0; + phi= M_PI/8.0; q[0]= cos(phi); si= sin(phi); @@ -3315,8 +3295,12 @@ static int spin_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); - - if(!spin_nurb(C, scene, obedit, 0, 0)) { + float cent[3], axis[3]; + + RNA_float_get_array(op->ptr, "center", cent); + RNA_float_get_array(op->ptr, "axis", axis); + + if(!spin_nurb(C, scene, obedit, axis, cent, 0)) { BKE_report(op->reports, RPT_ERROR, "Can't spin"); return OPERATOR_CANCELLED; } @@ -3327,6 +3311,18 @@ static int spin_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int spin_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d= ED_view3d_context_rv3d(C); + + RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d)); + RNA_float_set_array(op->ptr, "axis", rv3d->viewinv[2]); + + return spin_exec(C, op); +} + void CURVE_OT_spin(wmOperatorType *ot) { /* identifiers */ @@ -3335,10 +3331,14 @@ void CURVE_OT_spin(wmOperatorType *ot) /* api callbacks */ ot->exec= spin_exec; + ot->invoke = spin_invoke; ot->poll= ED_operator_editsurf; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_float_vector(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX, "Center", "Center in global view space", -FLT_MAX, FLT_MAX); + RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -FLT_MAX, FLT_MAX); } /***************** add vertex operator **********************/ @@ -4734,19 +4734,18 @@ int join_curve_exec(bContext *C, wmOperator *op) /************ add primitive, used by object/ module ****************/ -Nurb *add_nurbs_primitive(bContext *C, int type, int newname) +Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) { static int xzproj= 0; /* this function calls itself... */ Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); ListBase *editnurb= curve_get_editcurve(obedit); View3D *v3d= CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); Nurb *nu = NULL; BezTriple *bezt; BPoint *bp; - float *curs, cent[3],vec[3],imat[3][3],mat[3][3]; - float fac,cmat[3][3], grid; + float vec[3]; + float fac, grid; int a, b, cutype, stype; int force_3d = ((Curve *)obedit->data)->flag & CU_3D; /* could be adding to an existing 3D curve */ @@ -4756,38 +4755,8 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) if (v3d) grid = v3d->grid; else grid = 1.0; - /* imat and center and size */ - if(obedit) { - - copy_m3_m4(mat, obedit->obmat); - if(v3d) { - curs= give_cursor(scene, v3d); - VECCOPY(cent, curs); - } - else - cent[0]= cent[1]= cent[2]= 0.0f; - cent[0]-= obedit->obmat[3][0]; - cent[1]-= obedit->obmat[3][1]; - cent[2]-= obedit->obmat[3][2]; - - if(rv3d) { - if (!newname && (U.flag & USER_ADD_VIEWALIGNED)) - copy_m3_m4(imat, rv3d->viewmat); - else - unit_m3(imat); - - mul_m3_v3(imat, cent); - mul_m3_m3m3(cmat, imat, mat); - invert_m3_m3(imat, cmat); - } - else - unit_m3(imat); - - setflagsNurb(editnurb, 0); - } - else - return NULL; + setflagsNurb(editnurb, 0); /* these types call this function to return a Nurb */ if (stype!=CU_PRIM_TUBE && stype!=CU_PRIM_DONUT) { @@ -4814,26 +4783,25 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->radius = 1.0; - for(a=0;a<3;a++) { - VECCOPY(bezt->vec[a], cent); - } bezt->vec[1][0]+= -grid; bezt->vec[0][0]+= -1.5*grid; bezt->vec[0][1]+= -0.5*grid; bezt->vec[2][0]+= -0.5*grid; bezt->vec[2][1]+= 0.5*grid; - for(a=0;a<3;a++) mul_m3_v3(imat, bezt->vec[a]); + for(a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); bezt++; bezt->h1= bezt->h2= HD_ALIGN; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->radius = bezt->weight = 1.0; - for(a=0;a<3;a++) { - VECCOPY(bezt->vec[a], cent); - } - bezt->vec[1][0]+= grid; - for(a=0;a<3;a++) mul_m3_v3(imat, bezt->vec[a]); + bezt->vec[0][0] = 0; + bezt->vec[0][1] = 0; + bezt->vec[1][0] = grid; + bezt->vec[1][1] = 0; + bezt->vec[2][0] = grid*2; + bezt->vec[2][1] = 0; + for(a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); calchandlesNurb(nu); } @@ -4846,7 +4814,6 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bp= nu->bp; for(a=0;a<4;a++, bp++) { - VECCOPY(bp->vec, cent); bp->vec[3]= 1.0; bp->f1= SELECT; bp->radius = bp->weight = 1.0; @@ -4864,7 +4831,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bp->vec[0]+= 1.5*grid; bp= nu->bp; - for(a=0;a<4;a++, bp++) mul_m3_v3(imat,bp->vec); + for(a=0;a<4;a++, bp++) mul_m4_v3(mat,bp->vec); if(cutype==CU_NURBS) { nu->knotsu= 0; /* makeknots allocates */ @@ -4883,7 +4850,6 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bp= nu->bp; for(a=0;a<5;a++, bp++) { - VECCOPY(bp->vec, cent); bp->vec[3]= 1.0; bp->f1= SELECT; bp->radius = bp->weight = 1.0; @@ -4899,7 +4865,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) bp->vec[0]+= 2.0*grid; bp= nu->bp; - for(a=0;a<5;a++, bp++) mul_m3_v3(imat,bp->vec); + for(a=0;a<5;a++, bp++) mul_m4_v3(mat,bp->vec); if(cutype==CU_NURBS) { nu->knotsu= 0; /* makeknots allocates */ @@ -4920,43 +4886,31 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) nu->flagu= CU_CYCLIC; bezt= nu->bezt; - for(a=0;a<3;a++) { - VECCOPY(bezt->vec[a], cent); - } bezt->h1= bezt->h2= HD_AUTO; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->vec[1][0]+= -grid; - for(a=0;a<3;a++) mul_m3_v3(imat,bezt->vec[a]); + for(a=0;a<3;a++) mul_m4_v3(mat,bezt->vec[a]); bezt->radius = bezt->weight = 1.0; bezt++; - for(a=0;a<3;a++) { - VECCOPY(bezt->vec[a], cent); - } bezt->h1= bezt->h2= HD_AUTO; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->vec[1][1]+= grid; - for(a=0;a<3;a++) mul_m3_v3(imat,bezt->vec[a]); + for(a=0;a<3;a++) mul_m4_v3(mat,bezt->vec[a]); bezt->radius = bezt->weight = 1.0; bezt++; - for(a=0;a<3;a++) { - VECCOPY(bezt->vec[a], cent); - } bezt->h1= bezt->h2= HD_AUTO; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->vec[1][0]+= grid; - for(a=0;a<3;a++) mul_m3_v3(imat,bezt->vec[a]); + for(a=0;a<3;a++) mul_m4_v3(mat,bezt->vec[a]); bezt->radius = bezt->weight = 1.0; bezt++; - for(a=0;a<3;a++) { - VECCOPY(bezt->vec[a], cent); - } bezt->h1= bezt->h2= HD_AUTO; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->vec[1][1]+= -grid; - for(a=0;a<3;a++) mul_m3_v3(imat,bezt->vec[a]); + for(a=0;a<3;a++) mul_m4_v3(mat,bezt->vec[a]); bezt->radius = bezt->weight = 1.0; calchandlesNurb(nu); @@ -4971,8 +4925,6 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) for(a=0; a<8; a++) { bp->f1= SELECT; - VECCOPY(bp->vec, cent); - if(xzproj==0) { bp->vec[0]+= nurbcircle[a][0]*grid; bp->vec[1]+= nurbcircle[a][1]*grid; @@ -4983,7 +4935,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) } if(a & 1) bp->vec[3]= 0.25*sqrt(2.0); else bp->vec[3]= 1.0; - mul_m3_v3(imat,bp->vec); + mul_m4_v3(mat,bp->vec); bp->radius = bp->weight = 1.0; bp++; @@ -5011,7 +4963,6 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) for(a=0; a<4; a++) { for(b=0; b<4; b++) { - VECCOPY(bp->vec, cent); bp->f1= SELECT; fac= (float)a -1.5; bp->vec[0]+= fac*grid; @@ -5020,7 +4971,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) if(a==1 || a==2) if(b==1 || b==2) { bp->vec[2]+= grid; } - mul_m3_v3(imat,bp->vec); + mul_m4_v3(mat,bp->vec); bp->vec[3]= 1.0; bp++; } @@ -5032,18 +4983,19 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) break; case CU_PRIM_TUBE: /* tube */ if( cutype==CU_NURBS ) { + if(newname) { rename_id((ID *)obedit, "SurfTube"); rename_id((ID *)obedit->data, "SurfTube"); } - - nu= add_nurbs_primitive(C, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ + + nu= add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ nu->resolu= 4; nu->flag= CU_SMOOTH; BLI_addtail(editnurb, nu); /* temporal for extrude and translate */ vec[0]=vec[1]= 0.0; vec[2]= -grid; - mul_m3_v3(imat, vec); + translateflagNurb(editnurb, 1, vec); extrudeflagNurb(editnurb, 1); vec[0]= -2*vec[0]; @@ -5063,6 +5015,9 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) break; case CU_PRIM_SPHERE: /* sphere */ if( cutype==CU_NURBS ) { + float tmp_cent[3] = {0.f, 0.f, 0.f}; + float tmp_vec[3] = {0.f, 0.f, 0.f}; + if(newname) { rename_id((ID *)obedit, "SurfSphere"); rename_id((ID *)obedit->data, "SurfSphere"); @@ -5080,12 +5035,11 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) for(a=0; a<5; a++) { bp->f1= SELECT; - VECCOPY(bp->vec, cent); bp->vec[0]+= nurbcircle[a][0]*grid; bp->vec[2]+= nurbcircle[a][1]*grid; if(a & 1) bp->vec[3]= 0.5*sqrt(2.0); else bp->vec[3]= 1.0; - mul_m3_v3(imat,bp->vec); + mul_m4_v3(mat,bp->vec); bp++; } nu->flagu= 4; @@ -5093,9 +5047,9 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) BLI_addtail(editnurb, nu); /* temporal for spin */ if(newname && (U.flag & USER_ADD_VIEWALIGNED) == 0) - spin_nurb(C, scene, obedit, 0, 2); + spin_nurb(C, scene, obedit, tmp_vec, tmp_cent, 2); else - spin_nurb(C, scene, obedit, 0, 0); + spin_nurb(C, scene, obedit, tmp_vec, mat[3], 2); makeknots(nu, 2); @@ -5110,22 +5064,25 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname) break; case CU_PRIM_DONUT: /* donut */ if( cutype==CU_NURBS ) { + float tmp_cent[3] = {0.f, 0.f, 0.f}; + float tmp_vec[3] = {0.f, 0.f, 0.f}; + if(newname) { rename_id((ID *)obedit, "SurfDonut"); rename_id((ID *)obedit->data, "SurfDonut"); } xzproj= 1; - nu= add_nurbs_primitive(C, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ + nu= add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ xzproj= 0; nu->resolu= 4; nu->resolv= 4; nu->flag= CU_SMOOTH; BLI_addtail(editnurb, nu); /* temporal for extrude and translate */ if(newname && (U.flag & USER_ADD_VIEWALIGNED) == 0) - spin_nurb(C, scene, obedit, 0, 2); + spin_nurb(C, scene, obedit, tmp_vec, tmp_cent, 2); else - spin_nurb(C, scene, obedit, 0, 0); + spin_nurb(C, scene, obedit, tmp_vec, mat[3], 2); BLI_remlink(editnurb, nu); diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index 0cfa743b0fa..e6bb178c90a 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -57,7 +57,7 @@ void free_editNurb (struct Object *obedit); int mouse_nurb (struct bContext *C, short mval[2], int extend); -struct Nurb *add_nurbs_primitive(struct bContext *C, int type, int newname); +struct Nurb *add_nurbs_primitive(struct bContext *C, float mat[4][4], int type, int newname); int isNurbsel (struct Nurb *nu);; diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index b21bcb0cc09..bc4b79ad176 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -33,7 +33,7 @@ struct wmKeyConfig; void ED_operatortypes_metaball(void); void ED_keymap_metaball(struct wmKeyConfig *keyconf); -struct MetaElem *add_metaball_primitive(struct bContext *C, int type, int newname); +struct MetaElem *add_metaball_primitive(struct bContext *C, float mat[4][4], int type, int newname); int mouse_mball(struct bContext *C, short mval[2], int extend); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 4e3fed6b9f8..91b297b7581 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -82,6 +82,7 @@ void ED_object_enter_editmode(struct bContext *C, int flag); void ED_object_location_from_view(struct bContext *C, float *loc); void ED_object_rotation_from_view(struct bContext *C, float *rot); void ED_object_base_init_transform(struct bContext *C, struct Base *base, float *loc, float *rot); +float ED_object_new_primitive_matrix(struct bContext *C, float *loc, float *rot, float primmat[][4]); void ED_object_add_generic_props(struct wmOperatorType *ot, int do_editmode); int ED_object_add_generic_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 572cf214c6a..3a80d7c69bb 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -1270,36 +1270,6 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se BKE_mesh_end_editmesh(obedit->data, em); } - -/* uses context to figure out transform for primitive */ -/* returns standard diameter */ -static float new_primitive_matrix(bContext *C, float *loc, float *rot, float primmat[][4]) -{ - Object *obedit= CTX_data_edit_object(C); - View3D *v3d =CTX_wm_view3d(C); - float mat[3][3], rmat[3][3], cmat[3][3], imat[3][3]; - - unit_m4(primmat); - - eul_to_mat3(rmat, rot); - invert_m3(rmat); - - /* inverse transform for initial rotation and object */ - copy_m3_m4(mat, obedit->obmat); - mul_m3_m3m3(cmat, rmat, mat); - invert_m3_m3(imat, cmat); - copy_m4_m3(primmat, imat); - - /* center */ - VECCOPY(primmat[3], loc); - VECSUB(primmat[3], primmat[3], obedit->obmat[3]); - invert_m3_m3(imat, mat); - mul_m3_v3(imat, primmat[3]); - - if(v3d) return v3d->grid; - return 1.0f; -} - /* ********* add primitive operators ************* */ static void make_prim_ext(bContext *C, float *loc, float *rot, int enter_editmode, @@ -1319,7 +1289,7 @@ static void make_prim_ext(bContext *C, float *loc, float *rot, int enter_editmod } else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); - dia *= new_primitive_matrix(C, loc, rot, mat); + dia *= ED_object_new_primitive_matrix(C, loc, rot, mat); make_prim(obedit, type, mat, tot, seg, subdiv, dia, depth, ext, fill); diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index d8e36a503f1..c3afbe0d9e7 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -97,15 +97,11 @@ void load_editMball(Object *obedit) } /* Add metaelem primitive to metaball object (which is in edit mode) */ -MetaElem *add_metaball_primitive(bContext *C, int type, int newname) +MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int newname) { - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); - RegionView3D *rv3d = CTX_wm_region_view3d(C); Object *obedit= CTX_data_edit_object(C); MetaBall *mball = (MetaBall*)obedit->data; MetaElem *ml; - float *curs, mat[3][3], cent[3], imat[3][3], cmat[3][3]; if(!obedit) return NULL; @@ -116,36 +112,11 @@ MetaElem *add_metaball_primitive(bContext *C, int type, int newname) ml= ml->next; } - copy_m3_m4(mat, obedit->obmat); - if(v3d) { - curs= give_cursor(scene, v3d); - VECCOPY(cent, curs); - } - else - cent[0]= cent[1]= cent[2]= 0.0f; - - cent[0]-= obedit->obmat[3][0]; - cent[1]-= obedit->obmat[3][1]; - cent[2]-= obedit->obmat[3][2]; - - if (rv3d) { - if (!(newname) || U.flag & USER_ADD_VIEWALIGNED) - copy_m3_m4(imat, rv3d->viewmat); - else - unit_m3(imat); - mul_m3_v3(imat, cent); - mul_m3_m3m3(cmat, imat, mat); - invert_m3_m3(imat,cmat); - mul_m3_v3(imat, cent); - } - else - unit_m3(imat); - ml= MEM_callocN(sizeof(MetaElem), "metaelem"); - ml->x= cent[0]; - ml->y= cent[1]; - ml->z= cent[2]; + ml->x= mat[3][0]; + ml->y= mat[3][1]; + ml->z= mat[3][2]; ml->quat[0]= 1.0; ml->quat[1]= 0.0; ml->quat[2]= 0.0; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 28ddf07fe8e..9740a1cba01 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -143,6 +143,35 @@ void ED_object_base_init_transform(bContext *C, Base *base, float *loc, float *r where_is_object(scene, ob); } +/* uses context to figure out transform for primitive */ +/* returns standard diameter */ +float ED_object_new_primitive_matrix(bContext *C, float *loc, float *rot, float primmat[][4]) +{ + Object *obedit= CTX_data_edit_object(C); + View3D *v3d =CTX_wm_view3d(C); + float mat[3][3], rmat[3][3], cmat[3][3], imat[3][3]; + + unit_m4(primmat); + + eul_to_mat3(rmat, rot); + invert_m3(rmat); + + /* inverse transform for initial rotation and object */ + copy_m3_m4(mat, obedit->obmat); + mul_m3_m3m3(cmat, rmat, mat); + invert_m3_m3(imat, cmat); + copy_m4_m3(primmat, imat); + + /* center */ + VECCOPY(primmat[3], loc); + VECSUB(primmat[3], primmat[3], obedit->obmat[3]); + invert_m3_m3(imat, mat); + mul_m3_v3(imat, primmat[3]); + + if(v3d) return v3d->grid; + return 1.0f; +} + /********************* Add Object Operator ********************/ void add_object_draw(Scene *scene, View3D *v3d, int type) /* for toolbox or menus, only non-editmode stuff */ @@ -297,6 +326,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) Object *ob; int enter_editmode; float loc[3], rot[3]; + float mat[4][4]; object_add_generic_invoke_options(C, op); ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); @@ -307,7 +337,8 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) ((Curve*)ob->data)->flag |= CU_PATH|CU_3D; ED_object_enter_editmode(C, 0); - BLI_addtail(curve_get_editcurve(ob), add_nurbs_primitive(C, CU_NURBS|CU_PRIM_PATH, 1)); + ED_object_new_primitive_matrix(C, loc, rot, mat); + BLI_addtail(curve_get_editcurve(ob), add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_PATH, 1)); if(!enter_editmode) ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); @@ -424,6 +455,7 @@ static int object_add_curve_exec(bContext *C, wmOperator *op) int newob= 0, type= RNA_enum_get(op->ptr, "type"); int enter_editmode; float loc[3], rot[3]; + float mat[4][4]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); @@ -437,7 +469,9 @@ static int object_add_curve_exec(bContext *C, wmOperator *op) } else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); - nu= add_nurbs_primitive(C, type, newob); + ED_object_new_primitive_matrix(C, loc, rot, mat); + + nu= add_nurbs_primitive(C, mat, type, newob); editnurb= curve_get_editcurve(obedit); BLI_addtail(editnurb, nu); @@ -509,6 +543,7 @@ static int object_add_surface_exec(bContext *C, wmOperator *op) int newob= 0; int enter_editmode; float loc[3], rot[3]; + float mat[4][4]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); @@ -519,7 +554,9 @@ static int object_add_surface_exec(bContext *C, wmOperator *op) } else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); - nu= add_nurbs_primitive(C, RNA_enum_get(op->ptr, "type"), newob); + ED_object_new_primitive_matrix(C, loc, rot, mat); + + nu= add_nurbs_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob); editnurb= curve_get_editcurve(obedit); BLI_addtail(editnurb, nu); @@ -570,6 +607,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) int newob= 0; int enter_editmode; float loc[3], rot[3]; + float mat[4][4]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); @@ -580,7 +618,9 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) } else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); - elem= (MetaElem*)add_metaball_primitive(C, RNA_enum_get(op->ptr, "type"), newob); + ED_object_new_primitive_matrix(C, loc, rot, mat); + + elem= (MetaElem*)add_metaball_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob); mball= (MetaBall*)obedit->data; BLI_addtail(mball->editelems, elem); @@ -732,6 +772,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) int enter_editmode; float loc[3], rot[3]; + object_add_generic_invoke_options(C, op); ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); ob= ED_object_add_type(C, OB_LAMP, loc, rot, FALSE); From c798a11b3b06469141344f0dae8035554801fd0c Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 12 Jan 2010 02:13:20 +0000 Subject: [PATCH 044/202] Fix [#20224] Moving to layer pannel missing shortcuts --- source/blender/editors/interface/interface_handlers.c | 11 +++++++++-- source/blender/editors/interface/interface_regions.c | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 916a48b7442..9fdb6a9fd94 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4819,9 +4819,16 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, if(but->type!=LABEL && but->type!=SEPR) count++; - + + /* exception for rna layer buts */ + if(but->rnapoin.data && but->rnaprop) { + if (ELEM(RNA_property_subtype(but->rnaprop), PROP_LAYER, PROP_LAYER_MEMBER)) { + if (but->rnaindex== act-1) + doit=1; + } + } /* exception for menus like layer buts, with button aligning they're not drawn in order */ - if(but->type==TOGR) { + else if(but->type==TOGR) { if(but->bitnr==act-1) doit= 1; } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 3a02b1f7e0c..03422df9ba5 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1339,7 +1339,7 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut saferct= MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct"); saferct->safety= block->safety; BLI_addhead(&block->saferct, saferct); - block->flag |= UI_BLOCK_POPUP; + block->flag |= UI_BLOCK_POPUP|UI_BLOCK_NUMSELECT; } /* the block and buttons were positioned in window space as in 2.4x, now From d1f40710feb5a615a5977ce1dcac6ce8cf2130e6 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 12 Jan 2010 02:32:21 +0000 Subject: [PATCH 045/202] Fix for [#20272] Missing Options - Blender Game, Transparency Panel A little bit dodgy, but at least the options are accessible for the time being. --- release/scripts/ui/properties_material.py | 37 ++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/release/scripts/ui/properties_material.py b/release/scripts/ui/properties_material.py index dfd4270e97b..be5e98a362f 100644 --- a/release/scripts/ui/properties_material.py +++ b/release/scripts/ui/properties_material.py @@ -641,6 +641,40 @@ class MATERIAL_PT_transp(MaterialButtonsPanel): sub.prop(rayt, "gloss_threshold", text="Threshold") sub.prop(rayt, "gloss_samples", text="Samples") +class MATERIAL_PT_transp_game(MaterialButtonsPanel): + bl_label = "Transparency" + bl_default_closed = True + COMPAT_ENGINES = {'BLENDER_GAME'} + + def poll(self, context): + mat = active_node_mat(context.material) + engine = context.scene.render_data.engine + return mat and (engine in self.COMPAT_ENGINES) + + def draw_header(self, context): + mat = active_node_mat(context.material) + + self.layout.prop(mat, "transparency", text="") + + def draw(self, context): + layout = self.layout + + mat = active_node_mat(context.material) + rayt = mat.raytrace_transparency + wide_ui = context.region.width > narrowui + + row = layout.row() + row.active = mat.transparency and (not mat.shadeless) + if wide_ui: + row.prop(mat, "transparency_method", expand=True) + else: + row.prop(mat, "transparency_method", text="") + + split = layout.split() + + col = split.column() + col.prop(mat, "alpha") + class MATERIAL_PT_halo(MaterialButtonsPanel): bl_label = "Halo" @@ -740,7 +774,7 @@ bpy.types.register(MATERIAL_PT_physics) bpy.types.register(MATERIAL_PT_strand) bpy.types.register(MATERIAL_PT_options) bpy.types.register(MATERIAL_PT_shadow) - +bpy.types.register(MATERIAL_PT_transp_game) class VolumeButtonsPanel(bpy.types.Panel): bl_space_type = 'PROPERTIES' @@ -885,6 +919,7 @@ bpy.types.register(MATERIAL_PT_volume_density) bpy.types.register(MATERIAL_PT_volume_shading) bpy.types.register(MATERIAL_PT_volume_lighting) bpy.types.register(MATERIAL_PT_volume_transp) + bpy.types.register(MATERIAL_PT_volume_integration) bpy.types.register(MATERIAL_PT_custom_props) From a742824c1198e2ee704123e7267ea8aaa6121a47 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 12 Jan 2010 02:34:57 +0000 Subject: [PATCH 046/202] Fix [#20628] Color pickers: graphical slider bar doesn't update HSV and Hex num sliders --- source/blender/editors/interface/interface_regions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 03422df9ba5..90823481f18 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1698,7 +1698,7 @@ static void circle_picker(uiBlock *block, PointerRNA *ptr, const char *propname) uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); /* value */ - uiDefButR(block, HSVCUBE, 0, "", PICKER_W+PICKER_SPACE,0,PICKER_BAR,PICKER_H, ptr, propname, -1, 0.0, 0.0, 9, 0, ""); + bt= uiDefButR(block, HSVCUBE, 0, "", PICKER_W+PICKER_SPACE,0,PICKER_BAR,PICKER_H, ptr, propname, -1, 0.0, 0.0, 9, 0, ""); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); } @@ -1713,7 +1713,7 @@ static void square_picker(uiBlock *block, PointerRNA *ptr, const char *propname, uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); /* value */ - uiDefButR(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, propname, -1, 0.0, 0.0, bartype, 0, ""); + bt= uiDefButR(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, propname, -1, 0.0, 0.0, bartype, 0, ""); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); } From fd5657bd4fc8f8ea7f5d54ed7e92402b49a74870 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 12 Jan 2010 02:53:15 +0000 Subject: [PATCH 047/202] Fix [#20000] Connect to File Output node creates segfault --- source/blender/editors/space_node/node_edit.c | 2 +- source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index c177cb7f1f5..8166cfa9513 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1239,7 +1239,7 @@ bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float node_set_active(snode, node); if(snode->nodetree->type==NTREE_COMPOSIT) { - if(ELEM3(node->type, CMP_NODE_R_LAYERS, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS)) + if(ELEM4(node->type, CMP_NODE_R_LAYERS, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS, CMP_NODE_OUTPUT_FILE)) node->id = &scene->id; ntreeCompositForceHidden(snode->edittree, scene); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c b/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c index ebb7c1e8478..0ad11b4c936 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c @@ -62,7 +62,7 @@ static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack * } } - BKE_makepicstring(string, nif->name, rd->cfra, nif->imtype, ((Scene *)node->id)->r.scemode & R_EXTENSION); + BKE_makepicstring(string, nif->name, rd->cfra, nif->imtype, (rd->scemode & R_EXTENSION)); if(0 == BKE_write_ibuf((Scene *)node->id, ibuf, string, nif->imtype, nif->subimtype, nif->imtype==R_OPENEXR?nif->codec:nif->quality)) printf("Cannot save Node File Output to %s\n", string); From 6f79716326d0daab8b83b9b9701920bf3146211b Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 12 Jan 2010 03:01:19 +0000 Subject: [PATCH 048/202] Fix [#19966] Graph Editor does not refresh after automatic keyframe insertion --- source/blender/editors/interface/interface_anim.c | 3 ++- source/blender/editors/interface/interface_handlers.c | 2 +- source/blender/editors/interface/interface_intern.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index e35ffade342..1a747edce11 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -133,7 +133,7 @@ int ui_but_anim_expression_set(uiBut *but, const char *str) return 0; } -void ui_but_anim_autokey(uiBut *but, Scene *scene, float cfra) +void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) { ID *id; bAction *action; @@ -151,6 +151,7 @@ void ui_but_anim_autokey(uiBut *but, Scene *scene, float cfra) fcu->flag &= ~FCURVE_SELECTED; insert_keyframe(id, action, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); } } } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 9fdb6a9fd94..7c0fa1fbc74 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -323,7 +323,7 @@ static void ui_apply_autokey_undo(bContext *C, uiBut *but) } /* try autokey */ - ui_but_anim_autokey(but, scene, scene->r.cfra); + ui_but_anim_autokey(C, but, scene, scene->r.cfra); } static void ui_apply_but_funcs_after(bContext *C) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index aec48b5c7c7..c0dc54d2469 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -481,7 +481,7 @@ void ui_but_anim_add_keyingset(struct bContext *C); void ui_but_anim_remove_keyingset(struct bContext *C); int ui_but_anim_expression_get(uiBut *but, char *str, int maxlen); int ui_but_anim_expression_set(uiBut *but, const char *str); -void ui_but_anim_autokey(uiBut *but, struct Scene *scene, float cfra); +void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, float cfra); #endif From 629bfd2a315c1e6227342769e891d9642adbace7 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 12 Jan 2010 05:54:15 +0000 Subject: [PATCH 049/202] Fix [#19922] outliner+renaming+shift+home --- .../editors/interface/interface_widgets.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 418773cbe25..6c78a1f2a11 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -904,19 +904,23 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b if(but->editstr && but->pos != -1) { short t=0, pos=0, ch; short selsta_tmp, selend_tmp, selsta_draw, selwidth_draw; - + if ((but->selend - but->selsta) > 0) { /* text button selection */ selsta_tmp = but->selsta; selend_tmp = but->selend; if(but->drawstr[0]!=0) { - ch= but->drawstr[selsta_tmp]; - but->drawstr[selsta_tmp]= 0; - - selsta_draw = BLF_width(but->drawstr+but->ofs); - - but->drawstr[selsta_tmp]= ch; + + if (but->selsta >= but->ofs) { + ch= but->drawstr[selsta_tmp]; + but->drawstr[selsta_tmp]= 0; + + selsta_draw = BLF_width(but->drawstr+but->ofs); + + but->drawstr[selsta_tmp]= ch; + } else + selsta_draw = 0; ch= but->drawstr[selend_tmp]; but->drawstr[selend_tmp]= 0; From 85310d6413811e2c852ddade7c9c05545fc68731 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 12 Jan 2010 07:07:51 +0000 Subject: [PATCH 050/202] Partial fix for [#19926] clicks "fall through" when stacking nodes This still isn't ideal, but a bit better than before, it just tweaks the order of block processing so that at least the buttons on top of other buttons get processed first. The actual fix will be quite tricky, not sure about how best to do that so far.. --- source/blender/editors/space_node/node_draw.c | 82 +++++++++++-------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 4fc0d37f6a6..14c127cb7e5 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -161,6 +161,36 @@ static void node_scaling_widget(int color_id, float aspect, float xmin, float ym fdrawline(xmin+dx, ymin+aspect, xmax, ymax-dy+aspect); } +static void node_uiblocks_init(const bContext *C, bNodeTree *ntree) +{ + bNode *node; + char str[32]; + + /* add node uiBlocks in reverse order - prevents events going to overlapping nodes */ + + /* process selected nodes first so they're at the start of the uiblocks list */ + for(node= ntree->nodes.last; node; node= node->prev) { + + if (node->flag & NODE_SELECT) { + /* ui block */ + sprintf(str, "node buttons %p", node); + node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS); + uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node); + } + } + + /* then the rest */ + for(node= ntree->nodes.last; node; node= node->prev) { + + if (!(node->flag & (NODE_GROUP_EDIT|NODE_SELECT))) { + /* ui block */ + sprintf(str, "node buttons %p", node); + node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS); + uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node); + } + } +} + /* based on settings in node, sets drawing rect info. each redraw! */ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) { @@ -169,7 +199,6 @@ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) bNodeSocket *nsock; float dy= node->locy; int buty; - char str[32]; /* header */ dy-= NODE_DY; @@ -237,11 +266,6 @@ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) /* XXX ugly hack, typeinfo for group is generated */ if(node->type == NODE_GROUP) ; // XXX node->typeinfo->uifunc= node_buts_group; - - /* ui block */ - sprintf(str, "node buttons %p", node); - node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS); - uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node); /* buttons rect? */ if((node->flag & NODE_OPTIONS) && node->typeinfo->uifunc) { @@ -290,7 +314,6 @@ static void node_update_hidden(const bContext *C, bNode *node) bNodeSocket *nsock; float rad, drad, hiddenrad= HIDDEN_RAD; int totin=0, totout=0, tot; - char str[32]; /* calculate minimal radius */ for(nsock= node->inputs.first; nsock; nsock= nsock->next) @@ -331,11 +354,6 @@ static void node_update_hidden(const bContext *C, bNode *node) rad+= drad; } } - - /* ui block */ - sprintf(str, "node buttons %p", node); - node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS); - uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node); } static int node_get_colorid(bNode *node) @@ -368,10 +386,14 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) rctf *rect= &gnode->totr; int counter; + /* init ui blocks for sub-nodetrees */ + node_uiblocks_init(C, ngroup); + /* center them, is a bit of abuse of locx and locy though */ for(node= ngroup->nodes.first; node; node= node->next) { node->locx+= gnode->locx; node->locy+= gnode->locy; + if(node->flag & NODE_HIDDEN) node_update_hidden(C, node); else @@ -504,28 +526,20 @@ static void socket_circle_draw(bNodeSocket *sock, float size) { int col[3]; - /* choose color based on sock flags */ - if(sock->flag & SELECT) { - if(sock->type==SOCK_VALUE) { - col[0]= 200; col[1]= 200; col[2]= 200;} - else if(sock->type==SOCK_VECTOR) { - col[0]= 140; col[1]= 140; col[2]= 240;} - else if(sock->type==SOCK_RGBA) { - col[0]= 240; col[1]= 240; col[2]= 100;} - else { - col[0]= 140; col[1]= 240; col[2]= 140;} + if(sock->type==-1) { + col[0]= 0; col[1]= 0; col[2]= 0; } - else { - if(sock->type==-1) { - col[0]= 0; col[1]= 0; col[2]= 0;} - else if(sock->type==SOCK_VALUE) { - col[0]= 160; col[1]= 160; col[2]= 160;} - else if(sock->type==SOCK_VECTOR) { - col[0]= 100; col[1]= 100; col[2]= 200;} - else if(sock->type==SOCK_RGBA) { - col[0]= 200; col[1]= 200; col[2]= 40;} - else { - col[0]= 100; col[1]= 200; col[2]= 100;} + else if(sock->type==SOCK_VALUE) { + col[0]= 160; col[1]= 160; col[2]= 160; + } + else if(sock->type==SOCK_VECTOR) { + col[0]= 100; col[1]= 100; col[2]= 200; + } + else if(sock->type==SOCK_RGBA) { + col[0]= 200; col[1]= 200; col[2]= 40; + } + else { + col[0]= 100; col[1]= 200; col[2]= 100; } circle_draw(sock->locx, sock->locy, size, sock->type, col); @@ -1079,6 +1093,8 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) if(snode->nodetree) { bNode *node; + node_uiblocks_init(C, snode->nodetree); + /* for now, we set drawing coordinates on each redraw */ for(node= snode->nodetree->nodes.first; node; node= node->next) { if(node->flag & NODE_GROUP_EDIT) From 926cdffaf30e0c7a2f61269a610de6c2f0ec44da Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 12 Jan 2010 07:50:14 +0000 Subject: [PATCH 051/202] Renamed toolbar to Tool Shelf all over --- release/scripts/ui/space_view3d.py | 2 +- .../blender/editors/space_view3d/space_view3d.c | 6 +++--- .../blender/editors/space_view3d/view3d_intern.h | 4 ++-- source/blender/editors/space_view3d/view3d_ops.c | 4 ++-- .../editors/space_view3d/view3d_toolbar.c | 16 ++++++++-------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 30ea8e34710..0c844440250 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -231,7 +231,7 @@ class VIEW3D_MT_view(bpy.types.Menu): layout = self.layout layout.operator("view3d.properties", icon='MENU_PANEL') - layout.operator("view3d.toolbar", icon='MENU_PANEL') + layout.operator("view3d.toolshelf", icon='MENU_PANEL') layout.separator() diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 31c02be6621..b23b1b38804 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -221,8 +221,8 @@ static SpaceLink *view3d_new(const bContext *C) ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - /* toolbar */ - ar= MEM_callocN(sizeof(ARegion), "toolbar for view3d"); + /* tool shelf */ + ar= MEM_callocN(sizeof(ARegion), "toolshelf for view3d"); BLI_addtail(&v3d->regionbase, ar); ar->regiontype= RGN_TYPE_UI; @@ -834,7 +834,7 @@ void ED_spacetype_view3d(void) art->draw= view3d_tools_area_draw; BLI_addhead(&st->regiontypes, art); - view3d_toolbar_register(art); + view3d_toolshelf_register(art); /* regions: tool properties */ art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index a5d4c61bc01..f6d77b1b63d 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -161,8 +161,8 @@ void VIEW3D_OT_properties(struct wmOperatorType *ot); void view3d_buttons_register(struct ARegionType *art); /* view3d_toolbar.c */ -void VIEW3D_OT_toolbar(struct wmOperatorType *ot); -void view3d_toolbar_register(struct ARegionType *art); +void VIEW3D_OT_toolshelf(struct wmOperatorType *ot); +void view3d_toolshelf_register(struct ARegionType *art); void view3d_tool_props_register(struct ARegionType *art); /* view3d_snap.c */ diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 2e134da7e02..ea9441ec648 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -90,7 +90,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_layers); WM_operatortype_append(VIEW3D_OT_properties); - WM_operatortype_append(VIEW3D_OT_toolbar); + WM_operatortype_append(VIEW3D_OT_toolshelf); WM_operatortype_append(VIEW3D_OT_snap_selected_to_grid); WM_operatortype_append(VIEW3D_OT_snap_selected_to_cursor); @@ -110,7 +110,7 @@ void view3d_keymap(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "3D View Generic", SPACE_VIEW3D, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_properties", NKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "VIEW3D_OT_toolbar", TKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_toolshelf", TKEY, KM_PRESS, 0, 0); /* only for region 3D window */ keymap= WM_keymap_find(keyconf, "3D View", SPACE_VIEW3D, 0); diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index b05043cd76e..a08413293a5 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -282,7 +282,7 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) } -void view3d_toolbar_register(ARegionType *art) +void view3d_toolshelf_register(ARegionType *art) { PanelType *pt; @@ -305,9 +305,9 @@ void view3d_tool_props_register(ARegionType *art) BLI_addtail(&art->paneltypes, pt); } -/* ********** operator to open/close toolbar region */ +/* ********** operator to open/close toolshelf region */ -static int view3d_toolbar(bContext *C, wmOperator *op) +static int view3d_toolshelf(bContext *C, wmOperator *op) { ScrArea *sa= CTX_wm_area(C); ARegion *ar= view3d_has_tools_region(sa); @@ -318,13 +318,13 @@ static int view3d_toolbar(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void VIEW3D_OT_toolbar(wmOperatorType *ot) +void VIEW3D_OT_toolshelf(wmOperatorType *ot) { - ot->name= "Toolbar"; - ot->description= "Toggles toolbar display."; - ot->idname= "VIEW3D_OT_toolbar"; + ot->name= "Tool Shelf"; + ot->description= "Toggles tool shelf display."; + ot->idname= "VIEW3D_OT_toolshelf"; - ot->exec= view3d_toolbar; + ot->exec= view3d_toolshelf; ot->poll= ED_operator_view3d_active; /* flags */ From 9900d07a011deb2a58f77d9d7d9c49d360d151ab Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 12 Jan 2010 08:18:15 +0000 Subject: [PATCH 052/202] Fix [#19920] long list in outliner+renaming --- source/blender/editors/space_outliner/outliner.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 79a16a50544..be125725e4e 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -4838,6 +4838,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) break; } } + tselem->flag &= ~TSE_TEXTBUT; } } @@ -5278,8 +5279,9 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa else if(tselem->id && GS(tselem->id->name)==ID_LI) len = sizeof(((Library*) 0)->name); else len= sizeof(((ID*) 0)->name)-2; + dx= (int)UI_GetStringWidth(te->name); - if(dx<50) dx= 50; + if(dx<100) dx= 100; bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", (short)te->xs+2*OL_X-4, (short)te->ys, dx+10, OL_H-1, te->name, 1.0, (float)len-1, 0, 0, ""); uiButSetRenameFunc(bt, namebutton_cb, tselem); From ac3f7db076e91591c9dd35ce0d08b6fd9af08b7d Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 12 Jan 2010 08:30:01 +0000 Subject: [PATCH 053/202] Fix [#20556] Shear hotkey not matching keymap Select Sharp Edges was conflicting with it, fixed by removing it's shortcut, - if people use it frequently, they can easy add it back with a RMB click. --- source/blender/editors/mesh/mesh_ops.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 32141005c7c..4fbe695a3f0 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -235,7 +235,6 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1); RNA_float_set(WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0)->ptr,"sharpness",135.0); - RNA_float_set(WM_keymap_add_item(keymap, "MESH_OT_edges_select_sharp", SKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0)->ptr,"sharpness",135.0); WM_keymap_add_item(keymap, "MESH_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0); From b76551da68d6bc35d606cff6594df853cfee3234 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Tue, 12 Jan 2010 08:46:38 +0000 Subject: [PATCH 054/202] CMake fix for windows build Patch by Guillaume Lecocq. Thx! --- source/blender/makesrna/intern/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 113dfc51138..b42252fec99 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -63,7 +63,7 @@ IF(WITH_DDS) ENDIF(WITH_DDS) IF(WITH_QUICKTIME) - SET(INC "${INC} ../../quicktime") + SET(INC ${INC} ../../quicktime) ADD_DEFINITIONS(-DWITH_QUICKTIME) ENDIF(WITH_QUICKTIME) From f6c79c553b8ac512ff5bd394b956a0a8d0ff27a8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Jan 2010 10:04:03 +0000 Subject: [PATCH 055/202] [#20646] 2.5 does not load python scripts with multiple dots in the filename - not a bug so add a warning if people add scripts with invalid names like this. --- release/scripts/modules/bpy/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py index 6209cbe4f0e..c760268d6f7 100644 --- a/release/scripts/modules/bpy/__init__.py +++ b/release/scripts/modules/bpy/__init__.py @@ -47,6 +47,10 @@ def load_scripts(reload_scripts=False): t_main = time.time() def test_import(module_name): + if "." in module_name: + print("Ignoring '%s', can't import files containing multiple periods." % module_name) + return None + try: t = time.time() ret = __import__(module_name) From b01166428415cf7cf55404f10fe55b3e5d46269d Mon Sep 17 00:00:00 2001 From: Arystanbek Dyussenov Date: Tue, 12 Jan 2010 11:21:42 +0000 Subject: [PATCH 056/202] Fix #20641, #20645. Someone forgot to update scripts ;) --- release/scripts/io/import_scene_3ds.py | 3 +-- release/scripts/io/import_scene_obj.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/release/scripts/io/import_scene_3ds.py b/release/scripts/io/import_scene_3ds.py index 5f55b169d27..ed94d133ccb 100644 --- a/release/scripts/io/import_scene_3ds.py +++ b/release/scripts/io/import_scene_3ds.py @@ -586,8 +586,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH): # print("read material") #print 'elif (new_chunk.ID == MATERIAL):' - contextMaterial = bpy.data.add_material('Material') -# contextMaterial = bpy.data.materials.new('Material') + contextMaterial = bpy.data.materials.new('Material') elif (new_chunk.ID == MAT_NAME): #print 'elif (new_chunk.ID == MAT_NAME):' diff --git a/release/scripts/io/import_scene_obj.py b/release/scripts/io/import_scene_obj.py index 001ed923699..ecd45f54946 100644 --- a/release/scripts/io/import_scene_obj.py +++ b/release/scripts/io/import_scene_obj.py @@ -440,8 +440,7 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_ #Create new materials for name in unique_materials: # .keys() if name != None: - unique_materials[name]= bpy.data.add_material(name) -# unique_materials[name]= bpy.data.materials.new(name) + unique_materials[name]= bpy.data.materials.new(name) unique_material_images[name]= None, False # assign None to all material images to start with, add to later. unique_materials[None]= None From 6329f7b063057b3617810677e2175d5b8af30bc1 Mon Sep 17 00:00:00 2001 From: William Reynish Date: Tue, 12 Jan 2010 12:08:23 +0000 Subject: [PATCH 057/202] Made the color ramp template more compact, and made the position field an RNA item. --- .../blender/editors/interface/interface_templates.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 0cb916d7448..106875e3907 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1428,6 +1428,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand { uiBut *bt; + uiLayout *row; if(coba==NULL) return; @@ -1453,10 +1454,9 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand /* better to use rna so we can animate them */ PointerRNA ptr; RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr); - uiItemR(layout, NULL, 0, &ptr, "color", 0); - //uiItemR(layout, NULL, 0, &ptr, "position", 0); - bt= uiDefButF(block, NUM, 0, "Pos:", 0+xoffs,40+yoffs,100, 20, &cbd->pos, 0.0, 1.0, 10, 0, "The position of the active color stop"); - uiButSetNFunc(bt, colorband_pos_cb, MEM_dupallocN(cb), coba); + row= uiLayoutRow(layout, 0); + uiItemR(row, "Pos", 0, &ptr, "position", 0); + uiItemR(row, "", 0, &ptr, "color", 0); } } @@ -1467,11 +1467,12 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand float unit= (butr->xmax-butr->xmin)/14.0f; float xs= butr->xmin; - + uiBlockBeginAlign(block); bt= uiDefBut(block, BUT, 0, "Add", xs,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Add a new color stop to the colorband"); uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba); bt= uiDefBut(block, BUT, 0, "Delete", xs+2.0f*unit,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Delete the active position"); uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba); + uiBlockEndAlign(block); if(coba->tot) { CBData *cbd= coba->data + coba->cur; From f1a542b6b80b8a7dcce0484dd4146d2ede72831d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Jan 2010 13:20:49 +0000 Subject: [PATCH 058/202] particle edit the emitter field wasnt recalculated on entering on editmode. this meant you could use the puff brush in particle edit, move mesh verts, go back into particle edit... And the mesh data from the previous mesh would still be used. --- source/blender/editors/physics/particle_edit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index c510a28b7ad..c1846c6a493 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -88,6 +88,7 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, ParticleSystem *psys); static void PTCacheUndo_clear(PTCacheEdit *edit); +static void recalc_emitter_field(Object *ob, ParticleSystem *psys); #define KEY_K PTCacheEditKey *key; int k #define POINT_P PTCacheEditPoint *point; int p @@ -265,8 +266,13 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) } } - if(edit) + if(edit) { edit->pid = *pid; + + /* mesh may have changed since last entering editmode. + * note, this may have run before if the edit data was just created, so could avoid this and speed up a little */ + recalc_emitter_field(ob, edit->psys); + } BLI_freelistN(&pidlist); From 70942f9a8321e27d5c7dc2036301989364f9a5aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Jan 2010 13:40:29 +0000 Subject: [PATCH 059/202] last commit was no good since pe_get_current was running recalc_emitter_field on mousemove and poll() functions. run on entering particle editmode only. --- source/blender/blenkernel/BKE_pointcache.h | 2 +- .../blender/editors/physics/particle_edit.c | 20 +++++++++++-------- source/blender/makesrna/intern/rna_particle.c | 3 ++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 4b26eaa6d76..6686d10bb31 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -213,7 +213,7 @@ typedef struct PTCacheEdit { struct ParticleSystem *psys; struct ParticleData *particles; struct KDTree *emitter_field; - float *emitter_cosnos; + float *emitter_cosnos; /* localspace face centers and normals (average of its verts), from the derived mesh */ int *mirror_cache; struct ParticleCacheKey **pathcache; /* path cache (runtime) */ diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index c1846c6a493..400bb05d2b4 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -194,7 +194,10 @@ ParticleEditSettings *PE_settings(Scene *scene) return &scene->toolsettings->particle; } -/* always gets atleast the first particlesystem even if PSYS_CURRENT flag is not set */ +/* always gets atleast the first particlesystem even if PSYS_CURRENT flag is not set + * + * note: this function runs on poll, therefor it can runs many times a second + * keep it fast! */ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) { ParticleEditSettings *pset= PE_settings(scene); @@ -266,13 +269,8 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) } } - if(edit) { + if(edit) edit->pid = *pid; - - /* mesh may have changed since last entering editmode. - * note, this may have run before if the edit data was just created, so could avoid this and speed up a little */ - recalc_emitter_field(ob, edit->psys); - } BLI_freelistN(&pidlist); @@ -3909,8 +3907,14 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) Object *ob= CTX_data_active_object(C); if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) { + PTCacheEdit *edit; ob->mode |= OB_MODE_PARTICLE_EDIT; - PE_create_current(scene, ob); + edit= PE_create_current(scene, ob); + + /* mesh may have changed since last entering editmode. + * note, this may have run before if the edit data was just created, so could avoid this and speed up a little */ + recalc_emitter_field(ob, edit->psys); + toggle_particle_cursor(C, 1); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL); } diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 543965a337e..344ba7ef064 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -658,7 +658,8 @@ static void rna_def_particle_hair_key(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Time", "Relative time of key over hair length."); prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_UNSIGNED); - RNA_def_property_ui_text(prop, "Weight", "Weight for softbody simulation."); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_text(prop, "Weight", "Weight for cloth simulation."); } static void rna_def_particle_key(BlenderRNA *brna) From 78798ba4df75d3a17b9c8ea27176384d66a96ae6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Jan 2010 13:42:13 +0000 Subject: [PATCH 060/202] rename free_group to free_group_objects since it doesnt free the group its self. --- source/blender/blenkernel/BKE_group.h | 3 +-- source/blender/blenkernel/intern/group.c | 6 +++--- source/blender/blenkernel/intern/library.c | 2 +- source/blender/makesrna/intern/rna_main_api.c | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h index 877e09b037f..1a194cf2cfa 100644 --- a/source/blender/blenkernel/BKE_group.h +++ b/source/blender/blenkernel/BKE_group.h @@ -37,8 +37,7 @@ struct Object; struct bAction; struct Scene; -void free_group_object(struct GroupObject *go); -void free_group(struct Group *group); +void free_group_objects(struct Group *group); void unlink_group(struct Group *group); struct Group *add_group(char *name); struct Group *copy_group(struct Group *group); diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index f35a0a96bb4..9a690729d3e 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -57,13 +57,13 @@ #include #endif -void free_group_object(GroupObject *go) +static void free_group_object(GroupObject *go) { MEM_freeN(go); } -void free_group(Group *group) +void free_group_objects(Group *group) { /* don't free group itself */ GroupObject *go; @@ -130,7 +130,7 @@ void unlink_group(Group *group) } /* group stays in library, but no members */ - free_group(group); + free_group_objects(group); group->id.us= 0; } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index ae3d201a918..4b6257b8b18 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -768,7 +768,7 @@ void free_libblock(ListBase *lb, void *idv) sound_free((bSound*)id); break; case ID_GR: - free_group((Group *)id); + free_group_objects((Group *)id); break; case ID_AR: free_armature((bArmature *)id); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index a1cc8bbabc8..fdb192055b3 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -188,7 +188,6 @@ Group *rna_Main_groups_new(Main *bmain, char* name) } void rna_Main_groups_remove(Main *bmain, ReportList *reports, Group *group) { - free_group(group); unlink_group(group); group->id.us= 0; free_libblock(&bmain->group, group); From 636b4a0663893dd953d3efd90f939501e2313109 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Tue, 12 Jan 2010 14:12:44 +0000 Subject: [PATCH 061/202] Cocoa : activate multitouch trackpad features only on equipped macbooks --- intern/ghost/intern/GHOST_SystemCocoa.h | 3 +++ intern/ghost/intern/GHOST_SystemCocoa.mm | 27 +++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index 5b78f9b8fa3..23a945f4b76 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -277,6 +277,9 @@ protected: * Needed because cocoa event delta cursor move takes setCursorPosition changes too. */ GHOST_TInt32 m_cursorDelta_x, m_cursorDelta_y; + + /** Multitouch trackpad availability */ + bool m_hasMultiTouchTrackpad; }; #endif // _GHOST_SYSTEM_COCOA_H_ diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 735efcda395..128ef8a6edf 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -509,6 +509,11 @@ int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op) GHOST_SystemCocoa::GHOST_SystemCocoa() { + int mib[2]; + struct timeval boottime; + size_t len; + char *rstring = NULL; + m_modifierMask =0; m_pressedMouseButtons =0; m_cursorDelta_x=0; @@ -519,10 +524,6 @@ GHOST_SystemCocoa::GHOST_SystemCocoa() m_displayManager->initialize(); //NSEvent timeStamp is given in system uptime, state start date is boot time - int mib[2]; - struct timeval boottime; - size_t len; - mib[0] = CTL_KERN; mib[1] = KERN_BOOTTIME; len = sizeof(struct timeval); @@ -530,6 +531,22 @@ GHOST_SystemCocoa::GHOST_SystemCocoa() sysctl(mib, 2, &boottime, &len, NULL, 0); m_start_time = ((boottime.tv_sec*1000)+(boottime.tv_usec/1000)); + //Detect multitouch trackpad + mib[0] = CTL_HW; + mib[1] = HW_MODEL; + sysctl( mib, 2, NULL, &len, NULL, 0 ); + rstring = (char*)malloc( len ); + sysctl( mib, 2, rstring, &len, NULL, 0 ); + + //Hack on MacBook revision, as multitouch avail. function missing + if (strstr(rstring,"MacBookAir") || + (strstr(rstring,"MacBook") && (rstring[strlen(rstring)-3]>='5') && (rstring[strlen(rstring)-3]<='9'))) + m_hasMultiTouchTrackpad = true; + else m_hasMultiTouchTrackpad = false; + + free( rstring ); + rstring = NULL; + m_ignoreWindowSizedMessages = false; } @@ -1336,7 +1353,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) case NSScrollWheel: { /* Send Wheel event if sent from the mouse, trackpad event otherwise */ - if ([event subtype] == NSMouseEventSubtype) { + if (!m_hasMultiTouchTrackpad || ([event subtype] == NSMouseEventSubtype)) { GHOST_TInt32 delta; double deltaF = [event deltaY]; From 0a9321e532fd683bffd836451ce27a2b5da56ded Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Jan 2010 14:52:09 +0000 Subject: [PATCH 062/202] bugfix for puff brush, it wasnt working if the object had any transformation. some dna comments too. --- source/blender/editors/physics/particle_edit.c | 13 +++++++++++-- source/blender/makesdna/DNA_object_types.h | 6 +++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 400bb05d2b4..7c67b261caf 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2844,6 +2844,8 @@ static void brush_puff(PEData *data, int point_index) PTCacheEditPoint *point = edit->points + point_index; KEY_K; float mat[4][4], imat[4][4]; + float obmat[4][4], obimat[4][4]; + float lastco[3], rootco[3] = {0.0f, 0.0f, 0.0f}, co[3], nor[3], kco[3], dco[3], fac=0.0f, length=0.0f; if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { @@ -2855,17 +2857,23 @@ static void brush_puff(PEData *data, int point_index) unit_m4(imat); } + copy_m4_m4(obmat, data->ob->obmat); + invert_m4_m4(obimat, obmat); + LOOP_KEYS { if(k==0) { /* find root coordinate and normal on emitter */ VECCOPY(co, key->co); mul_m4_v3(mat, co); + mul_v3_m4v3(kco, obimat, co); /* use 'kco' as the object space version of worldspace 'co' */ - point_index= BLI_kdtree_find_nearest(edit->emitter_field, co, NULL, NULL); + point_index= BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL, NULL); if(point_index == -1) return; VECCOPY(rootco, co); copy_v3_v3(nor, &edit->emitter_cosnos[point_index*6+3]); + mul_mat3_m4_v3(obmat, nor); /* normal into worldspace */ + normalize_v3(nor); length= 0.0f; @@ -3913,7 +3921,8 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) /* mesh may have changed since last entering editmode. * note, this may have run before if the edit data was just created, so could avoid this and speed up a little */ - recalc_emitter_field(ob, edit->psys); + if(edit) + recalc_emitter_field(ob, edit->psys); toggle_particle_cursor(C, 1); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL); diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index ace56e78a46..8eb02b28331 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -135,15 +135,15 @@ typedef struct Object { /* rot en drot have to be together! (transform('r' en 's')) */ float loc[3], dloc[3], orig[3]; - float size[3], dsize[3]; + float size[3], dsize[3]; /* scale and delta scale */ float rot[3], drot[3]; /* euler rotation */ float quat[4], dquat[4]; /* quaternion rotation */ float rotAxis[3], drotAxis[3]; /* axis angle rotation - axis part */ float rotAngle, drotAngle; /* axis angle rotation - angle part */ - float obmat[4][4]; + float obmat[4][4]; /* final worldspace matrix with constraints & animsys applied */ float parentinv[4][4]; /* inverse result of parent, so that object doesn't 'stick' to parent */ float constinv[4][4]; /* inverse result of constraints. doesn't include effect of parent or object local transform */ - float imat[4][4]; /* for during render, old game engine, temporally: ipokeys of transform */ + float imat[4][4]; /* inverse matrix of 'obmat' for during render, old game engine, temporally: ipokeys of transform */ unsigned int lay; /* copy of Base */ From e672a083d91ec7095cc6de4a55a8768772a19784 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Jan 2010 16:29:05 +0000 Subject: [PATCH 063/202] bugfix for particle editmode operators from (Janne Karhu) psys_get_particle_on_path was taking dynamics into account, making subdivide add points in odd places. --- source/blender/blenkernel/intern/particle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 41ca5e1804a..169e39338bb 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3856,7 +3856,9 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * pind.cache = cached ? psys->pointcache : NULL; pind.epoint = NULL; pind.bspline = (psys->part->flag & PART_HAIR_BSPLINE); - pind.dm = psys->hair_out_dm; + /* pind.dm disabled in editmode means we dont get effectors taken into + * account when subdividing for instance */ + pind.dm = psys_in_edit_mode(sim->scene, psys) ? NULL : psys->hair_out_dm; init_particle_interpolation(sim->ob, psys, pa, &pind); do_particle_interpolation(psys, p, pa, t, frs_sec, &pind, state); From b8d743c9c6bcbd908c4cd0a3f161b6d08de41847 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Jan 2010 16:35:34 +0000 Subject: [PATCH 064/202] particle puff, volume option. When combing long hair it will often end up with no volume (flat on the head like its wet). a way to fix this is to use the puff tool however when applied points at the root only this just gives a bit of volume at the roots and the rest of the hair stays flat. This option moves the unselected parts of the hair without applying the puff tool to them, giving volume to the hair whilst preserving the desired style. --- release/scripts/ui/space_view3d_toolbar.py | 1 + .../blender/editors/physics/particle_edit.c | 64 ++++++++++++++++--- source/blender/makesdna/DNA_scene_types.h | 4 ++ .../makesrna/intern/rna_sculpt_paint.c | 4 ++ 4 files changed, 64 insertions(+), 9 deletions(-) diff --git a/release/scripts/ui/space_view3d_toolbar.py b/release/scripts/ui/space_view3d_toolbar.py index a7a8968fb05..6d0b34cc7c8 100644 --- a/release/scripts/ui/space_view3d_toolbar.py +++ b/release/scripts/ui/space_view3d_toolbar.py @@ -533,6 +533,7 @@ class VIEW3D_PT_tools_brush(PaintPanel): layout.prop(brush, "length_mode", expand=True) elif settings.tool == 'PUFF': layout.prop(brush, "puff_mode", expand=True) + layout.prop(brush, "use_puff_volume") # Sculpt Mode # diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 7c67b261caf..fc86971b8ac 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2846,7 +2846,15 @@ static void brush_puff(PEData *data, int point_index) float mat[4][4], imat[4][4]; float obmat[4][4], obimat[4][4]; - float lastco[3], rootco[3] = {0.0f, 0.0f, 0.0f}, co[3], nor[3], kco[3], dco[3], fac=0.0f, length=0.0f; + float lastco[3], rootco[3] = {0.0f, 0.0f, 0.0f}, co[3], nor[3], kco[3], dco[3], ofs[3] = {0.0f, 0.0f, 0.0f}, fac=0.0f, length=0.0f; + int puff_volume = 0; + int change= 0; + + { + ParticleEditSettings *pset= PE_settings(data->scene); + ParticleBrushData *brush= &pset->brush[pset->brushtype]; + puff_volume = brush->flag & PE_BRUSH_DATA_PUFF_VOLUME; + } if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { psys_mat_hair_to_global(data->ob, data->dm, psys->part->from, psys->particles + point_index, mat); @@ -2883,24 +2891,62 @@ static void brush_puff(PEData *data, int point_index) fac= -fac; } else { - /* compute position as if hair was standing up straight */ + /* compute position as if hair was standing up straight. + * */ VECCOPY(lastco, co); VECCOPY(co, key->co); mul_m4_v3(mat, co); length += len_v3v3(lastco, co); + if((key->flag & PEK_SELECT) && !(key->flag & PEK_HIDE)) { + VECADDFAC(kco, rootco, nor, length); - VECADDFAC(kco, rootco, nor, length); + /* blend between the current and straight position */ + VECSUB(dco, kco, co); + VECADDFAC(co, co, dco, fac); - /* blend between the current and straight position */ - VECSUB(dco, kco, co); - VECADDFAC(co, co, dco, fac); + /* re-use dco to compare before and after translation and add to the offset */ + VECCOPY(dco, key->co); - VECCOPY(key->co, co); - mul_m4_v3(imat, key->co); + mul_v3_m4v3(key->co, imat, co); + + if(puff_volume) { + /* accumulate the total distance moved to apply to unselected + * keys that come after */ + ofs[0] += key->co[0] - dco[0]; + ofs[1] += key->co[1] - dco[1]; + ofs[2] += key->co[2] - dco[2]; + } + change = 1; + } + else { + + if(puff_volume) { +#if 0 + /* this is simple but looks bad, adds annoying kinks */ + add_v3_v3(key->co, ofs); +#else + /* translate (not rotate) the rest of the hair if its not selected */ + if(ofs[0] || ofs[1] || ofs[2]) { + float c1[3], c2[3]; + VECSUB(dco, lastco, co); + mul_m4_v3(imat, dco); /* into particle space */ + + /* move the point allong a vector perpendicular to the + * hairs direction, reduces odd kinks, */ + cross_v3_v3v3(c1, ofs, dco); + cross_v3_v3v3(c2, c1, dco); + normalize_v3(c2); + mul_v3_fl(c2, len_v3(ofs)); + add_v3_v3(key->co, c2); + } +#endif + } + } } } - point->flag |= PEP_EDIT_RECALC; + if(change) + point->flag |= PEP_EDIT_RECALC; } static void brush_smooth_get(PEData *data, float mat[][4], float imat[][4], int point_index, int key_index, PTCacheEditKey *key) diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 974967c6aa6..a55d13cf160 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -521,6 +521,7 @@ typedef struct ImagePaintSettings { typedef struct ParticleBrushData { short size, strength; /* common settings */ short step, invert; /* for specific brushes only */ + int flag, pad; } ParticleBrushData; typedef struct ParticleEditSettings { @@ -1140,6 +1141,9 @@ typedef enum SculptFlags { /* this must equal ParticleEditSettings.brush array size */ #define PE_TOT_BRUSH 6 +/* ParticleBrushData->flag */ +#define PE_BRUSH_DATA_PUFF_VOLUME 1 + /* tooksettings->particle edittype */ #define PE_TYPE_PARTICLES 0 #define PE_TYPE_SOFTBODY 1 diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 99bee9413cd..5e5eb9d84ce 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -527,6 +527,10 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_enum_items(prop, puff_mode); RNA_def_property_ui_text(prop, "Puff Mode", ""); + prop= RNA_def_property(srna, "use_puff_volume", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_BRUSH_DATA_PUFF_VOLUME); + RNA_def_property_ui_text(prop, "Puff Volume", "Apply puff to unselected end-points, (helps maintain hair volume when puffing root)"); + prop= RNA_def_property(srna, "length_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "invert"); RNA_def_property_enum_items(prop, length_mode); From f7f98f3b05d166b7047ca54eb54b36a92e675a88 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Jan 2010 17:08:28 +0000 Subject: [PATCH 065/202] Proxy Protection Fixes * Mostly revert #24880: Transform Locks affecting animation system. This was implemented as a feature request from Nathan but was not the intended functionality, and actually gives problems instead. The transform locks should really only affect what the user can do, not if the property can be animated internally. * Revert #25868: fix for lib linked scenes not animating. This was needed due to the above feature, but meant that all lib linked properties were editable in the UI. * Make bone properties of on proxy-protected layers not editable. They will be overriden on reload/redo like lib linked data, so should not be edited. --- source/blender/blenkernel/intern/anim_sys.c | 36 +++++-------- .../editors/transform/transform_conversions.c | 2 +- source/blender/makesrna/intern/rna_access.c | 31 +++++------- source/blender/makesrna/intern/rna_pose.c | 50 ++++++++++++++++++- 4 files changed, 74 insertions(+), 45 deletions(-) diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 2a5a12cc513..c617ca33e8a 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -733,26 +733,20 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(&new_ptr, prop)) { - if (RNA_property_editable_index(&new_ptr, prop, array_index)) - RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value); - } + if (RNA_property_array_length(&new_ptr, prop)) + RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value); else RNA_property_boolean_set(&new_ptr, prop, (int)value); break; case PROP_INT: - if (RNA_property_array_length(&new_ptr, prop)){ - if (RNA_property_editable_index(&new_ptr, prop, array_index)) - RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value); - } + if (RNA_property_array_length(&new_ptr, prop)) + RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value); else RNA_property_int_set(&new_ptr, prop, (int)value); break; case PROP_FLOAT: - if (RNA_property_array_length(&new_ptr, prop)) { - if (RNA_property_editable_index(&new_ptr, prop, array_index)) - RNA_property_float_set_index(&new_ptr, prop, array_index, value); - } + if (RNA_property_array_length(&new_ptr, prop)) + RNA_property_float_set_index(&new_ptr, prop, array_index, value); else RNA_property_float_set(&new_ptr, prop, value); break; @@ -1476,26 +1470,20 @@ void nladata_flush_channels (ListBase *channels) switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(ptr, prop)) { - if (RNA_property_editable_index(ptr, prop, array_index)) - RNA_property_boolean_set_index(ptr, prop, array_index, (int)value); - } + if (RNA_property_array_length(ptr, prop)) + RNA_property_boolean_set_index(ptr, prop, array_index, (int)value); else RNA_property_boolean_set(ptr, prop, (int)value); break; case PROP_INT: - if (RNA_property_array_length(ptr, prop)) { - if (RNA_property_editable_index(ptr, prop, array_index)) - RNA_property_int_set_index(ptr, prop, array_index, (int)value); - } + if (RNA_property_array_length(ptr, prop)) + RNA_property_int_set_index(ptr, prop, array_index, (int)value); else RNA_property_int_set(ptr, prop, (int)value); break; case PROP_FLOAT: - if (RNA_property_array_length(ptr, prop)) { - if (RNA_property_editable_index(ptr, prop, array_index)) - RNA_property_float_set_index(ptr, prop, array_index, value); - } + if (RNA_property_array_length(ptr, prop)) + RNA_property_float_set_index(ptr, prop, array_index, value); else RNA_property_float_set(ptr, prop, value); break; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 7a89765fef2..5484e3cd8bf 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -714,7 +714,7 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob) for(pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { bone = pchan->bone; if(bone->layer & arm->layer) { - if(bone->flag & BONE_SELECTED) + if((bone->flag & BONE_SELECTED) && !(ob->proxy && pchan->bone->layer & arm->layer_protected)) bone->flag |= BONE_TRANSFORM; else bone->flag &= ~BONE_TRANSFORM; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 6932d775da7..29d97b273c4 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1060,9 +1060,7 @@ int RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop) id= ptr->id.data; - /* with this, libdata is not animated by its own library fcurves, FIXME */ -// return (flag & PROP_EDITABLE) && (!id || !id->lib || (flag & PROP_LIB_EXCEPTION)); - return (flag & PROP_EDITABLE) ? 1:0; + return (flag & PROP_EDITABLE) && (!id || !id->lib || (prop->flag & PROP_LIB_EXCEPTION)); } /* same as RNA_property_editable(), except this checks individual items in an array */ @@ -1072,18 +1070,18 @@ int RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index) int flag; prop= rna_ensure_property(prop); + + flag= prop->flag; - /* if there is no function to do this for a given index, - * just resort to doing this on the whole array - */ - if (prop->itemeditable == NULL) - return RNA_property_editable(ptr, prop); - - flag= prop->itemeditable(ptr, index); + if(prop->editable) + flag &= prop->editable(ptr); + + if (prop->itemeditable) + flag &= prop->itemeditable(ptr, index); + id= ptr->id.data; - /* with this, libdata is not animated by its own library fcurves, FIXME */ -// return (flag & PROP_EDITABLE) && (!id || !id->lib || (flag & PROP_LIB_EXCEPTION)); - return (flag & PROP_EDITABLE) ? 1:0; + + return (flag & PROP_EDITABLE) && (!id || !id->lib || (prop->flag & PROP_LIB_EXCEPTION)); } int RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop) @@ -1095,12 +1093,7 @@ int RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop) if(!(prop->flag & PROP_ANIMATEABLE)) return 0; - if(prop->editable) - flag= prop->editable(ptr); - else - flag= prop->flag; - - return (flag & PROP_EDITABLE); + return (prop->flag & PROP_EDITABLE); } int RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop) diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index b37442fab6a..0616894e902 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -446,10 +446,19 @@ static int rna_PoseChannel_constraints_remove(bPoseChannel *pchan, bContext *C, return remove_constraint_index(&pchan->constraints, index); } +static int rna_PoseChannel_proxy_editable(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + bArmature *arm= ob->data; + bPoseChannel *pchan= (bPoseChannel*)ptr->data; + + return (ob->proxy && pchan->bone && (pchan->bone->layer & arm->layer_protected))? 0: PROP_EDITABLE; +} + static int rna_PoseChannel_location_editable(PointerRNA *ptr, int index) { bPoseChannel *pchan= (bPoseChannel*)ptr->data; - + /* only if the axis in question is locked, not editable... */ if ((index == 0) && (pchan->protectflag & OB_LOCK_LOCX)) return 0; @@ -674,6 +683,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_PoseChannel_name_set"); RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_struct_name_property(srna, prop); prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); @@ -685,12 +695,14 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "pathsf"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bone Paths Calculation Start Frame", "Starting frame of range of frames to use for Bone Path calculations."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "pathef"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bone Paths Calculation End Frame", "End frame of range of frames to use for Bone Path calculations."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); rna_def_motionpath_common(srna); @@ -717,12 +729,14 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_editable_array_func(prop, "rna_PoseChannel_location_editable"); RNA_def_property_ui_text(prop, "Location", ""); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Pose_update"); prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_editable_array_func(prop, "rna_PoseChannel_scale_editable"); RNA_def_property_ui_text(prop, "Scale", ""); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Pose_update"); prop= RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION); @@ -730,6 +744,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable"); RNA_def_property_float_array_default(prop, default_quat); RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Pose_update"); /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but @@ -741,11 +756,13 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable"); RNA_def_property_float_array_default(prop, default_axisAngle); RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Pose_update"); prop= RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "eul"); RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_euler_editable"); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Pose_update"); @@ -753,6 +770,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "rotmode"); RNA_def_property_enum_items(prop, prop_rotmode_items); // XXX move to using a single define of this someday RNA_def_property_enum_funcs(prop, NULL, "rna_PoseChannel_rotation_mode_set", NULL); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_ui_text(prop, "Rotation Mode", ""); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); @@ -797,113 +815,133 @@ static void rna_def_pose_channel(BlenderRNA *brna) prop= RNA_def_property(srna, "ik_dof_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "ikflag", BONE_IK_NO_XDOF); RNA_def_property_ui_text(prop, "IK X DoF", "Allow movement around the X axis."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_dof_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "ikflag", BONE_IK_NO_YDOF); RNA_def_property_ui_text(prop, "IK Y DoF", "Allow movement around the Y axis."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_dof_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "ikflag", BONE_IK_NO_ZDOF); RNA_def_property_ui_text(prop, "IK Z DoF", "Allow movement around the Z axis."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_limit_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_XLIMIT); RNA_def_property_ui_text(prop, "IK X Limit", "Limit movement around the X axis."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_limit_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_YLIMIT); RNA_def_property_ui_text(prop, "IK Y Limit", "Limit movement around the Y axis."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_limit_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_ZLIMIT); RNA_def_property_ui_text(prop, "IK Z Limit", "Limit movement around the Z axis."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_rot_control", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_ROTCTL); RNA_def_property_ui_text(prop, "IK rot control", "Apply channel rotation as IK constraint"); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_lin_control", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_LINCTL); RNA_def_property_ui_text(prop, "IK rot control", "Apply channel size as IK constraint if stretching is enabled"); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_min_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmin[0]"); RNA_def_property_range(prop, -180.0f, 0.0f); RNA_def_property_ui_text(prop, "IK X Minimum", "Minimum angles for IK Limit"); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_max_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmax[0]"); RNA_def_property_range(prop, 0.0f, 180.0f); RNA_def_property_ui_text(prop, "IK X Maximum", "Maximum angles for IK Limit"); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_min_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmin[1]"); RNA_def_property_range(prop, -180.0f, 0.0f); RNA_def_property_ui_text(prop, "IK Y Minimum", "Minimum angles for IK Limit"); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_max_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmax[1]"); RNA_def_property_range(prop, 0.0f, 180.0f); RNA_def_property_ui_text(prop, "IK Y Maximum", "Maximum angles for IK Limit"); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_min_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmin[2]"); RNA_def_property_range(prop, -180.0f, 0.0f); RNA_def_property_ui_text(prop, "IK Z Minimum", "Minimum angles for IK Limit"); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_max_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "limitmax[2]"); RNA_def_property_range(prop, 0.0f, 180.0f); RNA_def_property_ui_text(prop, "IK Z Maximum", "Maximum angles for IK Limit"); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_stiffness_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "stiffness[0]"); RNA_def_property_range(prop, 0.0f, 0.99f); RNA_def_property_ui_text(prop, "IK X Stiffness", "IK stiffness around the X axis."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_stiffness_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "stiffness[1]"); RNA_def_property_range(prop, 0.0f, 0.99f); RNA_def_property_ui_text(prop, "IK Y Stiffness", "IK stiffness around the Y axis."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_stiffness_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "stiffness[2]"); RNA_def_property_range(prop, 0.0f, 0.99f); RNA_def_property_ui_text(prop, "IK Z Stiffness", "IK stiffness around the Z axis."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_stretch", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ikstretch"); RNA_def_property_range(prop, 0.0f,1.0f); RNA_def_property_ui_text(prop, "IK Stretch", "Allow scaling of the bone for IK."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_IK_update"); prop= RNA_def_property(srna, "ik_rot_weight", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ikrotweight"); RNA_def_property_range(prop, 0.0f,1.0f); RNA_def_property_ui_text(prop, "IK Rot Weight", "Weight of rotation constraint for IK."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); prop= RNA_def_property(srna, "ik_lin_weight", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "iklinweight"); RNA_def_property_range(prop, 0.0f,1.0f); RNA_def_property_ui_text(prop, "IK Lin Weight", "Weight of scale constraint for IK."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); /* custom bone shapes */ @@ -912,6 +950,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Object"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Custom Object", "Object that defines custom draw type for this bone."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); prop= RNA_def_property(srna, "custom_shape_transform", PROP_POINTER, PROP_NONE); @@ -919,6 +958,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_struct_type(prop, "PoseBone"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Custom Shape Transform", "Bone that defines the display transform of this custom shape."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); /* bone groups */ @@ -927,6 +967,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_int_funcs(prop, "rna_PoseChannel_bone_group_index_get", "rna_PoseChannel_bone_group_index_set", "rna_PoseChannel_bone_group_index_range"); RNA_def_property_ui_text(prop, "Bone Group Index", "Bone Group this pose channel belongs to (0=no group)."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); prop= RNA_def_property(srna, "bone_group", PROP_POINTER, PROP_NONE); @@ -934,6 +975,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_pointer_funcs(prop, "rna_PoseChannel_bone_group_get", "rna_PoseChannel_bone_group_set", NULL); RNA_def_property_ui_text(prop, "Bone Group", "Bone Group this pose channel belongs to"); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); /* transform locks */ @@ -941,29 +983,35 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); // XXX this is sub-optimal - it really should be included above, but due to technical reasons we can't do this! prop= RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTW); RNA_def_property_ui_text(prop, "Lock Rotation (4D Angle)", "Lock editing of 'angle' component of four-component rotations in the interface."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); + // XXX this needs a better name prop= RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROT4D); RNA_def_property_ui_text(prop, "Lock Rotations (4D)", "Lock editing of four component rotations by components (instead of as Eulers)."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); prop= RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface."); + RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); RNA_api_pose_channel(srna); From 59dfd24f752c6639fe22722afb7d03b50448de92 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Jan 2010 18:33:21 +0000 Subject: [PATCH 066/202] - bugfix [#20654] the property edge_face_count of the Mesh-Object does not work - remove unneeded particle function --- release/scripts/modules/bpy_types.py | 2 +- source/blender/blenkernel/intern/particle.c | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index a535673051c..88dcb7eb8de 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -299,7 +299,7 @@ class Mesh(bpy_types.ID): @property def edge_face_count(self): edge_face_count_dict = self.edge_face_count_dict - return [edge_face_count_dict.get(ed.key, 0) for ed in mesh.edges] + return [edge_face_count_dict.get(ed.key, 0) for ed in self.edges] def edge_loops(self, faces=None, seams=()): """ diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 169e39338bb..715d3610b31 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1000,12 +1000,7 @@ static float interpolate_particle_value(float v1, float v2, float v3, float v4, return value; } -static void weighted_particle_vector(float *v1, float *v2, float *v3, float *v4, float *weights, float *vec) -{ - vec[0]= weights[0]*v1[0] + weights[1]*v2[0] + weights[2]*v3[0] + weights[3]*v4[0]; - vec[1]= weights[0]*v1[1] + weights[1]*v2[1] + weights[2]*v3[1] + weights[3]*v4[1]; - vec[2]= weights[0]*v1[2] + weights[1]*v2[2] + weights[2]*v3[2] + weights[3]*v4[2]; -} + void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, ParticleKey *result, int velocity) { float t[4]; @@ -1016,19 +1011,19 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic else { key_curve_position_weights(dt, t, type); - weighted_particle_vector(keys[0].co, keys[1].co, keys[2].co, keys[3].co, t, result->co); + interp_v3_v3v3v3v3(result->co, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t); if(velocity){ float temp[3]; if(dt>0.999f){ key_curve_position_weights(dt-0.001f, t, type); - weighted_particle_vector(keys[0].co, keys[1].co, keys[2].co, keys[3].co, t, temp); + interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t); VECSUB(result->vel, result->co, temp); } else{ key_curve_position_weights(dt+0.001f, t, type); - weighted_particle_vector(keys[0].co, keys[1].co, keys[2].co, keys[3].co, t, temp); + interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t); VECSUB(result->vel, temp, result->co); } } From b58a14fe93a38c51231dd9f4df008480520430bc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Jan 2010 18:56:39 +0000 Subject: [PATCH 067/202] Fix for custom shapes getting lost on proxy armature bones. --- source/blender/blenkernel/intern/armature.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 9ae871b1dea..dff670a847f 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1515,9 +1515,10 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected pose->active_group= frompose->active_group; for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) { + pchanp= get_pose_channel(frompose, pchan->name); + if (pchan->bone->layer & layer_protected) { ListBase proxylocal_constraints = {NULL, NULL}; - pchanp= get_pose_channel(frompose, pchan->name); /* copy posechannel to temp, but restore important pointers */ pchanw= *pchanp; @@ -1565,6 +1566,10 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected /* the final copy */ *pchan= pchanw; } + else { + /* always copy custom shape */ + pchan->custom= pchanp->custom; + } } } From 000dcc7ad767511baec0e88b4e88b24c5667ef7e Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Tue, 12 Jan 2010 19:44:23 +0000 Subject: [PATCH 068/202] [#19960] When Loop Cutting, no Edge Sliding in Face Select Mode, but works in other Select Modes Force edge select (internally) when running edge slide. --- .../blender/editors/transform/transform_conversions.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 5484e3cd8bf..49e7f040390 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2139,14 +2139,20 @@ static void createTransEditVerts(bContext *C, TransInfo *t) int count=0, countsel=0, a, totleft; int propmode = t->flag & T_PROP_EDIT; int mirror = 0; + short selectmode = ts->selectmode; if (t->flag & T_MIRROR) { mirror = 1; } + /* edge slide forces edge select */ + if (t->mode == TFM_EDGE_SLIDE) { + selectmode = SCE_SELECT_EDGE; + } + // transform now requires awareness for select mode, so we tag the f1 flags in verts - if(ts->selectmode & SCE_SELECT_VERTEX) { + if(selectmode & SCE_SELECT_VERTEX) { for(eve= em->verts.first; eve; eve= eve->next) { if(eve->h==0 && (eve->f & SELECT)) eve->f1= SELECT; @@ -2154,7 +2160,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t) eve->f1= 0; } } - else if(ts->selectmode & SCE_SELECT_EDGE) { + else if(selectmode & SCE_SELECT_EDGE) { EditEdge *eed; for(eve= em->verts.first; eve; eve= eve->next) eve->f1= 0; for(eed= em->edges.first; eed; eed= eed->next) { From 6a0308aad332137c0b6f22152a439ca0f73914da Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Jan 2010 19:45:01 +0000 Subject: [PATCH 069/202] Raytrace: only print debug info when running with -d option. --- source/blender/render/intern/include/rayobject.h | 4 ++-- .../render/intern/raytrace/rayobject_vbvh.cpp | 12 ++++++++---- source/blender/render/intern/raytrace/reorganize.h | 4 +++- source/blender/render/intern/raytrace/svbvh.h | 11 +++++++---- source/blender/render/intern/source/rayshade.c | 7 ++++++- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/source/blender/render/intern/include/rayobject.h b/source/blender/render/intern/include/rayobject.h index 5579f3896c1..309048d8efb 100644 --- a/source/blender/render/intern/include/rayobject.h +++ b/source/blender/render/intern/include/rayobject.h @@ -181,7 +181,7 @@ int RE_rayobjectcontrol_test_break(RayObjectControl *c); #include #define BENCH(a,name) \ - do { \ + { \ double _t1, _t2; \ struct timeval _tstart, _tend; \ clock_t _clock_init = clock(); \ @@ -191,7 +191,7 @@ int RE_rayobjectcontrol_test_break(RayObjectControl *c); _t1 = ( double ) _tstart.tv_sec + ( double ) _tstart.tv_usec/ ( 1000*1000 ); \ _t2 = ( double ) _tend.tv_sec + ( double ) _tend.tv_usec/ ( 1000*1000 ); \ printf("BENCH:%s: %fs (real) %fs (cpu)\n", #name, _t2-_t1, (float)(clock()-_clock_init)/CLOCKS_PER_SEC);\ - } while(0) + } #else #define BENCH(a,name) (a) diff --git a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp index 4a2a56fa8ef..6185be324d6 100644 --- a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp @@ -37,6 +37,7 @@ int tot_hints = 0; #include "RE_raytrace.h" #include "BLI_memarena.h" #include "MEM_guardedalloc.h" +#include "BKE_global.h" #include "BKE_utildefines.h" #include "BLI_math.h" @@ -145,10 +146,13 @@ void bfree(VBVHTree *tree) { if(tot_pushup + tot_pushdown + tot_hints + tot_moves) { - printf("tot pushups: %d\n", tot_pushup); - printf("tot pushdowns: %d\n", tot_pushdown); - printf("tot moves: %d\n", tot_moves); - printf("tot hints created: %d\n", tot_hints); + if(G.f & G_DEBUG) { + printf("tot pushups: %d\n", tot_pushup); + printf("tot pushdowns: %d\n", tot_pushdown); + printf("tot moves: %d\n", tot_moves); + printf("tot hints created: %d\n", tot_hints); + } + tot_pushup = 0; tot_pushdown = 0; tot_hints = 0; diff --git a/source/blender/render/intern/raytrace/reorganize.h b/source/blender/render/intern/raytrace/reorganize.h index 7b14108760a..845f53605a8 100644 --- a/source/blender/render/intern/raytrace/reorganize.h +++ b/source/blender/render/intern/raytrace/reorganize.h @@ -32,6 +32,8 @@ #include #include +#include "BKE_global.h" + #ifdef _WIN32 #define INFINITY FLT_MAX // in mingw math.h: (1.0F/0.0F). This generates compile error, though. #endif @@ -515,7 +517,7 @@ struct VBVH_optimalPackSIMD if(num == 0) { num++; first = true; } calc_costs(node); - if(first) printf("expected cost = %f (%d)\n", node->cut_cost[0], node->best_cutsize ); + if((G.f & G_DEBUG) && first) printf("expected cost = %f (%d)\n", node->cut_cost[0], node->best_cutsize ); node->optimize(); } return node; diff --git a/source/blender/render/intern/raytrace/svbvh.h b/source/blender/render/intern/raytrace/svbvh.h index 80e6e2ea190..873f44d6d66 100644 --- a/source/blender/render/intern/raytrace/svbvh.h +++ b/source/blender/render/intern/raytrace/svbvh.h @@ -33,6 +33,7 @@ #include "bvh.h" #include "BLI_memarena.h" +#include "BKE_global.h" #include #include @@ -142,10 +143,12 @@ struct Reorganize_SVBVH ~Reorganize_SVBVH() { - printf("%f childs per node\n", childs_per_node / nodes); - printf("%d childs BB are useless\n", useless_bb); - for(int i=0; i<16; i++) - printf("%i childs per node: %d/%d = %f\n", i, nodes_with_childs[i], nodes, nodes_with_childs[i]/float(nodes)); + if(G.f & G_DEBUG) { + printf("%f childs per node\n", childs_per_node / nodes); + printf("%d childs BB are useless\n", useless_bb); + for(int i=0; i<16; i++) + printf("%i childs per node: %d/%d = %f\n", i, nodes_with_childs[i], nodes, nodes_with_childs[i]/float(nodes)); + } } SVBVHNode *create_node(int nchilds) diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 9fa23c73ec6..36284e7919d 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -435,7 +435,12 @@ void makeraytree(Render *re) if(re->r.raytrace_structure == R_RAYSTRUCTURE_OCTREE) re->r.raytrace_options &= ~( R_RAYTRACE_USE_INSTANCES | R_RAYTRACE_USE_LOCAL_COORDS); - BENCH(makeraytree_single(re), tree_build); + if(G.f & G_DEBUG) { + BENCH(makeraytree_single(re), tree_build); + } + else + makeraytree_single(re); + if(test_break(re)) { freeraytree(re); From 489ef9cff1abd74a938b06c3505705affd1b9d31 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Jan 2010 19:47:31 +0000 Subject: [PATCH 070/202] RNA: warning fixes. --- source/blender/makesrna/intern/rna_access.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 29d97b273c4..9dcd6eb81fa 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1086,8 +1086,6 @@ int RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index) int RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop) { - int flag; - prop= rna_ensure_property(prop); if(!(prop->flag & PROP_ANIMATEABLE)) @@ -2209,6 +2207,7 @@ int RNA_property_collection_raw_array(PointerRNA *ptr, PropertyRNA *prop, Proper case PROP_RAW_INT: ((int*)raw.array)[a] = (int)var; break; \ case PROP_RAW_FLOAT: ((float*)raw.array)[a] = (float)var; break; \ case PROP_RAW_DOUBLE: ((double*)raw.array)[a] = (double)var; break; \ + default: break; \ } \ } From ff353b49395c81305af5cec9ce4d9354e50d4cf7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Jan 2010 19:47:54 +0000 Subject: [PATCH 071/202] Math lib: added normalize_v3_v3 in addition to normalize_v3. --- source/blender/blenlib/BLI_math_vector.h | 5 ++- .../blenlib/intern/math_vector_inline.c | 35 ++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 4719a835788..9fb9e36bd2b 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -70,8 +70,9 @@ MINLINE void sub_v3_v3(float r[3], float a[3]); MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3]); MINLINE void mul_v2_fl(float r[2], float f); +MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f); MINLINE void mul_v3_fl(float r[3], float f); -MINLINE void mul_v3_v3fl(float r[3], float a[3], float f); +MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f); MINLINE void mul_v2_v2(float r[2], const float a[2]); MINLINE void mul_v3_v3(float r[3], float a[3]); MINLINE void mul_v3_v3v3(float r[3], float a[3], float b[3]); @@ -101,7 +102,9 @@ MINLINE float len_v3(const float a[3]); MINLINE float len_v3v3(const float a[3], const float b[3]); MINLINE float normalize_v2(float r[2]); +MINLINE float normalize_v2_v2(float r[2], const float a[2]); MINLINE float normalize_v3(float r[3]); +MINLINE float normalize_v3_v3(float r[3], const float a[3]); /******************************* Interpolation *******************************/ diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 86a0d0f49a1..9011234dccb 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -131,6 +131,12 @@ MINLINE void mul_v2_fl(float *v1, float f) v1[1]*= f; } +MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f) +{ + r[0]= a[0]*f; + r[1]= a[1]*f; +} + MINLINE void mul_v3_fl(float r[3], float f) { r[0] *= f; @@ -138,7 +144,7 @@ MINLINE void mul_v3_fl(float r[3], float f) r[2] *= f; } -MINLINE void mul_v3_v3fl(float r[3], float a[3], float f) +MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f) { r[0]= a[0]*f; r[1]= a[1]*f; @@ -275,38 +281,49 @@ MINLINE float len_v3v3(const float a[3], const float b[3]) return len_v3(d); } -MINLINE float normalize_v2(float n[2]) +MINLINE float normalize_v2_v2(float r[2], const float a[2]) { - float d= dot_v2v2(n, n); + float d= dot_v2v2(a, a); if(d > 1.0e-35f) { d= sqrtf(d); - mul_v2_fl(n, 1.0f/d); + mul_v2_v2fl(r, a, 1.0f/d); } else { - zero_v2(n); + zero_v2(r); d= 0.0f; } + return d; } -MINLINE float normalize_v3(float n[3]) +MINLINE float normalize_v2(float n[2]) { - float d= dot_v3v3(n, n); + return normalize_v2_v2(n, n); +} + +MINLINE float normalize_v3_v3(float r[3], const float a[3]) +{ + float d= dot_v3v3(a, a); /* a larger value causes normalize errors in a scaled down models with camera xtreme close */ if(d > 1.0e-35f) { d= sqrtf(d); - mul_v3_fl(n, 1.0f/d); + mul_v3_v3fl(r, a, 1.0f/d); } else { - zero_v3(n); + zero_v3(r); d= 0.0f; } return d; } +MINLINE float normalize_v3(float n[3]) +{ + return normalize_v3_v3(n, n); +} + MINLINE void normal_short_to_float_v3(float *out, short *in) { out[0] = in[0]*(1.0f/32767.0f); From 63e80e271dd3f9f79fe3a85c10253ee6eea2ba4e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Jan 2010 19:51:26 +0000 Subject: [PATCH 072/202] Bugfix: drivers on constraint properties could get set to invalid when transforming, due to the evaluation of the object transform without constraints, and the driver not finding the property. Constraints are now disabled in a way that should avoid this problem --- source/blender/blenkernel/intern/object.c | 2 +- .../editors/transform/transform_conversions.c | 13 ++++--------- source/blender/makesdna/DNA_object_types.h | 1 + 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 762ad2432b0..13e86dd3576 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2035,7 +2035,7 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) } /* solve constraints */ - if (ob->constraints.first) { + if (ob->constraints.first && !(ob->flag & OB_NO_CONSTRAINTS)) { bConstraintOb *cob; cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 49e7f040390..3d677d0789d 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4256,18 +4256,13 @@ static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object * track= ob->track; ob->track= NULL; - if (constinv == 0) { - fakecons.first = ob->constraints.first; - fakecons.last = ob->constraints.last; - ob->constraints.first = ob->constraints.last = NULL; - } + if (constinv == 0) + ob->transflag |= OB_NO_CONSTRAINTS; /* where_is_object_time checks this */ where_is_object(t->scene, ob); - if (constinv == 0) { - ob->constraints.first = fakecons.first; - ob->constraints.last = fakecons.last; - } + if (constinv == 0) + ob->transflag &= ~OB_NO_CONSTRAINTS; ob->track= track; } diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 8eb02b28331..2b4b0a7b612 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -334,6 +334,7 @@ extern Object workob; #define OB_DUPLIFACES_SCALE 1024 #define OB_DUPLIPARTS 2048 #define OB_RENDER_DUPLI 4096 +#define OB_NO_CONSTRAINTS 8096 /* runtime constraints disable */ /* (short) ipoflag */ // XXX depreceated - old animation system crap From b39be6007576021fb377343cd880bfcc44b77031 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Jan 2010 21:20:09 +0000 Subject: [PATCH 073/202] NLA: fix keyframes getting messed up when making strips longer. For drawing and other operations the nla mapping would be applied to the curves, but not restored correctly. The unmap function was not the inverse of the map function, and it's not clear to me it's even possible to make it so due to repeat, so now the old coordinates are backed up in a list and then restored afterwards. --- source/blender/editors/animation/anim_draw.c | 40 ++++++++++++------- .../editors/animation/keyframes_draw.c | 6 ++- source/blender/editors/include/ED_anim_api.h | 2 +- .../editors/include/ED_keyframes_edit.h | 1 + .../editors/space_action/action_edit.c | 19 +++++---- .../editors/space_action/action_select.c | 12 ++++-- .../blender/editors/space_graph/graph_draw.c | 5 ++- .../blender/editors/space_graph/graph_edit.c | 18 ++++++--- .../editors/space_graph/graph_select.c | 17 +++++--- .../editors/transform/transform_conversions.c | 19 +++++---- source/blender/makesrna/intern/rna_nla.c | 8 ++++ 11 files changed, 98 insertions(+), 49 deletions(-) diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 60242d3e837..fbacd22b360 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -252,20 +252,22 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale) /* ------------------- */ +typedef struct NlaMappingApplyBackup { + struct NlaMappingBackup *next, *prev; + BezTriple bezt; +} NlaMappingApplyBackup; + /* helper function for ANIM_nla_mapping_apply_fcurve() -> "restore", i.e. mapping points back to action-time */ static short bezt_nlamapping_restore(BeztEditData *bed, BezTriple *bezt) { - /* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */ - AnimData *adt= (AnimData *)bed->data; - short only_keys= (short)bed->i1; - - /* adjust BezTriple handles only if allowed to */ - if (only_keys == 0) { - bezt->vec[0][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_UNMAP); - bezt->vec[2][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_UNMAP); - } - - bezt->vec[1][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_UNMAP); + ListBase *lb= (ListBase*)bed->data2; + NlaMappingApplyBackup *backup= lb->first; + + /* restore beztriple from backup list. this used to use NLATIME_CONVERT_UNMAP, + but this was not the inverse of NLATIME_CONVERT_MAP and it's not clear how + that is even possible due to repeats - brecht. */ + *bezt= backup->bezt; + BLI_freelinkN(lb, backup); return 0; } @@ -274,8 +276,15 @@ static short bezt_nlamapping_restore(BeztEditData *bed, BezTriple *bezt) static short bezt_nlamapping_apply(BeztEditData *bed, BezTriple *bezt) { /* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */ - AnimData *adt= (AnimData *)bed->data; + AnimData *adt= (AnimData*)bed->data; + ListBase *lb= (ListBase*)bed->data2; + NlaMappingApplyBackup *backup; short only_keys= (short)bed->i1; + + /* backup for restore later */ + backup= MEM_callocN(sizeof(NlaMappingApplyBackup), "NlaMappingApplyBackup"); + backup->bezt= *bezt; + BLI_addtail(lb, backup); /* adjust BezTriple handles only if allowed to */ if (only_keys == 0) { @@ -289,12 +298,11 @@ static short bezt_nlamapping_apply(BeztEditData *bed, BezTriple *bezt) } - /* Apply/Unapply NLA mapping to all keyframes in the nominated F-Curve * - restore = whether to map points back to non-mapped time * - only_keys = whether to only adjust the location of the center point of beztriples */ -void ANIM_nla_mapping_apply_fcurve (AnimData *adt, FCurve *fcu, short restore, short only_keys) +void ANIM_nla_mapping_apply_fcurve (AnimData *adt, FCurve *fcu, short restore, short only_keys, ListBase *backup) { BeztEditData bed; BeztEditFunc map_cb; @@ -305,7 +313,11 @@ void ANIM_nla_mapping_apply_fcurve (AnimData *adt, FCurve *fcu, short restore, s */ memset(&bed, 0, sizeof(BeztEditData)); bed.data= (void *)adt; + bed.data2= (void *)backup; bed.i1= (int)only_keys; + + if(!restore) + backup->first= backup->last= NULL; /* get editing callback */ if (restore) diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 42fe9160946..63633468767 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -850,12 +850,13 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree { DLRBT_Tree *beztTree = NULL; BezTriple *bezt; + ListBase nlabackup; int v; if (fcu && fcu->totvert && fcu->bezt) { /* apply NLA-mapping (if applicable) */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1, &nlabackup); /* if getting long keyframes too, grab the BezTriples in a BST for * accelerated searching... @@ -891,7 +892,8 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree } /* unapply NLA-mapping if applicable */ - ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1); + if (adt) + ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1, &nlabackup); } } diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 531751a609e..6d81131492a 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -453,7 +453,7 @@ void getcolor_fcurve_rainbow(int cur, int tot, float *out); struct AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale); /* Apply/Unapply NLA mapping to all keyframes in the nominated F-Curve */ -void ANIM_nla_mapping_apply_fcurve(struct AnimData *adt, struct FCurve *fcu, short restore, short only_keys); +void ANIM_nla_mapping_apply_fcurve(struct AnimData *adt, struct FCurve *fcu, short restore, short only_keys, ListBase *backup); /* ..... */ diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index 9e29d747d4a..d567398209f 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -94,6 +94,7 @@ typedef struct BeztEditData { ListBase list; /* temp list for storing custom list of data to check */ struct Scene *scene; /* pointer to current scene - many tools need access to cfra/etc. */ void *data; /* pointer to custom data - usually 'Object' but also 'rectf', but could be other types too */ + void *data2; /* pointer to more custom data */ float f1, f2; /* storage of times/values as 'decimals' */ int i1, i2; /* storage of times/values/flags as 'whole' numbers */ } BeztEditData; diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 687e7c53644..b35f9594397 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -1133,11 +1133,12 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *op) for (ale= anim_data.first; ale; ale= ale->next) { AnimData *adt= ANIM_nla_mapping_get(&ac, ale); - if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); } else ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL); @@ -1215,9 +1216,11 @@ static void snap_action_keys(bAnimContext *ac, short mode) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); } //else if (ale->type == ACTTYPE_GPLAYER) // snap_gplayer_frames(ale->data, mode); @@ -1332,9 +1335,11 @@ static void mirror_action_keys(bAnimContext *ac, short mode) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); } //else if (ale->type == ACTTYPE_GPLAYER) // snap_gplayer_frames(ale->data, mode); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 8eeed6da100..9155f57c7a0 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -417,9 +417,11 @@ static void markers_selectkeys_between (bAnimContext *ac) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); } else { ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); @@ -663,9 +665,11 @@ static void actkeys_mselect_leftright (bAnimContext *ac, short leftright, short AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); } //else if (ale->type == ANIMTYPE_GPLAYER) // borderselect_gplayer_frames(ale->data, min, max, SELECT_ADD); diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 9681d20c13b..4735950c9d1 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -819,10 +819,11 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri FCurve *fcu= (FCurve *)ale->key_data; FModifier *fcm= find_active_fmodifier(&fcu->modifiers); AnimData *adt= ANIM_nla_mapping_get(ac, ale); + ListBase nlabackup; /* map keyframes for drawing if scaled F-Curve */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0, &nlabackup); /* draw curve: * - curve line may be result of one or more destructive modifiers or just the raw data, @@ -908,7 +909,7 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri /* undo mapping of keyframes for drawing if scaled F-Curve */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0, &nlabackup); } /* free list of curves */ diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 2adf783b338..1bae3686fe2 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1557,9 +1557,11 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *op) AnimData *adt= ANIM_nla_mapping_get(&ac, ale); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); } else ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL); @@ -1645,9 +1647,11 @@ static void snap_graph_keys(bAnimContext *ac, short mode) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); } else ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); @@ -1762,9 +1766,11 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); } else ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 8d2e2921b7f..b732d17e34f 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -394,9 +394,11 @@ static void markers_selectkeys_between (bAnimContext *ac) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); } else { ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); @@ -589,10 +591,11 @@ static short findnearest_fcurve_vert (bAnimContext *ac, int mval[2], FCurve **fc /* try to progressively get closer to the right point... */ if (fcu->bezt) { BezTriple *bezt1=fcu->bezt, *prevbezt=NULL; + ListBase nlabackup; /* apply NLA mapping to all the keyframes */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); for (i=0; i < fcu->totvert; i++, prevbezt=bezt1, bezt1++) { /* convert beztriple points to screen-space */ @@ -650,7 +653,7 @@ static short findnearest_fcurve_vert (bAnimContext *ac, int mval[2], FCurve **fc /* un-apply NLA mapping from all the keyframes */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); } } @@ -797,9 +800,11 @@ static void graphkeys_mselect_leftright (bAnimContext *ac, short leftright, shor AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); } else ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 3d677d0789d..2769112e5d5 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3014,9 +3014,11 @@ static void posttrans_action_clean (bAnimContext *ac, bAction *act) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); posttrans_fcurve_clean(ale->key_data); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); } else posttrans_fcurve_clean(ale->key_data); @@ -4230,7 +4232,6 @@ static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object * { Scene *scene = CTX_data_scene(C); Object *track; - ListBase fakecons = {NULL, NULL}; float obmtx[3][3]; short constinv; short skip_invert = 0; @@ -4784,9 +4785,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) ((cancelled == 0) || (duplicate)) ) { if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1, &nlabackup); posttrans_fcurve_clean(fcu); - ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1, &nlabackup); } else posttrans_fcurve_clean(fcu); @@ -4865,9 +4868,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) ((cancelled == 0) || (duplicate)) ) { if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1); + ListBase nlabackup; + + ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1, &nlabackup); posttrans_fcurve_clean(fcu); - ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1, &nlabackup); } else posttrans_fcurve_clean(fcu); diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 20d1a898303..426cb1f0772 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -85,6 +85,12 @@ static char *rna_NlaStrip_path(PointerRNA *ptr) return ""; } +static void rna_NlaStrip_transform_update(Main *bmain, PointerRNA *ptr) +{ + NlaStrip *strip= (NlaStrip*)ptr->data; + + BKE_nlameta_flush_transforms(strip); +} static void rna_NlaStrip_start_frame_set(PointerRNA *ptr, float value) { @@ -326,11 +332,13 @@ static void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "start"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Start Frame", ""); + RNA_def_property_update(prop, 0, "rna_NlaStrip_transform_update"); prop= RNA_def_property(srna, "end_frame", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "end"); RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_end_frame_set", NULL); RNA_def_property_ui_text(prop, "End Frame", ""); + RNA_def_property_update(prop, 0, "rna_NlaStrip_transform_update"); /* Blending */ prop= RNA_def_property(srna, "blend_in", PROP_FLOAT, PROP_NONE); From 17108481a9f934102c14bacdf0b994afba00e493 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Tue, 12 Jan 2010 23:30:19 +0000 Subject: [PATCH 074/202] [#20093] Consistent Crash in properties window Fun bug, took me the better part of the day to track down. Happens because maximizing swaps spacedata lists between the old area and the newly created maximized area (this one being empty) while ui handlers are still hanging with references to the first area (then trying to access spacedata when handled). And then only if a maximizing operator was run before the UI realign timer event from the previous maximize was handled (fun, I told you). After discussion with Matt on irc, we decided the best way to deal with that was to remove ui handlers that reference areas of a screen that is no longer used. That solution reflects the fact that the bug is more general that the reproducing steps would lead to believe. There's also absolutely no reason to run UI handlers on invisible areas. --- source/blender/editors/screen/screen_edit.c | 8 +++++++- source/blender/windowmanager/WM_api.h | 1 + .../windowmanager/intern/wm_event_system.c | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index f0003669a12..2069858c97d 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1271,7 +1271,13 @@ void ED_screen_set(bContext *C, bScreen *sc) if (oldscreen != sc) { wmTimer *wt= oldscreen->animtimer; - + ScrArea *sa; + + /* remove handlers referencing areas in old screen */ + for(sa = oldscreen->areabase.first; sa; sa = sa->next) { + WM_event_remove_area_handler(&win->modalhandlers, sa); + } + /* we put timer to sleep, so screen_exit has to think there's no timer */ oldscreen->animtimer= NULL; if(wt) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 94cd6ed85a0..4cc116e7bbd 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -150,6 +150,7 @@ struct wmEventHandler *WM_event_add_ui_handler(const struct bContext *C, ListBas void WM_event_remove_ui_handler(ListBase *handlers, int (*func)(struct bContext *C, struct wmEvent *event, void *userdata), void (*remove)(struct bContext *C, void *userdata), void *userdata); +void WM_event_remove_area_handler(struct ListBase *handlers, void *area); struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op); void WM_event_remove_handlers(struct bContext *C, ListBase *handlers); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 9a6d02790e5..f437e096755 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1620,6 +1620,25 @@ void WM_event_remove_ui_handler(ListBase *handlers, wmUIHandlerFunc func, wmUIHa } } +void WM_event_remove_area_handler(ListBase *handlers, void *area) +{ + wmEventHandler *handler, *nexthandler; + + for(handler = handlers->first; handler; handler= nexthandler) { + nexthandler = handler->next; + if (handler->ui_area == area || handler->op_area == area) { + BLI_remlink(handlers, handler); + wm_event_free_handler(handler); + } + } +} + +void WM_event_remove_handler(ListBase *handlers, wmEventHandler *handler) +{ + BLI_remlink(handlers, handler); + wm_event_free_handler(handler); +} + void WM_event_add_mousemove(bContext *C) { wmWindow *window= CTX_wm_window(C); From f0180b700d4573d0e3f780dcc177c33eeb7bc0a9 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 13 Jan 2010 00:15:17 +0000 Subject: [PATCH 075/202] Adding .glsl and .data to the Text filtering in the File editor (with Andrea's aval) (.data is what we use by default as a dome mesh warp format, btw) --- source/blender/editors/space_file/filelist.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 81aa63dcad9..7ccaa6e2789 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -863,7 +863,9 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) file->flags |= BLENDERFILE; } else if(BLI_testextensie(file->relname, ".py")) { file->flags |= PYSCRIPTFILE; - } else if(BLI_testextensie(file->relname, ".txt")) { + } else if(BLI_testextensie(file->relname, ".txt") + || BLI_testextensie(file->relname, ".glsl") + || BLI_testextensie(file->relname, ".data")) { file->flags |= TEXTFILE; } else if( BLI_testextensie(file->relname, ".ttf") || BLI_testextensie(file->relname, ".ttc") From 8e076e0341797cac449895f4ab57e0c0c94cc74f Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 13 Jan 2010 00:43:59 +0000 Subject: [PATCH 076/202] Fix [#20649] when header is on top of 3D View and all regions are collapsed, expansion icons overlap --- source/blender/editors/screen/area.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index c494afac79e..bf4dba5a4fe 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -512,9 +512,9 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) } else if(az->edge=='b') { az->x1= ar->winrct.xmin + AZONEPAD_ICON; - az->y1= ar->winrct.ymin - AZONEPAD_ICON; + az->y1= ar->winrct.ymin - 2*AZONEPAD_ICON; az->x2= ar->winrct.xmin + 2*AZONEPAD_ICON; - az->y2= ar->winrct.ymin - 2*AZONEPAD_ICON; + az->y2= ar->winrct.ymin - AZONEPAD_ICON; } else if(az->edge=='l') { az->x1= ar->winrct.xmin - 2*AZONEPAD_ICON; From 0edecb73cf2928108c42bf1ae667a1ce7a3f0b96 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 13 Jan 2010 02:01:34 +0000 Subject: [PATCH 077/202] Fix [#20655] wrong button shading Also restored copy/paste for color swatches --- source/blender/editors/interface/interface.c | 2 +- source/blender/editors/interface/interface_handlers.c | 2 +- source/blender/editors/interface/interface_widgets.c | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 5c91a91e447..7a1cc4f5bad 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -812,7 +812,7 @@ static void ui_is_but_sel(uiBut *but) if(value == but->hardmax) push= 1; break; case COL: - push= 1; + push= 2; break; default: push= 2; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 7c0fa1fbc74..705decec70d 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -948,7 +948,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, else { if (sscanf(buf, "[%f, %f, %f]", &rgb[0], &rgb[1], &rgb[2]) == 3) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - VECCOPY(data->vec, rgb); + ui_set_but_vectorf(but, rgb); button_activate_state(C, but, BUTTON_STATE_EXIT); } } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 6c78a1f2a11..7b975d17184 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1330,10 +1330,8 @@ static void widget_state(uiWidgetType *wt, int state) VECCOPY(wt->wcol.text, wt->wcol.text_sel); - /* only flip shade if it's not "pushed in" already */ - if(wt->wcol.shaded && wt->wcol.shadetop>wt->wcol.shadedown) { - SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); - } + /* swap for selection - show depressed */ + SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); } else { if(state & UI_BUT_ANIMATED_KEY) From 6f0acf3cf3b87c48b854d720ae5b50b5c8092682 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 13 Jan 2010 02:59:42 +0000 Subject: [PATCH 078/202] Fix for Martin's fix, caused file selector to stop working. Fileselect handlers are added to window's modalhandlers, and contain references to other areas/regions/etc... Still seems a little bit dodgy, but fixes file selectors for now. --- source/blender/windowmanager/intern/wm_event_system.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index f437e096755..11bd6f3e6ef 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1625,10 +1625,12 @@ void WM_event_remove_area_handler(ListBase *handlers, void *area) wmEventHandler *handler, *nexthandler; for(handler = handlers->first; handler; handler= nexthandler) { - nexthandler = handler->next; - if (handler->ui_area == area || handler->op_area == area) { - BLI_remlink(handlers, handler); - wm_event_free_handler(handler); + if (handler->type != WM_HANDLER_FILESELECT) { + nexthandler = handler->next; + if (handler->ui_area == area || handler->op_area == area) { + BLI_remlink(handlers, handler); + wm_event_free_handler(handler); + } } } } From 0e396094686210f81a86b1217c2f76e6262acfe9 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 13 Jan 2010 03:21:55 +0000 Subject: [PATCH 079/202] =?UTF-8?q?Fix=20[#20557]=20animated=20node=20valu?= =?UTF-8?q?es=20haven't=20effect=20while=20render=20animati=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Was only updating the animation system for the render process - if scene render was skipped (as is the case for comp trees without renderlayer nodes) then the animation system wouldn't update. Added in an update here, Aligorith, maybe you'd like to doublecheck. --- source/blender/render/intern/source/pipeline.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 54f89a65566..5824e917fca 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2366,6 +2366,7 @@ void RE_MergeFullSample(Render *re, Scene *sce, bNodeTree *ntree) static void do_render_composite_fields_blur_3d(Render *re) { bNodeTree *ntree= re->scene->nodetree; + int update_newframe=0; /* INIT seeding, compositor can use random texture */ BLI_srandom(re->r.cfra); @@ -2375,6 +2376,9 @@ static void do_render_composite_fields_blur_3d(Render *re) ntreeFreeCache(ntree); do_render_fields_blur_3d(re); + } else { + /* scene render process already updates animsys */ + update_newframe = 1; } /* swap render result */ @@ -2403,10 +2407,14 @@ static void do_render_composite_fields_blur_3d(Render *re) R.sdh= re->sdh; R.stats_draw= re->stats_draw; + if (update_newframe) + scene_update_for_newframe(re->scene, re->scene->lay); + if(re->r.scemode & R_FULL_SAMPLE) do_merge_fullsample(re, ntree); - else + else { ntreeCompositExecTree(ntree, &re->r, G.background==0); + } ntree->stats_draw= NULL; ntree->test_break= NULL; From 7c80ece9c8910ac68f7465cd7b728e97780ca913 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 13 Jan 2010 03:36:08 +0000 Subject: [PATCH 080/202] Fix [#20614] renaming certain things in outliner->datablocks makes blender unresponsive to keystrokes Outliner isn't able to rename things in datablocks view, disabled it from the UI. --- source/blender/editors/space_outliner/outliner.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index be125725e4e..9e9b0075f0f 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -2494,8 +2494,11 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T /* name and first icon */ if(mval[0]>te->xs && mval[0]xend) { - - if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) + + /* can't rename rna datablocks entries */ + if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) + ; + else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) error("Cannot edit builtin name"); else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) error("Cannot edit sequence name"); From 728359a6a5fd5736e1f1fdfa359f22474e76fd1d Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Wed, 13 Jan 2010 04:27:10 +0000 Subject: [PATCH 081/202] Don't loop forever. --- source/blender/windowmanager/intern/wm_event_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 11bd6f3e6ef..57d67400444 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1625,8 +1625,8 @@ void WM_event_remove_area_handler(ListBase *handlers, void *area) wmEventHandler *handler, *nexthandler; for(handler = handlers->first; handler; handler= nexthandler) { + nexthandler = handler->next; if (handler->type != WM_HANDLER_FILESELECT) { - nexthandler = handler->next; if (handler->ui_area == area || handler->op_area == area) { BLI_remlink(handlers, handler); wm_event_free_handler(handler); From 7df44b9cede3aa903c4463f9e5f885a705b4173a Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 13 Jan 2010 06:35:12 +0000 Subject: [PATCH 082/202] Fix: wasn't able to rename node group nodetree name, or access the nodetree at all. Now you can switch between them too. Wrapped group nodes in RNA as part of this. --- source/blender/editors/include/UI_interface.h | 2 + .../editors/interface/interface_templates.c | 16 +++---- source/blender/editors/space_node/drawnode.c | 45 +------------------ source/blender/editors/space_node/node_draw.c | 2 +- .../blender/editors/space_node/node_intern.h | 2 + source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_nodetree.c | 41 ++++++++++++++++- 7 files changed, 55 insertions(+), 54 deletions(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 0b7499b947a..5344c1a617f 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -642,6 +642,8 @@ void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus); void uiTemplateDopeSheetFilter(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr); void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop); +void uiTemplateIDBrowse(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, + char *newop, char *openop, char *unlinkop); void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, int rows, int cols); void uiTemplateAnyID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 106875e3907..e00cd8986e0 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -446,12 +446,11 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str uiBlockEndAlign(block); } -static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, int previews, int prv_rows, int prv_cols) +static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, int flag, int prv_rows, int prv_cols) { TemplateID *template; PropertyRNA *prop; StructRNA *type; - int flag; prop= RNA_struct_find_property(ptr, propname); @@ -466,14 +465,10 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char template->prv_rows = prv_rows; template->prv_cols = prv_cols; - flag= UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE; - if(newop) flag |= UI_ID_ADD_NEW; if(openop) flag |= UI_ID_OPEN; - if(previews) - flag |= UI_ID_PREVIEWS; type= RNA_property_pointer_type(ptr, prop); template->idlb= wich_libbase(CTX_data_main(C), RNA_type_to_ID_code(type)); @@ -492,12 +487,17 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop) { - ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, 0, 0, 0); + ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE, 0, 0); +} + +void uiTemplateIDBrowse(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop) +{ + ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME, 0, 0); } void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, int rows, int cols) { - ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, 1, rows, cols); + ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE|UI_ID_PREVIEWS, rows, cols); } /************************ ID Chooser Template ***************************/ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 7f8bf2618a4..5c5e316663c 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -94,54 +94,13 @@ #include "node_intern.h" -/* ****************** GENERAL CALLBACKS FOR NODES ***************** */ - -#if 0 -/* XXX not used yet, make compiler happy :) */ -static void node_group_alone_cb(bContext *C, void *node_v, void *unused_v) -{ - bNode *node= node_v; - - nodeCopyGroup(node); - - // allqueue(REDRAWNODE, 0); -} /* ****************** BUTTON CALLBACKS FOR ALL TREES ***************** */ -static void node_buts_group(uiLayout *layout, bContext *C, PointerRNA *ptr) +void node_buts_group(uiLayout *layout, bContext *C, PointerRNA *ptr) { - uiBlock *block= uiLayoutAbsoluteBlock(layout); - bNode *node= ptr->data; - rctf *butr= &node->butr; - - if(node->id) { - uiBut *bt; - short width; - - uiBlockBeginAlign(block); - - /* name button */ - width= (short)(butr->xmax-butr->xmin - (node->id->us>1?19.0f:0.0f)); - bt= uiDefBut(block, TEX, B_NOP, "NT:", - (short)butr->xmin, (short)butr->ymin, width, 19, - node->id->name+2, 0.0, 19.0, 0, 0, "NodeTree name"); - uiButSetFunc(bt, node_ID_title_cb, node, NULL); - - /* user amount */ - if(node->id->us>1) { - char str1[32]; - sprintf(str1, "%d", node->id->us); - bt= uiDefBut(block, BUT, B_NOP, str1, - (short)butr->xmax-19, (short)butr->ymin, 19, 19, - NULL, 0, 0, 0, 0, "Displays number of users."); - uiButSetFunc(bt, node_group_alone_cb, node, NULL); - } - - uiBlockEndAlign(block); - } + uiTemplateIDBrowse(layout, C, ptr, "nodetree", NULL, NULL, ""); } -#endif static void node_buts_value(uiLayout *layout, bContext *C, PointerRNA *ptr) { diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 14c127cb7e5..ad897e1dd6e 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -265,7 +265,7 @@ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) /* XXX ugly hack, typeinfo for group is generated */ if(node->type == NODE_GROUP) - ; // XXX node->typeinfo->uifunc= node_buts_group; + node->typeinfo->uifunc= node_buts_group; /* buttons rect? */ if((node->flag & NODE_OPTIONS) && node->typeinfo->uifunc) { diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 1ff2f7d7128..8f6d2c81026 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -69,6 +69,8 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int t int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol); void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage); +void node_buts_group(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr); + /* node_edit.c */ void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype); void snode_handle_recalc(bContext *C, SpaceNode *snode); diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index efd42878087..ba2d272309f 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -317,6 +317,7 @@ extern StructRNA RNA_NearSensor; extern StructRNA RNA_NlaStrip; extern StructRNA RNA_NlaTrack; extern StructRNA RNA_Node; +extern StructRNA RNA_NodeGroup; extern StructRNA RNA_NodeSocket; extern StructRNA RNA_NodeTree; extern StructRNA RNA_NoiseTexture; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 9922f099cd5..646a7419d68 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -63,6 +63,9 @@ static StructRNA *rna_Node_refine(struct PointerRNA *ptr) #undef DefNode + case NODE_GROUP: + return &RNA_NodeGroup; + default: return &RNA_Node; } @@ -177,6 +180,16 @@ static void rna_Node_update(Main *bmain, Scene *scene, PointerRNA *ptr) node_update(bmain, scene, ntree, node); } +static void rna_NodeGroup_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bNodeTree *ntree= (bNodeTree*)ptr->id.data; + bNode *node= (bNode*)ptr->data; + + nodeVerifyGroup((bNodeTree *)node->id); + + node_update(bmain, scene, ntree, node); +} + static void rna_Node_update_name(Main *bmain, Scene *scene, PointerRNA *ptr) { bNodeTree *ntree= (bNodeTree*)ptr->id.data; @@ -474,7 +487,7 @@ static EnumPropertyItem node_filter_items[] = { enum { - Category_NoCategory, + Category_GroupNode, Category_ShaderNode, Category_CompositorNode, Category_TextureNode @@ -521,6 +534,8 @@ static void init(void) #undef DefNode #undef Str + + reg_node(NODE_GROUP, Category_GroupNode, "GROUP", "NodeGroup", "Node", "Group", ""); } static StructRNA* def_node(BlenderRNA *brna, int node_id) @@ -567,6 +582,13 @@ static EnumPropertyItem* alloc_node_type_items(int category) item++; + item->value = NODE_GROUP; + item->identifier = "GROUP"; + item->name = "Group"; + item->description = ""; + + item++; + memset(item, 0, sizeof(EnumPropertyItem)); return items; @@ -575,6 +597,19 @@ static EnumPropertyItem* alloc_node_type_items(int category) /* -- Common nodes ---------------------------------------------------------- */ +static void def_group(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "nodetree", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "id"); + RNA_def_property_struct_type(prop, "NodeTree"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Node Tree", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeGroup_update"); +} + + static void def_math(StructRNA *srna) { PropertyRNA *prop; @@ -2106,13 +2141,15 @@ void RNA_def_nodetree(BlenderRNA *brna) rna_def_shader_node(brna); rna_def_compositor_node(brna); rna_def_texture_node(brna); - + #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \ define_specific_node(brna, ID, DefFunc); #include "rna_nodetree_types.h" #undef DefNode + + define_specific_node(brna, NODE_GROUP, def_group); } #endif From d2e7abec82010ae6edede459bbf33468a9f5a839 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jan 2010 08:12:57 +0000 Subject: [PATCH 083/202] makesrna was failing because of a buffer overrun from an error in r25949 --- source/blender/makesrna/intern/rna_nodetree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 646a7419d68..d7c72412e51 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -553,7 +553,7 @@ static StructRNA* def_node(BlenderRNA *brna, int node_id) static EnumPropertyItem* alloc_node_type_items(int category) { int i; - int count = 2; + int count = 3; EnumPropertyItem *item, *items; for(i=0; i Date: Wed, 13 Jan 2010 08:39:32 +0000 Subject: [PATCH 084/202] node uninitialized memory valgrind found while looking into crash. --- source/blender/makesrna/intern/CMakeLists.txt | 1 + source/blender/makesrna/intern/rna_nodetree.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index b42252fec99..eb524a650fd 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -99,6 +99,7 @@ TARGET_LINK_LIBRARIES(makesrna bf_dna) # Output rna_*_gen.c ADD_CUSTOM_COMMAND( OUTPUT ${GENSRC} + # with crashes try add this after COMMEND: valgrind --leak-check=full --track-origins=yes COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesrna ${CMAKE_CURRENT_BINARY_DIR}/ DEPENDS makesrna ) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index d7c72412e51..4ad3984d1d9 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -577,6 +577,7 @@ static EnumPropertyItem* alloc_node_type_items(int category) item->value = NODE_DYNAMIC; item->identifier = "SCRIPT"; + item->icon = 0; item->name = "Script"; item->description = ""; @@ -584,6 +585,7 @@ static EnumPropertyItem* alloc_node_type_items(int category) item->value = NODE_GROUP; item->identifier = "GROUP"; + item->icon = 0; item->name = "Group"; item->description = ""; From 54bb90bc7e0f9f14accd3315877871750772194f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Jan 2010 11:37:08 +0000 Subject: [PATCH 085/202] Fix rendering of normal maps, was broken by new bump mapping. --- source/blender/render/intern/source/texture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 7bf349705cb..38ee8f73616 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -1739,7 +1739,7 @@ void do_material_tex(ShadeInput *shi) // NOTE: test for shi->obr->ob here, since vlr/obr/obi can be 'fake' when called from fastshade(), another reason to move it.. // NOTE: shi->v1 is NULL when called from displace_render_vert, assigning verts in this case is not trivial because the shi quad face side is not know. if ((mtex->texflag & MTEX_NEW_BUMP) && shi->obr && shi->obr->ob && shi->v1) { - if(mtex->mapto & (MAP_NORM|MAP_DISPLACE|MAP_WARP)) { + if(mtex->mapto & (MAP_NORM|MAP_DISPLACE|MAP_WARP) && !((tex->type==TEX_IMAGE) && (tex->imaflag & TEX_NORMALMAP))) { MTFace* tf = RE_vlakren_get_tface(shi->obr, shi->vlr, i, NULL, 0); int j1 = shi->i1, j2 = shi->i2, j3 = shi->i3; @@ -1832,7 +1832,7 @@ void do_material_tex(ShadeInput *shi) nunvdone= 1; } - if(texres.nor) { + if(texres.nor && !((tex->type==TEX_IMAGE) && (tex->imaflag & TEX_NORMALMAP))) { TexResult ttexr = {0, 0, 0, 0, 0, texres.talpha, NULL}; // temp TexResult float tco[3], texv[3], cd, ud, vd, du, dv, idu, idv; const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0)); From e691c9d1512b480406e8fbda6abc743a9369f4e9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jan 2010 12:15:04 +0000 Subject: [PATCH 086/202] RNA NLA update function was wrong, taking the scene as a PointerRNA --- source/blender/makesrna/intern/rna_nla.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 426cb1f0772..79b34a4cfe3 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -85,7 +85,7 @@ static char *rna_NlaStrip_path(PointerRNA *ptr) return ""; } -static void rna_NlaStrip_transform_update(Main *bmain, PointerRNA *ptr) +static void rna_NlaStrip_transform_update(Main *bmain, Scene *scene, PointerRNA *ptr) { NlaStrip *strip= (NlaStrip*)ptr->data; From 3c888b63f0e7dfeff5003a80857a0285b29395c1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jan 2010 12:16:10 +0000 Subject: [PATCH 087/202] fix crash for projection painting with subsurf or multires, while drawing the verts & faces were bening freed. --- .../editors/sculpt_paint/paint_image.c | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 77e90e3c7b1..17223e3bc4a 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -2840,7 +2840,17 @@ static void project_paint_begin(ProjPaintState *ps) } } - + /* when using subsurf or multires, mface arrays are thrown away, we need to keep a copy */ + if(ps->dm->type != DM_TYPE_CDDM) { + ps->dm_mvert= MEM_dupallocN(ps->dm_mvert); + ps->dm_mface= MEM_dupallocN(ps->dm_mface); + /* looks like these are ok for now.*/ + /* + ps->dm_mtface= MEM_dupallocN(ps->dm_mtface); + ps->dm_mtface_clone= MEM_dupallocN(ps->dm_mtface_clone); + ps->dm_mtface_stencil= MEM_dupallocN(ps->dm_mtface_stencil); + */ + } ps->viewDir[0] = 0.0f; ps->viewDir[1] = 0.0f; @@ -3266,6 +3276,18 @@ static void project_paint_end(ProjPaintState *ps) BLI_memarena_free(ps->arena_mt[a]); } + /* copy for subsurf/multires, so throw away */ + if(ps->dm->type != DM_TYPE_CDDM) { + if(ps->dm_mvert) MEM_freeN(ps->dm_mvert); + if(ps->dm_mface) MEM_freeN(ps->dm_mface); + /* looks like these dont need copying */ + /* + if(ps->dm_mtface) MEM_freeN(ps->dm_mtface); + if(ps->dm_mtface_clone) MEM_freeN(ps->dm_mtface_clone); + if(ps->dm_mtface_stencil) MEM_freeN(ps->dm_mtface_stencil); + */ + } + if(ps->dm_release) ps->dm->release(ps->dm); } From e5be23c141a4d5e857cd1d08b9a5151f4eb74d9e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jan 2010 12:17:21 +0000 Subject: [PATCH 088/202] check if the layer exists rather then getting the array. --- source/blender/blenkernel/intern/modifier.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 2985eb7774b..7fffd7fc223 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -3617,7 +3617,7 @@ static void get_texture_coords(DisplaceModifierData *dmd, Object *ob, /* UVs need special handling, since they come from faces */ if(texmapping == MOD_DISP_MAP_UV) { - if(dm->getFaceDataArray(dm, CD_MTFACE)) { + if(CustomData_has_layer(&dm->faceData, CD_MTFACE)) { MFace *mface = dm->getFaceArray(dm); MFace *mf; char *done = MEM_callocN(sizeof(*done) * numVerts, @@ -3699,8 +3699,8 @@ static void get_texture_value(Tex *texture, float *tex_co, TexResult *texres) * if the texture didn't give an RGB value, copy the intensity across */ if(result_type & TEX_RGB) - texres->tin = (0.35 * texres->tr + 0.45 * texres->tg - + 0.2 * texres->tb); + texres->tin = (0.35f * texres->tr + 0.45f * texres->tg + + 0.2f * texres->tb); else texres->tr = texres->tg = texres->tb = texres->tin; } @@ -3924,7 +3924,8 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, if(num_projectors == 0) return dm; /* make sure there are UV layers available */ - if(!dm->getFaceDataArray(dm, CD_MTFACE)) return dm; + + if(!CustomData_has_layer(&dm->faceData, CD_MTFACE)) return dm; /* make sure we're using an existing layer */ validate_layer_name(&dm->faceData, CD_MTFACE, umd->uvlayer_name, uvname); @@ -5185,7 +5186,7 @@ static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob, /* UVs need special handling, since they come from faces */ if(texmapping == MOD_WAV_MAP_UV) { - if(dm->getFaceDataArray(dm, CD_MTFACE)) { + if(CustomData_has_layer(&dm->faceData, CD_MTFACE)) { MFace *mface = dm->getFaceArray(dm); MFace *mf; char *done = MEM_callocN(sizeof(*done) * numVerts, From 574049782a34dcdc0f67b6c3077dc1e99db0d09e Mon Sep 17 00:00:00 2001 From: Arystanbek Dyussenov Date: Wed, 13 Jan 2010 12:51:07 +0000 Subject: [PATCH 089/202] Merge -c 25963 from COLLADA branch into trunk. --- source/blender/collada/DocumentExporter.cpp | 31 +++++++-------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index ef36a2eea9a..f0dd24a735f 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -859,11 +859,9 @@ private: return ob_arm; } - std::string get_joint_sid(Bone *bone) + std::string get_joint_sid(Bone *bone, Object *ob_arm) { - char name[100]; - BLI_strncpy(name, bone->name, sizeof(name)); - return translate_id(name); + return get_joint_id(bone, ob_arm); } // parent_mat is armature-space @@ -871,7 +869,7 @@ private: { std::string node_id = get_joint_id(bone, ob_arm); std::string node_name = std::string(bone->name); - std::string node_sid = get_joint_sid(bone); + std::string node_sid = get_joint_sid(bone, ob_arm); COLLADASW::Node node(mSW); @@ -1017,7 +1015,7 @@ private: for (def = (bDeformGroup*)defbase->first; def; def = def->next) { Bone *bone = get_bone_from_defgroup(ob_arm, def); if (bone) - source.appendValues(get_joint_sid(bone)); + source.appendValues(get_joint_sid(bone, ob_arm)); } source.finish(); @@ -1377,7 +1375,6 @@ public: } }; - class EffectsExporter: COLLADASW::LibraryEffects { public: @@ -1786,19 +1783,16 @@ protected: const char *axis_names[] = {"X", "Y", "Z"}; const char *axis_name = NULL; char anim_id[200]; - char anim_name[200]; if (fcu->array_index < 3) axis_name = axis_names[fcu->array_index]; - BLI_snprintf(anim_id, sizeof(anim_id), "%s.%s.%s", (char*)translate_id(ob_name).c_str(), + BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), fcu->rna_path, axis_names[fcu->array_index]); - BLI_snprintf(anim_name, sizeof(anim_name), "%s.%s.%s", - (char*)ob_name.c_str(), fcu->rna_path, axis_names[fcu->array_index]); // check rna_path is one of: rotation, scale, location - openAnimation(anim_id, anim_name); + openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); // create input source std::string input_id = create_source_from_fcurve(Sampler::INPUT, fcu, anim_id, axis_name); @@ -1957,7 +1951,6 @@ protected: const char *axis_names[] = {"X", "Y", "Z"}; const char *axis_name = NULL; char anim_id[200]; - char anim_name[200]; bool is_rot = tm_type == 0; if (!fra.size()) @@ -1972,14 +1965,10 @@ protected: std::string transform_sid = get_transform_sid(NULL, tm_type, axis_name); - BLI_snprintf(anim_id, sizeof(anim_id), "%s.%s.%s", (char*)translate_id(ob_name).c_str(), + BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), (char*)translate_id(bone_name).c_str(), (char*)transform_sid.c_str()); - BLI_snprintf(anim_name, sizeof(anim_name), "%s.%s.%s", - (char*)ob_name.c_str(), (char*)bone_name.c_str(), (char*)transform_sid.c_str()); - // TODO check rna_path is one of: rotation, scale, location - - openAnimation(anim_id, anim_name); + openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); // create input source std::string input_id = create_source_from_vector(Sampler::INPUT, fra, is_rot, anim_id, axis_name); @@ -2244,13 +2233,13 @@ protected: char *name = extract_transform_name(rna_path); if (strstr(name, "rotation")) - return std::string("rotation") + axis_name; + return std::string("rotation") + std::string(axis_name) + ".ANGLE"; else if (!strcmp(name, "location") || !strcmp(name, "scale")) return std::string(name); } else { if (tm_type == 0) - return std::string("rotation") + axis_name; + return std::string("rotation") + std::string(axis_name) + ".ANGLE"; else return tm_type == 1 ? "scale" : "location"; } From 75ec61d128071f0646bfedbf900908a08b538e19 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jan 2010 14:39:08 +0000 Subject: [PATCH 090/202] link markers to another scene, Currently in Ctrl+L menu (which isnt ideal but no menu in timeline for this) needed for linking in scenes and copying markers about --- release/scripts/ui/space_view3d.py | 2 +- .../blender/editors/animation/anim_markers.c | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 0c844440250..4f4c98dee69 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -777,7 +777,7 @@ class VIEW3D_MT_make_links(bpy.types.Menu): layout = self.layout layout.operator_menu_enum("object.make_links_scene", "type", text="Objects to Scene...") - + layout.operator_menu_enum("marker.make_links_scene", "type", text="Markers to Scene...") layout.operator_enums("object.make_links_data", property="type") # inline diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 7d1ddda1c6d..4f7a02bb688 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -41,6 +41,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "BLI_blenlib.h" @@ -48,6 +49,8 @@ #include "BKE_global.h" #include "BKE_fcurve.h" #include "BKE_utildefines.h" +#include "BKE_main.h" +#include "BKE_report.h" #include "WM_api.h" #include "WM_types.h" @@ -985,6 +988,56 @@ static void MARKER_OT_delete(wmOperatorType *ot) } +static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) +{ + ListBase *markers= context_get_markers(C); + Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "type")); + TimeMarker *marker, *marker_new; + + if(scene_to==NULL) { + BKE_report(op->reports, RPT_ERROR, "Scene not found"); + return OPERATOR_CANCELLED; + } + + if(scene_to == CTX_data_scene(C)) { + BKE_report(op->reports, RPT_ERROR, "Can't link objects into the same scene"); + return OPERATOR_CANCELLED; + } + + /* copy markers */ + for (marker= markers->first; marker; marker= marker->next) { + if(marker->flag & SELECT) { + marker_new= MEM_dupallocN(marker); + BLI_addtail(&scene_to->markers, marker_new); + } + } + + /* one day multiple scenes will be visible, then we should have some update function for them */ + return OPERATOR_FINISHED; +} + +static void MARKER_OT_make_links_scene(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name= "Make Links to Scene"; + ot->description= "Link markers to another scene."; + ot->idname= "MARKER_OT_make_links_scene"; + + /* api callbacks */ + ot->exec= ed_marker_make_links_scene_exec; + ot->poll= ED_operator_areaactive; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", ""); + RNA_def_enum_funcs(prop, RNA_scene_itemf); + +} + #ifdef DURIAN_CAMERA_SWITCH /* ******************************* camera bind marker ***************** */ @@ -1039,6 +1092,7 @@ void ED_operatortypes_marker(void) WM_operatortype_append(MARKER_OT_select_border); WM_operatortype_append(MARKER_OT_select_all); WM_operatortype_append(MARKER_OT_delete); + WM_operatortype_append(MARKER_OT_make_links_scene); #ifdef DURIAN_CAMERA_SWITCH WM_operatortype_append(MARKER_OT_camera_bind); #endif From 32f4877c8ca590e9d6bf1d5cdabb015158f094c2 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Wed, 13 Jan 2010 17:43:42 +0000 Subject: [PATCH 091/202] Cocoa : properly distinguish mouse from multitouch trackpad scroll events Mighty mouse trackball now fires proper wheel events (and not trackpad pan ones) --- intern/ghost/intern/GHOST_SystemCocoa.h | 3 +++ intern/ghost/intern/GHOST_SystemCocoa.mm | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index 23a945f4b76..9f51d7b0748 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -280,6 +280,9 @@ protected: /** Multitouch trackpad availability */ bool m_hasMultiTouchTrackpad; + + /** Multitouch gesture in progress, useful to distinguish trackpad from mouse scroll events */ + bool m_isGestureInProgress; }; #endif // _GHOST_SYSTEM_COCOA_H_ diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 128ef8a6edf..5f0276c3555 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -516,6 +516,7 @@ GHOST_SystemCocoa::GHOST_SystemCocoa() m_modifierMask =0; m_pressedMouseButtons =0; + m_isGestureInProgress = false; m_cursorDelta_x=0; m_cursorDelta_y=0; m_outsideLoopEventProcessed = false; @@ -885,6 +886,8 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent) case NSOtherMouseDragged: case NSEventTypeMagnify: case NSEventTypeRotate: + case NSEventTypeBeginGesture: + case NSEventTypeEndGesture: handleMouseEvent(event); break; @@ -896,8 +899,6 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent) /* Trackpad features, fired only from OS X 10.5.2 case NSEventTypeGesture: case NSEventTypeSwipe: - case NSEventTypeBeginGesture: - case NSEventTypeEndGesture: break; */ /*Unused events @@ -1352,8 +1353,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) case NSScrollWheel: { - /* Send Wheel event if sent from the mouse, trackpad event otherwise */ - if (!m_hasMultiTouchTrackpad || ([event subtype] == NSMouseEventSubtype)) { + /* Send trackpad event if inside a trackpad gesture, send wheel event otherwise */ + if (!m_hasMultiTouchTrackpad || !m_isGestureInProgress) { GHOST_TInt32 delta; double deltaF = [event deltaY]; @@ -1399,6 +1400,12 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) pushEvent(new GHOST_EventTrackpad([event timestamp]*1000, window, GHOST_kTrackpadEventRotate, mousePos.x, mousePos.y, -[event rotation] * 5.0, 0)); } + case NSEventTypeBeginGesture: + m_isGestureInProgress = true; + break; + case NSEventTypeEndGesture: + m_isGestureInProgress = false; + break; default: return GHOST_kFailure; break; From 58f13d469ee923a2c4c114cd035c69312684a247 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jan 2010 17:58:26 +0000 Subject: [PATCH 092/202] UV mirror tool (copies UVs from one side of the mesh to the other) WIP, suffers from editmode bug where editmode python tools cant have redo-options set. and needs options for precission. --- release/scripts/modules/bpy_types.py | 11 +- release/scripts/op/mesh.py | 172 ++++++++++++++---- release/scripts/ui/space_image.py | 1 + .../blender/editors/animation/anim_markers.c | 1 - source/blender/makesrna/intern/CMakeLists.txt | 2 +- 5 files changed, 151 insertions(+), 36 deletions(-) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 88dcb7eb8de..731757668bd 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -388,10 +388,19 @@ class MeshEdge(StructRNA): class MeshFace(StructRNA): __slots__ = () + @property + def center(self): + """The midpoint of the face.""" + face_verts = self.verts[:] + mesh_verts = self.id_data.verts + if len(face_verts) == 3: + return (mesh_verts[face_verts[0]].co + mesh_verts[face_verts[1]].co + mesh_verts[face_verts[2]].co) / 3.0 + else: + return (mesh_verts[face_verts[0]].co + mesh_verts[face_verts[1]].co + mesh_verts[face_verts[2]].co + mesh_verts[face_verts[3]].co) / 4.0 @property def edge_keys(self): - verts = tuple(self.verts) + verts = self.verts[:] if len(verts) == 3: return ord_ind(verts[0], verts[1]), ord_ind(verts[1], verts[2]), ord_ind(verts[2], verts[0]) diff --git a/release/scripts/op/mesh.py b/release/scripts/op/mesh.py index a8f50f28178..f9b0b4d75b8 100644 --- a/release/scripts/op/mesh.py +++ b/release/scripts/op/mesh.py @@ -20,37 +20,6 @@ import bpy - -def main(context): - ob = context.active_object - bpy.ops.mesh.selection_type(type='FACE') - is_editmode = (ob.mode == 'EDIT') - if is_editmode: - bpy.ops.object.mode_set(mode='OBJECT', toggle=False) - - mesh = ob.data - - face_list = [face for face in mesh.faces] - face_edge_keys = [face.edge_keys for face in face_list] - - edge_face_count = mesh.edge_face_count_dict - - def test_interior(index): - for key in face_edge_keys[index]: - if edge_face_count[key] < 3: - return False - return True - - for index, face in enumerate(face_list): - if(test_interior(index)): - face.selected = True - else: - face.selected = False - - if is_editmode: - bpy.ops.object.mode_set(mode='EDIT', toggle=False) - - class MeshSelectInteriorFaces(bpy.types.Operator): '''Select faces where all edges have more then 2 face users.''' @@ -64,12 +33,149 @@ class MeshSelectInteriorFaces(bpy.types.Operator): return (ob and ob.type == 'MESH') def execute(self, context): - main(context) + ob = context.active_object + bpy.ops.mesh.selection_type(type='FACE') + is_editmode = (ob.mode == 'EDIT') + if is_editmode: + bpy.ops.object.mode_set(mode='OBJECT', toggle=False) + + mesh = ob.data + + face_list = [face for face in mesh.faces] + face_edge_keys = [face.edge_keys for face in face_list] + + edge_face_count = mesh.edge_face_count_dict + + def test_interior(index): + for key in face_edge_keys[index]: + if edge_face_count[key] < 3: + return False + return True + + for index, face in enumerate(face_list): + if(test_interior(index)): + face.selected = True + else: + face.selected = False + + if is_editmode: + bpy.ops.object.mode_set(mode='EDIT', toggle=False) return {'FINISHED'} +class MeshMirrorUV(bpy.types.Operator): + '''Copy mirror UV coordinates on the X axis based on a mirrored mesh''' + bl_idname = "mesh.faces_miror_uv" + bl_label = "Copy Mirrored UV coords" + bl_register = True + bl_undo = True + + def poll(self, context): + ob = context.active_object + return (ob and ob.type == 'MESH') + + def execute(self, context): + DIR = 1 # TODO, make an option + + from Mathutils import Vector + + ob = context.active_object + is_editmode = (ob.mode == 'EDIT') + if is_editmode: + bpy.ops.object.mode_set(mode='OBJECT', toggle=False) + + mesh = ob.data + + # mirror lookups + mirror_gt = {} + mirror_lt = {} + + vcos = [v.co.toTuple(5) for v in mesh.verts] + + for i, co in enumerate(vcos): + if co[0] > 0.0: + mirror_gt[co] = i + elif co[0] < 0.0: + mirror_lt[co] = i + else: + mirror_gt[co] = i + mirror_lt[co] = i + + #for i, v in enumerate(mesh.verts): + vmap = {} + for mirror_a, mirror_b in (mirror_gt, mirror_lt), (mirror_lt, mirror_gt): + for co, i in mirror_a.items(): + nco = (-co[0], co[1], co[2]) + j = mirror_b.get(nco) + if j is not None: + vmap[i] = j + + + active_uv_layer = None + for lay in mesh.uv_textures: + if lay.active: + active_uv_layer = lay.data + break + + fuvs = [(uv.uv1, uv.uv2, uv.uv3, uv.uv4) for uv in active_uv_layer] + fuvs_cpy = [(uv[0].copy(), uv[1].copy(), uv[2].copy(), uv[3].copy()) for uv in fuvs] + + # as a list + faces = mesh.faces[:] + + fuvsel = [(False not in uv.uv_selected) for uv in active_uv_layer] + fcents = [f.center for f in faces] + + # find mirror faces + mirror_fm = {} + for i, f in enumerate(faces): + verts = f.verts[:] + verts.sort() + verts = tuple(verts) + mirror_fm[verts] = i + + fmap = {} + for i, f in enumerate(faces): + verts = [vmap.get(j) for j in f.verts] + if None not in verts: + verts.sort() + j = mirror_fm.get(tuple(verts)) + if j is not None: + fmap[i] = j + + done = [False] * len(faces) + for i, j in fmap.items(): + + if not fuvsel[i] or not fuvsel[j]: + continue + elif DIR == 0 and fcents[i][0] < 0.0: + continue + elif DIR == 1 and fcents[i][0] > 0.0: + continue + + # copy UVs + uv1= fuvs[i] + uv2= fuvs_cpy[j] + + # get the correct rotation + v1 = faces[j].verts[:] + v2 = [vmap[k] for k in faces[i].verts[:]] + + + for k in range(len(uv1)): + k_map = v1.index(v2[k]) + uv1[k].x = -(uv2[k_map].x-0.5) + 0.5 + uv1[k].y = uv2[k_map].y + + if is_editmode: + bpy.ops.object.mode_set(mode='EDIT', toggle=False) + + return {'FINISHED'} + # Register the operator bpy.types.register(MeshSelectInteriorFaces) +bpy.types.register(MeshMirrorUV) if __name__ == "__main__": - bpy.ops.mesh.faces_select_interior() + # bpy.ops.mesh.faces_select_interior() + bpy.ops.mesh.faces_miror_uv() diff --git a/release/scripts/ui/space_image.py b/release/scripts/ui/space_image.py index 5d6bc70dd35..894ec60bb64 100644 --- a/release/scripts/ui/space_image.py +++ b/release/scripts/ui/space_image.py @@ -219,6 +219,7 @@ class IMAGE_MT_uvs(bpy.types.Menu): layout.operator("uv.average_islands_scale") layout.operator("uv.minimize_stretch") layout.operator("uv.stitch") + layout.operator("mesh.faces_miror_uv") layout.separator() diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 4f7a02bb688..d64787ba35b 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1012,7 +1012,6 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) } } - /* one day multiple scenes will be visible, then we should have some update function for them */ return OPERATOR_FINISHED; } diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index eb524a650fd..a9c3e354667 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -99,7 +99,7 @@ TARGET_LINK_LIBRARIES(makesrna bf_dna) # Output rna_*_gen.c ADD_CUSTOM_COMMAND( OUTPUT ${GENSRC} - # with crashes try add this after COMMEND: valgrind --leak-check=full --track-origins=yes + # with crashes try add this after COMMAND: valgrind --leak-check=full --track-origins=yes COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesrna ${CMAKE_CURRENT_BINARY_DIR}/ DEPENDS makesrna ) From ef5ab2b8e9d58ea5e54bb8cb5a852f6aa392bfd6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jan 2010 19:00:18 +0000 Subject: [PATCH 093/202] UV Layout export, writes an SVG, uses material colors. --- release/scripts/op/uv.py | 115 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 release/scripts/op/uv.py diff --git a/release/scripts/op/uv.py b/release/scripts/op/uv.py new file mode 100644 index 00000000000..4f20e60b373 --- /dev/null +++ b/release/scripts/op/uv.py @@ -0,0 +1,115 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# + +import bpy +from bpy.props import * + +class ExportUVLayout(bpy.types.Operator): + '''Export the Mesh as SVG.''' + + bl_idname = "uv.export_layout" + bl_label = "Export UV Layout" + bl_register = True + bl_undo = True + + path = StringProperty(name="File Path", description="File path used for exporting the SVG file", maxlen=1024, default="") + + def poll(self, context): + ob = context.active_object + return (ob and ob.type == 'MESH') + + def execute(self, context): + ob = context.active_object + is_editmode = (ob.mode == 'EDIT') + if is_editmode: + bpy.ops.object.mode_set(mode='OBJECT', toggle=False) + + mesh = ob.data + + active_uv_layer = None + for lay in mesh.uv_textures: + if lay.active: + active_uv_layer = lay.data + break + + fuvs = [(uv.uv1, uv.uv2, uv.uv3, uv.uv4) for uv in active_uv_layer] + fuvs_cpy = [(uv[0].copy(), uv[1].copy(), uv[2].copy(), uv[3].copy()) for uv in fuvs] + + # as a list + faces = mesh.faces[:] + + fuvsel = [(False not in uv.uv_selected) for uv in active_uv_layer] + + file = open(self.properties.path, "w") + fw = file.write + + fw('\n') + fw('\n') + fw('\n') + + fw('%s, %s, %s\n' % (bpy.data.filename, ob.name, mesh.name)) + + # svg colors + fill_settings = [] + for mat in mesh.materials: + if mat: + fill_settings.append('fill="rgb(%d, %d, %d)"' % tuple(int(c*255) for c in mat.diffuse_color)) + else: + fill_settings.append('fill="grey"') + + for i, uv in enumerate(active_uv_layer): + if len(faces[i].verts) == 3: + uvs = uv.uv1, uv.uv2, uv.uv3 + else: + uvs = uv.uv1, uv.uv2, uv.uv3, uv.uv4 + + fw('\n') + fw('\n') + fw('\n') + + if is_editmode: + bpy.ops.object.mode_set(mode='EDIT', toggle=False) + + return {'FINISHED'} + + def invoke(self, context, event): + wm = context.manager + wm.add_fileselect(self) + return {'RUNNING_MODAL'} + +# Register the operator +bpy.types.register(ExportUVLayout) + +def menu_func(self, context): + default_path = bpy.data.filename.replace(".blend", ".svg") + self.layout.operator(ExportUVLayout.bl_idname).path = default_path + +bpy.types.IMAGE_MT_uvs.append(menu_func) + +#if __name__ == "__main__": +# bpy.ops.uv.export_layout(path="/home/ideasman42/foo.svg") From e594a8739bd6a2665e00491b15f59801cbb12a4e Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 13 Jan 2010 19:02:13 +0000 Subject: [PATCH 094/202] Patch [#20588] Adding multisample support to Win32 Ghost - by Mitchell Stokes (Moguri) Note: AA is still disabled due to AA creating problems for selection tools. If you must, set AA to 2 or 4 in wm_window.c where the GHOST window is created (line 317). --- intern/ghost/CMakeLists.txt | 2 +- intern/ghost/SConscript | 2 +- intern/ghost/intern/GHOST_SystemWin32.cpp | 12 +- intern/ghost/intern/GHOST_WindowWin32.cpp | 232 ++++++++++++++++++---- intern/ghost/intern/GHOST_WindowWin32.h | 33 ++- 5 files changed, 242 insertions(+), 39 deletions(-) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 77afcc929aa..bf57da23c69 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -24,7 +24,7 @@ # # ***** END GPL LICENSE BLOCK ***** -SET(INC . ../string) +SET(INC . ../string ../../extern/glew/include) FILE(GLOB SRC intern/*.cpp intern/*.mm) diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript index 2a06a9d3c9e..ff98981a35e 100644 --- a/intern/ghost/SConscript +++ b/intern/ghost/SConscript @@ -57,7 +57,7 @@ else: if env['BF_GHOST_DEBUG']: defs.append('BF_GHOST_DEBUG') -incs = '. ../string ' + env['BF_OPENGL_INC'] +incs = '. ../string #extern/glew/include ' + env['BF_OPENGL_INC'] if window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64-vc'): incs = env['BF_WINTAB_INC'] + ' ' + incs env.BlenderLib ('bf_ghost', sources, Split(incs), defines=defs, libtype=['intern','player'], priority = [40,15] ) diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index d7d657fb496..7d52ab55692 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -193,7 +193,7 @@ GHOST_IWindow* GHOST_SystemWin32::createWindow( bool stereoVisual, const GHOST_TUns16 numOfAASamples, const GHOST_TEmbedderWindowID parentWindow ) { GHOST_Window* window = 0; - window = new GHOST_WindowWin32 (this, title, left, top, width, height, state, type, stereoVisual); + window = new GHOST_WindowWin32 (this, title, left, top, width, height, state, type, stereoVisual, numOfAASamples); if (window) { if (window->getValid()) { // Store the pointer to the window @@ -202,8 +202,18 @@ GHOST_IWindow* GHOST_SystemWin32::createWindow( // } } else { + // An invalid window could be one that was used to test for AA + GHOST_Window *other_window = ((GHOST_WindowWin32*)window)->getNextWindow(); + delete window; window = 0; + + // If another window is found, let the wm know about that one, but not the old one + if (other_window) + { + m_windowManager->addWindow(other_window); + window = other_window; + } } } return window; diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index e276f216fb7..16430c7c1b9 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -42,7 +42,10 @@ #include "GHOST_WindowWin32.h" #include "GHOST_SystemWin32.h" #include "GHOST_DropTargetWin32.h" -#include + +// Need glew for some defines +#include +#include #include // MSVC6 still doesn't define M_PI @@ -50,6 +53,10 @@ #define M_PI 3.1415926536 #endif +// Some more multisample defines +#define WGL_SAMPLE_BUFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 + // win64 doesn't define GWL_USERDATA #ifdef WIN32 #ifndef GWL_USERDATA @@ -106,7 +113,9 @@ GHOST_WindowWin32::GHOST_WindowWin32( GHOST_TWindowState state, GHOST_TDrawingContextType type, const bool stereoVisual, - const GHOST_TUns16 numOfAASamples) + const GHOST_TUns16 numOfAASamples, + GHOST_TSuccess msEnabled, + int msPixelFormat) : GHOST_Window(title, left, top, width, height, state, GHOST_kDrawingContextTypeNone, stereoVisual,numOfAASamples), @@ -119,7 +128,18 @@ GHOST_WindowWin32::GHOST_WindowWin32( m_wintab(NULL), m_tabletData(NULL), m_tablet(0), - m_maxPressure(0) + m_maxPressure(0), + m_multisample(numOfAASamples), + m_multisampleEnabled(msEnabled), + m_msPixelFormat(msPixelFormat), + //For recreation + m_title(title), + m_left(left), + m_top(top), + m_width(width), + m_height(height), + m_stereo(stereoVisual), + m_nextWindow(NULL) { if (state != GHOST_kWindowStateFullScreen) { RECT rect; @@ -195,10 +215,20 @@ GHOST_WindowWin32::GHOST_WindowWin32( nCmdShow = SW_SHOWNORMAL; break; } - setDrawingContextType(type); - ::ShowWindow(m_hWnd, nCmdShow); - // Force an initial paint of the window - ::UpdateWindow(m_hWnd); + GHOST_TSuccess success; + success = setDrawingContextType(type); + + if (success) + { + ::ShowWindow(m_hWnd, nCmdShow); + // Force an initial paint of the window + ::UpdateWindow(m_hWnd); + } + else + { + //invalidate the window + m_hWnd = 0; + } } m_wintab = ::LoadLibrary("Wintab32.dll"); @@ -277,6 +307,8 @@ GHOST_WindowWin32::~GHOST_WindowWin32() m_customCursor = NULL; } + m_multisampleEnabled = GHOST_kFailure; + m_multisample = 0; setDrawingContextType(GHOST_kDrawingContextTypeNone); if (m_hDC) { ::ReleaseDC(m_hWnd, m_hDC); @@ -289,6 +321,11 @@ GHOST_WindowWin32::~GHOST_WindowWin32() } } +GHOST_Window *GHOST_WindowWin32::getNextWindow() +{ + return m_nextWindow; +} + bool GHOST_WindowWin32::getValid() const { return m_hWnd != 0; @@ -516,6 +553,69 @@ GHOST_TSuccess GHOST_WindowWin32::invalidate() return success; } +GHOST_TSuccess GHOST_WindowWin32::initMultisample(PIXELFORMATDESCRIPTOR pfd) +{ + int pixelFormat; + bool success; + UINT numFormats; + HDC hDC = GetDC(getHWND()); + float fAttributes[] = {0, 0}; + + // The attributes to look for + int iAttributes[] = { + WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, + WGL_SUPPORT_OPENGL_ARB, GL_TRUE, + WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, + WGL_COLOR_BITS_ARB, pfd.cColorBits, + WGL_DEPTH_BITS_ARB, pfd.cDepthBits, + WGL_STENCIL_BITS_ARB, pfd.cStencilBits, + WGL_DOUBLE_BUFFER_ARB, GL_TRUE, + WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, + WGL_SAMPLES_ARB, m_multisample, + 0, 0 + }; + + // Get the function + PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); + + if (!wglChoosePixelFormatARB) + { + m_multisampleEnabled = GHOST_kFailure; + return GHOST_kFailure; + } + + // See if the format is valid + success = wglChoosePixelFormatARB(hDC, iAttributes, fAttributes, 1, &pixelFormat, &numFormats); + + if (success && numFormats >= 1) + { + m_multisampleEnabled = GHOST_kSuccess; + m_msPixelFormat = pixelFormat; + return GHOST_kSuccess; + } + else + { + // See if any formats are supported + while (!success && iAttributes[19] != 0) + { + iAttributes[19] /= 2; + + success = wglChoosePixelFormatARB(m_hDC, iAttributes, fAttributes, 1, &pixelFormat, &numFormats); + + if (success && numFormats >= 1) + { + m_multisampleEnabled = GHOST_kSuccess; + m_msPixelFormat = pixelFormat; + return GHOST_kSuccess; + } + + success = GHOST_kFailure; + } + } + + // No available pixel format... + return GHOST_kFailure; +} GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextType type) { @@ -523,36 +623,101 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp switch (type) { case GHOST_kDrawingContextTypeOpenGL: { - if(m_stereoVisual) - sPreferredFormat.dwFlags |= PFD_STEREO; - - // Attempt to match device context pixel format to the preferred format - int iPixelFormat = EnumPixelFormats(m_hDC); - if (iPixelFormat == 0) { - success = GHOST_kFailure; - break; - } - if (::SetPixelFormat(m_hDC, iPixelFormat, &sPreferredFormat) == FALSE) { - success = GHOST_kFailure; - break; - } - // For debugging only: retrieve the pixel format chosen - PIXELFORMATDESCRIPTOR preferredFormat; - ::DescribePixelFormat(m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &preferredFormat); - // Create the context - m_hGlRc = ::wglCreateContext(m_hDC); - if (m_hGlRc) { - if (s_firsthGLRc) { - wglShareLists(s_firsthGLRc, m_hGlRc); - } else { - s_firsthGLRc = m_hGlRc; + // If this window has multisample enabled, use the supplied format + if (m_multisampleEnabled) + { + if (SetPixelFormat(m_hDC, m_msPixelFormat, &sPreferredFormat)==FALSE) + { + success = GHOST_kFailure; + break; } - success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + // Create the context + m_hGlRc = ::wglCreateContext(m_hDC); + if (m_hGlRc) { + if (s_firsthGLRc) { + wglShareLists(s_firsthGLRc, m_hGlRc); + } else { + s_firsthGLRc = m_hGlRc; + } + + success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + } + else { + printf("Failed to get a context....\n"); + success = GHOST_kFailure; + } } - else { - success = GHOST_kFailure; + else + { + if(m_stereoVisual) + sPreferredFormat.dwFlags |= PFD_STEREO; + + // Attempt to match device context pixel format to the preferred format + int iPixelFormat = EnumPixelFormats(m_hDC); + if (iPixelFormat == 0) { + success = GHOST_kFailure; + break; + } + if (::SetPixelFormat(m_hDC, iPixelFormat, &sPreferredFormat) == FALSE) { + success = GHOST_kFailure; + break; + } + // For debugging only: retrieve the pixel format chosen + PIXELFORMATDESCRIPTOR preferredFormat; + ::DescribePixelFormat(m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &preferredFormat); + + // Create the context + m_hGlRc = ::wglCreateContext(m_hDC); + if (m_hGlRc) { + if (s_firsthGLRc) { + wglShareLists(s_firsthGLRc, m_hGlRc); + } else { + s_firsthGLRc = m_hGlRc; + } + + success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + } + else { + printf("Failed to get a context....\n"); + success = GHOST_kFailure; + } + + // Attempt to enable multisample + if (m_multisample && WGL_ARB_multisample && !m_multisampleEnabled) + { + success = initMultisample(preferredFormat); + + if (success) + { + + // Make sure we don't screw up the context + m_drawingContextType = GHOST_kDrawingContextTypeOpenGL; + removeDrawingContext(); + + // Create a new window + GHOST_TWindowState new_state = getState(); + + m_nextWindow = new GHOST_WindowWin32((GHOST_SystemWin32*)GHOST_ISystem::getSystem(), + m_title, + m_left, + m_top, + m_width, + m_height, + new_state, + type, + m_stereo, + m_multisample, + m_multisampleEnabled, + m_msPixelFormat); + + // Return failure so we can trash this window. + success = GHOST_kFailure; + break; + } + } } + } break; @@ -566,7 +731,6 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp return success; } - GHOST_TSuccess GHOST_WindowWin32::removeDrawingContext() { GHOST_TSuccess success; diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h index 954546f3d82..fb561127a2e 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.h +++ b/intern/ghost/intern/GHOST_WindowWin32.h @@ -87,7 +87,9 @@ public: GHOST_TWindowState state, GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone, const bool stereoVisual = false, - const GHOST_TUns16 numOfAASamples = 0 + const GHOST_TUns16 numOfAASamples = 0, + GHOST_TSuccess msEnabled = GHOST_kFailure, + int msPixelFormat = 0 ); /** @@ -96,6 +98,13 @@ public: */ virtual ~GHOST_WindowWin32(); + /** + * Returns the window to replace this one if it's getting replaced + * @return The window replacing this one. + */ + + GHOST_Window *getNextWindow(); + /** * Returns indication as to whether the window is valid. * @return The validity of the window. @@ -243,6 +252,8 @@ public: void processWin32TabletEvent(WPARAM wParam, LPARAM lParam); protected: + GHOST_TSuccess initMultisample(PIXELFORMATDESCRIPTOR pfd); + /** * Tries to install a rendering context in this window. * @param type The type of rendering context installed. @@ -325,7 +336,25 @@ protected: LONG m_maxPressure; LONG m_maxAzimuth, m_maxAltitude; + /** Preferred number of samples */ + GHOST_TUns16 m_multisample; + + /** Check if multisample is supported */ + GHOST_TSuccess m_multisampleEnabled; + + /** The pixelFormat to use for multisample */ + int m_msPixelFormat; + + /** We need to following to recreate the window */ + const STR_String& m_title; + GHOST_TInt32 m_left; + GHOST_TInt32 m_top; + GHOST_TUns32 m_width; + GHOST_TUns32 m_height; + bool m_stereo; + + /** The GHOST_System passes this to wm if this window is being replaced */ + GHOST_Window *m_nextWindow; }; #endif // _GHOST_WINDOW_WIN32_H_ - From 76d736edae006a3c945af82826b964550f987f54 Mon Sep 17 00:00:00 2001 From: Stefan Gartner Date: Wed, 13 Jan 2010 19:48:34 +0000 Subject: [PATCH 095/202] Makefiles: add -DNAN_BUILDINFO to CPPFLAGS in windowmanager/intern when building with NAN_BUILDINFO enabled --- source/blender/windowmanager/intern/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/windowmanager/intern/Makefile b/source/blender/windowmanager/intern/Makefile index e472c87fe54..18085194405 100644 --- a/source/blender/windowmanager/intern/Makefile +++ b/source/blender/windowmanager/intern/Makefile @@ -78,6 +78,10 @@ ifeq ($(WITH_OPENCOLLADA), true) CPPFLAGS += -DWITH_COLLADA endif +ifeq ($(NAN_BUILDINFO), true) + CPPFLAGS += -DNAN_BUILDINFO +endif + ifeq ($(OS),linux) ifeq ($(CPU),alpha) CPPFLAGS += -I$(NAN_MESA)/include From 27dc5be73055ac316a9c52f0e0a66d37a49c062b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jan 2010 19:53:34 +0000 Subject: [PATCH 096/202] - when the image is available export the SVG with the pixel width and height, saves typing into the gimp each time. - option to only export selected faces. - add in some metadata from the scene --- release/scripts/op/uv.py | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/release/scripts/op/uv.py b/release/scripts/op/uv.py index 4f20e60b373..eedd690a63f 100644 --- a/release/scripts/op/uv.py +++ b/release/scripts/op/uv.py @@ -30,19 +30,37 @@ class ExportUVLayout(bpy.types.Operator): bl_undo = True path = StringProperty(name="File Path", description="File path used for exporting the SVG file", maxlen=1024, default="") + only_selected = BoolProperty(name="Only Selected", description="Export Only the selected UVs", default=False) def poll(self, context): ob = context.active_object return (ob and ob.type == 'MESH') + + def _image_size(self, context, default_width=1024, default_height=1024): + # fallback if not in image context. + image_width, image_height = default_width, default_height + + space_data = context.space_data + if type(space_data) == bpy.types.SpaceImageEditor: + image = space_data.image + if image: + width, height = tuple(context.space_data.image.size) + # incase no data is found. + if width and height: + image_width, image_height = width, height + return image_width, image_height + def execute(self, context): ob = context.active_object is_editmode = (ob.mode == 'EDIT') if is_editmode: bpy.ops.object.mode_set(mode='OBJECT', toggle=False) - mesh = ob.data + image_width, image_height = self._image_size(context) + mesh = ob.data + active_uv_layer = None for lay in mesh.uv_textures: if lay.active: @@ -63,10 +81,10 @@ class ExportUVLayout(bpy.types.Operator): fw('\n') fw('\n') - fw('\n') - fw('%s, %s, %s\n' % (bpy.data.filename, ob.name, mesh.name)) + fw('%s, %s, %s (Blender %s)\n' % (bpy.data.filename, ob.name, mesh.name, bpy.app.version_string)) # svg colors fill_settings = [] @@ -76,7 +94,13 @@ class ExportUVLayout(bpy.types.Operator): else: fill_settings.append('fill="grey"') + only_selected = self.properties.only_selected + for i, uv in enumerate(active_uv_layer): + + if only_selected and False in uv.uv_selected: + continue + if len(faces[i].verts) == 3: uvs = uv.uv1, uv.uv2, uv.uv3 else: @@ -87,7 +111,7 @@ class ExportUVLayout(bpy.types.Operator): for j, uv in enumerate(uvs): x, y = uv.x, 1.0 - uv.y - fw('%f.3f,%f.3f ' % (x * 1000.0, y * 1000.0)) + fw('%f.3f,%f.3f ' % (x * image_width, y * image_height)) fw('" />\n') fw('\n') fw('\n') From 9bcfcfb8730e2f0d2ae0d988227fb5891640da00 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Wed, 13 Jan 2010 21:37:13 +0000 Subject: [PATCH 097/202] [#20112] User Preferences window causes a crash Opened preference window caused a crash (context pointing to freed screen) when Load UI was turned off. --- source/blender/editors/screen/screen_edit.c | 8 +++++++- source/blender/windowmanager/intern/wm_files.c | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 2069858c97d..20c629ab69c 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1125,7 +1125,13 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) screen->winid= 0; /* before deleting the temp screen or we get invalid access */ - CTX_wm_window_set(C, prevwin); + if (prevwin->screen->full != SCREENTEMP) { + /* use previous window if possible */ + CTX_wm_window_set(C, prevwin); + } else { + /* none otherwise */ + CTX_wm_window_set(C, NULL); + } /* if temp screen, delete it */ if(screen->full == SCREENTEMP) { diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 05fdb500d9e..6f44ce8934d 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -109,11 +109,13 @@ static void writeBlog(void); static void wm_window_match_init(bContext *C, ListBase *wmlist) { wmWindowManager *wm= G.main->wm.first; - wmWindow *win; + wmWindow *win, *active_win; *wmlist= G.main->wm; G.main->wm.first= G.main->wm.last= NULL; + active_win = CTX_wm_window(C); + /* first wrap up running stuff */ /* code copied from wm_init_exit.c */ for(wm= wmlist->first; wm; wm= wm->id.next) { @@ -129,6 +131,9 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist) } } + /* reset active window */ + CTX_wm_window_set(C, active_win); + ED_editors_exit(C); return; From 0befa75009a7924aca838cf893c57caca33ba73a Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Wed, 13 Jan 2010 22:17:56 +0000 Subject: [PATCH 098/202] [#20583] Snap Cursor to Center and more View edits Patches by Jonathan Smith (jaydez) Add a Cursor Center entry in the snap menu (Shift-S) to reset the cursor to 0,0,0. Also rename the view_center operator to view_selected to reflect better what it does (in the code only, description and name were already ok). --- release/scripts/ui/space_view3d.py | 1 + .../editors/space_view3d/view3d_edit.c | 8 ++-- .../editors/space_view3d/view3d_intern.h | 3 +- .../blender/editors/space_view3d/view3d_ops.c | 5 ++- .../editors/space_view3d/view3d_snap.c | 38 +++++++++++++++++++ 5 files changed, 48 insertions(+), 7 deletions(-) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 4f4c98dee69..a3e3d2d3b53 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -200,6 +200,7 @@ class VIEW3D_MT_snap(bpy.types.Menu): layout.separator() layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected") + layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center") layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid") layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active") diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 288918c3c1e..9bb7d35f96d 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1286,7 +1286,7 @@ void VIEW3D_OT_view_all(wmOperatorType *ot) RNA_def_boolean(ot->srna, "center", 0, "Center", ""); } -static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview without local!, was centerview() in 2.4x */ +static int viewselected_exec(bContext *C, wmOperator *op) /* like a localview without local!, was centerview() in 2.4x */ { ARegion *ar= CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); @@ -1403,16 +1403,16 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with return OPERATOR_FINISHED; } -void VIEW3D_OT_view_center(wmOperatorType *ot) +void VIEW3D_OT_view_selected(wmOperatorType *ot) { /* identifiers */ ot->name= "View Selected"; ot->description = "Move the view to the selection center."; - ot->idname= "VIEW3D_OT_view_center"; + ot->idname= "VIEW3D_OT_view_selected"; /* api callbacks */ - ot->exec= viewcenter_exec; + ot->exec= viewselected_exec; ot->poll= ED_operator_view3d_active; /* flags */ diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index f6d77b1b63d..7d2f6294041 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -73,7 +73,7 @@ void VIEW3D_OT_move(struct wmOperatorType *ot); void VIEW3D_OT_rotate(struct wmOperatorType *ot); void VIEW3D_OT_view_all(struct wmOperatorType *ot); void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot); -void VIEW3D_OT_view_center(struct wmOperatorType *ot); +void VIEW3D_OT_view_selected(struct wmOperatorType *ot); void VIEW3D_OT_view_center_cursor(struct wmOperatorType *ot); void VIEW3D_OT_view_pan(struct wmOperatorType *ot); void VIEW3D_OT_view_persportho(struct wmOperatorType *ot); @@ -172,6 +172,7 @@ void VIEW3D_OT_snap_selected_to_grid(struct wmOperatorType *ot); void VIEW3D_OT_snap_selected_to_cursor(struct wmOperatorType *ot); void VIEW3D_OT_snap_selected_to_center(struct wmOperatorType *ot); void VIEW3D_OT_snap_cursor_to_grid(struct wmOperatorType *ot); +void VIEW3D_OT_snap_cursor_to_center(struct wmOperatorType *ot); void VIEW3D_OT_snap_cursor_to_selected(struct wmOperatorType *ot); void VIEW3D_OT_snap_cursor_to_active(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index ea9441ec648..9c0c50790fa 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -70,7 +70,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_view_orbit); WM_operatortype_append(VIEW3D_OT_view_pan); WM_operatortype_append(VIEW3D_OT_view_persportho); - WM_operatortype_append(VIEW3D_OT_view_center); + WM_operatortype_append(VIEW3D_OT_view_selected); WM_operatortype_append(VIEW3D_OT_view_center_cursor); WM_operatortype_append(VIEW3D_OT_select); WM_operatortype_append(VIEW3D_OT_select_border); @@ -96,6 +96,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_snap_selected_to_cursor); WM_operatortype_append(VIEW3D_OT_snap_selected_to_center); WM_operatortype_append(VIEW3D_OT_snap_cursor_to_grid); + WM_operatortype_append(VIEW3D_OT_snap_cursor_to_center); WM_operatortype_append(VIEW3D_OT_snap_cursor_to_selected); WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active); @@ -126,7 +127,7 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "VIEW3D_OT_rotate", MIDDLEMOUSE, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_move", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); - WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center", PADPERIOD, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_fly", FKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index b56a853d5b7..66d2fe1ef7b 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -1084,6 +1084,44 @@ void VIEW3D_OT_snap_selected_to_center(wmOperatorType *ot) } +/* **************************************************** */ +/*New Code - Snap Cursor to Center -*/ +static int snap_curs_to_center(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + RegionView3D *rv3d= CTX_wm_region_data(C); + View3D *v3d= CTX_wm_view3d(C); + float *curs; + curs= give_cursor(scene, v3d); + + curs[0]= 0.0; + curs[1]= 0.0; + curs[2]= 0.0; + + WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM, scene); // hrm + + return OPERATOR_FINISHED; +} + +void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name= "Snap Cursor to Center"; + ot->description= "Snap cursor to the Center"; + ot->idname= "VIEW3D_OT_snap_cursor_to_center"; + + /* api callbacks */ + ot->exec= snap_curs_to_center; + ot->poll= ED_operator_view3d_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* **************************************************** */ + + int minmax_verts(Object *obedit, float *min, float *max) { TransVert *tv; From ddafe3f5df52e650e68c4e8f9ed3fc2bac7590c5 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 13 Jan 2010 23:12:48 +0000 Subject: [PATCH 099/202] Fix [#19902] sculpt brush texture not accessible when the object has no material Texture handling really needs deeper improvement, this fix doesn't really help for other situations like modifiers, but solves the inconvenient case of sculpting with no material at least. --- .../editors/space_buttons/buttons_context.c | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index c4bdd3a6c5b..c689e994c17 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -332,16 +332,17 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path World *wo; Tex *tex; PointerRNA *ptr= &path->ptr[path->len-1]; + int orig_len = path->len; /* if we already have a (pinned) texture, we're done */ if(RNA_struct_is_a(ptr->type, &RNA_Texture)) { return 1; } /* try brush */ - else if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(C, path)) { + if(buttons_context_path_brush(C, path)) { br= path->ptr[path->len-1].data; - - if(br) { + + if(br && (path->flag & SB_BRUSH_TEX)) { tex= give_current_brush_texture(br); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -350,7 +351,7 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path } } /* try world */ - else if((path->flag & SB_WORLD_TEX) && buttons_context_path_world(path)) { + if((path->flag & SB_WORLD_TEX) && buttons_context_path_world(path)) { wo= path->ptr[path->len-1].data; if(wo && GS(wo->id.name)==ID_WO) { @@ -362,7 +363,7 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path } } /* try material */ - else if(buttons_context_path_material(path)) { + if(buttons_context_path_material(path)) { ma= path->ptr[path->len-1].data; if(ma) { @@ -374,7 +375,7 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path } } /* try lamp */ - else if(buttons_context_path_data(path, OB_LAMP)) { + if(buttons_context_path_data(path, OB_LAMP)) { la= path->ptr[path->len-1].data; if(la) { @@ -385,6 +386,19 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path return 1; } } + /* try brushes again in case of no material, lamp, etc */ + path->len = orig_len; + if(buttons_context_path_brush(C, path)) { + br= path->ptr[path->len-1].data; + + if(br) { + tex= give_current_brush_texture(br); + + RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); + path->len++; + return 1; + } + } /* TODO: material nodes */ /* no path to a texture possible */ From 61d4ff5890a21672e1e757484a436c0152ab802a Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 14 Jan 2010 00:03:58 +0000 Subject: [PATCH 100/202] Fix for saved animation image sequence renders being too dark (caused by my recent color management commit) --- source/blender/render/intern/source/pipeline.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 5824e917fca..8a608feebec 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2803,9 +2803,8 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R /* float factor for random dither, imbuf takes care of it */ ibuf->dither= scene->r.dither_intensity; - /* gamma correct to sRGB color space */ - if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) - ibuf->profile = IB_PROFILE_SRGB; + /* prepare to gamma correct to sRGB color space */ + ibuf->profile = IB_PROFILE_LINEAR_RGB; ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); From f3c89524c39d780b4962627f324de392842d6f1a Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 14 Jan 2010 01:47:25 +0000 Subject: [PATCH 101/202] Fix [#20663] Mouse cursor icon changes back to default in edit mode Seemed simple but actually turned out to be quite complex. ND_MODE notifier was being misused, changed to ND_TOOLSETTINGS Note: Although the fix itself doesn't involve this much, debugging uncovered that listeners can't rely on notifier->swinid to be correct, since notifiers can now be added from RNA without a region context. --- source/blender/editors/screen/screen_ops.c | 2 +- .../editors/space_view3d/space_view3d.c | 1 + source/blender/makesrna/intern/rna_scene.c | 18 +++++++++--------- source/blender/windowmanager/WM_types.h | 4 ++-- .../windowmanager/intern/wm_event_system.c | 8 +++++--- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4125ced4e71..e45c8bc48ee 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3773,7 +3773,7 @@ static int scene_delete_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); - WM_event_add_notifier(C, NC_SCENE|ND_SCENEDELETE, scene); + WM_event_add_notifier(C, NC_SCENE|NA_REMOVED, scene); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index b23b1b38804..fe3ec2a5e50 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -573,6 +573,7 @@ static void view3d_header_area_listener(ARegion *ar, wmNotifier *wmn) case ND_OB_SELECT: case ND_MODE: case ND_LAYER: + case ND_TOOLSETTINGS: ED_region_tag_redraw(ar); break; } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index f3903b97d21..3d36dbedd19 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -628,7 +628,7 @@ static void rna_Scene_editmesh_select_mode_update(Main *bmain, Scene *scene, Poi } WM_main_add_notifier(NC_GEOM|ND_SELECT, me); - WM_main_add_notifier(NC_SCENE|ND_MODE, NULL); /* header redraw */ + WM_main_add_notifier(NC_SCENE|ND_TOOLSETTINGS, NULL); } #else @@ -717,13 +717,13 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "proportional"); RNA_def_property_enum_items(prop, proportional_editing_items); RNA_def_property_ui_text(prop, "Proportional Editing", "Proportional editing mode."); - RNA_def_property_update(prop, NC_SCENE|ND_MODE, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ prop= RNA_def_property(srna, "proportional_editing_falloff", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "prop_mode"); RNA_def_property_enum_items(prop, proportional_falloff_items); RNA_def_property_ui_text(prop, "Proportional Editing Falloff", "Falloff type for proportional editing mode."); - RNA_def_property_update(prop, NC_SCENE|ND_MODE, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ prop= RNA_def_property(srna, "normal_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "normalsize"); @@ -740,37 +740,37 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP); RNA_def_property_ui_text(prop, "Snap", "Snap during transform."); RNA_def_property_ui_icon(prop, ICON_SNAP_OFF, 1); - RNA_def_property_update(prop, NC_SCENE|ND_MODE, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ prop= RNA_def_property(srna, "snap_align_rotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_ROTATE); RNA_def_property_ui_text(prop, "Snap Align Rotation", "Align rotation with the snapping target."); RNA_def_property_ui_icon(prop, ICON_SNAP_NORMAL, 0); - RNA_def_property_update(prop, NC_SCENE|ND_MODE, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ prop= RNA_def_property(srna, "snap_element", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "snap_mode"); RNA_def_property_enum_items(prop, snap_element_items); RNA_def_property_ui_text(prop, "Snap Element", "Type of element to snap to."); - RNA_def_property_update(prop, NC_SCENE|ND_MODE, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ prop= RNA_def_property(srna, "snap_target", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "snap_target"); RNA_def_property_enum_items(prop, snap_target_items); RNA_def_property_ui_text(prop, "Snap Target", "Which part to snap onto the target."); - RNA_def_property_update(prop, NC_SCENE|ND_MODE, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ prop= RNA_def_property(srna, "snap_peel_object", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PEEL_OBJECT); RNA_def_property_ui_text(prop, "Snap Peel Object", "Consider objects as whole when finding volume center."); RNA_def_property_ui_icon(prop, ICON_SNAP_PEEL_OBJECT, 0); - RNA_def_property_update(prop, NC_SCENE|ND_MODE, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ prop= RNA_def_property(srna, "snap_project", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PROJECT); RNA_def_property_ui_text(prop, "Project Individual Elements", "DOC_BROKEN"); RNA_def_property_ui_icon(prop, ICON_RETOPO, 0); - RNA_def_property_update(prop, NC_SCENE|ND_MODE, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ /* Auto Keying */ prop= RNA_def_property(srna, "enable_auto_key", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 442177ef7ba..ee82fccc864 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -106,7 +106,7 @@ typedef struct wmNotifier { struct wmWindowManager *wm; struct wmWindow *window; - int swinid; + int swinid; /* can't rely on this, notifiers can be added without context, swinid of 0 */ unsigned int category, data, subtype, action; void *reference; @@ -171,7 +171,7 @@ typedef struct wmNotifier { #define ND_RENDER_RESULT (10<<16) #define ND_COMPO_RESULT (11<<16) #define ND_KEYINGSET (12<<16) -#define ND_SCENEDELETE (13<<16) +#define ND_TOOLSETTINGS (13<<16) #define ND_LAYER (14<<16) #define ND_SEQUENCER_SELECT (15<<16) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 57d67400444..f38f14e5315 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -193,13 +193,15 @@ void wm_event_do_notifiers(bContext *C) if(G.f & G_DEBUG) printf("scene set %p\n", note->reference); } - if(note->data==ND_SCENEDELETE) { + else if(note->data==ND_FRAME) + do_anim= 1; + + if(note->action == NA_REMOVED) { ED_screen_delete_scene(C, note->reference); // XXX hrms, think this over! if(G.f & G_DEBUG) printf("scene delete %p\n", note->reference); } - else if(note->data==ND_FRAME) - do_anim= 1; + } } if(ELEM4(note->category, NC_SCENE, NC_OBJECT, NC_GEOM, NC_SCENE)) { From 36229bd39a35bdcfd9c37d6fc5ba289bb5d01f74 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Thu, 14 Jan 2010 02:06:08 +0000 Subject: [PATCH 102/202] Missing notifiers in some transform orientations operators. Also, nice harmless typo (only because KM_SHIFT|KM_CLICK (1|3) == KM_SHIFT|KM_CTRL (1|2)) --- source/blender/editors/transform/transform_ops.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index f3789880ce9..0601d0b296e 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -108,7 +108,7 @@ static int snap_type_exec(bContext *C, wmOperator *op) ts->snap_mode = RNA_enum_get(op->ptr,"type"); - WM_event_add_notifier(C, NC_SCENE|ND_MODE, NULL); /* header redraw */ + WM_event_add_notifier(C, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ return OPERATOR_FINISHED; } @@ -187,6 +187,7 @@ static int delete_orientation_exec(bContext *C, wmOperator *op) BIF_removeTransformOrientationIndex(C, selected_index); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); + WM_event_add_notifier(C, NC_SCENE|NA_EDITED, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -237,6 +238,7 @@ static int create_orientation_exec(bContext *C, wmOperator *op) BIF_createTransformOrientation(C, op->reports, name, use, overwrite); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); + WM_event_add_notifier(C, NC_SCENE|NA_EDITED, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -863,7 +865,7 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac km = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(km->ptr, "path", "tool_settings.snap"); - km = WM_keymap_add_item(keymap, "TRANSFORM_OT_snap_type", TABKEY, KM_PRESS, KM_SHIFT|KM_CLICK, 0); + km = WM_keymap_add_item(keymap, "TRANSFORM_OT_snap_type", TABKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); break; case SPACE_ACTION: From 2b1e59500fe838e89cbbcbd332e4a6185976174c Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 14 Jan 2010 02:13:08 +0000 Subject: [PATCH 103/202] Fix URL to new py API docs --- release/scripts/ui/space_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/ui/space_info.py b/release/scripts/ui/space_info.py index fc0c2e460e6..9b29603e01e 100644 --- a/release/scripts/ui/space_info.py +++ b/release/scripts/ui/space_info.py @@ -363,7 +363,7 @@ class HELP_OT_python_api(HelpOperator): '''Reference for operator and data Python API''' bl_idname = "help.python_api" bl_label = "Python API Reference" - _url = 'http://www.blender.org/documentation/250PythonDoc/' + _url = 'http://www.blender.org/documentation/250PythonDoc/contents.html' class HELP_OT_operator_cheat_sheet(bpy.types.Operator): From 7d251de01cb80f289479e3c6a4b9316237640fee Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Thu, 14 Jan 2010 02:16:45 +0000 Subject: [PATCH 104/202] view3d bg image now updates on frame change, and the panel for it properly draws an image user template. someone else might want to look over the UI stuff, hopefully it's ok. also added some ffmpeg .dlls to the SConscript to install. --- SConstruct | 6 +++++- release/scripts/ui/space_view3d.py | 14 ++++++++------ .../editors/space_view3d/space_view3d.c | 18 +++++++++++++++++- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/SConstruct b/SConstruct index 8a026a0c083..83570cb5c1a 100644 --- a/SConstruct +++ b/SConstruct @@ -611,7 +611,11 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc'): '${LCGDIR}/ffmpeg/lib/avformat-52.dll', '${LCGDIR}/ffmpeg/lib/avdevice-52.dll', '${LCGDIR}/ffmpeg/lib/avutil-50.dll', - '${LCGDIR}/ffmpeg/lib/swscale-0.dll'] + '${LCGDIR}/ffmpeg/lib/swscale-0.dll', + '${LCGDIR}/ffmpeg/lib/libfaac-0.dll', + '${LCGDIR}/ffmpeg/lib/libfaad-2.dll', + '${LCGDIR}/ffmpeg/lib/libmp3lame-0.dll', + '${LCGDIR}/ffmpeg/lib/libx264-67.dll'] if env['WITH_BF_JACK']: dllsources += ['${LCGDIR}/jack/lib/libjack.dll'] windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index a3e3d2d3b53..db77918458a 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -1795,19 +1795,21 @@ class VIEW3D_PT_background_image(bpy.types.Panel): if bg: layout.active = view.display_background_image - + box = layout.box() + box.template_image(bg, "image", bg.image_user, compact=True) + + col = layout.column() + col.label(text="Display Settings") + col = layout.column() - col.template_ID(bg, "image", open="image.open") col.prop(bg, "size") col.prop(bg, "transparency", slider=True) - - col = layout.column(align=True) - col.label(text="Offset:") + col = layout.column() + col.label(text="Offset") col.prop(bg, "offset_x", text="X") col.prop(bg, "offset_y", text="Y") - class VIEW3D_PT_transform_orientations(bpy.types.Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index fe3ec2a5e50..986d8003e6e 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -48,6 +48,7 @@ #include "BKE_global.h" #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "BKE_image.h" #include "ED_armature.h" #include "ED_space_api.h" @@ -447,8 +448,8 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) break; case NC_SCENE: switch(wmn->data) { - case ND_TRANSFORM: case ND_FRAME: + case ND_TRANSFORM: case ND_OB_ACTIVE: case ND_OB_SELECT: case ND_LAYER: @@ -783,6 +784,20 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes return -1; /* found but not available */ } +/*area (not region) level listener*/ +void space_view3d_listener(struct ScrArea *area, struct wmNotifier *wmn) +{ + if (wmn->category == NC_SCENE && wmn->data == ND_FRAME) { + View3D *v3d = area->spacedata.first; + + if (v3d->bgpic && v3d->bgpic->ima) { + Scene *scene = wmn->reference; + + BKE_image_user_calc_imanr(&v3d->bgpic->iuser, scene->r.cfra, 0); + } + } +} + /* only called once, from space/spacetypes.c */ void ED_spacetype_view3d(void) { @@ -795,6 +810,7 @@ void ED_spacetype_view3d(void) st->new= view3d_new; st->free= view3d_free; st->init= view3d_init; + st->listener = space_view3d_listener; st->duplicate= view3d_duplicate; st->operatortypes= view3d_operatortypes; st->keymap= view3d_keymap; From 70c673621af6f128f713ab12f6ce45c72aedcd89 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Thu, 14 Jan 2010 02:41:08 +0000 Subject: [PATCH 105/202] fixed missing buttons if no bg image --- release/scripts/ui/space_view3d.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index db77918458a..a597916365c 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -200,7 +200,6 @@ class VIEW3D_MT_snap(bpy.types.Menu): layout.separator() layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected") - layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center") layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid") layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active") @@ -1796,7 +1795,10 @@ class VIEW3D_PT_background_image(bpy.types.Panel): if bg: layout.active = view.display_background_image box = layout.box() - box.template_image(bg, "image", bg.image_user, compact=True) + if (bg.image): + box.template_image(bg, "image", bg.image_user, compact=True) + else: + box.template_ID(bg, "image", open="image.open") col = layout.column() col.label(text="Display Settings") From 0801544a7a7df6f63259e3bd8ae6851e2d82a0eb Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Thu, 14 Jan 2010 02:51:17 +0000 Subject: [PATCH 106/202] renamed view_center to view_selected in view3d menu code --- release/scripts/ui/space_view3d.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index a597916365c..6be8612357a 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -265,7 +265,7 @@ class VIEW3D_MT_view(bpy.types.Menu): layout.separator() layout.operator("view3d.localview", text="View Global/Local") - layout.operator("view3d.view_center") + layout.operator("view3d.view_selected") layout.operator("view3d.view_all") layout.separator() @@ -313,7 +313,7 @@ class VIEW3D_MT_view_align(bpy.types.Menu): layout.operator("view3d.view_all", text="Center Cursor and View All").center = True layout.operator("view3d.camera_to_view", text="Align Active Camera to View") - layout.operator("view3d.view_center") + layout.operator("view3d.view_selected") layout.operator("view3d.view_center_cursor") From e93d6655bd20fe93c42a3818e2a2f4e01d265835 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 14 Jan 2010 04:16:45 +0000 Subject: [PATCH 107/202] Fix [#19932] When reducing panels vertically the scrollbar should not continue redraw in opposite direction --- source/blender/editors/interface/view2d.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 6cc344b891e..cba314b0bf3 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1367,6 +1367,9 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short vert.ymin+=4; vert.ymax-=4; + CLAMP(vert.ymin, vert.ymin, vert.ymax-V2D_SCROLLER_HANDLE_SIZE); + CLAMP(hor.xmin, hor.xmin, hor.xmax-V2D_SCROLLER_HANDLE_SIZE); + /* store in scrollers, used for drawing */ scrollers->vert= vert; scrollers->hor= hor; @@ -1597,8 +1600,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v state= (v2d->scroll_ui & V2D_SCROLL_H_ACTIVE)?UI_SCROLL_PRESSED:0; - // TODO: disable this for button regions... - if (!(v2d->keepzoom & V2D_LOCKZOOM_X)) + if (!(v2d->keepzoom & V2D_LOCKZOOM_X) && (slider.xmax - slider.xmin > V2D_SCROLLER_HANDLE_SIZE)) state |= UI_SCROLL_ARROWS; uiWidgetScrollDraw(&wcol, &hor, &slider, state); @@ -1695,8 +1697,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v state= (v2d->scroll_ui & V2D_SCROLL_V_ACTIVE)?UI_SCROLL_PRESSED:0; - // TODO: disable this for button regions... - if (!(v2d->keepzoom & V2D_LOCKZOOM_Y)) + if (!(v2d->keepzoom & V2D_LOCKZOOM_Y) && (slider.ymax - slider.ymin > V2D_SCROLLER_HANDLE_SIZE)) state |= UI_SCROLL_ARROWS; uiWidgetScrollDraw(&wcol, &vert, &slider, state); From 4880b2789163e09df00153a63e495cfa96b59cc1 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 14 Jan 2010 04:25:06 +0000 Subject: [PATCH 108/202] Show the image ID template too for 3D View BG image --- release/scripts/ui/space_view3d.py | 1 + 1 file changed, 1 insertion(+) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 6be8612357a..b578cbc34dd 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -1796,6 +1796,7 @@ class VIEW3D_PT_background_image(bpy.types.Panel): layout.active = view.display_background_image box = layout.box() if (bg.image): + box.template_ID(bg, "image", open="image.open") box.template_image(bg, "image", bg.image_user, compact=True) else: box.template_ID(bg, "image", open="image.open") From 874ef4c747440740125bbf32e558670c30ea2a0d Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 14 Jan 2010 04:36:27 +0000 Subject: [PATCH 109/202] Changed 3D View menu Duplicate Linked to use the same duplicate linked + move macro as in the default key map (alt d). --- release/scripts/ui/space_view3d.py | 2 +- source/blender/editors/object/object_ops.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index b578cbc34dd..e17d068b586 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -639,7 +639,7 @@ class VIEW3D_MT_object(bpy.types.Menu): layout.separator() layout.operator("object.duplicate_move") - layout.operator("object.duplicate", text="Duplicate Linked").linked = True + layout.operator("object.duplicate_move_linked") layout.operator("object.delete", text="Delete...") layout.operator("object.proxy_make", text="Make Proxy...") layout.menu("VIEW3D_MT_make_links", text="Make Links...") diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 5d6636f68d0..0837051ae0c 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -214,7 +214,7 @@ void ED_operatormacros_object(void) } /* grr, should be able to pass options on... */ - ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", OPTYPE_UNDO|OPTYPE_REGISTER); if(ot) { otmacro= WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); RNA_boolean_set(otmacro->ptr, "linked", 1); From b886f7ada0d592398ea6de6e36bd767d09ce2407 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 14 Jan 2010 05:21:20 +0000 Subject: [PATCH 110/202] Fix for previous properties editor crash, only remove ui handlers on new screens. Was preventing openGL render and possibly other things from working --- source/blender/windowmanager/intern/wm_event_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index f38f14e5315..a940c6054fa 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1629,7 +1629,7 @@ void WM_event_remove_area_handler(ListBase *handlers, void *area) for(handler = handlers->first; handler; handler= nexthandler) { nexthandler = handler->next; if (handler->type != WM_HANDLER_FILESELECT) { - if (handler->ui_area == area || handler->op_area == area) { + if (handler->ui_area == area) { BLI_remlink(handlers, handler); wm_event_free_handler(handler); } From 109f719f46d608e2045c06e1ad1a3a51ae416e2a Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Thu, 14 Jan 2010 05:22:16 +0000 Subject: [PATCH 111/202] ctrl +/- should be in default keymap for 3d view zoom in/out, probably other views too --- source/blender/editors/space_view3d/view3d_ops.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 9c0c50790fa..a673efb0499 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -139,8 +139,15 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW3D_OT_move", MOUSEPAN, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MOUSEZOOM, 0, 0, 0); + /*numpad +/-*/ RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADMINUS, KM_PRESS, 0, 0)->ptr, "delta", -1); + + /*ctrl +/-*/ + RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", EQUALKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1); + RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MINUSKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1); + + /*wheel mouse forward/back*/ RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELINMOUSE, KM_PRESS, 0, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELOUTMOUSE, KM_PRESS, 0, 0)->ptr, "delta", -1); From 72b14be4609fd3d9717fcc0a8b59c9c0644032ad Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 14 Jan 2010 05:29:25 +0000 Subject: [PATCH 112/202] * Added an 'enable manipulator' operator, with boolean properties for each of translate/rotate/scale, for people to bind to shortcut keys. wm.context_set doesn't work well here since it just toggles each component on/off. Fixes [#19730] Missing/conflicting keymaps for "Change Manipulator Mode" function Good defaults for this can be decided on for an updated 2.5 key layout. --- .../editors/space_view3d/view3d_edit.c | 33 +++++++++++++++++++ .../editors/space_view3d/view3d_intern.h | 1 + .../blender/editors/space_view3d/view3d_ops.c | 3 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 9bb7d35f96d..d565199ef55 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2283,7 +2283,40 @@ void VIEW3D_OT_manipulator(wmOperatorType *ot) RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", ""); } +static int enable_manipulator_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + View3D *v3d = CTX_wm_view3d(C); + v3d->twtype=0; + + if (RNA_boolean_get(op->ptr, "translate")) + v3d->twtype |= V3D_MANIP_TRANSLATE; + if (RNA_boolean_get(op->ptr, "rotate")) + v3d->twtype |= V3D_MANIP_ROTATE; + if (RNA_boolean_get(op->ptr, "scale")) + v3d->twtype |= V3D_MANIP_SCALE; + + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + + return OPERATOR_FINISHED; +} + +void VIEW3D_OT_enable_manipulator(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Enable 3D Manipulator"; + ot->description = "Enable the transform manipulator for use."; + ot->idname= "VIEW3D_OT_enable_manipulator"; + + /* api callbacks */ + ot->invoke= enable_manipulator_invoke; + ot->poll= ED_operator_view3d_active; + + /* rna later */ + RNA_def_boolean(ot->srna, "translate", 0, "Translate", "Enable the translate manipulator"); + RNA_def_boolean(ot->srna, "rotate", 0, "Rotate", "Enable the rotate manipulator"); + RNA_def_boolean(ot->srna, "scale", 0, "Scale", "Enable the scale manipulator"); +} /* ************************* below the line! *********************** */ diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 7d2f6294041..81de9ac7d34 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -81,6 +81,7 @@ void VIEW3D_OT_view_orbit(struct wmOperatorType *ot); void VIEW3D_OT_clip_border(struct wmOperatorType *ot); void VIEW3D_OT_cursor3d(struct wmOperatorType *ot); void VIEW3D_OT_manipulator(struct wmOperatorType *ot); +void VIEW3D_OT_enable_manipulator(struct wmOperatorType *ot); void VIEW3D_OT_render_border(struct wmOperatorType *ot); void VIEW3D_OT_zoom_border(struct wmOperatorType *ot); void VIEW3D_OT_drawtype(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index a673efb0499..ad5bdcf0095 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -80,6 +80,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_render_border); WM_operatortype_append(VIEW3D_OT_zoom_border); WM_operatortype_append(VIEW3D_OT_manipulator); + WM_operatortype_append(VIEW3D_OT_enable_manipulator); WM_operatortype_append(VIEW3D_OT_cursor3d); WM_operatortype_append(VIEW3D_OT_select_lasso); WM_operatortype_append(VIEW3D_OT_setcameratoview); @@ -264,7 +265,7 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW3D_OT_object_as_camera", PAD0, KM_PRESS, KM_CTRL, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); - + /* context ops */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "path", "space_data.pivot_point"); From c1f2fd0a464c62e01e78f3b8f544219fa087ffc2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Jan 2010 08:53:10 +0000 Subject: [PATCH 113/202] particle weight brush back (mostly the same as in 2.4x), needed to control long hairs movement. --- source/blender/blenkernel/intern/particle.c | 69 ++++++++++++++----- .../blenkernel/intern/particle_system.c | 6 +- .../blender/editors/physics/particle_edit.c | 40 +++++++++-- .../blender/editors/space_view3d/drawobject.c | 6 ++ source/blender/makesdna/DNA_scene_types.h | 1 + .../makesrna/intern/rna_sculpt_paint.c | 1 + 6 files changed, 94 insertions(+), 29 deletions(-) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 715d3610b31..9889fa9c7b3 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2983,12 +2983,21 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f; - sel_col[0] = (float)edit->sel_col[0] / 255.0f; - sel_col[1] = (float)edit->sel_col[1] / 255.0f; - sel_col[2] = (float)edit->sel_col[2] / 255.0f; - nosel_col[0] = (float)edit->nosel_col[0] / 255.0f; - nosel_col[1] = (float)edit->nosel_col[1] / 255.0f; - nosel_col[2] = (float)edit->nosel_col[2] / 255.0f; + if(pset->brushtype == PE_BRUSH_WEIGHT){ + /* use weight painting colors now... */ +#if 0 + sel_col[0] = sel_col[1] = sel_col[2] = 1.0f; + nosel_col[0] = nosel_col[1] = nosel_col[2] = 0.0f; +#endif + } + else{ + sel_col[0] = (float)edit->sel_col[0] / 255.0f; + sel_col[1] = (float)edit->sel_col[1] / 255.0f; + sel_col[2] = (float)edit->sel_col[2] / 255.0f; + nosel_col[0] = (float)edit->nosel_col[0] / 255.0f; + nosel_col[1] = (float)edit->nosel_col[1] / 255.0f; + nosel_col[2] = (float)edit->nosel_col[2] / 255.0f; + } /*---first main loop: create all actual particles' paths---*/ for(i=0; ipart->flag & PART_HAIR_BSPLINE) : 0; pind.dm = NULL; + + /* should init_particle_interpolation set this ? */ + if(pset->brushtype==PE_BRUSH_WEIGHT){ + pind.hkey[0] = pa->hair; + pind.hkey[1] = pa->hair + 1; + } + + memset(cache[i], 0, sizeof(*cache[i])*(steps+1)); cache[i]->steps = steps; @@ -3035,6 +3052,12 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf do_particle_interpolation(psys, i, pa, t, frs_sec, &pind, &result); + /* should init_particle_interpolation set this ? */ + if(pset->brushtype==PE_BRUSH_WEIGHT){ + pind.hkey[0] = pind.hkey[1]; + pind.hkey[1]++; + } + /* non-hair points are allready in global space */ if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { mul_m4_v3(hairmat, result.co); @@ -3091,22 +3114,30 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf ca->vel[1] = 1.0f; /* selection coloring in edit mode */ - if((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT){ - if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ - VECCOPY(ca->col, sel_col); - } - else{ - keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); - interp_v3_v3v3(ca->col, sel_col, nosel_col, keytime); - } + if(pset->brushtype==PE_BRUSH_WEIGHT){ + if(k==steps) + weight_to_rgb(pind.hkey[0]->weight, ca->col, ca->col+1, ca->col+2); + else + weight_to_rgb((1.0f - keytime) * pind.hkey[0]->weight + keytime * pind.hkey[1]->weight, ca->col, ca->col+1, ca->col+2); } - else{ - if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ - keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); - interp_v3_v3v3(ca->col, nosel_col, sel_col, keytime); + else { + if((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT){ + if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ + VECCOPY(ca->col, sel_col); + } + else{ + keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); + interp_v3_v3v3(ca->col, sel_col, nosel_col, keytime); + } } else{ - VECCOPY(ca->col, nosel_col); + if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ + keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); + interp_v3_v3v3(ca->col, nosel_col, sel_col, keytime); + } + else{ + VECCOPY(ca->col, nosel_col); + } } } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 27e0c632a81..acdab80bb37 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3071,10 +3071,8 @@ static void do_hair_dynamics(ParticleSimulationData *sim) dvert->dw = MEM_callocN (sizeof(MDeformWeight), "deformWeight"); dvert->totweight = 1; } - - /* no special reason for the 0.5 */ - /* just seems like a nice value from experiments */ - dvert->dw->weight = k ? 0.5f : 1.0f; + /* roots should be 1.0, the rest can be anything from 0.0 to 1.0 */ + dvert->dw->weight = key->weight; dvert++; } } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index fc86971b8ac..f9c786b29b0 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2844,7 +2844,6 @@ static void brush_puff(PEData *data, int point_index) PTCacheEditPoint *point = edit->points + point_index; KEY_K; float mat[4][4], imat[4][4]; - float obmat[4][4], obimat[4][4]; float lastco[3], rootco[3] = {0.0f, 0.0f, 0.0f}, co[3], nor[3], kco[3], dco[3], ofs[3] = {0.0f, 0.0f, 0.0f}, fac=0.0f, length=0.0f; int puff_volume = 0; @@ -2865,22 +2864,19 @@ static void brush_puff(PEData *data, int point_index) unit_m4(imat); } - copy_m4_m4(obmat, data->ob->obmat); - invert_m4_m4(obimat, obmat); - LOOP_KEYS { if(k==0) { /* find root coordinate and normal on emitter */ VECCOPY(co, key->co); mul_m4_v3(mat, co); - mul_v3_m4v3(kco, obimat, co); /* use 'kco' as the object space version of worldspace 'co' */ + mul_v3_m4v3(kco, data->ob->imat, co); /* use 'kco' as the object space version of worldspace 'co', ob->imat is set before calling */ point_index= BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL, NULL); if(point_index == -1) return; VECCOPY(rootco, co); copy_v3_v3(nor, &edit->emitter_cosnos[point_index*6+3]); - mul_mat3_m4_v3(obmat, nor); /* normal into worldspace */ + mul_mat3_m4_v3(data->ob->obmat, nor); /* normal into worldspace */ normalize_v3(nor); length= 0.0f; @@ -2949,6 +2945,21 @@ static void brush_puff(PEData *data, int point_index) point->flag |= PEP_EDIT_RECALC; } + +static void brush_weight(PEData *data, float mat[][4], float imat[][4], int point_index, int key_index, PTCacheEditKey *key) +{ + /* roots have full weight allways */ + if(key_index) { + PTCacheEdit *edit = data->edit; + ParticleSystem *psys = edit->psys; + + ParticleData *pa= psys->particles + point_index; + pa->hair[key_index].weight = data->weightfac; + + (data->edit->points + point_index)->flag |= PEP_EDIT_RECALC; + } +} + static void brush_smooth_get(PEData *data, float mat[][4], float imat[][4], int point_index, int key_index, PTCacheEditKey *key) { if(key_index) { @@ -3394,6 +3405,23 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) foreach_mouse_hit_key(&data, brush_smooth_do, selected); } + break; + } + case PE_BRUSH_WEIGHT: + { + PEData data; + PE_set_view3d_data(C, &data); + + if(edit->psys) { + data.dm= psmd->dm; + data.mval= mval; + data.rad= (float)brush->size; + + data.weightfac = (float)(brush->strength / 100.0f); /* note that this will never be zero */ + + foreach_mouse_hit_key(&data, brush_weight, selected); + } + break; } } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 8e269d98014..dd43c34c4dc 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3812,6 +3812,12 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, RegionView3D *rv3d, Obj glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + if(pset->brushtype == PE_BRUSH_WEIGHT) { + glLineWidth(2.0f); + glDisable(GL_LIGHTING); + /* TODO, nice color blending */ + } + cache=edit->pathcache; for(i=0; i Date: Thu, 14 Jan 2010 09:01:57 +0000 Subject: [PATCH 114/202] enable smooth shading of particle colors in particle editmode, for weight painting and selection. --- source/blender/editors/space_view3d/drawobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index dd43c34c4dc..a5a82b22e27 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3811,11 +3811,11 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, RegionView3D *rv3d, Obj glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glShadeModel(GL_SMOOTH); if(pset->brushtype == PE_BRUSH_WEIGHT) { glLineWidth(2.0f); glDisable(GL_LIGHTING); - /* TODO, nice color blending */ } cache=edit->pathcache; @@ -3924,9 +3924,9 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, RegionView3D *rv3d, Obj glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); + glShadeModel(GL_FLAT); glEnable(GL_DEPTH_TEST); glLineWidth(1.0f); - glPointSize(1.0); } //static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float tw,float th) From e8c4be18a84456301204f27082aed9bd8933eb77 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 14 Jan 2010 09:56:41 +0000 Subject: [PATCH 115/202] Fix [#20029] Text input fields with dropdown list bugs --- source/blender/editors/interface/interface.c | 2 +- source/blender/editors/interface/interface_handlers.c | 5 ++++- source/blender/editors/interface/interface_widgets.c | 9 ++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 7a1cc4f5bad..72502dd018f 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1360,7 +1360,7 @@ void ui_set_but_val(uiBut *but, double value) int ui_get_but_string_max_length(uiBut *but) { - if(but->type == TEX) + if(ELEM(but->type, TEX, SEARCH_MENU)) return but->hardmax; else if(but->type == IDPOIN) return sizeof(((ID*)NULL)->name)-2; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 705decec70d..75b03e0069d 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1083,8 +1083,11 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho /* XXX solve generic */ if(but->type==NUM || but->type==NUMSLI) startx += (int)(0.5f*(but->y2 - but->y1)); - else if(but->type==TEX) + else if(ELEM(but->type, TEX, SEARCH_MENU)) { startx += 5; + if (but->flag & UI_HAS_ICON) + startx += 16; + } /* XXX does not take zoom level into account */ while((BLF_width(origstr+but->ofs) + startx) > x) { diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 7b975d17184..575f298b3cd 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -804,6 +804,8 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) int border= (but->flag & UI_BUT_ALIGN_RIGHT)? 8: 10; int okwidth= rect->xmax-rect->xmin - border; + if (but->flag & UI_HAS_ICON) okwidth -= 16; + /* need to set this first */ uiStyleFontSet(fstyle); @@ -984,7 +986,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB if (ELEM4(but->type, NUM, NUMABS, NUMSLI, SLI)) { ui_text_label_rightclip(fstyle, but, rect); } - else if (but->type == TEX) { + else if (ELEM(but->type, TEX, SEARCH_MENU)) { ui_text_leftclip(fstyle, but, rect); } else but->ofs= 0; @@ -1330,8 +1332,9 @@ static void widget_state(uiWidgetType *wt, int state) VECCOPY(wt->wcol.text, wt->wcol.text_sel); - /* swap for selection - show depressed */ - SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); + if (!(state & UI_TEXTINPUT)) + /* swap for selection - show depressed */ + SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); } else { if(state & UI_BUT_ANIMATED_KEY) From fffbb2c7ebb2b7d3a0c20e9b04fa4132a070afb3 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 14 Jan 2010 10:43:53 +0000 Subject: [PATCH 116/202] Fix [#20671] No access to creating textures for a material Caused by my previous commit here. --- source/blender/editors/space_buttons/buttons_context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index c689e994c17..39990df34a7 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -339,10 +339,10 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path return 1; } /* try brush */ - if(buttons_context_path_brush(C, path)) { + if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(C, path)) { br= path->ptr[path->len-1].data; - if(br && (path->flag & SB_BRUSH_TEX)) { + if(br) { tex= give_current_brush_texture(br); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); From 9de67b8ca9247be79b91450e98a18464c39a052b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Jan 2010 10:50:58 +0000 Subject: [PATCH 117/202] UV operator template --- release/scripts/templates/operator_uv.py | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 release/scripts/templates/operator_uv.py diff --git a/release/scripts/templates/operator_uv.py b/release/scripts/templates/operator_uv.py new file mode 100644 index 00000000000..737059ab666 --- /dev/null +++ b/release/scripts/templates/operator_uv.py @@ -0,0 +1,42 @@ + +def main(context): + obj = context.active_object + mesh = obj.data + + is_editmode = (obj.mode == 'EDIT') + if is_editmode: + bpy.ops.object.mode_set(mode='OBJECT', toggle=False) + + + if not mesh.active_uv_texture: + bpy.ops.mesh.uv_texture_add() + + # adjust UVs + for i, uv in enumerate(mesh.active_uv_texture.data): + uvs = uv.uv1, uv.uv2, uv.uv3, uv.uv4 + for j, v_idx in enumerate(mesh.faces[i].verts): + if uv.uv_selected[j]: + # apply the location of the vertex as a UV + uvs[j][:] = mesh.verts[v_idx].co.xy + + + if is_editmode: + bpy.ops.object.mode_set(mode='EDIT', toggle=False) + +class UvOperator(bpy.types.Operator): + '''''' + bl_idname = "uv.simple_operator" + bl_label = "Simple Object Operator" + + def poll(self, context): + obj = context.active_object + return (obj and obj.type == 'MESH') + + def execute(self, context): + main(context) + return {'FINISHED'} + +bpy.types.register(UvOperator) + +if __name__ == "__main__": + bpy.ops.uv.simple_operator() From dd59f4df90a39c79c72b3107bcc16eeb1af047a9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 14 Jan 2010 10:57:24 +0000 Subject: [PATCH 118/202] Fix mistake in recent commit, typed in wrong number for bitflag causing various issues with constraints and duplis. --- source/blender/makesdna/DNA_object_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 2b4b0a7b612..dbb7294f108 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -334,7 +334,7 @@ extern Object workob; #define OB_DUPLIFACES_SCALE 1024 #define OB_DUPLIPARTS 2048 #define OB_RENDER_DUPLI 4096 -#define OB_NO_CONSTRAINTS 8096 /* runtime constraints disable */ +#define OB_NO_CONSTRAINTS 8192 /* runtime constraints disable */ /* (short) ipoflag */ // XXX depreceated - old animation system crap From 4371c3b0444bdaa8f47e43692095a70c388b57f2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Jan 2010 10:58:03 +0000 Subject: [PATCH 119/202] no-functional change - use interpolation functions where possible. --- source/blender/blenkernel/intern/particle.c | 58 ++++++++------------- 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 9889fa9c7b3..63d681cce0b 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1305,46 +1305,33 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or float tuv[4][2]; float *o1, *o2, *o3, *o4; - v1= (mvert+mface->v1)->co; - v2= (mvert+mface->v2)->co; - v3= (mvert+mface->v3)->co; - VECCOPY(n1,(mvert+mface->v1)->no); - VECCOPY(n2,(mvert+mface->v2)->no); - VECCOPY(n3,(mvert+mface->v3)->no); - normalize_v3(n1); - normalize_v3(n2); - normalize_v3(n3); + v1= mvert[mface->v1].co; + v2= mvert[mface->v2].co; + v3= mvert[mface->v3].co; + + normal_short_to_float_v3(n1, mvert[mface->v1].no); + normal_short_to_float_v3(n2, mvert[mface->v2].no); + normal_short_to_float_v3(n3, mvert[mface->v3].no); if(mface->v4) { - v4= (mvert+mface->v4)->co; - VECCOPY(n4,(mvert+mface->v4)->no); - normalize_v3(n4); + v4= mvert[mface->v4].co; + normal_short_to_float_v3(n4, mvert[mface->v4].no); - vec[0]= w[0]*v1[0] + w[1]*v2[0] + w[2]*v3[0] + w[3]*v4[0]; - vec[1]= w[0]*v1[1] + w[1]*v2[1] + w[2]*v3[1] + w[3]*v4[1]; - vec[2]= w[0]*v1[2] + w[1]*v2[2] + w[2]*v3[2] + w[3]*v4[2]; + interp_v3_v3v3v3v3(vec, v1, v2, v3, v4, w); if(nor){ - if(mface->flag & ME_SMOOTH){ - nor[0]= w[0]*n1[0] + w[1]*n2[0] + w[2]*n3[0] + w[3]*n4[0]; - nor[1]= w[0]*n1[1] + w[1]*n2[1] + w[2]*n3[1] + w[3]*n4[1]; - nor[2]= w[0]*n1[2] + w[1]*n2[2] + w[2]*n3[2] + w[3]*n4[2]; - } + if(mface->flag & ME_SMOOTH) + interp_v3_v3v3v3v3(nor, n1, n2, n3, n4, w); else normal_quad_v3(nor,v1,v2,v3,v4); } } else { - vec[0]= w[0]*v1[0] + w[1]*v2[0] + w[2]*v3[0]; - vec[1]= w[0]*v1[1] + w[1]*v2[1] + w[2]*v3[1]; - vec[2]= w[0]*v1[2] + w[1]*v2[2] + w[2]*v3[2]; - + interp_v3_v3v3v3(vec, v1, v2, v3, w); + if(nor){ - if(mface->flag & ME_SMOOTH){ - nor[0]= w[0]*n1[0] + w[1]*n2[0] + w[2]*n3[0]; - nor[1]= w[0]*n1[1] + w[1]*n2[1] + w[2]*n3[1]; - nor[2]= w[0]*n1[2] + w[1]*n2[2] + w[2]*n3[2]; - } + if(mface->flag & ME_SMOOTH) + interp_v3_v3v3v3(nor, n1, n2, n3, w); else normal_tri_v3(nor,v1,v2,v3); } @@ -1405,17 +1392,14 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or if(mface->v4) { o4= orcodata[mface->v4]; - orco[0]= w[0]*o1[0] + w[1]*o2[0] + w[2]*o3[0] + w[3]*o4[0]; - orco[1]= w[0]*o1[1] + w[1]*o2[1] + w[2]*o3[1] + w[3]*o4[1]; - orco[2]= w[0]*o1[2] + w[1]*o2[2] + w[2]*o3[2] + w[3]*o4[2]; + + interp_v3_v3v3v3v3(orco, o1, o2, o3, o4, w); if(ornor) normal_quad_v3( ornor,o1, o2, o3, o4); } else { - orco[0]= w[0]*o1[0] + w[1]*o2[0] + w[2]*o3[0]; - orco[1]= w[0]*o1[1] + w[1]*o2[1] + w[2]*o3[1]; - orco[2]= w[0]*o1[2] + w[1]*o2[2] + w[2]*o3[2]; + interp_v3_v3v3v3(orco, o1, o2, o3, w); if(ornor) normal_tri_v3( ornor,o1, o2, o3); @@ -2842,7 +2826,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) do_particle_interpolation(psys, p, pa, t, frs_sec, &pind, &result); /* dynamic hair is in object space */ - /* keyed and baked are allready in global space */ + /* keyed and baked are already in global space */ if(hair_dm) mul_m4_v3(sim->ob->obmat, result.co); else if(!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR)) @@ -3058,7 +3042,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf pind.hkey[1]++; } - /* non-hair points are allready in global space */ + /* non-hair points are already in global space */ if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { mul_m4_v3(hairmat, result.co); From b0f87935a8d0de0f9ed886c7f26f1b7af41ed12a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Jan 2010 10:59:42 +0000 Subject: [PATCH 120/202] spelling errors, no real changes to code. --- intern/bsp/intern/BSP_CSGMesh.h | 2 +- intern/ghost/intern/GHOST_SystemWin32.cpp | 2 +- release/scripts/templates/operator_uv.py | 2 +- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/cloth.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/image.c | 2 +- source/blender/blenkernel/intern/modifier.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/softbody.c | 2 +- source/blender/blenlib/intern/math_vector.c | 2 +- source/blender/editors/armature/editarmature.c | 4 ++-- source/blender/editors/interface/interface_widgets.c | 2 +- source/blender/editors/mesh/editmesh_add.c | 2 +- source/blender/editors/mesh/editmesh_lib.c | 2 +- source/blender/editors/object/object_select.c | 2 +- source/blender/imbuf/intern/jpeg.c | 2 +- source/blender/imbuf/intern/radiance_hdr.c | 2 +- source/blender/makesrna/intern/rna_object_force.c | 2 +- source/blender/python/generic/vector.c | 2 +- source/gameengine/Ketsji/KX_PyConstraintBinding.cpp | 2 +- 21 files changed, 22 insertions(+), 22 deletions(-) diff --git a/intern/bsp/intern/BSP_CSGMesh.h b/intern/bsp/intern/BSP_CSGMesh.h index 64ecafc2fc0..1fbc8db5286 100644 --- a/intern/bsp/intern/BSP_CSGMesh.h +++ b/intern/bsp/intern/BSP_CSGMesh.h @@ -83,7 +83,7 @@ public : DestroyEdges( ); - // return a new seperate copy of the + // return a new separate copy of the // mesh allocated on the heap. BSP_CSGMesh * diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 7d52ab55692..1a1cc99742d 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -665,7 +665,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, case VK_CONTROL: case VK_MENU: if (!system->m_separateLeftRightInitialized) { - // Check whether this system supports seperate left and right keys + // Check whether this system supports separate left and right keys switch (wParam) { case VK_SHIFT: system->m_separateLeftRight = diff --git a/release/scripts/templates/operator_uv.py b/release/scripts/templates/operator_uv.py index 737059ab666..15ae9d261a0 100644 --- a/release/scripts/templates/operator_uv.py +++ b/release/scripts/templates/operator_uv.py @@ -26,7 +26,7 @@ def main(context): class UvOperator(bpy.types.Operator): '''''' bl_idname = "uv.simple_operator" - bl_label = "Simple Object Operator" + bl_label = "Simple UV Operator" def poll(self, context): obj = context.active_object diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index dff670a847f..e4079eac31b 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -274,7 +274,7 @@ void bone_flip_name (char *name, int strip_number) /* We first check the case with a .### extension, let's find the last period */ if(isdigit(name[len-1])) { - index= strrchr(name, '.'); // last occurrance + index= strrchr(name, '.'); // last occurrence if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever! if(strip_number==0) strcpy(number, index); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index dc9a70f2767..de1c2ef8ddc 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -478,7 +478,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, } } - // unused in the moment, calculated seperately in implicit.c + // unused in the moment, calculated separately in implicit.c clmd->sim_parms->dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame; /* handle continuous simulation with the play button */ diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index e664dd01f4d..d584b18aa84 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -809,7 +809,7 @@ DagNode * dag_find_node (DagForest *forest,void * fob) static int ugly_hack_sorry= 1; // prevent type check -/* no checking of existance, use dag_find_node first or dag_get_node */ +/* no checking of existence, use dag_find_node first or dag_get_node */ DagNode * dag_add_node (DagForest *forest, void * fob) { DagNode *node; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index f7edb2bd146..464f4a2875f 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1480,7 +1480,7 @@ struct anim *openanim(char *name, int flags) */ -/* forces existance of 1 Image for renderout or nodes, returns Image */ +/* forces existence of 1 Image for renderout or nodes, returns Image */ /* name is only for default, when making new one */ Image *BKE_image_verify_viewer(int type, const char *name) { diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 7fffd7fc223..7e211f60cd5 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -1817,7 +1817,7 @@ static void vertgroup_flip_name (char *name, int strip_number) /* We first check the case with a .### extension, let's find the last period */ if(isdigit(name[len-1])) { - index= strrchr(name, '.'); // last occurrance + index= strrchr(name, '.'); // last occurrence if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever! if(strip_number==0) strcpy(number, index); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 7b2cf72e311..b31131554bd 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1447,7 +1447,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) } } - /* don't read old cache if allready simulated past cached frame */ + /* don't read old cache if already simulated past cached frame */ if(!pm && !pf && cfra1 && cfra1 <= pid->cache->simframe) error = 1; if(cfra1 && cfra1==cfra2) diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 735c57ea0ce..54cd8691e79 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1269,7 +1269,7 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa normalize_v3(d_nvect); if ( /* isect_line_tri_v3(nv1, nv3, face_v1, face_v2, face_v3, &t, NULL) || - we did that edge allready */ + we did that edge already */ isect_line_tri_v3(nv3, nv4, face_v1, face_v2, face_v3, &t, NULL) || isect_line_tri_v3(nv4, nv1, face_v1, face_v2, face_v3, &t, NULL) ){ Vec3PlusStVec(force,-0.5f,d_nvect); diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index d99d96d28ff..bb7c65c4884 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -69,7 +69,7 @@ void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const fl } /* weight 3 vectors, - * 'w' must be unit length but is not a vector, just 3 weights */ + * 'w' must be unit length but is not a vector, just 4 weights */ void interp_v3_v3v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float w[4]) { p[0] = v1[0]*w[0] + v2[0]*w[1] + v3[0]*w[2] + v4[0]*w[3]; diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index f382896c868..1b6b489488c 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -517,7 +517,7 @@ void unique_editbone_name (ListBase *edbo, char *name, EditBone *bone) /* Strip off the suffix, if it's a number */ number= strlen(name); if (number && isdigit(name[number-1])) { - dot= strrchr(name, '.'); // last occurrance + dot= strrchr(name, '.'); // last occurrence if (dot) *dot=0; } @@ -5318,7 +5318,7 @@ void unique_bone_name (bArmature *arm, char *name) /* Strip off the suffix, if it's a number */ number= strlen(name); if(number && isdigit(name[number-1])) { - dot= strrchr(name, '.'); // last occurrance + dot= strrchr(name, '.'); // last occurrence if (dot) *dot=0; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 575f298b3cd..b5d656bc2b6 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1008,7 +1008,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB } /* If there's an icon too (made with uiDefIconTextBut) then draw the icon - and offset the text label to accomodate it */ + and offset the text label to accommodate it */ if (but->flag & UI_HAS_ICON) { widget_draw_icon(but, but->icon+but->iconadd, 1.0f, rect); diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 3a80d7c69bb..d6b4b43c569 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -484,7 +484,7 @@ static int compareface_overlaps(EditFace *vl1, EditFace *vl2) return 0; } -/* checks for existance, and for tria overlapping inside quad */ +/* checks for existence, and for tria overlapping inside quad */ static EditFace *exist_face_overlaps(EditMesh *em, EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4) { EditFace *efa, efatest; diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index d99765bd199..69043d9fa98 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -1975,7 +1975,7 @@ int compareface(EditFace *vl1, EditFace *vl2) return 0; } -/* checks for existance, not tria overlapping inside quad */ +/* checks for existence, not tria overlapping inside quad */ EditFace *exist_face(EditMesh *em, EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4) { EditFace *efa, efatest; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index becad003d5c..b3a160dfff4 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -786,7 +786,7 @@ void object_flip_name (char *name) /* We first check the case with a .### extension, let's find the last period */ if(isdigit(name[len-1])) { - index= strrchr(name, '.'); // last occurrance + index= strrchr(name, '.'); // last occurrence if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever! strcpy(number, index); *index= 0; diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 2b2d17784e2..97d700f3af7 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -64,7 +64,7 @@ static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int f type 3 is unsupported as of jul 05 2000 Frank. - * 3. jstr - as 2, but written in 2 seperate fields + * 3. jstr - as 2, but written in 2 separate fields * 4. jmax - no scaling in the components */ diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 5acde1232fd..ac62872479b 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -283,7 +283,7 @@ static int fwritecolrs(FILE* file, int width, int channels, unsigned char* ibufs putc(2, file); putc((unsigned char)(width >> 8), file); putc((unsigned char)(width & 255), file); - /* put components seperately */ + /* put components separately */ for (i=0;i<4;i++) { for (j=0;j Date: Thu, 14 Jan 2010 12:51:17 +0000 Subject: [PATCH 121/202] weight paint without shading when in wire view. use stipple wire to help show where verts are. only way to do this previously was to have a UV layer, be in textured mode, not have any lights or textures and then set weight paint mode. --- .../blender/editors/space_view3d/drawobject.c | 94 ++++++++++++------- 1 file changed, 62 insertions(+), 32 deletions(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index a5a82b22e27..c3e248c9d7c 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2360,44 +2360,70 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } else if(dt==OB_SOLID) { - Paint *p; + if(ob==OBACT && ob && ob->mode & OB_MODE_WEIGHT_PAINT) { + /* weight paint in solid mode, special case. focus on making the weights clear + * rather then the shading, this is also forced in wire view */ + GPU_enable_material(0, NULL); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1); - if((v3d->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !draw_wire && !ob->sculpt) - draw_mesh_object_outline(v3d, ob, dm); + bglPolygonOffset(rv3d->dist, 1.0); + glDepthMask(0); // disable write in zbuffer, selected edge wires show better - glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED ); + glEnable(GL_BLEND); + glColor4ub(196, 196, 196, 196); + glEnable(GL_LINE_STIPPLE); + glLineStipple(1, 0x8888); - glEnable(GL_LIGHTING); - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + dm->drawEdges(dm, 1); - if(ob->sculpt && (p=paint_get_active(scene))) { - float planes[4][4]; - float (*fpl)[4] = NULL; - int fast= (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING); + bglPolygonOffset(rv3d->dist, 0.0); + glDepthMask(1); + glDisable(GL_LINE_STIPPLE); - if(ob->sculpt->partial_redraw) { - sculpt_get_redraw_planes(planes, ar, rv3d, ob); - fpl = planes; - ob->sculpt->partial_redraw = 0; + GPU_disable_material(); + + + } + else { + Paint *p; + + if((v3d->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !draw_wire && !ob->sculpt) + draw_mesh_object_outline(v3d, ob, dm); + + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED ); + + glEnable(GL_LIGHTING); + glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + + if(ob->sculpt && (p=paint_get_active(scene))) { + float planes[4][4]; + float (*fpl)[4] = NULL; + int fast= (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING); + + if(ob->sculpt->partial_redraw) { + sculpt_get_redraw_planes(planes, ar, rv3d, ob); + fpl = planes; + ob->sculpt->partial_redraw = 0; + } + + dm->drawFacesSolid(dm, fpl, fast, GPU_enable_material); } + else + dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); - dm->drawFacesSolid(dm, fpl, fast, GPU_enable_material); + GPU_disable_material(); + + glFrontFace(GL_CCW); + glDisable(GL_LIGHTING); + + if(base->flag & SELECT) { + UI_ThemeColor((ob==OBACT)?TH_ACTIVE:TH_SELECT); + } else { + UI_ThemeColor(TH_WIRE); + } + if(!ob->sculpt) + dm->drawLooseEdges(dm); } - else - dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); - - GPU_disable_material(); - - glFrontFace(GL_CCW); - glDisable(GL_LIGHTING); - - if(base->flag & SELECT) { - UI_ThemeColor((ob==OBACT)?TH_ACTIVE:TH_SELECT); - } else { - UI_ThemeColor(TH_WIRE); - } - if(!ob->sculpt) - dm->drawLooseEdges(dm); } else if(dt==OB_SHADED) { int do_draw= 1; /* to resolve all G.f settings below... */ @@ -5298,10 +5324,14 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(ob->mode & OB_MODE_EDIT); else { - if(dt Date: Thu, 14 Jan 2010 13:42:15 +0000 Subject: [PATCH 122/202] Little fun feature for SCons users: set BF_LINE_OVERWRITE=True in your user-config.py or on command-line when BF_QUIET=True. This will reuse the same line of the previous compile message (Compiling ==>...). Warnings and other messages will still go on their own lines. Remember to set BF_LINE_OVERWRITE=False when you are redirecting the build output to a file --- tools/Blender.py | 8 ++++++++ tools/btools.py | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/Blender.py b/tools/Blender.py index 4dad70bbef5..c51c1367f33 100644 --- a/tools/Blender.py +++ b/tools/Blender.py @@ -268,6 +268,12 @@ def buildinfo(lenv, build_type): ##### ACTION STUFF ############# +def my_print_cmd_line(self, s, target, source, env): + sys.stdout.write(' ' * 70 + '\r') + sys.stdout.flush() + sys.stdout.write(s + "\r") + sys.stdout.flush() + def my_compile_print(target, source, env): a = '%s' % (source[0]) d, f = os.path.split(a) @@ -330,6 +336,8 @@ def set_quiet_output(env): env['BUILDERS']['StaticLibrary'] = static_lib env['BUILDERS']['Library'] = static_lib env['BUILDERS']['Program'] = program + if env['BF_LINE_OVERWRITE']: + SCons.Action._ActionAction.print_cmd_line = my_print_cmd_line class CompZipFile(zipfile.ZipFile): diff --git a/tools/btools.py b/tools/btools.py index b3a97f96417..7dde9a14f6c 100644 --- a/tools/btools.py +++ b/tools/btools.py @@ -66,7 +66,7 @@ def validate_arguments(args, bc): 'WITH_BF_OPENMP', 'WITH_GHOST_COCOA', 'USE_QTKIT', - 'BF_FANCY', 'BF_QUIET', + 'BF_FANCY', 'BF_QUIET', 'BF_LINE_OVERWRITE', 'BF_X264_CONFIG', 'BF_XVIDCORE_CONFIG', 'WITH_BF_LCMS', 'BF_LCMS_LIB', @@ -97,7 +97,7 @@ def validate_arguments(args, bc): arg_list = ['BF_DEBUG', 'BF_QUIET', 'BF_CROSS', 'BF_UPDATE', 'BF_INSTALLDIR', 'BF_TOOLSET', 'BF_BINNAME', - 'BF_BUILDDIR', 'BF_FANCY', 'BF_QUICK', 'BF_PROFILE', + 'BF_BUILDDIR', 'BF_FANCY', 'BF_QUICK', 'BF_PROFILE', 'BF_LINE_OVERWRITE', 'BF_BSC', 'BF_CONFIG', 'BF_PRIORITYLIST', 'BF_BUILDINFO','CC', 'CXX', 'BF_QUICKDEBUG', 'BF_LISTDEBUG', 'LCGDIR', 'BF_X264_CONFIG', 'BF_XVIDCORE_CONFIG', @@ -403,6 +403,7 @@ def read_opts(cfg, args): (BoolVariable('WITHOUT_BF_PYTHON_INSTALL', 'dont install Python modules if true', False)), (BoolVariable('BF_FANCY', 'Enable fancy output if true', True)), (BoolVariable('BF_QUIET', 'Enable silent output if true', True)), + (BoolVariable('BF_LINE_OVERWRITE', 'Enable overwriting of compile line in BF_QUIET mode if true', False)), (BoolVariable('WITH_BF_BINRELOC', 'Enable relocatable binary (linux only)', False)), (BoolVariable('WITH_BF_LZO', 'Enable fast LZO pointcache compression', True)), From 231d29ccce00d746b9666f52d453613c57195e80 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Jan 2010 14:06:27 +0000 Subject: [PATCH 123/202] Join as UVs.... (copies matching UVs to another object with the same topology) nice that it uses foreach_get/set for fast array copying from python. note: this is getting out of hand, we beed some central panel/interface for copying mesh data about - shapes, UVs weights etc. at the moment they are accessed from all different places. --- release/scripts/op/object.py | 59 ++++++++++++++++++++++++++++++ release/scripts/ui/space_view3d.py | 1 + 2 files changed, 60 insertions(+) diff --git a/release/scripts/op/object.py b/release/scripts/op/object.py index dd95c6f51a6..1cf46d514c7 100644 --- a/release/scripts/op/object.py +++ b/release/scripts/op/object.py @@ -320,7 +320,66 @@ class ShapeTransfer(bpy.types.Operator): return self._main(ob_act, objects, self.properties.mode, self.properties.use_clamp) +class JoinUVs(bpy.types.Operator): + '''Copy UV Layout to objects with matching geometry''' + bl_idname = "object.join_uvs" + bl_label = "Join as UVs" + + def poll(self, context): + obj = context.active_object + return (obj and obj.type == 'MESH') + + def _main(self, context): + import array + obj = context.active_object + mesh = obj.data + + is_editmode = (obj.mode == 'EDIT') + if is_editmode: + bpy.ops.object.mode_set(mode='OBJECT', toggle=False) + + len_faces = len(mesh.faces) + + uv_array = array.array('f', [0.0] * 8) * len_faces # seems to be the fastest way to create an array + mesh.active_uv_texture.data.foreach_get("uv_raw", uv_array) + + objects = context.selected_editable_objects[:] + + for obj_other in objects: + if obj_other.type == 'MESH': + obj_other.data.tag = False + + for obj_other in objects: + if obj_other != obj and obj_other.type == 'MESH': + mesh_other = obj_other.data + if mesh_other != mesh: + if mesh_other.tag == False: + mesh_other.tag = True + + if len(mesh_other.faces) != len_faces: + self.report({'WARNING'}, "Object: %s, Mesh: '%s' has %d faces, expected %d\n" % (obj_other.name, mesh_other.name, len(mesh_other.faces), len_faces)) + else: + uv_other = mesh_other.active_uv_texture + if not uv_other: + mesh_other.uv_texture_add() # should return the texture it adds + uv_other = mesh_other.active_uv_texture + + # finally do the copy + uv_other.data.foreach_set("uv_raw", uv_array) + + if is_editmode: + bpy.ops.object.mode_set(mode='EDIT', toggle=False) + + def execute(self, context): + self._main(context) + return {'FINISHED'} + +if __name__ == "__main__": + bpy.ops.uv.simple_operator() + + bpy.types.register(SelectPattern) bpy.types.register(SubdivisionSet) bpy.types.register(Retopo) bpy.types.register(ShapeTransfer) +bpy.types.register(JoinUVs) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index e17d068b586..101fb6f7acc 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -656,6 +656,7 @@ class VIEW3D_MT_object(bpy.types.Menu): layout.separator() layout.operator("object.join_shapes") + layout.operator("object.join_uvs") layout.operator("object.join") layout.separator() From f8518a9b26f96a391f20b671331e3365f7f6a69b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Jan 2010 14:26:39 +0000 Subject: [PATCH 124/202] UV layout - set the width of the line to be 1 pixel - add the object name onto the blendfile name. --- release/scripts/op/uv.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/op/uv.py b/release/scripts/op/uv.py index eedd690a63f..00b65c38088 100644 --- a/release/scripts/op/uv.py +++ b/release/scripts/op/uv.py @@ -106,7 +106,7 @@ class ExportUVLayout(bpy.types.Operator): else: uvs = uv.uv1, uv.uv2, uv.uv3, uv.uv4 - fw(' Date: Thu, 14 Jan 2010 14:33:05 +0000 Subject: [PATCH 125/202] uv layout svg files were not importing into inkscape or firefox (gimp worked) --- release/scripts/op/uv.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/op/uv.py b/release/scripts/op/uv.py index 00b65c38088..476d3ab44c3 100644 --- a/release/scripts/op/uv.py +++ b/release/scripts/op/uv.py @@ -111,7 +111,7 @@ class ExportUVLayout(bpy.types.Operator): for j, uv in enumerate(uvs): x, y = uv.x, 1.0 - uv.y - fw('%f.3f,%f.3f ' % (x * image_width, y * image_height)) + fw('%.3f,%.3f ' % (x * image_width, y * image_height)) fw('" />\n') fw('\n') fw('\n') @@ -130,7 +130,7 @@ class ExportUVLayout(bpy.types.Operator): bpy.types.register(ExportUVLayout) def menu_func(self, context): - default_path = bpy.data.filename.replace(".blend", "_%s.svg" % bpy.utils.clean_name(getattr(context.object, "name", "none"))) + default_path = bpy.data.filename.replace(".blend", ".svg") self.layout.operator(ExportUVLayout.bl_idname).path = default_path bpy.types.IMAGE_MT_uvs.append(menu_func) From 672aede6a0a6200a928a4f2c57612444f3d541f4 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Thu, 14 Jan 2010 16:01:05 +0000 Subject: [PATCH 126/202] Cocoa : fix for modifiers keys handling upon application switching - fix race condition between applicationBecomeActive, and WindowBecomeKey events that discarded the modifiers keys status change event message - workaround for a 10.6 bug that made the Cmd (oskey) modifier erroneously on. --- intern/ghost/intern/GHOST_SystemCocoa.h | 3 +++ intern/ghost/intern/GHOST_SystemCocoa.mm | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index 9f51d7b0748..47a1acdb473 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -264,6 +264,9 @@ protected: /** Event has been processed directly by Cocoa and has sent a ghost event to be dispatched */ bool m_outsideLoopEventProcessed; + /** Raised window is not yet known by the window manager, so delay application become active event handling */ + bool m_needDelayedApplicationBecomeActiveEventProcessing; + /** Mouse buttons state */ GHOST_TUns32 m_pressedMouseButtons; diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 5f0276c3555..d8bb903dbe7 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -520,6 +520,7 @@ GHOST_SystemCocoa::GHOST_SystemCocoa() m_cursorDelta_x=0; m_cursorDelta_y=0; m_outsideLoopEventProcessed = false; + m_needDelayedApplicationBecomeActiveEventProcessing = false; m_displayManager = new GHOST_DisplayManagerCocoa (); GHOST_ASSERT(m_displayManager, "GHOST_SystemCocoa::GHOST_SystemCocoa(): m_displayManager==0\n"); m_displayManager->initialize(); @@ -919,6 +920,8 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent) } while (event!= nil); //} while (waitForEvent && !anyProcessed); Needed only for timer implementation + if (m_needDelayedApplicationBecomeActiveEventProcessing) handleApplicationBecomeActiveEvent(); + if (m_outsideLoopEventProcessed) { m_outsideLoopEventProcessed = false; return true; @@ -934,6 +937,12 @@ GHOST_TSuccess GHOST_SystemCocoa::handleApplicationBecomeActiveEvent() //(that is when update events are sent to another application) unsigned int modifiers; GHOST_IWindow* window = m_windowManager->getActiveWindow(); + + if (!window) { + m_needDelayedApplicationBecomeActiveEventProcessing = true; + return GHOST_kFailure; + } + else m_needDelayedApplicationBecomeActiveEventProcessing = false; #ifdef MAC_OS_X_VERSION_10_6 modifiers = [NSEvent modifierFlags]; @@ -948,6 +957,9 @@ GHOST_TSuccess GHOST_SystemCocoa::handleApplicationBecomeActiveEvent() } #endif + /* Discard erroneous 10.6 modifiers values reported when switching back from spaces */ + if ((modifiers & NSDeviceIndependentModifierFlagsMask) == 0xb00000) modifiers = 0; + if ((modifiers & NSShiftKeyMask) != (m_modifierMask & NSShiftKeyMask)) { pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & NSShiftKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftShift) ); } @@ -963,6 +975,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleApplicationBecomeActiveEvent() m_modifierMask = modifiers; + m_outsideLoopEventProcessed = true; return GHOST_kSuccess; } @@ -1430,7 +1443,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr) * the window go away and we still get an HKey up. */ if (!window) { - printf("\nW failure"); + //printf("\nW failure"); return GHOST_kFailure; } From 6d4d43c85ec2708ab470d35770257ca12fb79827 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Jan 2010 16:14:24 +0000 Subject: [PATCH 127/202] improve volume preserving puff to shape the end strands of the hair in relation to the underlying form of the head. --- .../blender/editors/physics/particle_edit.c | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index f9c786b29b0..fe38d71dc92 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2923,9 +2923,13 @@ static void brush_puff(PEData *data, int point_index) #else /* translate (not rotate) the rest of the hair if its not selected */ if(ofs[0] || ofs[1] || ofs[2]) { +#if 0 /* kindof works but looks worse then whats below */ + + /* Move the unselected point on a vector based on the + * hair direction and the offset */ float c1[3], c2[3]; VECSUB(dco, lastco, co); - mul_m4_v3(imat, dco); /* into particle space */ + mul_mat3_m4_v3(imat, dco); /* into particle space */ /* move the point allong a vector perpendicular to the * hairs direction, reduces odd kinks, */ @@ -2934,6 +2938,26 @@ static void brush_puff(PEData *data, int point_index) normalize_v3(c2); mul_v3_fl(c2, len_v3(ofs)); add_v3_v3(key->co, c2); +#else + /* Move the unselected point on a vector based on the + * the normal of the closest geometry */ + float oco[3], onor[3]; + VECCOPY(oco, key->co); + mul_m4_v3(mat, oco); + mul_v3_m4v3(kco, data->ob->imat, oco); /* use 'kco' as the object space version of worldspace 'co', ob->imat is set before calling */ + + point_index= BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL, NULL); + if(point_index != -1) { + copy_v3_v3(onor, &edit->emitter_cosnos[point_index*6+3]); + mul_mat3_m4_v3(data->ob->obmat, onor); /* normal into worldspace */ + mul_mat3_m4_v3(imat, onor); /* worldspace into particle space */ + normalize_v3(onor); + + + mul_v3_fl(onor, len_v3(ofs)); + add_v3_v3(key->co, onor); + } +#endif } #endif } From be680ae69bd17639108b9df285d276845d3f8d30 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Jan 2010 18:11:10 +0000 Subject: [PATCH 128/202] Mkey toggles mask while in vertex/texture/weight paint mode. remove unused operator property --- source/blender/editors/sculpt_paint/paint_ops.c | 9 +++++++++ source/blender/editors/sculpt_paint/paint_vertex.c | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 715a41e6431..a901b27b38f 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -276,6 +276,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "tool_settings.vertex_paint.active_brush_index"); ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ + RNA_string_set(kmi->ptr, "path", "vertex_paint_object.data.use_paint_mask"); + /* Weight Paint mode */ keymap= WM_keymap_find(keyconf, "Weight Paint", 0, 0); keymap->poll= weight_paint_poll; @@ -291,6 +294,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "tool_settings.weight_paint.active_brush_index"); ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ + RNA_string_set(kmi->ptr, "path", "weight_paint_object.data.use_paint_mask"); + /* Image/Texture Paint mode */ keymap= WM_keymap_find(keyconf, "Image Paint", 0, 0); keymap->poll= image_texture_paint_poll; @@ -305,6 +311,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "tool_settings.image_paint.active_brush_index"); ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ + RNA_string_set(kmi->ptr, "path", "texture_paint_object.data.use_paint_mask"); + /* face-mask mode */ keymap= WM_keymap_find(keyconf, "Face Mask", 0, 0); keymap->poll= facemask_paint_poll; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index cddfad19fa7..52a71352768 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1700,8 +1700,6 @@ void PAINT_OT_weight_set(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first."); } /* ************ set / clear vertex paint mode ********** */ From 9e79f2d92a991e12e5314f3bbc0a20993868bd17 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Thu, 14 Jan 2010 18:15:12 +0000 Subject: [PATCH 129/202] [#19978] Can not switch view with keymaps while emulate numpad is activated; in modes other than object and edit Was caused by event emulation (numpad and mmb) happening separately at each level of the keymap, so brush selection was latching on the event before it had time to test emulated values with view navigation entries (at a lower level in the hierarchy). After discussion with Matt, decided that event emulation should be done at the root of the event loop, replacing the event with the emulated values. This is much more predictable and more logical as far as event emulation goes. --- .../windowmanager/intern/wm_event_system.c | 68 +++++++++---------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index a940c6054fa..456f0b62a30 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -768,48 +768,42 @@ int WM_userdef_event_map(int kmitype) return kmitype; } +static void wm_eventemulation(wmEvent *event) +{ + /* middlemouse emulation */ + if(U.flag & USER_TWOBUTTONMOUSE) { + if(event->type == LEFTMOUSE && event->alt) { + event->type = MIDDLEMOUSE; + event->alt = 0; + } + } + + /* numpad emulation */ + if(U.flag & USER_NONUMPAD) { + switch(event->type) { + case ZEROKEY: event->type = PAD0; break; + case ONEKEY: event->type = PAD1; break; + case TWOKEY: event->type = PAD2; break; + case THREEKEY: event->type = PAD3; break; + case FOURKEY: event->type = PAD4; break; + case FIVEKEY: event->type = PAD5; break; + case SIXKEY: event->type = PAD6; break; + case SEVENKEY: event->type = PAD7; break; + case EIGHTKEY: event->type = PAD8; break; + case NINEKEY: event->type = PAD9; break; + case MINUSKEY: event->type = PADMINUS; break; + case EQUALKEY: event->type = PADPLUSKEY; break; + case BACKSLASHKEY: event->type = PADSLASHKEY; break; + } + } +} + static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi) { int kmitype= WM_userdef_event_map(kmi->type); if(kmi->flag & KMI_INACTIVE) return 0; - /* exception for middlemouse emulation */ - if((U.flag & USER_TWOBUTTONMOUSE) && (kmi->type == MIDDLEMOUSE)) { - if(winevent->type == LEFTMOUSE && winevent->alt) { - wmKeyMapItem tmp= *kmi; - - tmp.type= winevent->type; - tmp.alt= winevent->alt; - if(wm_eventmatch(winevent, &tmp)) - return 1; - } - } - /* exception for numpad emulation */ - else if(U.flag & USER_NONUMPAD) { - wmKeyMapItem tmp= *kmi; - - switch(kmi->type) { - case PAD0: tmp.type = ZEROKEY; break; - case PAD1: tmp.type = ONEKEY; break; - case PAD2: tmp.type = TWOKEY; break; - case PAD3: tmp.type = THREEKEY; break; - case PAD4: tmp.type = FOURKEY; break; - case PAD5: tmp.type = FIVEKEY; break; - case PAD6: tmp.type = SIXKEY; break; - case PAD7: tmp.type = SEVENKEY; break; - case PAD8: tmp.type = EIGHTKEY; break; - case PAD9: tmp.type = NINEKEY; break; - case PADMINUS: tmp.type = MINUSKEY; break; - case PADPLUSKEY: tmp.type = EQUALKEY; break; - case PADSLASHKEY: tmp.type = BACKSLASHKEY; break; - } - - if(tmp.type != kmi->type) - if(wm_eventmatch(winevent, &tmp)) - return 1; - } - /* the matching rules */ if(kmitype==KM_TEXTINPUT) if(ISTEXTINPUT(winevent->type) && winevent->ascii) return 1; @@ -1335,6 +1329,8 @@ void wm_event_do_handlers(bContext *C) while( (event= win->queue.first) ) { int action = WM_HANDLER_CONTINUE; + wm_eventemulation(event); + CTX_wm_window_set(C, win); /* we let modal handlers get active area/region, also wm_paintcursor_test needs it */ From e9e89ecfc3d7f1b29f58fc9d18e981853bef0bda Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Thu, 14 Jan 2010 19:53:26 +0000 Subject: [PATCH 130/202] [#20672] TimeLine (arrows will not proceed animation) RNA notifiers don't have a window and didn't get picked up correctly by the animation redraw system. If there's no window defined in a scene notifier, handle it anyway if the scene matches (or if there aren't any). --- source/blender/windowmanager/intern/wm_event_system.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 456f0b62a30..775d8c2b4ab 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -187,7 +187,10 @@ void wm_event_do_notifiers(bContext *C) printf("screen delete %p\n", note->reference); } } - else if(note->category==NC_SCENE) { + } + + if(note->window==win || (note->window == NULL && (note->reference == NULL || note->reference == CTX_data_scene(C)))) { + if(note->category==NC_SCENE) { if(note->data==ND_SCENEBROWSE) { ED_screen_set_scene(C, note->reference); // XXX hrms, think this over! if(G.f & G_DEBUG) From 5d16a5b7d998c3110e41f1343def4c7e4454ce2b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Jan 2010 20:48:25 +0000 Subject: [PATCH 131/202] Ctrl+RMB select in the dope-sheet wasnt working, this nlabackup stuff isnt being done for select-all so not sure why its there, commented it out for now. Aligorith, please check. --- source/blender/editors/space_action/action_select.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 9155f57c7a0..3f7a568fc00 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -663,7 +663,8 @@ static void actkeys_mselect_leftright (bAnimContext *ac, short leftright, short /* select keys on the side where most data occurs */ for (ale= anim_data.first; ale; ale= ale->next) { AnimData *adt= ANIM_nla_mapping_get(ac, ale); - + +#if 0 // This does not work even in simple cases I tested - campbell if (adt) { ListBase nlabackup; @@ -674,6 +675,7 @@ static void actkeys_mselect_leftright (bAnimContext *ac, short leftright, short //else if (ale->type == ANIMTYPE_GPLAYER) // borderselect_gplayer_frames(ale->data, min, max, SELECT_ADD); else +#endif ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); } From 690ad15099fefd3e1f994529149652fde4929c99 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 14 Jan 2010 21:30:51 +0000 Subject: [PATCH 132/202] Text Editor: Add an option "Tabs as Spaces". So now tab is not ALWAYS converted to spaces. This is stored by text datablock (what allows to do nice things in the future, as automatic check for the indentation type of the file). Ideally we should redraw the other Text Editor windows after changing that (in case the same file is opened and the Property panel is also open). Not sure how to do that though. I'm using TABSTOSPACES as the DEFINE flag because TABSASSPACES sounds too ugly. (also fix for interface divisor bug) --- release/scripts/ui/space_text.py | 2 ++ source/blender/blenkernel/intern/text.c | 2 +- source/blender/editors/interface/interface_widgets.c | 2 +- source/blender/makesdna/DNA_text_types.h | 1 + source/blender/makesrna/intern/rna_text.c | 4 ++++ 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/release/scripts/ui/space_text.py b/release/scripts/ui/space_text.py index 5df937aacde..9ec723b51f1 100644 --- a/release/scripts/ui/space_text.py +++ b/release/scripts/ui/space_text.py @@ -78,6 +78,7 @@ class TEXT_PT_properties(bpy.types.Panel): layout = self.layout st = context.space_data + text = st.text flow = layout.column_flow() flow.prop(st, "line_numbers") @@ -88,6 +89,7 @@ class TEXT_PT_properties(bpy.types.Panel): flow = layout.column_flow() flow.prop(st, "font_size") flow.prop(st, "tab_width") + flow.prop(text, "tabs_as_spaces") class TEXT_PT_find(bpy.types.Panel): diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index c5c23c8b6c7..9af0d11c162 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2380,7 +2380,7 @@ int txt_add_char (Text *text, char add) } /* insert spaces rather then tabs */ - if (add == '\t') { + if (add == '\t' && text->flags & TXT_TABSTOSPACES) { txt_convert_tab_to_spaces(text); return 1; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index b5d656bc2b6..fee0ee04f2e 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1800,7 +1800,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) static void ui_draw_separator(uiBut *but, rcti *rect, uiWidgetColors *wcol) { int y = rect->ymin + (rect->ymax - rect->ymin)/2 - 1; - unsigned char col[3]; + unsigned char col[4]; col[0] = wcol->text[0]; col[1] = wcol->text[1]; diff --git a/source/blender/makesdna/DNA_text_types.h b/source/blender/makesdna/DNA_text_types.h index 5793f061f06..9a9daf56e8a 100644 --- a/source/blender/makesdna/DNA_text_types.h +++ b/source/blender/makesdna/DNA_text_types.h @@ -84,6 +84,7 @@ typedef struct Text { #define TXT_ISSCRIPT 0x0010 /* used by space handler scriptlinks */ #define TXT_READONLY 0x0100 #define TXT_FOLLOW 0x0200 /* always follow cursor (console) */ +#define TXT_TABSTOSPACES 0x0400 /* use space instead of tabs */ /* format continuation flags */ #define TXT_NOCONT 0x00 /* no continuation */ diff --git a/source/blender/makesrna/intern/rna_text.c b/source/blender/makesrna/intern/rna_text.c index bed686ed360..3445933a3dc 100644 --- a/source/blender/makesrna/intern/rna_text.c +++ b/source/blender/makesrna/intern/rna_text.c @@ -198,6 +198,10 @@ static void rna_def_text(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flags", TXT_ISSCRIPT); RNA_def_property_ui_text(prop, "Register", "Register this text as a module on loading."); + prop= RNA_def_property(srna, "tabs_as_spaces", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", TXT_TABSTOSPACES); + RNA_def_property_ui_text(prop, "Tabs as Spaces", "Automatically converts all new tabs into spaces."); + prop= RNA_def_property(srna, "lines", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "TextLine"); RNA_def_property_ui_text(prop, "Lines", "Lines of text."); From 6f8ee9b0f9070636bdeb68b86b5b818af2f41f7d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Jan 2010 22:45:56 +0000 Subject: [PATCH 133/202] patch [#20673] Fixed descriptions in Torus mesh controls, and added some requested controls from Jaevixa McNomera (jaevixa) --- release/scripts/op/add_mesh_torus.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/release/scripts/op/add_mesh_torus.py b/release/scripts/op/add_mesh_torus.py index 865b1d57daf..ccc9a4ba776 100644 --- a/release/scripts/op/add_mesh_torus.py +++ b/release/scripts/op/add_mesh_torus.py @@ -93,9 +93,24 @@ class AddTorus(bpy.types.Operator): minor_segments = IntProperty(name="Minor Segments", description="Number of segments for the minor ring of the torus", default=16, min=3, max=256) + use_abso = BoolProperty(name="Use Int+Ext Controls", + description="Use the Int / Ext controls for torus dimensions", default=False) + abso_major_rad = FloatProperty(name="Exterior Radius", + description="Total Exterior Radius of the torus", + default=1.0, min=0.01, max=100.0) + abso_minor_rad = FloatProperty(name="Inside Radius", + description="Total Interior Radius of the torus", + default=0.5, min=0.01, max=100.0) def execute(self, context): + #deleting between THESE lines makes it re-appear in blender + if self.properties.use_abso == True: + extra_helper = (self.properties.abso_major_rad - self.properties.abso_minor_rad) * 0.5 + self.properties.major_radius = self.properties.abso_minor_rad + extra_helper + self.properties.minor_radius = extra_helper + #deleting between THESE lines makes it re-appear in blender + verts_loc, faces = add_torus(self.properties.major_radius, self.properties.minor_radius, self.properties.major_segments, From 4770cc031d6897a9384f39e61eadba3b8ace8250 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Jan 2010 23:59:13 +0000 Subject: [PATCH 134/202] fix for possible crash with the boundbox of a mesh used when freed. --- source/blender/editors/space_view3d/view3d_draw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 8af16641c00..914344647bd 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1493,7 +1493,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas ListBase *lb; DupliObject *dob; Base tbase; - BoundBox *bb= NULL; + BoundBox bb; /* use a copy because draw_object, calls clear_mesh_caches */ GLuint displist=0; short transflag, use_displist= -1; /* -1 is initialize */ char dt, dtx; @@ -1535,7 +1535,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas /* disable boundbox check for list creation */ object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1); /* need this for next part of code */ - bb= object_get_boundbox(dob->ob); + bb= *object_get_boundbox(dob->ob); unit_m4(dob->ob->obmat); /* obmat gets restored */ @@ -1550,7 +1550,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas } if(use_displist) { wmMultMatrix(dob->mat); - if(boundbox_clip(rv3d, dob->mat, bb)) + if(boundbox_clip(rv3d, dob->mat, &bb)) glCallList(displist); wmLoadMatrix(rv3d->viewmat); } From 01236d49f94e30efed5c151ebfd9a2a0d3b1ee69 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Fri, 15 Jan 2010 00:35:21 +0000 Subject: [PATCH 135/202] Transform Constraints: When axis is quasi perpendicular to the screen (within 5 degrees), it uses vertical motion of the mouse instead of normal axis projection. This behavior isn't new, but the 5 degrees limit is (it's also the limit at which manipulator axis disappear), it used to be much lower than that making small angles hard to manage. --- .../editors/transform/transform_constraints.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index fd53f6fcd20..d8a738a2d45 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -198,15 +198,23 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) { } static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3]) { - float norm[3], vec[3], factor; + float norm[3], vec[3], factor, angle; if(in[0]==0.0f && in[1]==0.0f && in[2]==0.0f) return; + print_v3("viewinv[2]", t->viewinv[2]); + + angle = fabs(angle_v3v3(axis, t->viewinv[2])); + if (angle > M_PI / 2) { + angle = M_PI - angle; + } + angle = 180.0f * angle / M_PI; + /* For when view is parallel to constraint... will cause NaNs otherwise So we take vertical motion in 3D space and apply it to the constraint axis. Nice for camera grab + MMB */ - if(1.0f - fabs(dot_v3v3(axis, t->viewinv[2])) < 0.000001f) { + if(angle < 5.0f) { project_v3_v3v3(vec, in, t->viewinv[1]); factor = dot_v3v3(t->viewinv[1], vec) * 2.0f; /* since camera distance is quite relative, use quadratic relationship. holding shift can compensate */ From 336c96e1204e8ee8266eb5133041b459eb409d2c Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Fri, 15 Jan 2010 01:21:56 +0000 Subject: [PATCH 136/202] Adding back cursor to center menu entry that was mistakingly removed by an unnamed person. --- release/scripts/ui/space_view3d.py | 1 + 1 file changed, 1 insertion(+) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 101fb6f7acc..bb369b5aa22 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -200,6 +200,7 @@ class VIEW3D_MT_snap(bpy.types.Menu): layout.separator() layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected") + layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center") layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid") layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active") From 085795e356c2f8a7701c842735ca4f163ff75058 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 15 Jan 2010 05:00:02 +0000 Subject: [PATCH 137/202] Fix [#20514] In sculpting mode is possible to use page down/up to exceed the actual multiresolution level --- release/scripts/op/object.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/release/scripts/op/object.py b/release/scripts/op/object.py index 1cf46d514c7..8c9108f9baa 100644 --- a/release/scripts/op/object.py +++ b/release/scripts/op/object.py @@ -102,20 +102,24 @@ class SubdivisionSet(bpy.types.Operator): def set_object_subd(obj): for mod in obj.modifiers: if mod.type == 'MULTIRES': - if level <= mod.total_levels: - if obj.mode == 'SCULPT': - if relative: - mod.sculpt_levels += level - else: + if not relative: + if level <= mod.total_levels: + if obj.mode == 'SCULPT': if mod.sculpt_levels != level: mod.sculpt_levels = level - elif obj.mode == 'OBJECT': - if relative: - mod.levels += level - else: + elif obj.mode == 'OBJECT': if mod.levels != level: - mod.levels = level - return + mod.levels = level + return + else: + if obj.mode == 'SCULPT': + if mod.sculpt_levels+level <= mod.total_levels: + mod.sculpt_levels += level + elif obj.mode == 'OBJECT': + if mod.levels+level <= mod.total_levels: + mod.levels += level + return + elif mod.type == 'SUBSURF': if relative: mod.levels += level From 87c5ed37a5aee2b9d5db3408add9d9254f032b3f Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 15 Jan 2010 06:10:05 +0000 Subject: [PATCH 138/202] Tweaked/added poll functions to prevent operators that require a 3D View from being used outside the 3D View (i.e. the info header search button) --- source/blender/editors/armature/editarmature.c | 12 +++++++++++- source/blender/editors/mesh/editmesh_mods.c | 6 +++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 1b6b489488c..42ac4b8b6b5 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -1486,6 +1486,11 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *ev return OPERATOR_FINISHED; } +static int pose_select_linked_poll(bContext *C) +{ + return ( ED_operator_view3d_active(C) && ED_operator_posemode(C) ); +} + void POSE_OT_select_linked(wmOperatorType *ot) { /* identifiers */ @@ -1495,7 +1500,7 @@ void POSE_OT_select_linked(wmOperatorType *ot) /* api callbacks */ ot->exec= NULL; ot->invoke= pose_select_connected_invoke; - ot->poll= ED_operator_posemode; + ot->poll= select_linked_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1580,6 +1585,11 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, wmEvent *e return OPERATOR_FINISHED; } +static int armature_select_linked_poll(bContext *C) +{ + return ( ED_operator_view3d_active(C) && ED_operator_editarmature(C) ); +} + void ARMATURE_OT_select_linked(wmOperatorType *ot) { /* identifiers */ diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index dee831b7fd0..ab558afe897 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -2111,7 +2111,7 @@ void MESH_OT_loop_select(wmOperatorType *ot) /* api callbacks */ ot->invoke= mesh_select_loop_invoke; - ot->poll= ED_operator_editmesh; + ot->poll= ED_operator_editmesh_view3d; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2213,7 +2213,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot) /* api callbacks */ ot->invoke= mesh_shortest_path_select_invoke; - ot->poll= ED_operator_editmesh; + ot->poll= ED_operator_editmesh_view3d; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2521,7 +2521,7 @@ void MESH_OT_select_linked_pick(wmOperatorType *ot) /* api callbacks */ ot->invoke= select_linked_pick_invoke; - ot->poll= ED_operator_editmesh; + ot->poll= ED_operator_editmesh_view3d; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; From bd6ce45ef48abaa43e14a41d988ad3c42a485261 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 15 Jan 2010 06:17:28 +0000 Subject: [PATCH 139/202] Fix [#20129] emulate numpad Converted Command+LMB to send a RMB click event on Mac OS X, if Emulate 3 Button Mouse is switched on. Also fixes for previous commit, didn't all go through. --- source/blender/editors/armature/editarmature.c | 4 ++-- source/blender/windowmanager/intern/wm_event_system.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 42ac4b8b6b5..410da6662aa 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -1500,7 +1500,7 @@ void POSE_OT_select_linked(wmOperatorType *ot) /* api callbacks */ ot->exec= NULL; ot->invoke= pose_select_connected_invoke; - ot->poll= select_linked_poll; + ot->poll= pose_select_linked_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1599,7 +1599,7 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot) /* api callbacks */ ot->exec= NULL; ot->invoke= armature_select_linked_invoke; - ot->poll= ED_operator_editarmature; + ot->poll= armature_select_linked_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 775d8c2b4ab..15adb33d527 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -781,6 +781,16 @@ static void wm_eventemulation(wmEvent *event) } } +#ifdef __APPLE__ + /* rightmouse emulation */ + if(U.flag & USER_TWOBUTTONMOUSE) { + if(event->type == LEFTMOUSE && event->oskey) { + event->type = RIGHTMOUSE; + event->oskey = 0; + } + } +#endif + /* numpad emulation */ if(U.flag & USER_NONUMPAD) { switch(event->type) { From 3664670f2a06de5974ac1a36e3521fc0eab1ff61 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Fri, 15 Jan 2010 07:04:00 +0000 Subject: [PATCH 140/202] * Fix two issues: - makesrna would crash on Windows with this malloc business (writing wrong places). - The one malloc never got freed (apart from not being MEM_callocN - which should be used instead of vanilla malloc/calloc!) --- source/blender/makesrna/intern/rna_nodetree.c | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 4ad3984d1d9..2105e10bbd1 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -44,6 +44,8 @@ #include "WM_types.h" +#include "MEM_guardedalloc.h" + #ifdef RNA_RUNTIME #include "ED_node.h" @@ -550,17 +552,17 @@ static StructRNA* def_node(BlenderRNA *brna, int node_id) return srna; } -static EnumPropertyItem* alloc_node_type_items(int category) +void alloc_node_type_items(EnumPropertyItem *items, int category) { int i; int count = 3; - EnumPropertyItem *item, *items; + EnumPropertyItem *item = items; for(i=0; i Date: Fri, 15 Jan 2010 07:26:38 +0000 Subject: [PATCH 141/202] Fix [#20437] Impossible to load "voxel data" sequence file from texture panel (field missing?) --- release/scripts/ui/properties_texture.py | 2 ++ source/blender/makesrna/intern/rna_texture.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/release/scripts/ui/properties_texture.py b/release/scripts/ui/properties_texture.py index 7b70b355731..7aafc3a839f 100644 --- a/release/scripts/ui/properties_texture.py +++ b/release/scripts/ui/properties_texture.py @@ -853,6 +853,8 @@ class TEXTURE_PT_voxeldata(TextureButtonsPanel): layout.prop(vd, "resolution") elif vd.file_format == 'SMOKE': layout.prop(vd, "domain_object") + elif vd.file_format == 'IMAGE_SEQUENCE': + layout.template_image(tex, "image", tex.image_user) layout.prop(vd, "still") row = layout.row() diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 79a75c89a08..11d99b6f356 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -1772,6 +1772,18 @@ static void rna_def_texture_voxeldata(BlenderRNA *brna) RNA_def_property_struct_type(prop, "VoxelData"); RNA_def_property_ui_text(prop, "Voxel Data", "The voxel data associated with this texture"); RNA_def_property_update(prop, 0, "rna_Texture_update"); + + prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "ima"); + RNA_def_property_struct_type(prop, "Image"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Image", ""); + RNA_def_property_update(prop, 0, "rna_Texture_update"); + + prop= RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "iuser"); + RNA_def_property_ui_text(prop, "Image User", "Parameters defining which layer, pass and frame of the image is displayed."); + RNA_def_property_update(prop, 0, "rna_Texture_update"); } static void rna_def_texture(BlenderRNA *brna) From 4d2c55824eddf5dd4188c1d3c71afde47624b11e Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Fri, 15 Jan 2010 09:59:42 +0000 Subject: [PATCH 142/202] * don't copy .pyc files --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 83570cb5c1a..c56ee99bb80 100644 --- a/SConstruct +++ b/SConstruct @@ -500,7 +500,7 @@ if env['OURPLATFORM']!='darwin': else: dir = os.path.join(env['BF_INSTALLDIR'], '.blender') dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):] - source=[os.path.join(dp, f) for f in df] + source=[os.path.join(dp, f) for f in df if f[-3:]!='pyc'] scriptinstall.append(env.Install(dir=dir,source=source)) #-- icons From aed721e01cc4c0f03b03628f8a5898739c7eaf8e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Jan 2010 10:02:02 +0000 Subject: [PATCH 143/202] [#20685] Fixed: cleaned up descriptions, removed unrelated comments in code from Jaevixa McNomera (jaevixa) --- release/scripts/op/add_mesh_torus.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/release/scripts/op/add_mesh_torus.py b/release/scripts/op/add_mesh_torus.py index ccc9a4ba776..2d482108ab0 100644 --- a/release/scripts/op/add_mesh_torus.py +++ b/release/scripts/op/add_mesh_torus.py @@ -82,10 +82,10 @@ class AddTorus(bpy.types.Operator): bl_undo = True major_radius = FloatProperty(name="Major Radius", - description="Number of segments for the main ring of the torus", + description="Radius from center of torus to center of it's cross section", default=1.0, min=0.01, max=100.0) minor_radius = FloatProperty(name="Minor Radius", - description="Number of segments for the minor ring of the torus", + description="Radius of the torus' cross section", default=0.25, min=0.01, max=100.0) major_segments = IntProperty(name="Major Segments", description="Number of segments for the main ring of the torus", @@ -104,12 +104,10 @@ class AddTorus(bpy.types.Operator): def execute(self, context): - #deleting between THESE lines makes it re-appear in blender if self.properties.use_abso == True: extra_helper = (self.properties.abso_major_rad - self.properties.abso_minor_rad) * 0.5 self.properties.major_radius = self.properties.abso_minor_rad + extra_helper self.properties.minor_radius = extra_helper - #deleting between THESE lines makes it re-appear in blender verts_loc, faces = add_torus(self.properties.major_radius, self.properties.minor_radius, From 39ff5d7eb978d16370c37508c012bd9d319ac348 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 15 Jan 2010 10:34:39 +0000 Subject: [PATCH 144/202] Reverting changes made in r25940 with the NLA unmapping. The reverted code was just blindly restoring the old state of the keyframes; changes to selection state, value changes, handle type, etc. were overridden, and the cases where keyframes were deliberately retimed or otherwise were also ignored. I'm not sure what problems these changes were meant to be solving, but will reassess the situation when I get more info on this. --- source/blender/editors/animation/anim_draw.c | 32 +++++++------------ .../editors/animation/keyframes_draw.c | 5 ++- source/blender/editors/include/ED_anim_api.h | 2 +- .../editors/include/ED_keyframes_edit.h | 1 - .../editors/space_action/action_edit.c | 18 ++++------- .../editors/space_action/action_select.c | 18 ++++------- .../blender/editors/space_graph/graph_draw.c | 5 ++- .../blender/editors/space_graph/graph_edit.c | 18 ++++------- .../editors/space_graph/graph_select.c | 17 ++++------ .../editors/transform/transform_conversions.c | 18 ++++------- 10 files changed, 47 insertions(+), 87 deletions(-) diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index fbacd22b360..f8a5a9daa06 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -260,14 +260,17 @@ typedef struct NlaMappingApplyBackup { /* helper function for ANIM_nla_mapping_apply_fcurve() -> "restore", i.e. mapping points back to action-time */ static short bezt_nlamapping_restore(BeztEditData *bed, BezTriple *bezt) { - ListBase *lb= (ListBase*)bed->data2; - NlaMappingApplyBackup *backup= lb->first; - - /* restore beztriple from backup list. this used to use NLATIME_CONVERT_UNMAP, - but this was not the inverse of NLATIME_CONVERT_MAP and it's not clear how - that is even possible due to repeats - brecht. */ - *bezt= backup->bezt; - BLI_freelinkN(lb, backup); + /* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */ + AnimData *adt= (AnimData *)bed->data; + short only_keys= (short)bed->i1; + + /* adjust BezTriple handles only if allowed to */ + if (only_keys == 0) { + bezt->vec[0][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_UNMAP); + bezt->vec[2][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_UNMAP); + } + + bezt->vec[1][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_UNMAP); return 0; } @@ -277,14 +280,7 @@ static short bezt_nlamapping_apply(BeztEditData *bed, BezTriple *bezt) { /* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */ AnimData *adt= (AnimData*)bed->data; - ListBase *lb= (ListBase*)bed->data2; - NlaMappingApplyBackup *backup; short only_keys= (short)bed->i1; - - /* backup for restore later */ - backup= MEM_callocN(sizeof(NlaMappingApplyBackup), "NlaMappingApplyBackup"); - backup->bezt= *bezt; - BLI_addtail(lb, backup); /* adjust BezTriple handles only if allowed to */ if (only_keys == 0) { @@ -302,7 +298,7 @@ static short bezt_nlamapping_apply(BeztEditData *bed, BezTriple *bezt) * - restore = whether to map points back to non-mapped time * - only_keys = whether to only adjust the location of the center point of beztriples */ -void ANIM_nla_mapping_apply_fcurve (AnimData *adt, FCurve *fcu, short restore, short only_keys, ListBase *backup) +void ANIM_nla_mapping_apply_fcurve (AnimData *adt, FCurve *fcu, short restore, short only_keys) { BeztEditData bed; BeztEditFunc map_cb; @@ -313,11 +309,7 @@ void ANIM_nla_mapping_apply_fcurve (AnimData *adt, FCurve *fcu, short restore, s */ memset(&bed, 0, sizeof(BeztEditData)); bed.data= (void *)adt; - bed.data2= (void *)backup; bed.i1= (int)only_keys; - - if(!restore) - backup->first= backup->last= NULL; /* get editing callback */ if (restore) diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 63633468767..3a48aa0b063 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -850,13 +850,12 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree { DLRBT_Tree *beztTree = NULL; BezTriple *bezt; - ListBase nlabackup; int v; if (fcu && fcu->totvert && fcu->bezt) { /* apply NLA-mapping (if applicable) */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1); /* if getting long keyframes too, grab the BezTriples in a BST for * accelerated searching... @@ -893,7 +892,7 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree /* unapply NLA-mapping if applicable */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1); } } diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 6d81131492a..531751a609e 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -453,7 +453,7 @@ void getcolor_fcurve_rainbow(int cur, int tot, float *out); struct AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale); /* Apply/Unapply NLA mapping to all keyframes in the nominated F-Curve */ -void ANIM_nla_mapping_apply_fcurve(struct AnimData *adt, struct FCurve *fcu, short restore, short only_keys, ListBase *backup); +void ANIM_nla_mapping_apply_fcurve(struct AnimData *adt, struct FCurve *fcu, short restore, short only_keys); /* ..... */ diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index d567398209f..9e29d747d4a 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -94,7 +94,6 @@ typedef struct BeztEditData { ListBase list; /* temp list for storing custom list of data to check */ struct Scene *scene; /* pointer to current scene - many tools need access to cfra/etc. */ void *data; /* pointer to custom data - usually 'Object' but also 'rectf', but could be other types too */ - void *data2; /* pointer to more custom data */ float f1, f2; /* storage of times/values as 'decimals' */ int i1, i2; /* storage of times/values/flags as 'whole' numbers */ } BeztEditData; diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index b35f9594397..6dcd3049c0e 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -1134,11 +1134,9 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *op) for (ale= anim_data.first; ale; ale= ale->next) { AnimData *adt= ANIM_nla_mapping_get(&ac, ale); if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL); @@ -1216,11 +1214,9 @@ static void snap_action_keys(bAnimContext *ac, short mode) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } //else if (ale->type == ACTTYPE_GPLAYER) // snap_gplayer_frames(ale->data, mode); @@ -1335,11 +1331,9 @@ static void mirror_action_keys(bAnimContext *ac, short mode) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } //else if (ale->type == ACTTYPE_GPLAYER) // snap_gplayer_frames(ale->data, mode); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 3f7a568fc00..1881cfbc99c 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -416,12 +416,10 @@ static void markers_selectkeys_between (bAnimContext *ac) for (ale= anim_data.first; ale; ale= ale->next) { AnimData *adt= ANIM_nla_mapping_get(ac, ale); - if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); + if (adt) { + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else { ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); @@ -663,19 +661,15 @@ static void actkeys_mselect_leftright (bAnimContext *ac, short leftright, short /* select keys on the side where most data occurs */ for (ale= anim_data.first; ale; ale= ale->next) { AnimData *adt= ANIM_nla_mapping_get(ac, ale); - -#if 0 // This does not work even in simple cases I tested - campbell + if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } //else if (ale->type == ANIMTYPE_GPLAYER) // borderselect_gplayer_frames(ale->data, min, max, SELECT_ADD); else -#endif ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); } diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 4735950c9d1..9681d20c13b 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -819,11 +819,10 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri FCurve *fcu= (FCurve *)ale->key_data; FModifier *fcm= find_active_fmodifier(&fcu->modifiers); AnimData *adt= ANIM_nla_mapping_get(ac, ale); - ListBase nlabackup; /* map keyframes for drawing if scaled F-Curve */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); /* draw curve: * - curve line may be result of one or more destructive modifiers or just the raw data, @@ -909,7 +908,7 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri /* undo mapping of keyframes for drawing if scaled F-Curve */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); } /* free list of curves */ diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 1bae3686fe2..2adf783b338 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1557,11 +1557,9 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *op) AnimData *adt= ANIM_nla_mapping_get(&ac, ale); if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL); @@ -1647,11 +1645,9 @@ static void snap_graph_keys(bAnimContext *ac, short mode) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); @@ -1766,11 +1762,9 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index b732d17e34f..8d2e2921b7f 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -394,11 +394,9 @@ static void markers_selectkeys_between (bAnimContext *ac) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else { ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); @@ -591,11 +589,10 @@ static short findnearest_fcurve_vert (bAnimContext *ac, int mval[2], FCurve **fc /* try to progressively get closer to the right point... */ if (fcu->bezt) { BezTriple *bezt1=fcu->bezt, *prevbezt=NULL; - ListBase nlabackup; /* apply NLA mapping to all the keyframes */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); for (i=0; i < fcu->totvert; i++, prevbezt=bezt1, bezt1++) { /* convert beztriple points to screen-space */ @@ -653,7 +650,7 @@ static short findnearest_fcurve_vert (bAnimContext *ac, int mval[2], FCurve **fc /* un-apply NLA mapping from all the keyframes */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } } @@ -800,11 +797,9 @@ static void graphkeys_mselect_leftright (bAnimContext *ac, short leftright, shor AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 2769112e5d5..ebd25271a8a 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3014,11 +3014,9 @@ static void posttrans_action_clean (bAnimContext *ac, bAction *act) AnimData *adt= ANIM_nla_mapping_get(ac, ale); if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); posttrans_fcurve_clean(ale->key_data); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else posttrans_fcurve_clean(ale->key_data); @@ -4785,11 +4783,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) ((cancelled == 0) || (duplicate)) ) { if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1); posttrans_fcurve_clean(fcu); - ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1); } else posttrans_fcurve_clean(fcu); @@ -4868,11 +4864,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) ((cancelled == 0) || (duplicate)) ) { if (adt) { - ListBase nlabackup; - - ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1); posttrans_fcurve_clean(fcu); - ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1, &nlabackup); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1); } else posttrans_fcurve_clean(fcu); From 3ff987c46a284c6fe7acb574d42a25c32ee29f7a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Jan 2010 12:21:33 +0000 Subject: [PATCH 145/202] bugfix [#20688] Mesh with no materials fails to export UV layout --- release/scripts/op/uv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/op/uv.py b/release/scripts/op/uv.py index 476d3ab44c3..1ca369abe64 100644 --- a/release/scripts/op/uv.py +++ b/release/scripts/op/uv.py @@ -88,7 +88,7 @@ class ExportUVLayout(bpy.types.Operator): # svg colors fill_settings = [] - for mat in mesh.materials: + for mat in mesh.materials if mesh.materials else [None]: if mat: fill_settings.append('fill="rgb(%d, %d, %d)"' % tuple(int(c*255) for c in mat.diffuse_color)) else: From 1b580dde6e633056c1a9f0436b778dc2797ef469 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 15 Jan 2010 17:00:37 +0000 Subject: [PATCH 146/202] Console: * Added Theme support for the console. You can change: -Header Color -Text Color of Output, Input, Info and Error Messages. (Inside the User Preferences -> Themes) --- release/scripts/ui/space_userpref.py | 13 ++++++ source/blender/editors/include/UI_resources.h | 5 +++ source/blender/editors/interface/resources.c | 21 +++++++++ .../editors/space_console/console_draw.c | 12 +++-- source/blender/makesdna/DNA_userdef_types.h | 3 ++ source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_userdef.c | 45 +++++++++++++++++++ 7 files changed, 96 insertions(+), 4 deletions(-) diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py index 534735bfc24..ca89878c9d9 100644 --- a/release/scripts/ui/space_userpref.py +++ b/release/scripts/ui/space_userpref.py @@ -920,6 +920,19 @@ class USERPREF_PT_theme(bpy.types.Panel): col = split.column() col.prop(prefs, "header_text") + + elif theme.theme_area == 'CONSOLE': + prefs = theme.console + + col = split.column() + col.prop(prefs, "header") + + col = split.column() + col.prop(prefs, "line_output") + col.prop(prefs, "line_input") + col.prop(prefs, "line_info") + col.prop(prefs, "line_error") + class USERPREF_PT_file(bpy.types.Panel): diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 787a39591c7..ad06e56dfa3 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -184,6 +184,11 @@ enum { TH_NODE_CONVERTOR, TH_NODE_GROUP, + TH_CONSOLE_OUTPUT, + TH_CONSOLE_INPUT, + TH_CONSOLE_INFO, + TH_CONSOLE_ERROR, + TH_SEQ_MOVIE, TH_SEQ_IMAGE, TH_SEQ_SCENE, diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 15513daa624..28f9a6e79f5 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -154,6 +154,9 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) case SPACE_USERPREF: ts= &btheme->tuserpref; break; + case SPACE_CONSOLE: + ts= &btheme->tconsole; + break; case SPACE_TIME: ts= &btheme->ttime; break; @@ -340,6 +343,15 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) case TH_SEQ_META: cp= ts->meta; break; + case TH_CONSOLE_OUTPUT: + cp= ts->console_output; break; + case TH_CONSOLE_INPUT: + cp= ts-> console_input; break; + case TH_CONSOLE_INFO: + cp= ts->console_info; break; + case TH_CONSOLE_ERROR: + cp= ts->console_error; break; + case TH_HANDLE_VERTEX: cp= ts->handle_vertex; break; @@ -407,6 +419,7 @@ static void ui_theme_init_new(bTheme *btheme) ui_theme_init_new_do(&btheme->tnode); ui_theme_init_new_do(&btheme->tlogic); ui_theme_init_new_do(&btheme->tuserpref); + ui_theme_init_new_do(&btheme->tconsole); } @@ -594,6 +607,14 @@ void ui_theme_init_userdef(void) /* space user preferences */ btheme->tuserpref= btheme->tv3d; SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0); + + /* space console */ + btheme->tconsole= btheme->tv3d; + SETCOL(btheme->tconsole.console_output, 96, 128, 255, 255); + SETCOL(btheme->tconsole.console_input, 255, 255, 255, 255); + SETCOL(btheme->tconsole.console_info, 0, 170, 0, 255); + SETCOL(btheme->tconsole.console_error, 220, 96, 96, 255); + /* space sound */ btheme->tsnd= btheme->tv3d; diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index ab1fc8a5fca..3fee2b6277b 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -78,16 +78,20 @@ static void console_line_color(unsigned char *fg, int type) { switch(type) { case CONSOLE_LINE_OUTPUT: - fg[0]=96; fg[1]=128; fg[2]=255; + UI_GetThemeColor3ubv(TH_CONSOLE_OUTPUT, fg); + fg[0], fg[1], fg[2]; break; case CONSOLE_LINE_INPUT: - fg[0]=255; fg[1]=255; fg[2]=255; + UI_GetThemeColor3ubv(TH_CONSOLE_INPUT, fg); + fg[0], fg[1], fg[2]; break; case CONSOLE_LINE_INFO: - fg[0]=0; fg[1]=170; fg[2]=0; + UI_GetThemeColor3ubv(TH_CONSOLE_INFO, fg); + fg[0], fg[1], fg[2]; break; case CONSOLE_LINE_ERROR: - fg[0]=220; fg[1]=96; fg[2]=96; + UI_GetThemeColor3ubv(TH_CONSOLE_ERROR, fg); + fg[0], fg[1], fg[2]; break; } } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index bd8573fe8ce..96c578c9d35 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -201,6 +201,8 @@ typedef struct ThemeSpace { char cframe[4]; char ds_channel[4], ds_subchannel[4]; // dopesheet + char console_output[4], console_input[4], console_info[4], console_error[4]; // Console + char vertex_size, facedot_size; char bpad[2]; @@ -261,6 +263,7 @@ typedef struct bTheme { ThemeSpace tnode; ThemeSpace tlogic; ThemeSpace tuserpref; + ThemeSpace tconsole; /* 20 sets of bone colors for this theme */ ThemeWireColor tarm[20]; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index ba2d272309f..3be97710dd5 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -492,6 +492,7 @@ extern StructRNA RNA_TextureSlot; extern StructRNA RNA_Theme; extern StructRNA RNA_ThemeAudioWindow; extern StructRNA RNA_ThemeBoneColorSet; +extern StructRNA RNA_ThemeConsole; extern StructRNA RNA_ThemeDopeSheet; extern StructRNA RNA_ThemeFileBrowser; extern StructRNA RNA_ThemeFontStyle; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index bc0e11bf780..903ed5796dc 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -906,6 +906,44 @@ static void rna_def_userdef_theme_space_userpref(BlenderRNA *brna) rna_def_userdef_theme_spaces_main(srna, SPACE_USERPREF); } +static void rna_def_userdef_theme_space_console(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + /* space_console */ + + srna= RNA_def_struct(brna, "ThemeConsole", NULL); + RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_ui_text(srna, "Theme Console", "Theme settings for the Console."); + + rna_def_userdef_theme_spaces_main(srna, SPACE_CONSOLE); + + prop= RNA_def_property(srna, "line_output", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "console_output"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Line Output", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop= RNA_def_property(srna, "line_input", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "console_input"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Line Input", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop= RNA_def_property(srna, "line_info", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "console_info"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Line Info", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop= RNA_def_property(srna, "line_error", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "console_error"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Line Error", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); +} + static void rna_def_userdef_theme_space_info(BlenderRNA *brna) { StructRNA *srna; @@ -1562,6 +1600,12 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "tuserpref"); RNA_def_property_struct_type(prop, "ThemeUserPreferences"); RNA_def_property_ui_text(prop, "User Preferences", ""); + + prop= RNA_def_property(srna, "console", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "tconsole"); + RNA_def_property_struct_type(prop, "ThemeConsole"); + RNA_def_property_ui_text(prop, "Console", ""); prop= RNA_def_property(srna, "bone_color_sets", PROP_COLLECTION, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); @@ -1590,6 +1634,7 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna) rna_def_userdef_theme_space_outliner(brna); rna_def_userdef_theme_space_info(brna); rna_def_userdef_theme_space_userpref(brna); + rna_def_userdef_theme_space_console(brna); rna_def_userdef_theme_space_sound(brna); rna_def_userdef_theme_space_logic(brna); rna_def_userdef_theme_colorset(brna); From 2aaee044e565f1123b812d1a0350bfb5ac5e1de4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Jan 2010 17:19:01 +0000 Subject: [PATCH 147/202] fix for compiler error, probably unlikely but if 'v' is NULL it could crash. --- .../blender/windowmanager/intern/wm_gesture.c | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 80d6869067a..958832ce314 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -214,7 +214,7 @@ static void wm_gesture_draw_circle(wmWindow *win, wmGesture *gt) static void draw_filled_lasso(wmGesture *gt) { - EditVert *v, *lastv=NULL, *firstv=NULL; + EditVert *v=NULL, *lastv=NULL, *firstv=NULL; EditEdge *e; EditFace *efa; short *lasso= (short *)gt->customdata; @@ -230,21 +230,24 @@ static void draw_filled_lasso(wmGesture *gt) if (firstv==NULL) firstv = v; } - BLI_addfilledge(firstv, v); - BLI_edgefill(0, 0); + /* highly unlikely this will fail, but could crash if (gt->points == 0) */ + if(firstv) { + BLI_addfilledge(firstv, v); + BLI_edgefill(0, 0); - glEnable(GL_BLEND); - glColor4f(1.0, 1.0, 1.0, 0.05); - glBegin(GL_TRIANGLES); - for (efa = fillfacebase.first; efa; efa=efa->next) { - glVertex2f(efa->v1->co[0], efa->v1->co[1]); - glVertex2f(efa->v2->co[0], efa->v2->co[1]); - glVertex2f(efa->v3->co[0], efa->v3->co[1]); + glEnable(GL_BLEND); + glColor4f(1.0, 1.0, 1.0, 0.05); + glBegin(GL_TRIANGLES); + for (efa = fillfacebase.first; efa; efa=efa->next) { + glVertex2f(efa->v1->co[0], efa->v1->co[1]); + glVertex2f(efa->v2->co[0], efa->v2->co[1]); + glVertex2f(efa->v3->co[0], efa->v3->co[1]); + } + glEnd(); + glDisable(GL_BLEND); + + BLI_end_edgefill(); } - glEnd(); - glDisable(GL_BLEND); - - BLI_end_edgefill(); } static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt) From a4732eefa5fa4ba06b8042c530748be6a4e4194c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Jan 2010 17:23:16 +0000 Subject: [PATCH 148/202] a new generic invoke function - WM_enum_search_invoke() This can search operators enum property. Make proxy menu could easily get too big. use the new search popup. --- .../blender/editors/object/object_relations.c | 105 +++++++----------- source/blender/windowmanager/WM_api.h | 1 + .../windowmanager/intern/wm_operators.c | 82 ++++++++++++++ 3 files changed, 121 insertions(+), 67 deletions(-) diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 95fbcdd4223..5cf11771004 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -261,39 +261,6 @@ void OBJECT_OT_vertex_parent_set(wmOperatorType *ot) /********************** Make Proxy Operator *************************/ -/* present menu listing the possible objects within the group to proxify */ -static void proxy_group_objects_menu (bContext *C, wmOperator *op, Object *ob, Group *group) -{ - uiPopupMenu *pup; - uiLayout *layout; - GroupObject *go; - int len=0; - - /* check if there are any objects within the group to assign for */ - for (go= group->gobject.first; go; go= go->next) { - if (go->ob) len++; - } - if (len==0) return; - - /* now create the menu to draw */ - pup= uiPupMenuBegin(C, "Make Proxy For:", 0); - layout= uiPupMenuLayout(pup); - - for (go= group->gobject.first; go; go= go->next) { - if (go->ob) { - PointerRNA props_ptr; - - /* create operator menu item with relevant properties filled in */ - props_ptr= uiItemFullO(layout, go->ob->id.name+2, 0, op->idname, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); - RNA_string_set(&props_ptr, "object", go->ob->id.name+2); - RNA_string_set(&props_ptr, "group_object", go->ob->id.name+2); - } - } - - /* display the menu, and be done */ - uiPupMenuEnd(C, pup); -} - /* set the object to proxify */ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) { @@ -307,7 +274,10 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) /* Get object to work on - use a menu if we need to... */ if (ob->dup_group && ob->dup_group->id.lib) { /* gives menu with list of objects in group */ - proxy_group_objects_menu(C, op, ob, ob->dup_group); + //proxy_group_objects_menu(C, op, ob, ob->dup_group); + WM_enum_search_invoke(C, op, evt); + return OPERATOR_CANCELLED; + } else if (ob->id.lib) { uiPopupMenu *pup= uiPupMenuBegin(C, "OK?", ICON_QUESTION); @@ -332,39 +302,10 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) static int make_proxy_exec (bContext *C, wmOperator *op) { - Object *ob=NULL, *gob=NULL; + Object *ob, *gob= CTX_data_active_object(C); + GroupObject *go= BLI_findlink(&gob->dup_group->gobject, RNA_enum_get(op->ptr, "type")); Scene *scene= CTX_data_scene(C); - char ob_name[21], gob_name[21]; - - /* get object and group object - * - firstly names - * - then pointers from context - */ - RNA_string_get(op->ptr, "object", ob_name); - RNA_string_get(op->ptr, "group_object", gob_name); - - if (gob_name[0]) { - Group *group; - GroupObject *go; - - /* active object is group object... */ - // FIXME: we should get the nominated name instead - gob= CTX_data_active_object(C); - group= gob->dup_group; - - /* find the object to affect */ - for (go= group->gobject.first; go; go= go->next) { - if ((go->ob) && strcmp(go->ob->id.name+2, gob_name)==0) { - ob= go->ob; - break; - } - } - } - else { - /* just use the active object for now */ - // FIXME: we should get the nominated name instead - ob= CTX_data_active_object(C); - } + ob= go->ob; if (ob) { Object *newob; @@ -407,8 +348,37 @@ static int make_proxy_exec (bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +/* Generic itemf's for operators that take library args */ +static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem *item= NULL, item_tmp; + int totitem= 0; + int i= 0; + Object *ob= CTX_data_active_object(C); + GroupObject *go; + + if(!ob || !ob->dup_group) + return &DummyRNA_NULL_items; + + memset(&item_tmp, 0, sizeof(item_tmp)); + + /* find the object to affect */ + for (go= ob->dup_group->gobject.first; go; go= go->next) { + item_tmp.identifier= item_tmp.name= go->ob->id.name+2; + item_tmp.value= i++; + RNA_enum_item_add(&item, &totitem, &item_tmp); + } + + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; +} + void OBJECT_OT_proxy_make (wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name= "Make Proxy"; ot->idname= "OBJECT_OT_proxy_make"; @@ -424,7 +394,8 @@ void OBJECT_OT_proxy_make (wmOperatorType *ot) /* properties */ RNA_def_string(ot->srna, "object", "", 19, "Proxy Object", "Name of lib-linked/grouped object to make a proxy for."); - RNA_def_string(ot->srna, "group_object", "", 19, "Group Object", "Name of group instancer (if applicable)."); + prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "Group object"); /* XXX, relies on hard coded ID at the moment */ + RNA_def_enum_funcs(prop, proxy_group_object_itemf); } /********************** Clear Parent Operator ******************* */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 4cc116e7bbd..4defd781db9 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -171,6 +171,7 @@ void WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, str /* operator api, default callbacks */ /* invoke callback, uses enum property named "type" */ int WM_menu_invoke (struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); /* invoke callback, confirm menu + exec */ int WM_operator_confirm (struct bContext *C, struct wmOperator *op, struct wmEvent *event); /* invoke callback, file selector "path" unset + exec */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 88ac8986936..278c597ab4a 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -632,6 +632,88 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } + +/* ENUM Search popup */ +static void operator_enum_search_cb(const struct bContext *C, void *arg_ot, char *str, uiSearchItems *items) +{ + wmOperatorType *ot = (wmOperatorType *)arg_ot; + PointerRNA ptr; + PropertyRNA *prop; + + /* enum */ + EnumPropertyItem *item, *item_array; + int free, found; + + RNA_pointer_create(NULL, ot->srna, NULL, &ptr); + prop = RNA_struct_find_property(&ptr, "type"); // XXX, SHOULD NOT USE HARD CODED VALUE + + RNA_property_enum_items((bContext *)C, &ptr, prop, &item_array, NULL, &free); + + for(item= item_array; item->identifier; item++) { + /* note: need to give the intex rather then the dientifier because the enum can be freed */ + if(BLI_strcasestr(item->name, str)) + if(0==uiSearchItemAdd(items, item->name, SET_INT_IN_POINTER(item->value), 0)) + break; + } + + found= (item->identifier != NULL); /* could be alloc'd, assign before free */ + + if(free) + MEM_freeN(item_array); + +} + +static void operator_enum_call_cb(struct bContext *C, void *arg1, void *arg2) +{ + wmOperatorType *ot= arg1; + int enum_value= GET_INT_FROM_POINTER(arg2); + + if(ot) { + PointerRNA props_ptr; + WM_operator_properties_create_ptr(&props_ptr, ot); + RNA_enum_set(&props_ptr, "type", enum_value); // XXX, SHOULD NOT USE HARD CODED VALUE + WM_operator_name_call(C, ot->idname, WM_OP_EXEC_DEFAULT, &props_ptr); + WM_operator_properties_free(&props_ptr); + } +} + +static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op) +{ + static char search[256]= ""; + wmEvent event; + wmWindow *win= CTX_wm_window(C); + uiBlock *block; + uiBut *but; + + block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); + + but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 10, 180, 19, 0, 0, ""); + uiButSetSearchFunc(but, operator_enum_search_cb, ((wmOperator *)arg_op)->type, operator_enum_call_cb, NULL); + + /* fake button, it holds space for search items */ + uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 180, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); + + uiPopupBoundsBlock(block, 6.0f, 0, -20); /* move it downwards, mouse over button */ + uiEndBlock(C, block); + + event= *(win->eventstate); /* XXX huh huh? make api call */ + event.type= EVT_BUT_OPEN; + event.val= KM_PRESS; + event.customdata= but; + event.customdatafree= FALSE; + wm_event_add(win, &event); + + return block; +} + + +int WM_enum_search_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + uiPupBlock(C, wm_enum_search_menu, op); + return OPERATOR_CANCELLED; +} + /* Can't be used as an invoke directly, needs message arg (can be NULL) */ int WM_operator_confirm_message(bContext *C, wmOperator *op, char *message) { From ace8d45c1c7cdd754771f9e4aceae80de2154653 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Jan 2010 17:28:00 +0000 Subject: [PATCH 149/202] - particle drawing was using invalid memory with weights. - particle set weight operator (Shift + K) and from the menu. - mirror vertex groups operator can also flip weight group names. a number of utility functions for weight groups added int *get_defgroup_flip_map(struct Object *ob); void flip_vertexgroup_name (char *name_r, const char *name, int strip_number); // moved from modifier.c void copy_defvert (struct MDeformVert *dvert_r, const struct MDeformVert *dvert); void flip_defvert (struct MDeformVert *dvert, int *flip_map); --- release/scripts/ui/space_view3d.py | 3 + source/blender/blenkernel/BKE_deform.h | 5 + source/blender/blenkernel/intern/deform.c | 176 ++++++++++++++++++ source/blender/blenkernel/intern/modifier.c | 116 +----------- source/blender/blenkernel/intern/particle.c | 19 +- source/blender/editors/mesh/editmesh_mods.c | 2 +- source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + source/blender/editors/object/object_vgroup.c | 100 +++++++++- .../blender/editors/physics/particle_edit.c | 46 +++++ .../blender/editors/physics/physics_intern.h | 1 + source/blender/editors/physics/physics_ops.c | 3 + 12 files changed, 346 insertions(+), 127 deletions(-) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index bb369b5aa22..4e394839166 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -186,6 +186,8 @@ class VIEW3D_MT_mirror(bpy.types.Menu): props.constraint_axis = (False, False, True) props.constraint_orientation = 'LOCAL' + layout.operator("object.vertex_group_mirror") + class VIEW3D_MT_snap(bpy.types.Menu): bl_label = "Snap" @@ -898,6 +900,7 @@ class VIEW3D_MT_particle(bpy.types.Menu): layout.operator("particle.subdivide") layout.operator("particle.rekey") + layout.operator("particle.weight_set") layout.separator() diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index 8a34b286881..d9cf6bc8feb 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -44,11 +44,16 @@ void copy_defgroups (struct ListBase *lb1, struct ListBase *lb2); struct bDeformGroup *copy_defgroup (struct bDeformGroup *ingroup); struct bDeformGroup *get_named_vertexgroup (Object *ob, char *name); int get_defgroup_num (struct Object *ob, struct bDeformGroup *dg); +int *get_defgroup_flip_map(struct Object *ob); int get_named_vertexgroup_num (Object *ob, const char *name); void unique_vertexgroup_name (struct bDeformGroup *dg, struct Object *ob); +void flip_vertexgroup_name (char *name_r, const char *name, int strip_number); float deformvert_get_weight(const struct MDeformVert *dvert, int group_num); float vertexgroup_get_vertex_weight(const struct MDeformVert *dvert, int index, int group_num); +void copy_defvert (struct MDeformVert *dvert_r, const struct MDeformVert *dvert); +void flip_defvert (struct MDeformVert *dvert, int *flip_map); + #endif diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index c1e45243bb5..620e114bad2 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -34,6 +34,7 @@ #include #include +#include "ctype.h" #include "MEM_guardedalloc.h" @@ -95,6 +96,36 @@ bDeformGroup *copy_defgroup (bDeformGroup *ingroup) return outgroup; } +void copy_defvert (MDeformVert *dvert_r, const MDeformVert *dvert) +{ + if(dvert_r->totweight == dvert->totweight) { + if(dvert->totweight) + memcpy(dvert_r->dw, dvert->dw, dvert->totweight * sizeof(MDeformWeight)); + } + else { + if(dvert_r->dw) + MEM_freeN(dvert_r->dw); + + if(dvert->totweight) + dvert_r->dw= MEM_dupallocN(dvert->dw); + else + dvert_r->dw= NULL; + + dvert_r->totweight = dvert->totweight; + } +} + +void flip_defvert (MDeformVert *dvert, int *flip_map) +{ + MDeformWeight *dw; + int i; + + for(dw= dvert->dw, i=0; itotweight; dw++, i++) + if(flip_map[dw->def_nr] >= 0) + dw->def_nr= flip_map[dw->def_nr]; +} + + bDeformGroup *get_named_vertexgroup (Object *ob, char *name) { /* return a pointer to the deform group with this name @@ -167,6 +198,36 @@ int get_defgroup_num (Object *ob, bDeformGroup *dg) } +/* note, must be freed */ +int *get_defgroup_flip_map(Object *ob) +{ + bDeformGroup *dg; + int totdg= BLI_countlist(&ob->defbase); + + if(totdg==0) { + return NULL; + } + else { + char name[sizeof(dg->name)]; + int i, flip_num, *map= MEM_mallocN(totdg * sizeof(int), "get_defgroup_flip_map"); + memset(map, -1, totdg * sizeof(int)); + + for (dg=ob->defbase.first, i=0; dg; dg=dg->next, i++) { + if(map[i] == -1) { /* may be calculated previously */ + flip_vertexgroup_name(name, dg->name, 0); + if(strcmp(name, dg->name)) { + flip_num= get_named_vertexgroup_num(ob, name); + if(flip_num > -1) { + map[i]= flip_num; + map[flip_num]= i; /* save an extra lookup */ + } + } + } + } + return map; + } +} + void unique_vertexgroup_name (bDeformGroup *dg, Object *ob) { bDeformGroup *curdef; @@ -221,6 +282,121 @@ void unique_vertexgroup_name (bDeformGroup *dg, Object *ob) } } + +/* finds the best possible flipped name. For renaming; check for unique names afterwards */ +/* if strip_number: removes number extensions */ +void flip_vertexgroup_name (char *name_r, const char *name, int strip_number) +{ + int len; + char prefix[sizeof((bDeformGroup *)NULL)->name]={""}; /* The part before the facing */ + char suffix[sizeof((bDeformGroup *)NULL)->name]={""}; /* The part after the facing */ + char replace[sizeof((bDeformGroup *)NULL)->name]={""}; /* The replacement string */ + char number[sizeof((bDeformGroup *)NULL)->name]={""}; /* The number extension string */ + char *index=NULL; + + len= strlen(name); + if(len<3) return; // we don't do names like .R or .L + + /* We first check the case with a .### extension, let's find the last period */ + if(isdigit(name[len-1])) { + index= strrchr(name, '.'); // last occurrence + if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever! + if(strip_number==0) + strcpy(number, index); + *index= 0; + len= strlen(name); + } + } + + strcpy (prefix, name); + +#define IS_SEPARATOR(a) ((a)=='.' || (a)==' ' || (a)=='-' || (a)=='_') + + /* first case; separator . - _ with extensions r R l L */ + if( IS_SEPARATOR(name[len-2]) ) { + switch(name[len-1]) { + case 'l': + prefix[len-1]= 0; + strcpy(replace, "r"); + break; + case 'r': + prefix[len-1]= 0; + strcpy(replace, "l"); + break; + case 'L': + prefix[len-1]= 0; + strcpy(replace, "R"); + break; + case 'R': + prefix[len-1]= 0; + strcpy(replace, "L"); + break; + } + } + /* case; beginning with r R l L , with separator after it */ + else if( IS_SEPARATOR(name[1]) ) { + switch(name[0]) { + case 'l': + strcpy(replace, "r"); + strcpy(suffix, name+1); + prefix[0]= 0; + break; + case 'r': + strcpy(replace, "l"); + strcpy(suffix, name+1); + prefix[0]= 0; + break; + case 'L': + strcpy(replace, "R"); + strcpy(suffix, name+1); + prefix[0]= 0; + break; + case 'R': + strcpy(replace, "L"); + strcpy(suffix, name+1); + prefix[0]= 0; + break; + } + } + else if(len > 5) { + /* hrms, why test for a separator? lets do the rule 'ultimate left or right' */ + index = BLI_strcasestr(prefix, "right"); + if (index==prefix || index==prefix+len-5) { + if(index[0]=='r') + strcpy (replace, "left"); + else { + if(index[1]=='I') + strcpy (replace, "LEFT"); + else + strcpy (replace, "Left"); + } + *index= 0; + strcpy (suffix, index+5); + } + else { + index = BLI_strcasestr(prefix, "left"); + if (index==prefix || index==prefix+len-4) { + if(index[0]=='l') + strcpy (replace, "right"); + else { + if(index[1]=='E') + strcpy (replace, "RIGHT"); + else + strcpy (replace, "Right"); + } + *index= 0; + strcpy (suffix, index+4); + } + } + } + +#undef IS_SEPARATOR + + sprintf (name_r, "%s%s%s%s", prefix, replace, suffix, number); +} + + + float deformvert_get_weight(const struct MDeformVert *dvert, int group_num) { if(dvert) diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 7e211f60cd5..3c925e5ff25 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -39,7 +39,6 @@ #include "stdarg.h" #include "math.h" #include "float.h" -#include "ctype.h" #include "BLI_math.h" #include "BLI_blenlib.h" @@ -1801,118 +1800,6 @@ static void mirrorModifier_updateDepgraph(ModifierData *md, DagForest *forest, S } } -/* finds the best possible flipped name. For renaming; check for unique names afterwards */ -/* if strip_number: removes number extensions */ -static void vertgroup_flip_name (char *name, int strip_number) -{ - int len; - char prefix[128]={""}; /* The part before the facing */ - char suffix[128]={""}; /* The part after the facing */ - char replace[128]={""}; /* The replacement string */ - char number[128]={""}; /* The number extension string */ - char *index=NULL; - - len= strlen(name); - if(len<3) return; // we don't do names like .R or .L - - /* We first check the case with a .### extension, let's find the last period */ - if(isdigit(name[len-1])) { - index= strrchr(name, '.'); // last occurrence - if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever! - if(strip_number==0) - strcpy(number, index); - *index= 0; - len= strlen(name); - } - } - - strcpy (prefix, name); - -#define IS_SEPARATOR(a) ((a)=='.' || (a)==' ' || (a)=='-' || (a)=='_') - - /* first case; separator . - _ with extensions r R l L */ - if( IS_SEPARATOR(name[len-2]) ) { - switch(name[len-1]) { - case 'l': - prefix[len-1]= 0; - strcpy(replace, "r"); - break; - case 'r': - prefix[len-1]= 0; - strcpy(replace, "l"); - break; - case 'L': - prefix[len-1]= 0; - strcpy(replace, "R"); - break; - case 'R': - prefix[len-1]= 0; - strcpy(replace, "L"); - break; - } - } - /* case; beginning with r R l L , with separator after it */ - else if( IS_SEPARATOR(name[1]) ) { - switch(name[0]) { - case 'l': - strcpy(replace, "r"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - case 'r': - strcpy(replace, "l"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - case 'L': - strcpy(replace, "R"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - case 'R': - strcpy(replace, "L"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - } - } - else if(len > 5) { - /* hrms, why test for a separator? lets do the rule 'ultimate left or right' */ - index = BLI_strcasestr(prefix, "right"); - if (index==prefix || index==prefix+len-5) { - if(index[0]=='r') - strcpy (replace, "left"); - else { - if(index[1]=='I') - strcpy (replace, "LEFT"); - else - strcpy (replace, "Left"); - } - *index= 0; - strcpy (suffix, index+5); - } - else { - index = BLI_strcasestr(prefix, "left"); - if (index==prefix || index==prefix+len-4) { - if(index[0]=='l') - strcpy (replace, "right"); - else { - if(index[1]=='E') - strcpy (replace, "RIGHT"); - else - strcpy (replace, "Right"); - } - *index= 0; - strcpy (suffix, index+4); - } - } - } - -#undef IS_SEPARATOR - - sprintf (name, "%s%s%s%s", prefix, replace, suffix, number); -} - static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, Object *ob, DerivedMesh *dm, @@ -2022,8 +1909,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, continue; def = vector_def[dvert->dw[j].def_nr]; - strcpy(tmpname, def->name); - vertgroup_flip_name(tmpname,0); + flip_vertexgroup_name(tmpname, def->name, 0); for(b = 0, defb = ob->defbase.first; defb; defb = defb->next, b++) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 63d681cce0b..006e05370b1 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2999,8 +2999,8 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* should init_particle_interpolation set this ? */ if(pset->brushtype==PE_BRUSH_WEIGHT){ - pind.hkey[0] = pa->hair; - pind.hkey[1] = pa->hair + 1; + pind.hkey[0] = NULL; + pind.hkey[1] = pa->hair; } @@ -3036,12 +3036,6 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf do_particle_interpolation(psys, i, pa, t, frs_sec, &pind, &result); - /* should init_particle_interpolation set this ? */ - if(pset->brushtype==PE_BRUSH_WEIGHT){ - pind.hkey[0] = pind.hkey[1]; - pind.hkey[1]++; - } - /* non-hair points are already in global space */ if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { mul_m4_v3(hairmat, result.co); @@ -3099,10 +3093,17 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* selection coloring in edit mode */ if(pset->brushtype==PE_BRUSH_WEIGHT){ - if(k==steps) + if(k==0) + weight_to_rgb(pind.hkey[1]->weight, ca->col, ca->col+1, ca->col+2); + else if(k >= steps - 1) weight_to_rgb(pind.hkey[0]->weight, ca->col, ca->col+1, ca->col+2); else weight_to_rgb((1.0f - keytime) * pind.hkey[0]->weight + keytime * pind.hkey[1]->weight, ca->col, ca->col+1, ca->col+2); + + /* at the moment this is only used for weight painting. + * will need to move out of this check if its used elsewhere. */ + pind.hkey[0] = pind.hkey[1]; + pind.hkey[1]++; } else { if((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT){ diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index ab558afe897..412a733dee0 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -120,7 +120,7 @@ void EM_cache_x_mirror_vert(struct Object *ob, struct EditMesh *em) } } -void EM_select_mirrored(Object *obedit, EditMesh *em, int extend) +static void EM_select_mirrored(Object *obedit, EditMesh *em, int extend) { EditVert *eve; diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 861b2cc0a6e..cfb4cda2460 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -187,6 +187,7 @@ void OBJECT_OT_vertex_group_levels(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_invert(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_blend(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_clean(struct wmOperatorType *ot); +void OBJECT_OT_vertex_group_mirror(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_set_active(struct wmOperatorType *ot); void OBJECT_OT_game_property_new(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 0837051ae0c..8b29e2ca2ae 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -173,6 +173,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_vertex_group_levels); WM_operatortype_append(OBJECT_OT_vertex_group_blend); WM_operatortype_append(OBJECT_OT_vertex_group_clean); + WM_operatortype_append(OBJECT_OT_vertex_group_mirror); WM_operatortype_append(OBJECT_OT_vertex_group_set_active); WM_operatortype_append(OBJECT_OT_game_property_new); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 43fabff6793..84b70e0a690 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -903,6 +903,68 @@ static void vgroup_clean_all(Object *ob, float eul, int keep_single) } } +static void vgroup_mirror(Object *ob, int mirror_weights, int flip_vgroups) +{ + EditVert *eve, *eve_mirr; + MDeformVert *dvert, *dvert_mirr; + int *flip_map; + + if(mirror_weights==0 && flip_vgroups==0) + return; + + /* only the active group */ + if(ob->type == OB_MESH) { + Mesh *me= ob->data; + EditMesh *em = BKE_mesh_get_editmesh(me); + + EM_cache_x_mirror_vert(ob, em); + + if(!CustomData_has_layer(&em->vdata, CD_MDEFORMVERT)) + return; + + flip_map= get_defgroup_flip_map(ob); + + /* Go through the list of editverts and assign them */ + for(eve=em->verts.first; eve; eve=eve->next){ + if((eve_mirr=eve->tmp.v)) { + if(eve_mirr->f & SELECT || eve->f & SELECT) { + dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT); + dvert_mirr= CustomData_em_get(&em->vdata, eve_mirr->data, CD_MDEFORMVERT); + if(dvert && dvert_mirr) { + if(eve_mirr->f & SELECT && eve->f & SELECT) { + /* swap */ + if(mirror_weights) + SWAP(MDeformVert, *dvert, *dvert_mirr); + if(flip_vgroups) { + flip_defvert(dvert, flip_map); + flip_defvert(dvert_mirr, flip_map); + } + } + else { + /* dvert should always be the target */ + if(eve_mirr->f & SELECT) { + SWAP(MDeformVert *, dvert, dvert_mirr); + } + + if(mirror_weights) + copy_defvert(dvert, dvert_mirr); + if(flip_vgroups) { + flip_defvert(dvert, flip_map); + } + } + } + } + + eve->tmp.v= eve_mirr->tmp.v= NULL; + } + } + + MEM_freeN(flip_map); + + BKE_mesh_end_editmesh(me, em); + } +} + static void vgroup_delete_update_users(Object *ob, int id) { ExplodeModifierData *emd; @@ -1026,7 +1088,7 @@ static void vgroup_active_remove_verts(Object *ob, int allverts) for(eve=em->verts.first; eve; eve=eve->next){ dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT); - if(dvert && dvert->dw && ((eve->f & 1) || allverts)){ + if(dvert && dvert->dw && ((eve->f & SELECT) || allverts)){ for(i=0; itotweight; i++){ /* Find group */ eg = BLI_findlink(&ob->defbase, dvert->dw[i].def_nr); @@ -1208,7 +1270,7 @@ static void vgroup_assign_verts(Object *ob, float weight) for(eve=em->verts.first; eve; eve=eve->next){ dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT); - if(dvert && (eve->f & 1)){ + if(dvert && (eve->f & SELECT)){ done=0; /* See if this vert already has a reference to this group */ /* If so: Change its weight */ @@ -1684,6 +1746,40 @@ void OBJECT_OT_vertex_group_clean(wmOperatorType *ot) } +static int vertex_group_mirror_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + + vgroup_mirror(ob, RNA_boolean_get(op->ptr,"mirror_weights"), RNA_boolean_get(op->ptr,"flip_group_names")); + + DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_vertex_group_mirror(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Mirror Vertex Group"; + ot->idname= "OBJECT_OT_vertex_group_mirror"; + ot->description= "Mirror weights, and flip vertex group names, copying when only one side is selected."; + + /* api callbacks */ + ot->poll= vertex_group_poll_edit; + ot->exec= vertex_group_mirror_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "mirror_weights", TRUE, "Mirror Weights", "Mirror weights."); + RNA_def_boolean(ot->srna, "flip_group_names", TRUE, "Flip Groups", "Flip vertex group names while mirroring."); + +} + + static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index fe38d71dc92..f0870ca9764 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2366,6 +2366,52 @@ void PARTICLE_OT_remove_doubles(wmOperatorType *ot) RNA_def_float(ot->srna, "threshold", 0.0002f, 0.0f, FLT_MAX, "Threshold", "Threshold distance withing which particles are removed", 0.00001f, 0.1f); } + +static int weight_set_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + ParticleEditSettings *pset= PE_settings(scene); + Object *ob= CTX_data_active_object(C); + PTCacheEdit *edit= PE_get_current(scene, ob); + ParticleSystem *psys = edit->psys; + POINT_P; + KEY_K; + HairKey *hkey; + float weight; + ParticleBrushData *brush= &pset->brush[pset->brushtype]; + edit= psys->edit; + + weight= (float)(brush->strength / 100.0f); + + LOOP_SELECTED_POINTS { + ParticleData *pa= psys->particles + p; + + LOOP_SELECTED_KEYS { + hkey= pa->hair + k; + hkey->weight= weight; + } + } + + DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, ob); + + return OPERATOR_FINISHED; +} + +void PARTICLE_OT_weight_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Weight Set"; + ot->idname= "PARTICLE_OT_weight_set"; + + /* api callbacks */ + ot->exec= weight_set_exec; + ot->poll= PE_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /************************ cursor drawing *******************************/ static void brush_drawcursor(bContext *C, int x, int y, void *customdata) diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index cc0a288f8be..3de5c256df7 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -50,6 +50,7 @@ void PARTICLE_OT_reveal(struct wmOperatorType *ot); void PARTICLE_OT_rekey(struct wmOperatorType *ot); void PARTICLE_OT_subdivide(struct wmOperatorType *ot); void PARTICLE_OT_remove_doubles(struct wmOperatorType *ot); +void PARTICLE_OT_weight_set(struct wmOperatorType *ot); void PARTICLE_OT_delete(struct wmOperatorType *ot); void PARTICLE_OT_mirror(struct wmOperatorType *ot); diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 5cb8230e463..2728f64a777 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -57,6 +57,7 @@ static void operatortypes_particle(void) WM_operatortype_append(PARTICLE_OT_rekey); WM_operatortype_append(PARTICLE_OT_subdivide); WM_operatortype_append(PARTICLE_OT_remove_doubles); + WM_operatortype_append(PARTICLE_OT_weight_set); WM_operatortype_append(PARTICLE_OT_delete); WM_operatortype_append(PARTICLE_OT_mirror); @@ -111,6 +112,8 @@ static void keymap_particle(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "PARTICLE_OT_brush_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0); + + WM_keymap_add_item(keymap, "PARTICLE_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0); ED_object_generic_keymap(keyconf, keymap, 1); } From 6d1f5f8f5dcabd9071dc190b85ab5aa118eb03c9 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 15 Jan 2010 17:36:06 +0000 Subject: [PATCH 150/202] *Fix for last commit. Removed unused code. --- source/blender/editors/space_console/console_draw.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 3fee2b6277b..9b4ec3882de 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -79,19 +79,15 @@ static void console_line_color(unsigned char *fg, int type) switch(type) { case CONSOLE_LINE_OUTPUT: UI_GetThemeColor3ubv(TH_CONSOLE_OUTPUT, fg); - fg[0], fg[1], fg[2]; break; case CONSOLE_LINE_INPUT: UI_GetThemeColor3ubv(TH_CONSOLE_INPUT, fg); - fg[0], fg[1], fg[2]; break; case CONSOLE_LINE_INFO: UI_GetThemeColor3ubv(TH_CONSOLE_INFO, fg); - fg[0], fg[1], fg[2]; break; case CONSOLE_LINE_ERROR: UI_GetThemeColor3ubv(TH_CONSOLE_ERROR, fg); - fg[0], fg[1], fg[2]; break; } } From 2b3a6b38b764717878de39a97feeee186e3694ad Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Jan 2010 22:02:32 +0000 Subject: [PATCH 151/202] remove duplicate code from operator/macro initialization --- .../blender/python/intern/bpy_operator_wrap.c | 86 ++++++------------- 1 file changed, 24 insertions(+), 62 deletions(-) diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index 11f36d5f8ec..0b855a9cacb 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -23,24 +23,38 @@ * ***** END GPL LICENSE BLOCK ***** */ - #include "bpy_operator_wrap.h" -#include "BLI_listbase.h" #include "BKE_context.h" -#include "BKE_report.h" -#include "DNA_windowmanager_types.h" -#include "MEM_guardedalloc.h" #include "WM_api.h" #include "WM_types.h" -#include "UI_interface.h" -#include "ED_screen.h" #include "RNA_define.h" #include "bpy_rna.h" #include "bpy_util.h" -#include "../generic/bpy_internal_import.h" // our own imports +static void operator_properties_init(wmOperatorType *ot) +{ + PyObject *py_class = ot->ext.data; + PyObject *item= ((PyTypeObject*)py_class)->tp_dict; /* getattr(..., "__dict__") returns a proxy */ + + RNA_struct_blender_type_set(ot->ext.srna, ot); + + if(item) { + /* only call this so pyrna_deferred_register_props gives a useful error + * WM_operatortype_append_ptr will call RNA_def_struct_identifier + * later */ + RNA_def_struct_identifier(ot->srna, ot->idname); + + if(pyrna_deferred_register_props(ot->srna, item) != 0) { + PyErr_Print(); /* failed to register operator props */ + PyErr_Clear(); + } + } + else { + PyErr_Clear(); + } +} void operator_wrapper(wmOperatorType *ot, void *userdata) { @@ -50,33 +64,7 @@ void operator_wrapper(wmOperatorType *ot, void *userdata) *ot= *((wmOperatorType *)userdata); ot->srna= srna; /* restore */ - RNA_struct_blender_type_set(ot->ext.srna, ot); - - - /* Can't use this because it returns a dict proxy - * - * item= PyObject_GetAttrString(py_class, "__dict__"); - */ - { - PyObject *py_class = ot->ext.data; - PyObject *item= ((PyTypeObject*)py_class)->tp_dict; - if(item) { - /* only call this so pyrna_deferred_register_props gives a useful error - * WM_operatortype_append_ptr will call RNA_def_struct_identifier - * later */ - RNA_def_struct_identifier(ot->srna, ot->idname); - - if(pyrna_deferred_register_props(ot->srna, item)!=0) { - /* failed to register operator props */ - PyErr_Print(); - PyErr_Clear(); - - } - } - else { - PyErr_Clear(); - } - } + operator_properties_init(ot); } void macro_wrapper(wmOperatorType *ot, void *userdata) @@ -92,33 +80,7 @@ void macro_wrapper(wmOperatorType *ot, void *userdata) ot->ui = data->ui; ot->ext = data->ext; - RNA_struct_blender_type_set(ot->ext.srna, ot); - - - /* Can't use this because it returns a dict proxy - * - * item= PyObject_GetAttrString(py_class, "__dict__"); - */ - { - PyObject *py_class = ot->ext.data; - PyObject *item= ((PyTypeObject*)py_class)->tp_dict; - if(item) { - /* only call this so pyrna_deferred_register_props gives a useful error - * WM_operatortype_append_ptr will call RNA_def_struct_identifier - * later */ - RNA_def_struct_identifier(ot->srna, ot->idname); - - if(pyrna_deferred_register_props(ot->srna, item)!=0) { - /* failed to register operator props */ - PyErr_Print(); - PyErr_Clear(); - - } - } - else { - PyErr_Clear(); - } - } + operator_properties_init(ot); } PyObject *PYOP_wrap_macro_define(PyObject *self, PyObject *args) From 5272991e8b91c527fbe3923d75ae2c5148dd7177 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Jan 2010 22:40:33 +0000 Subject: [PATCH 152/202] generic operator menu was searching for "type" and using the first enum property if it wasnt found. this is too arbitrary and could break if roperty order is changed. store the property in the operator type that is to be used for menu and enum search func's. python function for searching operator enums on invoke. (just need dynamic python enums now) wm.invoke_search_popup(self) --- release/scripts/templates/operator.py | 16 ++++- .../editors/animation/anim_channels_edit.c | 6 +- .../blender/editors/armature/editarmature.c | 12 ++-- source/blender/editors/armature/poselib.c | 3 +- source/blender/editors/armature/poseobject.c | 2 +- source/blender/editors/curve/editcurve.c | 2 +- source/blender/editors/gpencil/gpencil_edit.c | 2 +- source/blender/editors/mesh/editmesh.c | 2 +- source/blender/editors/mesh/editmesh_mods.c | 1 + source/blender/editors/mesh/editmesh_tools.c | 3 +- source/blender/editors/object/object_add.c | 6 +- .../editors/object/object_constraint.c | 8 +-- source/blender/editors/object/object_hook.c | 1 + .../blender/editors/object/object_modifier.c | 1 + .../blender/editors/object/object_relations.c | 17 +++-- source/blender/editors/object/object_select.c | 6 +- .../blender/editors/object/object_transform.c | 3 +- source/blender/editors/object/object_vgroup.c | 1 + .../blender/editors/physics/particle_boids.c | 2 +- .../blender/editors/physics/particle_edit.c | 2 +- source/blender/editors/screen/screen_ops.c | 2 +- .../editors/space_action/action_edit.c | 14 ++-- .../editors/space_console/console_draw.c | 8 +-- .../blender/editors/space_graph/graph_edit.c | 12 ++-- source/blender/editors/space_nla/nla_edit.c | 2 +- .../blender/editors/space_outliner/outliner.c | 8 +-- .../editors/space_view3d/view3d_snap.c | 1 - .../blender/editors/transform/transform_ops.c | 2 +- source/blender/makesrna/intern/rna_wm_api.c | 47 +++++++++---- .../blender/python/intern/bpy_operator_wrap.c | 10 +++ source/blender/python/intern/bpy_rna.c | 3 + source/blender/windowmanager/WM_types.h | 4 ++ .../windowmanager/intern/wm_operators.c | 68 ++++++++----------- 33 files changed, 159 insertions(+), 118 deletions(-) diff --git a/release/scripts/templates/operator.py b/release/scripts/templates/operator.py index f175ca06f28..92fbdaee989 100644 --- a/release/scripts/templates/operator.py +++ b/release/scripts/templates/operator.py @@ -19,6 +19,11 @@ class ExportSomeData(bpy.types.Operator): path = StringProperty(name="File Path", description="File path used for exporting the PLY file", maxlen= 1024, default= "") use_setting = BoolProperty(name="Example Boolean", description="Example Tooltip", default= True) + type = bpy.props.EnumProperty(items=(('OPT_A', "First Option", "Description one"), ('OPT_B', "Second Option", "Description two.")), + name="Example Enum", + description="Choose between two items", + default='OPT_A') + def poll(self, context): return context.active_object != None @@ -39,13 +44,18 @@ class ExportSomeData(bpy.types.Operator): # File selector wm.add_fileselect(self) # will run self.execute() return {'RUNNING_MODAL'} - elif 0: + elif True: + # search the enum + wm.invoke_search_popup(self) + return {'RUNNING_MODAL'} + elif False: # Redo popup return wm.invoke_props_popup(self, event) # - elif 0: + elif False: return self.execute(context) + bpy.types.register(ExportSomeData) # Only needed if you want to add into a dynamic menu @@ -53,4 +63,4 @@ menu_func = lambda self, context: self.layout.operator("export.some_data", text= bpy.types.INFO_MT_file_export.append(menu_func) if __name__ == "__main__": - bpy.ops.export.some_data(path="/tmp/test.ply") + bpy.ops.export.some_data('INVOKE_DEFAULT', path="/tmp/test.ply") \ No newline at end of file diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 530e9179474..fffc546394d 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1260,7 +1260,7 @@ void ANIM_OT_channels_setting_enable (wmOperatorType *ot) /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_ADD, "Mode", ""); /* setting to set */ - RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } void ANIM_OT_channels_setting_disable (wmOperatorType *ot) @@ -1282,7 +1282,7 @@ void ANIM_OT_channels_setting_disable (wmOperatorType *ot) /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_CLEAR, "Mode", ""); /* setting to set */ - RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } void ANIM_OT_channels_setting_toggle (wmOperatorType *ot) @@ -1304,7 +1304,7 @@ void ANIM_OT_channels_setting_toggle (wmOperatorType *ot) /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); /* setting to set */ - RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } // XXX currently, this is a separate operator, but perhaps we could in future specify in keymaps whether to call invoke or exec? diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 410da6662aa..cf7cd3e1f27 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -1384,7 +1384,7 @@ void ARMATURE_OT_flags_set (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", prop_bone_setting_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_bone_setting_types, 0, "Type", ""); RNA_def_enum(ot->srna, "mode", prop_bone_setting_modes, 0, "Mode", ""); } @@ -1404,7 +1404,7 @@ void POSE_OT_flags_set (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", prop_bone_setting_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_bone_setting_types, 0, "Type", ""); RNA_def_enum(ot->srna, "mode", prop_bone_setting_modes, 0, "Mode", ""); } @@ -2164,7 +2164,7 @@ void ARMATURE_OT_calculate_roll(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", prop_calc_roll_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_calc_roll_types, 0, "Type", ""); } /* **************** undo for armatures ************** */ @@ -3200,7 +3200,7 @@ void ARMATURE_OT_merge (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", merge_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", merge_types, 0, "Type", ""); } /* ************** END Add/Remove stuff in editmode ************ */ @@ -3973,7 +3973,7 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", prop_editarm_clear_parent_types, 0, "ClearType", "What way to clear parenting"); + ot->prop= RNA_def_enum(ot->srna, "type", prop_editarm_clear_parent_types, 0, "ClearType", "What way to clear parenting"); } /* **************** Selections ******************/ @@ -5559,7 +5559,7 @@ void ARMATURE_OT_autoside_names (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* settings */ - RNA_def_enum(ot->srna, "type", axis_items, 0, "Axis", "Axis tag names with."); + ot->prop= RNA_def_enum(ot->srna, "type", axis_items, 0, "Axis", "Axis tag names with."); } diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 0837e9cb48a..f4cf907ed4b 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -519,7 +519,8 @@ void POSELIB_OT_pose_remove (wmOperatorType *ot) /* properties */ prop= RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to remove"); - RNA_def_enum_funcs(prop, poselib_stored_pose_itemf); + RNA_def_enum_funcs(prop, poselib_stored_pose_itemf); + ot->prop= prop; } static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt) diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index df5f551fb0c..d26238150ca 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -1617,7 +1617,7 @@ void POSE_OT_autoside_names (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* settings */ - RNA_def_enum(ot->srna, "axis", axis_items, 0, "Axis", "Axis tag names with."); + ot->prop= RNA_def_enum(ot->srna, "axis", axis_items, 0, "Axis", "Axis tag names with."); } /* ********************************************** */ diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index f61596f397f..948448411bf 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -2581,7 +2581,7 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", type_items, CU_POLY, "Type", "Spline type"); + ot->prop= RNA_def_enum(ot->srna, "type", type_items, CU_POLY, "Type", "Spline type"); } /***************** set handle type operator *******************/ diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index e5a0cd0f8cb..8926f63ceaa 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -594,7 +594,7 @@ void GPENCIL_OT_convert (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", prop_gpencil_convertmodes, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_gpencil_convertmodes, 0, "Type", ""); } /* ************************************************ */ diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index a286c0ad8e8..cdd5cee881f 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1504,7 +1504,7 @@ void MESH_OT_separate(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", prop_separate_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_separate_types, 0, "Type", ""); } diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 412a733dee0..d73ce1a1214 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -1304,6 +1304,7 @@ void MESH_OT_select_similar(wmOperatorType *ot) /* properties */ prop= RNA_def_enum(ot->srna, "type", prop_similar_types, SIMVERT_NORMAL, "Type", ""); RNA_def_enum_funcs(prop, select_similar_type_itemf); + ot->prop= prop; } /* ******************************************* */ diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index e41d60783fe..92b4800ccfd 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -5881,6 +5881,7 @@ void MESH_OT_merge(wmOperatorType *ot) /* properties */ prop= RNA_def_enum(ot->srna, "type", merge_type_items, 3, "Type", "Merge method to use."); RNA_def_enum_funcs(prop, merge_type_itemf); + ot->prop= prop; RNA_def_boolean(ot->srna, "uvs", 0, "UVs", "Move UVs according to merge."); } @@ -6082,7 +6083,7 @@ void MESH_OT_select_vertex_path(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", type_items, PATH_SELECT_EDGE_LENGTH, "Type", "Method to compute distance."); + ot->prop= RNA_def_enum(ot->srna, "type", type_items, PATH_SELECT_EDGE_LENGTH, "Type", "Method to compute distance."); } /********************** Region/Loop Operators *************************/ diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 9740a1cba01..9e9619a30ea 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -384,7 +384,7 @@ void OBJECT_OT_effector_add(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", field_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", field_type_items, 0, "Type", ""); ED_object_add_generic_props(ot, TRUE); } @@ -806,7 +806,7 @@ void OBJECT_OT_lamp_add(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", lamp_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", lamp_type_items, 0, "Type", ""); ED_object_add_generic_props(ot, FALSE); } @@ -1360,7 +1360,7 @@ void OBJECT_OT_convert(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "target", convert_target_items, OB_MESH, "Target", "Type of object to convert to."); + ot->prop= RNA_def_enum(ot->srna, "target", convert_target_items, OB_MESH, "Target", "Type of object to convert to."); RNA_def_boolean(ot->srna, "keep_original", 0, "Keep Original", "Keep original objects instead of replacing them."); } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 19ba5f7b32b..497b5e82e26 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -1218,7 +1218,7 @@ void OBJECT_OT_constraint_add(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); } void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot) @@ -1237,7 +1237,7 @@ void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); } void POSE_OT_constraint_add(wmOperatorType *ot) @@ -1256,7 +1256,7 @@ void POSE_OT_constraint_add(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); } void POSE_OT_constraint_add_with_targets(wmOperatorType *ot) @@ -1275,7 +1275,7 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); } /************************ IK Constraint operators *********************/ diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 313ffe79c66..c9730e3490b 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -612,6 +612,7 @@ void OBJECT_OT_hook_remove(wmOperatorType *ot) /* properties */ prop= RNA_def_enum(ot->srna, "modifier", hook_mod_items, 0, "Modifier", "Modifier number to remove."); RNA_def_enum_funcs(prop, hook_mod_itemf); + ot->prop= prop; } static int object_hook_reset_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index a44ad47b94f..eec8104f29b 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -558,6 +558,7 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) /* properties */ prop= RNA_def_enum(ot->srna, "type", modifier_type_items, eModifierType_Subsurf, "Type", ""); RNA_def_enum_funcs(prop, modifier_add_itemf); + ot->prop= prop; } /************************ remove modifier operator *********************/ diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 5cf11771004..fbee03e3a30 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -286,7 +286,6 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) /* create operator menu item with relevant properties filled in */ props_ptr= uiItemFullO(layout, op->type->name, 0, op->idname, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); - RNA_string_set(&props_ptr, "object", ob->id.name+2); /* present the menu and be done... */ uiPupMenuEnd(C, pup); @@ -337,8 +336,7 @@ static int make_proxy_exec (bContext *C, wmOperator *op) /* depsgraph flushes are needed for the new data */ DAG_scene_sort(scene); DAG_id_flush_update(&newob->id, OB_RECALC); - - WM_event_add_notifier(C, NC_OBJECT, NULL); + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, newob); } else { BKE_report(op->reports, RPT_ERROR, "No object to make proxy for"); @@ -358,7 +356,7 @@ static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *ptr, GroupObject *go; if(!ob || !ob->dup_group) - return &DummyRNA_NULL_items; + return DummyRNA_NULL_items; memset(&item_tmp, 0, sizeof(item_tmp)); @@ -396,6 +394,7 @@ void OBJECT_OT_proxy_make (wmOperatorType *ot) RNA_def_string(ot->srna, "object", "", 19, "Proxy Object", "Name of lib-linked/grouped object to make a proxy for."); prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "Group object"); /* XXX, relies on hard coded ID at the moment */ RNA_def_enum_funcs(prop, proxy_group_object_itemf); + ot->prop= prop; } /********************** Clear Parent Operator ******************* */ @@ -452,7 +451,7 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", ""); } /* ******************** Make Parent Operator *********************** */ @@ -893,7 +892,7 @@ void OBJECT_OT_track_clear(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", prop_clear_track_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_clear_track_types, 0, "Type", ""); } /************************** Make Track Operator *****************************/ @@ -986,7 +985,7 @@ void OBJECT_OT_track_set(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", prop_make_track_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_make_track_types, 0, "Type", ""); } /************************** Move to Layer Operator *****************************/ @@ -1768,7 +1767,7 @@ void OBJECT_OT_make_local(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); } static int make_single_user_exec(bContext *C, wmOperator *op) @@ -1819,7 +1818,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); RNA_def_boolean(ot->srna, "object", 0, "Object", "Make single user objects"); RNA_def_boolean(ot->srna, "obdata", 0, "Object Data", "Make single user object data"); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index b3a160dfff4..c671a81bc71 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -157,7 +157,7 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first."); - RNA_def_enum(ot->srna, "type", object_type_items, 1, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", object_type_items, 1, "Type", ""); } /*********************** Selection by Links *********************/ @@ -318,7 +318,7 @@ void OBJECT_OT_select_linked(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first."); - RNA_def_enum(ot->srna, "type", prop_select_linked_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_select_linked_types, 0, "Type", ""); } /*********************** Selected Grouped ********************/ @@ -619,7 +619,7 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first."); - RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", ""); } /************************* Select by Layer **********************/ diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 43382562a8a..9e4cc012171 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -1040,6 +1040,7 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", ""); + } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 84b70e0a690..4e31dffd3da 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1882,5 +1882,6 @@ void OBJECT_OT_vertex_group_set_active(wmOperatorType *ot) /* properties */ prop= RNA_def_enum(ot->srna, "group", vgroup_items, 0, "Group", "Vertex group to set as active."); RNA_def_enum_funcs(prop, vgroup_itemf); + ot->prop= prop; } diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c index b7a97d1131a..50a1bffbf30 100644 --- a/source/blender/editors/physics/particle_boids.c +++ b/source/blender/editors/physics/particle_boids.c @@ -97,7 +97,7 @@ void BOID_OT_rule_add(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", boidrule_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", boidrule_type_items, 0, "Type", ""); } static int rule_del_exec(bContext *C, wmOperator *op) { diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index f0870ca9764..eb03d3954d2 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2586,7 +2586,7 @@ void PARTICLE_OT_delete(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", delete_type_items, DEL_PARTICLE, "Type", "Delete a full particle or only keys."); + ot->prop= RNA_def_enum(ot->srna, "type", delete_type_items, DEL_PARTICLE, "Type", "Delete a full particle or only keys."); } /*************************** mirror operator **************************/ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index e45c8bc48ee..912ac98aee4 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3764,7 +3764,7 @@ void SCENE_OT_new(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); } /********************* delete scene operator *********************/ diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 6dcd3049c0e..d94d5bec490 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -513,7 +513,7 @@ void ACTION_OT_keyframe_insert (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", prop_actkeys_insertkey_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_actkeys_insertkey_types, 0, "Type", ""); } /* ******************** Duplicate Keyframes Operator ************************* */ @@ -872,7 +872,7 @@ void ACTION_OT_extrapolation_type (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", prop_actkeys_expo_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_actkeys_expo_types, 0, "Type", ""); } /* ******************** Set Interpolation-Type Operator *********************** */ @@ -943,7 +943,7 @@ void ACTION_OT_interpolation_type (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", beztriple_interpolation_mode_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", beztriple_interpolation_mode_items, 0, "Type", ""); } /* ******************** Set Handle-Type Operator *********************** */ @@ -1032,7 +1032,7 @@ void ACTION_OT_handle_type (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", beztriple_handle_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", beztriple_handle_type_items, 0, "Type", ""); } /* ******************** Set Keyframe-Type Operator *********************** */ @@ -1103,7 +1103,7 @@ void ACTION_OT_keyframe_type (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", beztriple_keyframe_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", beztriple_keyframe_type_items, 0, "Type", ""); } /* ************************************************************************** */ @@ -1268,7 +1268,7 @@ void ACTION_OT_snap (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", prop_actkeys_snap_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_actkeys_snap_types, 0, "Type", ""); } /* ******************** Mirror Keyframes Operator *********************** */ @@ -1385,7 +1385,7 @@ void ACTION_OT_mirror (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", prop_actkeys_mirror_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_actkeys_mirror_types, 0, "Type", ""); } /* ************************************************************************** */ diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 9b4ec3882de..eda2b2021e5 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -78,16 +78,16 @@ static void console_line_color(unsigned char *fg, int type) { switch(type) { case CONSOLE_LINE_OUTPUT: - UI_GetThemeColor3ubv(TH_CONSOLE_OUTPUT, fg); + UI_GetThemeColor3ubv(TH_CONSOLE_OUTPUT, (char *)fg); break; case CONSOLE_LINE_INPUT: - UI_GetThemeColor3ubv(TH_CONSOLE_INPUT, fg); + UI_GetThemeColor3ubv(TH_CONSOLE_INPUT, (char *)fg); break; case CONSOLE_LINE_INFO: - UI_GetThemeColor3ubv(TH_CONSOLE_INFO, fg); + UI_GetThemeColor3ubv(TH_CONSOLE_INFO, (char *)fg); break; case CONSOLE_LINE_ERROR: - UI_GetThemeColor3ubv(TH_CONSOLE_ERROR, fg); + UI_GetThemeColor3ubv(TH_CONSOLE_ERROR, (char *)fg); break; } } diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 2adf783b338..db63499d645 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -497,7 +497,7 @@ void GRAPH_OT_keyframe_insert (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", prop_graphkeys_insertkey_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_graphkeys_insertkey_types, 0, "Type", ""); } /* ******************** Click-Insert Keyframes Operator ************************* */ @@ -1270,7 +1270,7 @@ void GRAPH_OT_extrapolation_type (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", prop_graphkeys_expo_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_graphkeys_expo_types, 0, "Type", ""); } /* ******************** Set Interpolation-Type Operator *********************** */ @@ -1339,7 +1339,7 @@ void GRAPH_OT_interpolation_type (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", beztriple_interpolation_mode_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", beztriple_interpolation_mode_items, 0, "Type", ""); } /* ******************** Set Handle-Type Operator *********************** */ @@ -1427,7 +1427,7 @@ void GRAPH_OT_handle_type (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", beztriple_handle_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", beztriple_handle_type_items, 0, "Type", ""); } /* ************************************************************************** */ @@ -1697,7 +1697,7 @@ void GRAPH_OT_snap (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", prop_graphkeys_snap_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_graphkeys_snap_types, 0, "Type", ""); } /* ******************** Mirror Keyframes Operator *********************** */ @@ -1814,7 +1814,7 @@ void GRAPH_OT_mirror (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", prop_graphkeys_mirror_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_graphkeys_mirror_types, 0, "Type", ""); } /* ******************** Smooth Keyframes Operator *********************** */ diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 4422bc2d158..a54627ec0d8 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -1484,7 +1484,7 @@ void NLA_OT_snap (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "type", prop_nlaedit_snap_types, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_nlaedit_snap_types, 0, "Type", ""); } /* *********************************************** */ diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 9e9b0075f0f..97f1d34f673 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -3319,7 +3319,7 @@ void OUTLINER_OT_object_operation(wmOperatorType *ot) ot->flag= 0; - RNA_def_enum(ot->srna, "type", prop_object_op_types, 0, "Object Operation", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_object_op_types, 0, "Object Operation", ""); } /* **************************************** */ @@ -3377,7 +3377,7 @@ void OUTLINER_OT_group_operation(wmOperatorType *ot) ot->flag= 0; - RNA_def_enum(ot->srna, "type", prop_group_op_types, 0, "Group Operation", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_group_op_types, 0, "Group Operation", ""); } /* **************************************** */ @@ -3443,7 +3443,7 @@ void OUTLINER_OT_id_operation(wmOperatorType *ot) ot->flag= 0; - RNA_def_enum(ot->srna, "type", prop_id_op_types, 0, "ID data Operation", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_id_op_types, 0, "ID data Operation", ""); } /* **************************************** */ @@ -3514,7 +3514,7 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot) ot->flag= 0; - RNA_def_enum(ot->srna, "type", prop_data_op_types, 0, "Data Operation", ""); + ot->prop= RNA_def_enum(ot->srna, "type", prop_data_op_types, 0, "Data Operation", ""); } diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 66d2fe1ef7b..2ff45ea600e 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -1089,7 +1089,6 @@ void VIEW3D_OT_snap_selected_to_center(wmOperatorType *ot) static int snap_curs_to_center(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); - RegionView3D *rv3d= CTX_wm_region_data(C); View3D *v3d= CTX_wm_view3d(C); float *curs; curs= give_cursor(scene, v3d); diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 0601d0b296e..14f0e860576 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -130,7 +130,7 @@ void TRANSFORM_OT_snap_type(wmOperatorType *ot) ot->flag= OPTYPE_UNDO; /* props */ - RNA_def_enum(ot->srna, "type", snap_element_items, 0, "Type", "Set the snap element type"); + ot->prop= RNA_def_enum(ot->srna, "type", snap_element_items, 0, "Type", "Set the snap element type"); } diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 9ed6046ecd0..c69e706e28d 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -144,18 +144,42 @@ static void rna_Operator_report(wmOperator *op, int type, char *msg) BKE_report(op->reports, type, msg); } +/* since event isnt needed... */ +static int rna_Operator_enum_search_invoke(bContext *C, wmOperator *op) +{ + WM_enum_search_invoke(C, op, NULL); +} + #else +static void rna_generic_op_invoke(FunctionRNA *func, int use_event, int use_ret) +{ + PropertyRNA *parm; + + RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); + parm= RNA_def_pointer(func, "operator", "Operator", "", "Operator to call."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + if(use_event) { + parm= RNA_def_pointer(func, "event", "Event", "", "Event."); + RNA_def_property_flag(parm, PROP_REQUIRED); + } + + if(use_ret) { + parm= RNA_def_enum(func, "result", operator_return_items, 0, "result", ""); + RNA_def_property_flag(parm, PROP_ENUM_FLAG); + RNA_def_function_return(func, parm); + } +} + void RNA_api_wm(StructRNA *srna) { FunctionRNA *func; PropertyRNA *parm; func= RNA_def_function(srna, "add_fileselect", "WM_event_add_fileselect"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Show up the file selector."); - parm= RNA_def_pointer(func, "operator", "Operator", "", "Operator to call."); - RNA_def_property_flag(parm, PROP_REQUIRED); + rna_generic_op_invoke(func, 0, 0); func= RNA_def_function(srna, "add_keyconfig", "WM_keyconfig_add"); parm= RNA_def_string(func, "name", "", 0, "Name", ""); @@ -165,24 +189,17 @@ void RNA_api_wm(StructRNA *srna) /* invoke functions, for use with python */ func= RNA_def_function(srna, "invoke_props_popup", "WM_operator_props_popup"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Operator popup invoke."); - parm= RNA_def_pointer(func, "operator", "Operator", "", "Operator to call."); - RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_pointer(func, "event", "Event", "", "Event."); - RNA_def_property_flag(parm, PROP_REQUIRED); - - parm= RNA_def_enum(func, "result", operator_return_items, 0, "result", ""); // better name? - RNA_def_property_flag(parm, PROP_ENUM_FLAG); - RNA_def_function_return(func, parm); + rna_generic_op_invoke(func, 1, 1); + /* invoke enum */ + func= RNA_def_function(srna, "invoke_search_popup", "rna_Operator_enum_search_invoke"); + rna_generic_op_invoke(func, 0, 1); /* invoke functions, for use with python */ func= RNA_def_function(srna, "invoke_popup", "WM_operator_ui_popup"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Operator popup invoke."); - parm= RNA_def_pointer(func, "operator", "Operator", "", "Operator to call."); - RNA_def_property_flag(parm, PROP_REQUIRED); + rna_generic_op_invoke(func, 0, 0); parm= RNA_def_int(func, "width", 300, 0, INT_MAX, "", "Width of the popup.", 0, INT_MAX); parm= RNA_def_int(func, "height", 20, 0, INT_MAX, "", "Height of the popup.", 0, INT_MAX); } diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index 0b855a9cacb..ebe063b7c6f 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -65,6 +65,16 @@ void operator_wrapper(wmOperatorType *ot, void *userdata) ot->srna= srna; /* restore */ operator_properties_init(ot); + + { /* XXX - not nice, set the first enum as searchable, should have a way for python to set */ + PointerRNA ptr; + PropertyRNA *prop; + + RNA_pointer_create(NULL, ot->srna, NULL, &ptr); + prop = RNA_struct_find_property(&ptr, "type"); + if(prop) + ot->prop= prop; + } } void macro_wrapper(wmOperatorType *ot, void *userdata) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index ace638914dc..a4f61b7292d 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -4011,6 +4011,9 @@ int pyrna_deferred_register_props(StructRNA *srna, PyObject *class_dict) order= PyDict_GetItemString(class_dict, "order"); + if(order==NULL) + PyErr_Clear(); + if(order && PyList_Check(order)) { for(pos= 0; postype->prop; uiPopupMenu *pup; uiLayout *layout; - prop= RNA_struct_find_property(op->ptr, "type"); - - if(!prop) { - RNA_STRUCT_BEGIN(op->ptr, findprop) { - if(RNA_property_type(findprop) == PROP_ENUM) { - prop= findprop; - break; - } - } - RNA_STRUCT_END; - } - if(prop==NULL) { - printf("WM_menu_invoke: %s has no \"type\" enum property\n", op->type->idname); + printf("WM_menu_invoke: %s has no enum property set\n", op->type->idname); } else if (RNA_property_type(prop) != PROP_ENUM) { - printf("WM_menu_invoke: %s \"type\" is not an enum property\n", op->type->idname); + printf("WM_menu_invoke: %s \"%s\" is not an enum property\n", op->type->idname, RNA_property_identifier(prop)); } else if (RNA_property_is_set(op->ptr, RNA_property_identifier(prop))) { return op->type->exec(C, op); @@ -633,45 +621,47 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event) } -/* ENUM Search popup */ +/* generic enum search invoke popup */ static void operator_enum_search_cb(const struct bContext *C, void *arg_ot, char *str, uiSearchItems *items) { wmOperatorType *ot = (wmOperatorType *)arg_ot; - PointerRNA ptr; - PropertyRNA *prop; + PropertyRNA *prop= ot->prop; - /* enum */ - EnumPropertyItem *item, *item_array; - int free, found; - - RNA_pointer_create(NULL, ot->srna, NULL, &ptr); - prop = RNA_struct_find_property(&ptr, "type"); // XXX, SHOULD NOT USE HARD CODED VALUE - - RNA_property_enum_items((bContext *)C, &ptr, prop, &item_array, NULL, &free); - - for(item= item_array; item->identifier; item++) { - /* note: need to give the intex rather then the dientifier because the enum can be freed */ - if(BLI_strcasestr(item->name, str)) - if(0==uiSearchItemAdd(items, item->name, SET_INT_IN_POINTER(item->value), 0)) - break; + if(prop==NULL) { + printf("WM_enum_search_invoke: %s has no enum property set\n", ot->idname); } + else if (RNA_property_type(prop) != PROP_ENUM) { + printf("WM_enum_search_invoke: %s \"%s\" is not an enum property\n", ot->idname, RNA_property_identifier(prop)); + } + else { + PointerRNA ptr; - found= (item->identifier != NULL); /* could be alloc'd, assign before free */ + EnumPropertyItem *item, *item_array; + int free; - if(free) - MEM_freeN(item_array); + RNA_pointer_create(NULL, ot->srna, NULL, &ptr); + RNA_property_enum_items((bContext *)C, &ptr, prop, &item_array, NULL, &free); + for(item= item_array; item->identifier; item++) { + /* note: need to give the intex rather then the dientifier because the enum can be freed */ + if(BLI_strcasestr(item->name, str)) + if(0==uiSearchItemAdd(items, item->name, SET_INT_IN_POINTER(item->value), 0)) + break; + } + + if(free) + MEM_freeN(item_array); + } } static void operator_enum_call_cb(struct bContext *C, void *arg1, void *arg2) { wmOperatorType *ot= arg1; - int enum_value= GET_INT_FROM_POINTER(arg2); if(ot) { PointerRNA props_ptr; WM_operator_properties_create_ptr(&props_ptr, ot); - RNA_enum_set(&props_ptr, "type", enum_value); // XXX, SHOULD NOT USE HARD CODED VALUE + RNA_property_enum_set(&props_ptr, ot->prop, GET_INT_FROM_POINTER(arg2)); WM_operator_name_call(C, ot->idname, WM_OP_EXEC_DEFAULT, &props_ptr); WM_operator_properties_free(&props_ptr); } @@ -684,12 +674,14 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op) wmWindow *win= CTX_wm_window(C); uiBlock *block; uiBut *but; + wmOperator *op= (wmOperator *)arg_op; block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); + //uiDefBut(block, LABEL, 0, op->type->name, 10, 10, 180, 19, NULL, 0.0, 0.0, 0, 0, ""); // ok, this isnt so easy... but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 10, 180, 19, 0, 0, ""); - uiButSetSearchFunc(but, operator_enum_search_cb, ((wmOperator *)arg_op)->type, operator_enum_call_cb, NULL); + uiButSetSearchFunc(but, operator_enum_search_cb, op->type, operator_enum_call_cb, NULL); /* fake button, it holds space for search items */ uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 180, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); From 61acdb61cb79a34889fca09e640613317c06698a Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sat, 16 Jan 2010 00:59:59 +0000 Subject: [PATCH 153/202] Fix [#20418] ring select in face mode selects edges not faces --- source/blender/editors/mesh/loopcut.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/mesh/loopcut.c b/source/blender/editors/mesh/loopcut.c index 9510e40c6ac..089ac1a300c 100644 --- a/source/blender/editors/mesh/loopcut.c +++ b/source/blender/editors/mesh/loopcut.c @@ -332,16 +332,23 @@ static int ringsel_invoke (bContext *C, wmOperator *op, wmEvent *evt) tringselOpData *lcd; EditEdge *edge; int dist = 75; - + view3d_operator_needs_opengl(C); if (!ringsel_init(C, op, 0)) return OPERATOR_CANCELLED; + lcd = op->customdata; + + if (lcd->em->selectmode == SCE_SELECT_FACE) { + ringsel_exit(C, op); + WM_operator_name_call(C, "MESH_OT_loop_select", WM_OP_INVOKE_REGION_WIN, NULL); + return OPERATOR_CANCELLED; + } + /* add a modal handler for this operator - handles loop selection */ WM_event_add_modal_handler(C, op); - lcd = op->customdata; lcd->vc.mval[0] = evt->mval[0]; lcd->vc.mval[1] = evt->mval[1]; From 03e924cdee264352fbc8e0a822212a169415185b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jan 2010 01:15:47 +0000 Subject: [PATCH 154/202] mirror modifier vgroup option was doing string name conversion to find the flipped name for every vertex for every weight. the vertex flip mapping only needs to be made once. warning fixes too. --- source/blender/blenkernel/intern/modifier.c | 56 ++++--------------- .../editors/space_console/console_ops.c | 4 +- source/blender/makesrna/intern/rna_wm_api.c | 5 +- 3 files changed, 17 insertions(+), 48 deletions(-) diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 3c925e5ff25..830c484b841 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -1813,9 +1813,8 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, int maxVerts = dm->getNumVerts(dm); int maxEdges = dm->getNumEdges(dm); int maxFaces = dm->getNumFaces(dm); - int vector_size=0, j, a, b; - bDeformGroup *def, *defb; - bDeformGroup **vector_def = NULL; + int *flip_map; + int do_vgroup_mirr= (mmd->flag & MOD_MIR_VGROUP); int (*indexMap)[2]; float mtx[4][4], imtx[4][4]; @@ -1826,18 +1825,10 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, result = CDDM_from_template(dm, maxVerts * 2, maxEdges * 2, maxFaces * 2); - if (mmd->flag & MOD_MIR_VGROUP) { - /* calculate the number of deformedGroups */ - for(vector_size = 0, def = ob->defbase.first; def; - def = def->next, vector_size++); - - /* load the deformedGroups for fast access */ - vector_def = - (bDeformGroup **)MEM_mallocN(sizeof(bDeformGroup*) * vector_size, - "group_index"); - for(a = 0, def = ob->defbase.first; def; def = def->next, a++) { - vector_def[a] = def; - } + if (do_vgroup_mirr) { + flip_map= get_defgroup_flip_map(ob); + if(flip_map == NULL) + do_vgroup_mirr= 0; } if (mmd->mirror_ob) { @@ -1884,7 +1875,6 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, mv->flag |= ME_VERT_MERGED; } else { MVert *mv2 = CDDM_get_vert(result, numVerts); - MDeformVert *dvert = NULL; DM_copy_vert_data(dm, result, i, numVerts, 1); *mv2 = *mv; @@ -1895,35 +1885,13 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, } copy_v3_v3(mv2->co, co); - if (mmd->flag & MOD_MIR_VGROUP){ - dvert = DM_get_vert_data(result, numVerts, CD_MDEFORMVERT); - - if (dvert) - { - for(j = 0; j < dvert[0].totweight; ++j) - { - char tmpname[32]; - - if(dvert->dw[j].def_nr < 0 || - dvert->dw[j].def_nr >= vector_size) - continue; - - def = vector_def[dvert->dw[j].def_nr]; - flip_vertexgroup_name(tmpname, def->name, 0); - - for(b = 0, defb = ob->defbase.first; defb; - defb = defb->next, b++) - { - if(!strcmp(defb->name, tmpname)) - { - dvert->dw[j].def_nr = b; - break; - } - } - } + if (do_vgroup_mirr) { + MDeformVert *dvert= DM_get_vert_data(result, numVerts, CD_MDEFORMVERT); + if(dvert) { + flip_defvert(dvert, flip_map); } } - + numVerts++; } } @@ -2008,7 +1976,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, } } - if (vector_def) MEM_freeN(vector_def); + if (flip_map) MEM_freeN(flip_map); MEM_freeN(indexMap); diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 76e1231b0d4..969918392c9 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -279,12 +279,12 @@ static int console_edit_poll(bContext *C) return 1; } - +#if 0 static int console_poll(bContext *C) { return (CTX_wm_space_console(C) != NULL); } - +#endif /* static funcs for text editing */ diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index c69e706e28d..3fa646598d6 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -145,9 +145,10 @@ static void rna_Operator_report(wmOperator *op, int type, char *msg) } /* since event isnt needed... */ -static int rna_Operator_enum_search_invoke(bContext *C, wmOperator *op) +static void rna_Operator_enum_search_invoke(bContext *C, wmOperator *op) { WM_enum_search_invoke(C, op, NULL); + } #else @@ -194,7 +195,7 @@ void RNA_api_wm(StructRNA *srna) /* invoke enum */ func= RNA_def_function(srna, "invoke_search_popup", "rna_Operator_enum_search_invoke"); - rna_generic_op_invoke(func, 0, 1); + rna_generic_op_invoke(func, 0, 0); /* invoke functions, for use with python */ func= RNA_def_function(srna, "invoke_popup", "WM_operator_ui_popup"); From 13295aec305ecf2d293c0f15b79b24bf7261f3ad Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sat, 16 Jan 2010 02:12:03 +0000 Subject: [PATCH 155/202] Small patch from freakabcd in irc: disable camera dof distance if dof object is set --- release/scripts/ui/properties_data_camera.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/release/scripts/ui/properties_data_camera.py b/release/scripts/ui/properties_data_camera.py index d2889b6629e..44fa3013bd2 100644 --- a/release/scripts/ui/properties_data_camera.py +++ b/release/scripts/ui/properties_data_camera.py @@ -116,7 +116,12 @@ class DATA_PT_camera(DataButtonsPanel): if wide_ui: col = split.column() + else: + col = col.column() + if cam.dof_object != None: + col.enabled = False col.prop(cam, "dof_distance", text="Distance") + class DATA_PT_camera_display(DataButtonsPanel): From a33e12c184162c4daf2d3363c847619609c813ed Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sat, 16 Jan 2010 04:18:21 +0000 Subject: [PATCH 156/202] Fix: MESH_OT_DELETE wasn't working since rev. 26027, MESH_OT_select_by_number_vertices neither for the MESH_OT_select_... ENUM text fix (s/Triangles/Quads) and invoke added (WM_menu_invoke). --- source/blender/editors/mesh/editmesh_mods.c | 5 +++-- source/blender/editors/mesh/editmesh_tools.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index d73ce1a1214..fc1e677b174 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -2859,7 +2859,7 @@ void MESH_OT_select_by_number_vertices(wmOperatorType *ot) { static const EnumPropertyItem type_items[]= { {3, "TRIANGLES", 0, "Triangles", NULL}, - {4, "QUADS", 0, "Triangles", NULL}, + {4, "QUADS", 0, "Quads", NULL}, {5, "OTHER", 0, "Other", NULL}, {0, NULL, 0, NULL, NULL}}; @@ -2870,13 +2870,14 @@ void MESH_OT_select_by_number_vertices(wmOperatorType *ot) /* api callbacks */ ot->exec= select_by_number_vertices_exec; + ot->invoke= WM_menu_invoke; ot->poll= ED_operator_editmesh; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* props */ - RNA_def_enum(ot->srna, "type", type_items, 3, "Type", "Type of elements to select."); + ot->prop= RNA_def_enum(ot->srna, "type", type_items, 3, "Type", "Type of elements to select."); } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 92b4800ccfd..db04dfa19fe 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -1326,7 +1326,7 @@ void MESH_OT_delete(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /*props */ - RNA_def_enum(ot->srna, "type", prop_mesh_delete_types, 10, "Type", "Method used for deleting mesh data"); + ot->prop= RNA_def_enum(ot->srna, "type", prop_mesh_delete_types, 10, "Type", "Method used for deleting mesh data"); } From 2ca119c66db1b4f2af46b0933720740da6a6a371 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jan 2010 14:05:39 +0000 Subject: [PATCH 157/202] possible fix for [#20674] SegFault from console 'c = data.texts["text1"].copy()' fix for freeing the undo buffer from a copied text block. (the copy had the old undo pointer) since I only got an error, not a segfault Im not sure this is the real cause of the crash. --- source/blender/blenkernel/intern/text.c | 27 +++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 9af0d11c162..f17a3a2423f 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -150,6 +150,13 @@ int txt_get_undostate(void) return undoing; } +static void init_undo_text(Text *text) +{ + text->undo_pos= -1; + text->undo_len= TXT_INIT_UNDO; + text->undo_buf= MEM_mallocN(text->undo_len, "undo buf"); +} + void free_text(Text *text) { TextLine *tmp; @@ -180,10 +187,8 @@ Text *add_empty_text(char *name) ta->name= NULL; - ta->undo_pos= -1; - ta->undo_len= TXT_INIT_UNDO; - ta->undo_buf= MEM_mallocN(ta->undo_len, "undo buf"); - + init_undo_text(ta); + ta->nlines=1; ta->flags= TXT_ISDIRTY | TXT_ISMEM; @@ -259,9 +264,7 @@ int reopen_text(Text *text) /* clear undo buffer */ MEM_freeN(text->undo_buf); - text->undo_pos= -1; - text->undo_len= TXT_INIT_UNDO; - text->undo_buf= MEM_mallocN(text->undo_len, "undo buf"); + init_undo_text(text); fseek(fp, 0L, SEEK_END); len= ftell(fp); @@ -359,9 +362,7 @@ Text *add_text(char *file, const char *relpath) ta->name= MEM_mallocN(strlen(file)+1, "text_name"); strcpy(ta->name, file); - ta->undo_pos= -1; - ta->undo_len= TXT_INIT_UNDO; - ta->undo_buf= MEM_mallocN(ta->undo_len, "undo buf"); + init_undo_text(ta); buffer= MEM_mallocN(len, "text_buffer"); // under windows fread can return less then len bytes because @@ -458,6 +459,8 @@ Text *copy_text(Text *ta) tan->curl= tan->sell= tan->lines.first; tan->curc= tan->selc= 0; + init_undo_text(tan); + return tan; } @@ -1399,9 +1402,7 @@ static int max_undo_test(Text *text, int x) if(text->undo_len*2 > TXT_MAX_UNDO) { /* XXX error("Undo limit reached, buffer cleared\n"); */ MEM_freeN(text->undo_buf); - text->undo_len= TXT_INIT_UNDO; - text->undo_buf= MEM_mallocN(text->undo_len, "undo buf"); - text->undo_pos=-1; + init_undo_text(text); return 0; } else { void *tmp= text->undo_buf; From 6a8dc9bdec8167775611ad6304d2d23f46a7d145 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jan 2010 14:31:21 +0000 Subject: [PATCH 158/202] - UV header sync selection vert/edge/face buttons were displayed as 3 tickboxes - fix for all of them being able to be disabled at once. - 3D header now uses the rna buttons. --- release/scripts/ui/space_image.py | 65 ++++++++++--------- release/scripts/ui/space_view3d.py | 8 ++- .../editors/space_view3d/view3d_header.c | 13 ---- source/blender/makesrna/intern/rna_scene.c | 14 ++-- 4 files changed, 49 insertions(+), 51 deletions(-) diff --git a/release/scripts/ui/space_image.py b/release/scripts/ui/space_image.py index 894ec60bb64..0a8784732a6 100644 --- a/release/scripts/ui/space_image.py +++ b/release/scripts/ui/space_image.py @@ -30,7 +30,7 @@ class IMAGE_MT_view(bpy.types.Menu): sima = context.space_data # uv = sima.uv_editor - settings = context.tool_settings + toolsettings = context.tool_settings show_uvedit = sima.show_uvedit @@ -40,7 +40,7 @@ class IMAGE_MT_view(bpy.types.Menu): layout.prop(sima, "update_automatically") if show_uvedit: - layout.prop(settings, "uv_local_view") # Numpad / + layout.prop(toolsettings, "uv_local_view") # Numpad / layout.separator() @@ -201,7 +201,7 @@ class IMAGE_MT_uvs(bpy.types.Menu): sima = context.space_data uv = sima.uv_editor - settings = context.tool_settings + toolsettings = context.tool_settings layout.prop(uv, "snap_to_pixels") layout.prop(uv, "constrain_to_image_bounds") @@ -230,8 +230,8 @@ class IMAGE_MT_uvs(bpy.types.Menu): layout.separator() - layout.prop_menu_enum(settings, "proportional_editing") - layout.prop_menu_enum(settings, "proportional_editing_falloff") + layout.prop_menu_enum(toolsettings, "proportional_editing") + layout.prop_menu_enum(toolsettings, "proportional_editing_falloff") layout.separator() @@ -247,7 +247,7 @@ class IMAGE_HT_header(bpy.types.Header): sima = context.space_data ima = sima.image iuser = sima.image_user - settings = context.tool_settings + toolsettings = context.tool_settings # show_render = sima.show_render # show_paint = sima.show_paint @@ -279,22 +279,25 @@ class IMAGE_HT_header(bpy.types.Header): uvedit = sima.uv_editor layout.prop(uvedit, "pivot", text="", icon_only=True) - layout.prop(settings, "uv_sync_selection", text="") + layout.prop(toolsettings, "uv_sync_selection", text="") - if settings.uv_sync_selection: - layout.prop(settings, "mesh_selection_mode", text="", expand=True) + if toolsettings.uv_sync_selection: + row = layout.row(align=True) + row.prop(toolsettings, "mesh_selection_mode", text="", index=0, icon='VERTEXSEL') + row.prop(toolsettings, "mesh_selection_mode", text="", index=1, icon='EDGESEL') + row.prop(toolsettings, "mesh_selection_mode", text="", index=2, icon='FACESEL') else: - layout.prop(settings, "uv_selection_mode", text="", expand=True) + layout.prop(toolsettings, "uv_selection_mode", text="", expand=True) layout.prop(uvedit, "sticky_selection_mode", text="", icon_only=True) row = layout.row(align=True) - row.prop(settings, "proportional_editing", text="", icon_only=True) - if settings.proportional_editing != 'DISABLED': - row.prop(settings, "proportional_editing_falloff", text="", icon_only=True) + row.prop(toolsettings, "proportional_editing", text="", icon_only=True) + if toolsettings.proportional_editing != 'DISABLED': + row.prop(toolsettings, "proportional_editing_falloff", text="", icon_only=True) row = layout.row(align=True) - row.prop(settings, "snap", text="") - row.prop(settings, "snap_element", text="", icon_only=True) + row.prop(toolsettings, "snap", text="") + row.prop(toolsettings, "snap_element", text="", icon_only=True) # mesh = context.edit_object.data # row.prop_object(mesh, "active_uv_layer", mesh, "uv_textures") @@ -455,24 +458,24 @@ class IMAGE_PT_paint(bpy.types.Panel): def draw(self, context): layout = self.layout - settings = context.tool_settings.image_paint - brush = settings.brush + toolsettings = context.tool_settings.image_paint + brush = toolsettings.brush wide_ui = context.region.width > narrowui col = layout.split().column() row = col.row() - row.template_list(settings, "brushes", settings, "active_brush_index", rows=2) + row.template_list(toolsettings, "brushes", toolsettings, "active_brush_index", rows=2) - col.template_ID(settings, "brush", new="brush.add") + col.template_ID(toolsettings, "brush", new="brush.add") if wide_ui: sub = layout.row(align=True) else: sub = layout.column(align=True) - sub.prop_enum(settings, "tool", 'DRAW') - sub.prop_enum(settings, "tool", 'SOFTEN') - sub.prop_enum(settings, "tool", 'CLONE') - sub.prop_enum(settings, "tool", 'SMEAR') + sub.prop_enum(toolsettings, "tool", 'DRAW') + sub.prop_enum(toolsettings, "tool", 'SOFTEN') + sub.prop_enum(toolsettings, "tool", 'CLONE') + sub.prop_enum(toolsettings, "tool", 'SMEAR') if brush: col = layout.column() @@ -502,14 +505,14 @@ class IMAGE_PT_paint_stroke(bpy.types.Panel): def poll(self, context): sima = context.space_data - settings = context.tool_settings.image_paint - return sima.show_paint and settings.brush + toolsettings = context.tool_settings.image_paint + return sima.show_paint and toolsettings.brush def draw(self, context): layout = self.layout - settings = context.tool_settings.image_paint - brush = settings.brush + toolsettings = context.tool_settings.image_paint + brush = toolsettings.brush layout.prop(brush, "use_airbrush") col = layout.column() @@ -531,14 +534,14 @@ class IMAGE_PT_paint_curve(bpy.types.Panel): def poll(self, context): sima = context.space_data - settings = context.tool_settings.image_paint - return sima.show_paint and settings.brush + toolsettings = context.tool_settings.image_paint + return sima.show_paint and toolsettings.brush def draw(self, context): layout = self.layout - settings = context.tool_settings.image_paint - brush = settings.brush + toolsettings = context.tool_settings.image_paint + brush = toolsettings.brush layout.template_curve_mapping(brush, "curve") layout.operator_menu_enum("brush.curve_preset", property="shape") diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 4e394839166..af0e2ec7879 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -30,7 +30,7 @@ class VIEW3D_HT_header(bpy.types.Header): mode_string = context.mode edit_object = context.edit_object obj = context.active_object - toolsettings = context.scene.tool_settings + toolsettings = context.tool_settings row = layout.row() row.template_header() @@ -56,6 +56,12 @@ class VIEW3D_HT_header(bpy.types.Header): row.template_header_3D() + if obj and obj.mode == 'EDIT' and obj.type == 'MESH': + row_sub = row.row(align=True) + row_sub.prop(toolsettings, "mesh_selection_mode", text="", index=0, icon='VERTEXSEL') + row_sub.prop(toolsettings, "mesh_selection_mode", text="", index=1, icon='EDGESEL') + row_sub.prop(toolsettings, "mesh_selection_mode", text="", index=2, icon='FACESEL') + # Particle edit if obj and obj.mode == 'PARTICLE_EDIT': row.prop(toolsettings.particle_edit, "selection_mode", text="", expand=True, toggle=True) diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 98f0f2fec65..3ef6166bc7c 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -533,17 +533,4 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) /* Scene lock */ uiItemR(layout, "", 0, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY); } - - /* selection modus */ - if(obedit && (obedit->type == OB_MESH)) { - EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data); - - row= uiLayoutRow(layout, 1); - block= uiLayoutGetBlock(row); - uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0,0,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode"); - uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0,0,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select mode"); - uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, 0,0,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Face select mode"); - - BKE_mesh_end_editmesh(obedit->data, em); - } } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 3d36dbedd19..d68ac2ce14c 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -606,13 +606,15 @@ static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const int *value ToolSettings *ts = (ToolSettings*)ptr->data; int flag = (value[0] ? SCE_SELECT_VERTEX:0) | (value[1] ? SCE_SELECT_EDGE:0) | (value[2] ? SCE_SELECT_FACE:0); - ts->selectmode = flag; + if(flag) { + ts->selectmode = flag; - if(scene->basact) { - Mesh *me= get_mesh(scene->basact->object); - if(me && me->edit_mesh && me->edit_mesh->selectmode != flag) { - me->edit_mesh->selectmode= flag; - EM_selectmode_set(me->edit_mesh); + if(scene->basact) { + Mesh *me= get_mesh(scene->basact->object); + if(me && me->edit_mesh && me->edit_mesh->selectmode != flag) { + me->edit_mesh->selectmode= flag; + EM_selectmode_set(me->edit_mesh); + } } } } From 459f55ed9502c435d4f4117b1a053c4c598a016d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jan 2010 15:17:40 +0000 Subject: [PATCH 159/202] bugix [#20687] Selection code on duplis gets incorrect draw mode flag could make selection very slow in some cases --- source/blender/editors/space_view3d/view3d_view.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index adb1e6c6f1c..8fe34df103f 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1199,6 +1199,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b ARegion *ar= vc->ar; rctf rect; short code, hits; + char dt, dtx; G.f |= G_PICKSEL; @@ -1269,8 +1270,16 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b tbase.object= dob->ob; copy_m4_m4(dob->ob->obmat, dob->mat); + /* extra service: draw the duplicator in drawtype of parent */ + /* MIN2 for the drawtype to allow bounding box objects in groups for lods */ + dt= tbase.object->dt; tbase.object->dt= MIN2(tbase.object->dt, base->object->dt); + dtx= tbase.object->dtx; tbase.object->dtx= base->object->dtx; + draw_object(scene, ar, v3d, &tbase, DRAW_PICKING|DRAW_CONSTCOLOR); + tbase.object->dt= dt; + tbase.object->dtx= dtx; + copy_m4_m4(dob->ob->obmat, dob->omat); } free_object_duplilist(lb); From 7bea39af62d8e83c7e375b925b5eee2aee851f66 Mon Sep 17 00:00:00 2001 From: Arystanbek Dyussenov Date: Sat, 16 Jan 2010 15:20:27 +0000 Subject: [PATCH 160/202] Workaround to fix #20645. Iteration over multidim arrays and slicing of them is broken. Before fixing this I'd like to clean BPY a bit. --- release/scripts/io/export_fbx.py | 7 ++++--- release/scripts/io/export_obj.py | 3 ++- release/scripts/io/export_x3d.py | 4 +++- source/blender/python/intern/bpy_array.c | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/release/scripts/io/export_fbx.py b/release/scripts/io/export_fbx.py index a7e126446bd..ffd7c3f3efa 100644 --- a/release/scripts/io/export_fbx.py +++ b/release/scripts/io/export_fbx.py @@ -1751,9 +1751,10 @@ def write(filename, batch_objects = None, \ ii = 0 # Count how many UVs we write for uf in uvlayer.data: -# for f in me.faces: - for uv in uf.uv: -# for uv in f.uv: +# for f in me.faces: + # workaround, since uf.uv iteration is wrong atm + for uv in [uf.uv1, uf.uv2, uf.uv3, uf.uv4][:len(uf.uv)]: +# for uv in f.uv: if i==-1: file.write('%.6f,%.6f' % tuple(uv)) i=0 diff --git a/release/scripts/io/export_obj.py b/release/scripts/io/export_obj.py index 8d1a9a9aced..7c4c83c53c7 100644 --- a/release/scripts/io/export_obj.py +++ b/release/scripts/io/export_obj.py @@ -563,7 +563,8 @@ def write(filename, objects, scene, tface = uv_layer.data[f_index] - uvs = tface.uv + # workaround, since tface.uv iteration is wrong atm + uvs = [tface.uv1, tface.uv2, tface.uv3, tface.uv4][:len(tface.uv)] # uvs = [tface.uv1, tface.uv2, tface.uv3] # # add another UV if it's a quad diff --git a/release/scripts/io/export_x3d.py b/release/scripts/io/export_x3d.py index 6b94a0cc91a..c492c4a6b15 100644 --- a/release/scripts/io/export_x3d.py +++ b/release/scripts/io/export_x3d.py @@ -616,7 +616,8 @@ class x3d_class: for face in mesh.active_uv_texture.data: # for face in mesh.faces: - uvs = face.uv + # workaround, since tface.uv iteration is wrong atm + uvs = [face.uv1, face.uv2, face.uv3, face.uv4][:len(face.uv)] # uvs = [face.uv1, face.uv2, face.uv3, face.uv4] if face.verts[3] else [face.uv1, face.uv2, face.uv3] for uv in uvs: @@ -625,6 +626,7 @@ class x3d_class: texCoordList.append(uv) j=j+1 texIndexList.append(-1) + if self.writingtexture == 0: self.file.write("\n\t\t\ttexCoordIndex=\"") texIndxStr="" diff --git a/source/blender/python/intern/bpy_array.c b/source/blender/python/intern/bpy_array.c index 5f228836b42..76c9a0f6e11 100644 --- a/source/blender/python/intern/bpy_array.c +++ b/source/blender/python/intern/bpy_array.c @@ -1,5 +1,5 @@ /** - * + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * From 70060b2936edeff58f7d80ce175e202fd1a87dfd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jan 2010 15:39:00 +0000 Subject: [PATCH 161/202] fix for own un-initialized pointer --- source/blender/blenkernel/intern/modifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 830c484b841..f09c92d6091 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -1813,7 +1813,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, int maxVerts = dm->getNumVerts(dm); int maxEdges = dm->getNumEdges(dm); int maxFaces = dm->getNumFaces(dm); - int *flip_map; + int *flip_map= NULL; int do_vgroup_mirr= (mmd->flag & MOD_MIR_VGROUP); int (*indexMap)[2]; float mtx[4][4], imtx[4][4]; From 083e5b66a971fe7c03e91fad1cfbcd698e1b0a7e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jan 2010 17:47:56 +0000 Subject: [PATCH 162/202] GPU_buffer_setup could return a freed buffer. (when VBO's were used) --- source/blender/gpu/intern/gpu_buffers.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 33aa4168ff8..6590d838b90 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -772,6 +772,7 @@ GPUBuffer *GPU_buffer_setup( DerivedMesh *dm, GPUDrawObject *object, int size, G DEBUG_VBO( "Failed to map buffer to client address space\n" ); GPU_buffer_free( buffer, globalPool ); GPU_buffer_pool_delete_last( globalPool ); + buffer= NULL; if( globalPool->size > 0 ) { GPU_buffer_pool_delete_last( globalPool ); buffer = GPU_buffer_alloc( size, globalPool ); From 86414f48809413a326db2529486f302233a07e38 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jan 2010 22:03:26 +0000 Subject: [PATCH 163/202] from freakabcd to compile with MSVC10 (beta) --- intern/bsp/intern/BSP_CSGMesh.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/intern/bsp/intern/BSP_CSGMesh.cpp b/intern/bsp/intern/BSP_CSGMesh.cpp index ca7795b3cf5..8f14cb597e4 100644 --- a/intern/bsp/intern/BSP_CSGMesh.cpp +++ b/intern/bsp/intern/BSP_CSGMesh.cpp @@ -33,6 +33,9 @@ #include "MT_Plane3.h" #include "BSP_CSGException.h" +// for insert_iterator +#include + // for vector reverse #include #include From 0f55410e3d0f7997999ac8147677e572ef47e94e Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 16 Jan 2010 22:12:19 +0000 Subject: [PATCH 164/202] Short term workaround for OpenAL + pulse bugs on ubuntu. Not sure if it works, people have to test and report please, I don't have ubuntu. Longer term we hope for an update of the ubuntu packages to fix the problem. --- intern/audaspace/OpenAL/AUD_OpenALDevice.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp index 0d90b014943..087c7849a2c 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp @@ -270,7 +270,23 @@ AUD_OpenALDevice::AUD_OpenALDevice(AUD_DeviceSpecs specs, int buffersize) specs.channels = AUD_CHANNELS_STEREO; specs.format = AUD_FORMAT_S16; - m_device = alcOpenDevice(NULL); +#if 0 + if(alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT") == AL_TRUE) + { + ALCchar* devices = const_cast(alcGetString(NULL, ALC_DEVICE_SPECIFIER)); + printf("OpenAL devices (standard is: %s):\n", alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER)); + + while(*devices) + { + printf("%s\n", devices); + devices += strlen(devices) + 1; + } + } +#endif + + m_device = alcOpenDevice("ALSA Software"); + if(m_device == NULL) + m_device = alcOpenDevice(NULL); if(!m_device) AUD_THROW(AUD_ERROR_OPENAL); From 23607fc91fcf203ce87d5f53fef79e3eea0049c2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jan 2010 22:32:15 +0000 Subject: [PATCH 165/202] this isnt needed since the node window can enable it. materials also dont have this option. --- release/scripts/ui/properties_texture.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/release/scripts/ui/properties_texture.py b/release/scripts/ui/properties_texture.py index 7aafc3a839f..ab72de1abcb 100644 --- a/release/scripts/ui/properties_texture.py +++ b/release/scripts/ui/properties_texture.py @@ -131,8 +131,6 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel): col.prop(space, "brush_texture", text="Brush", toggle=True) if tex: - layout.prop(tex, "use_nodes") - split = layout.split(percentage=0.2) if tex.use_nodes: From 8c74944a8e6e21cca35a2f610360e1e2a1418b76 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jan 2010 22:53:05 +0000 Subject: [PATCH 166/202] debug prints are too much on my system it hangs ddd. --- source/blender/blenloader/intern/readfile.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6bf347e9bd5..3bb94ecf169 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -10691,7 +10691,8 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old) if(id==NULL) { read_libblock(fd, ptr, bhead, LIB_READ+LIB_INDIRECT, NULL); - if(G.f & G_DEBUG) printf("expand_doit: other lib %s\n", lib->name); + // commented because this can print way too much + // if(G.f & G_DEBUG) printf("expand_doit: other lib %s\n", lib->name); /* for outliner dependency only */ ptr->curlib->parent= mainvar->curlib; @@ -10706,7 +10707,8 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old) /*oldnewmap_insert(fd->libmap, bhead->old, id, 1);*/ change_idid_adr_fd(fd, bhead->old, id); - if(G.f & G_DEBUG) printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name); + // commented because this can print way too much + // if(G.f & G_DEBUG) printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name); } MEM_freeN(lib); From 9c9209f7e59d1561935ddeb7f5f42181ac965a86 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jan 2010 22:56:52 +0000 Subject: [PATCH 167/202] resizing any area/region would redraw all views in every window. This means a large scene will make blender resize the border between the timeline and the graph editor slow since it redraws the 3d view for each update. edited the operators to only redraw whats needed. since tons away IFDEF'd this incse it needs to be reverted. --- source/blender/editors/screen/area.c | 2 + source/blender/editors/screen/screen_intern.h | 3 + source/blender/editors/screen/screen_ops.c | 59 +++++++++++++++++-- 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index bf4dba5a4fe..56dd9b4a361 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -121,10 +121,12 @@ void ED_region_do_listen(ARegion *ar, wmNotifier *note) case NC_WINDOW: ED_region_tag_redraw(ar); break; +#ifndef WM_FAST_DRAW case NC_SCREEN: if(note->action==NA_EDITED) ED_region_tag_redraw(ar); /* pass on */ +#endif default: if(ar->type && ar->type->listener) ar->type->listener(ar, note); diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index 6278ea8db88..d7d94a9ec62 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -60,6 +60,9 @@ void ed_screen_context(const bContext *C, const char *member, bContextDataResult void SCREEN_OT_screenshot(struct wmOperatorType *ot); void SCREEN_OT_screencast(struct wmOperatorType *ot); +/* partial updates, much faster then drawing everything, ton is away so allow easy undo'ing - campbell */ +#define WM_FAST_DRAW + #endif /* ED_SCREEN_INTERN_H */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 912ac98aee4..4461549aa28 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -640,6 +640,11 @@ static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event) area_swap_exit(C, op); +#ifdef WM_FAST_DRAW + ED_area_tag_redraw(sad->sa1); + ED_area_tag_redraw(sad->sa2); +#endif + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -708,6 +713,10 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event) /* copy area to new screen */ area_copy_data((ScrArea *)newsc->areabase.first, sa, 0); +#ifdef WM_FAST_DRAW + ED_area_tag_redraw((ScrArea *)newsc->areabase.first); +#endif + /* screen, areas init */ WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); @@ -854,8 +863,16 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int } } } - - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); +#ifdef WM_FAST_DRAW + { + ScrArea *sa; + for(sa= sc->areabase.first; sa; sa= sa->next) + if(sa->v1->flag || sa->v2->flag || sa->v3->flag || sa->v4->flag) + ED_area_tag_redraw(sa); + } + +#endif + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); /* redraw everything */ } static void area_move_apply(bContext *C, wmOperator *op) @@ -1116,7 +1133,11 @@ static int area_split_apply(bContext *C, wmOperator *op) if(dir=='h') sd->origval= sd->nedge->v1->vec.y; else sd->origval= sd->nedge->v1->vec.x; - + +#ifdef WM_FAST_DRAW + ED_area_tag_redraw(sd->sarea); + ED_area_tag_redraw(sd->narea); +#endif WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); return 1; @@ -1128,6 +1149,12 @@ static int area_split_apply(bContext *C, wmOperator *op) static void area_split_exit(bContext *C, wmOperator *op) { if (op->customdata) { +#ifdef WM_FAST_DRAW + sAreaSplitData *sd= (sAreaSplitData *)op->customdata; + if(sd->sarea) ED_area_tag_redraw(sd->sarea); + if(sd->narea) ED_area_tag_redraw(sd->narea); +#endif + MEM_freeN(op->customdata); op->customdata = NULL; } @@ -1250,8 +1277,6 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) fac= (dir == 'v') ? event->x-sd->origmin : event->y-sd->origmin; RNA_float_set(op->ptr, "factor", fac / (float)sd->origsize); - - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); break; case LEFTMOUSE: @@ -1414,7 +1439,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) else if(rmd->ar->flag & RGN_FLAG_HIDDEN) ED_region_toggle_hidden(C, rmd->ar); } - +#ifdef WM_FAST_DRAW + ED_area_tag_redraw(rmd->sa); +#endif WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); break; @@ -1425,6 +1452,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) if(ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { if(rmd->ar->flag & RGN_FLAG_HIDDEN) { ED_region_toggle_hidden(C, rmd->ar); +#ifdef WM_FAST_DRAW + ED_area_tag_redraw(rmd->sa); +#endif WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } } @@ -1907,6 +1937,10 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) break; case LEFTMOUSE: if(event->val==KM_RELEASE) { +#ifdef WM_FAST_DRAW + ED_area_tag_redraw(jd->sa1); + ED_area_tag_redraw(jd->sa2); +#endif area_join_apply(C, op); WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); area_join_exit(C, op); @@ -2089,6 +2123,9 @@ static int region_quadview_exec(bContext *C, wmOperator *op) MEM_freeN(ar); } } +#ifdef WM_FAST_DRAW + ED_area_tag_redraw(sa); +#endif WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } else if(ar->next) @@ -2125,6 +2162,9 @@ static int region_quadview_exec(bContext *C, wmOperator *op) rv3d->view= RV3D_VIEW_CAMERA; rv3d->persp= RV3D_CAMOB; } +#ifdef WM_FAST_DRAW + ED_area_tag_redraw(sa); +#endif WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } @@ -2167,6 +2207,9 @@ static int region_flip_exec(bContext *C, wmOperator *op) else if(ar->alignment==RGN_ALIGN_RIGHT) ar->alignment= RGN_ALIGN_LEFT; +#ifdef WM_FAST_DRAW + ED_area_tag_redraw(CTX_wm_area(C)); +#endif WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -2220,6 +2263,10 @@ static int header_flip_exec(bContext *C, wmOperator *op) else if(ar->alignment==RGN_ALIGN_RIGHT) ar->alignment= RGN_ALIGN_LEFT; +#ifdef WM_FAST_DRAW + ED_area_tag_redraw(CTX_wm_area(C)); +#endif + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); printf("executed header region flip\n"); From 68c8054191560d68a9856e60311ed410cd32e5c7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jan 2010 23:53:51 +0000 Subject: [PATCH 168/202] patch [#20560] [patch] KX_GameObject.obcolor by Mitchell Stokes (moguri) * renamed attribute obcolor to color --- source/gameengine/Ketsji/KX_GameObject.cpp | 37 +++++++++++++++++++++- source/gameengine/Ketsji/KX_GameObject.h | 5 +++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6865f9f04a2..1b9c82b432c 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -811,6 +811,11 @@ void KX_GameObject::SetObjectColor(const MT_Vector4& rgbavec) m_objectColor = rgbavec; } +const MT_Vector4& KX_GameObject::GetObjectColor() +{ + return m_objectColor; +} + void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) { MT_Matrix3x3 orimat; @@ -1238,6 +1243,7 @@ void KX_GameObject::Relink(GEN_Map *map_parameter) #define MATHUTILS_VEC_CB_SCALE_LOCAL 3 #define MATHUTILS_VEC_CB_SCALE_GLOBAL 4 #define MATHUTILS_VEC_CB_INERTIA_LOCAL 5 +#define MATHUTILS_VEC_CB_OBJECT_COLOR 6 static int mathutils_kxgameob_vector_cb_index= -1; /* index for our callbacks */ @@ -1273,6 +1279,9 @@ static int mathutils_kxgameob_vector_get(PyObject *self_v, int subtype, float *v if(!self->GetPhysicsController()) return 0; self->GetPhysicsController()->GetLocalInertia().getValue(vec_from); break; + case MATHUTILS_VEC_CB_OBJECT_COLOR: + self->GetObjectColor().getValue(vec_from); + break; } return 1; @@ -1302,6 +1311,9 @@ static int mathutils_kxgameob_vector_set(PyObject *self_v, int subtype, float *v case MATHUTILS_VEC_CB_INERTIA_LOCAL: /* read only */ break; + case MATHUTILS_VEC_CB_OBJECT_COLOR: + self->SetObjectColor(MT_Vector4(vec_to)); + break; } return 1; @@ -1475,6 +1487,7 @@ PyAttributeDef KX_GameObject::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("children", KX_GameObject, pyattr_get_children), KX_PYATTRIBUTE_RO_FUNCTION("childrenRecursive", KX_GameObject, pyattr_get_children_recursive), KX_PYATTRIBUTE_RO_FUNCTION("attrDict", KX_GameObject, pyattr_get_attrDict), + KX_PYATTRIBUTE_RW_FUNCTION("obcolor", KX_GameObject, pyattr_get_obcolor, pyattr_set_obcolor), /* Experemental, dont rely on these yet */ KX_PYATTRIBUTE_RO_FUNCTION("sensors", KX_GameObject, pyattr_get_sensors), @@ -2033,7 +2046,28 @@ PyObject* KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DE return meshes; } -/* experemental! */ +PyObject* KX_GameObject::pyattr_get_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ +#ifdef USE_MATHUTILS + return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 4, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_OBJECT_COLOR); +#else + KX_GameObject* self= static_cast(self_v); + return PyObjectFrom(self->GetObjectColor()); +#endif +} + +int KX_GameObject::pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) +{ + KX_GameObject* self= static_cast(self_v); + MT_Vector4 obcolor; + if (!PyVecTo(value, obcolor)) + return PY_SET_ATTR_FAIL; + + self->SetObjectColor(obcolor); + return PY_SET_ATTR_SUCCESS; +} + +/* These are experimental! */ PyObject* KX_GameObject::pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { return KX_PythonSeq_CreatePyObject((static_cast(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_SENSORS); @@ -2048,6 +2082,7 @@ PyObject* KX_GameObject::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE { return KX_PythonSeq_CreatePyObject((static_cast(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_ACTUATORS); } +/* End experimental */ PyObject* KX_GameObject::pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 41e04eef91c..596e69f25b3 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -339,6 +339,9 @@ public: const MT_Vector4& rgbavec ); + const MT_Vector4& + GetObjectColor(); + void ResolveCombinedVelocities( @@ -882,6 +885,8 @@ public: static PyObject* pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject* pyattr_get_obcolor(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef); + static int pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); /* Experemental! */ static PyObject* pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); From a806cfb6a59971bd00a49fcab678d9fae659e851 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sun, 17 Jan 2010 02:10:54 +0000 Subject: [PATCH 169/202] Test Editor fix: Ctrl+LEFT/RIGHT was set twice (one of them wrongly) --- source/blender/editors/space_text/space_text.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index c7601ef692e..80e6c89fc34 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -280,8 +280,6 @@ static void text_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", HOMEKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_BEGIN); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", ENDKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_END); - RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", LINE_BEGIN); - RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", LINE_END); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", EKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", LINE_END); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", EKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "type", LINE_END); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_CHAR); From e02ad764eeef214bd550d4266dc2d582bd7060ec Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sun, 17 Jan 2010 03:15:27 +0000 Subject: [PATCH 170/202] Text Editor: indent and unindent now supports tabs/spaces according to (text->flags & TXT_TABSTOSPACES). Code-wise it looks now (again) that tab is the default. I hope that'ok. For bitwise operation it's cleaner IMO if the check is for positive values on them. * TXT_TABSIZE is still harcoded to 4 spaces * --- source/blender/blenkernel/intern/text.c | 31 +++++++++++++++++-------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index f17a3a2423f..50f7f6682f1 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2461,13 +2461,18 @@ void indent(Text *text) { int len, num; char *tmp; - /* char *addtab = "\t"; - int tablen = 1; */ + + char *add = "\t"; + int indentlen = 1; + /* hardcoded: TXT_TABSIZE = 4 spaces: */ int spaceslen = TXT_TABSIZE; - /* hardcoded: use spaces: */ - char *add = tab_to_spaces; - int indentlen = spaceslen; + + /* insert spaces rather then tabs */ + if (text->flags & TXT_TABSTOSPACES){ + add = tab_to_spaces; + indentlen = spaceslen; + } if (!text) return; if (!text->curl) return; @@ -2518,11 +2523,17 @@ void indent(Text *text) void unindent(Text *text) { int num = 0; - /* char *rmtab = "\t"; */ - char *remove = tab_to_spaces; - /* int indenttab = 1; */ - int indentspaces = TXT_TABSIZE; - int indent = indentspaces; + char *remove = "\t"; + int indent = 1; + + /* hardcoded: TXT_TABSIZE = 4 spaces: */ + int spaceslen = TXT_TABSIZE; + + /* insert spaces rather then tabs */ + if (text->flags & TXT_TABSTOSPACES){ + remove = tab_to_spaces; + indent = spaceslen; + } if (!text) return; if (!text->curl) return; From e53043189316ddca2e6f084de4f7ed19c7fff7c6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Jan 2010 14:04:40 +0000 Subject: [PATCH 171/202] have makesrna only replace newly generated files when their contents changes. previously changing one rna_*.c file would rebuild them all making it slow to test small changes on the rna api. also made errors in rna and dna generated give C defined #error's and line numbers that cause them. --- source/blender/makesdna/intern/makesdna.c | 6 +- source/blender/makesrna/intern/makesrna.c | 101 +++++++++++++++++++--- 2 files changed, 93 insertions(+), 14 deletions(-) diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index cae28f163ed..905dae7b0a5 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -1050,10 +1050,10 @@ int make_structDNA(char *baseDirectory, FILE *file) /* ************************* END MAKE DNA ********************** */ -static void make_bad_file(char *file) +static void make_bad_file(char *file, int line) { FILE *fp= fopen(file, "w"); - fprintf(fp, "ERROR! Cannot make correct DNA.c file, STUPID!\n"); + fprintf(fp, "#error \"Error! can't make correct DNA.c file from %s:%d, STUPID!\"\n", __FILE__, line); fclose(fp); } @@ -1087,7 +1087,7 @@ int main(int argc, char ** argv) if (make_structDNA(baseDirectory, file)) { // error fclose(file); - make_bad_file(argv[1]); + make_bad_file(argv[1], __LINE__); return_status = 1; } else { fprintf(file, "};\n"); diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index a03903eb652..3ca30709d34 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -44,6 +44,82 @@ #endif #endif +/* Replace if different */ +#define TMP_EXT ".tmp" + +static int replace_if_different(char *tmpfile) +{ + +#define REN_IF_DIFF \ + if(rename(tmpfile, orgfile) != 0) { \ + fprintf(stderr, "%s:%d, rename error: \"%s\" -> \"%s\"", __FILE__, __LINE__, tmpfile, orgfile); \ + return -1; \ + } \ + remove(tmpfile); \ + return 1; \ + + + FILE *fp_new, *fp_org; + int len_new, len_org; + char *arr_new, *arr_org; + int cmp; + + char orgfile[4096]; + + strcpy(orgfile, tmpfile); + orgfile[strlen(orgfile) - strlen(TMP_EXT)] = '\0'; /* strip '.tmp' */ + + fp_org= fopen(orgfile, "rb"); + + if(fp_org==NULL) { + REN_IF_DIFF; + } + + fp_new= fopen(tmpfile, "rb"); + + if(fp_new==NULL) { + /* shouldn't happen, just to be safe */ + fprintf(stderr, "%s:%d, open error: \"%s\"", __FILE__, __LINE__, tmpfile); + return -1; + } + + fseek(fp_new, 0L, SEEK_END); len_new = ftell(fp_new); fseek(fp_new, 0L, SEEK_SET); + fseek(fp_org, 0L, SEEK_END); len_org = ftell(fp_org); fseek(fp_org, 0L, SEEK_SET); + + + if(len_new != len_org) { + fclose(fp_new); + fclose(fp_org); + REN_IF_DIFF; + } + + /* now compare the files... */ + arr_new= MEM_mallocN(sizeof(char)*len_new, "rna_cmp_file_new"); + arr_org= MEM_mallocN(sizeof(char)*len_org, "rna_cmp_file_org"); + + fread(arr_new, sizeof(char), len_new, fp_new); + fread(arr_org, sizeof(char), len_org, fp_org); + + fclose(fp_new); + fclose(fp_org); + + cmp= memcmp(arr_new, arr_org, len_new); + + MEM_freeN(arr_new); + MEM_freeN(arr_org); + + if(cmp) { + REN_IF_DIFF; + } + else { + return 0; + } + +#undef REN_IF_DIFF +} + + + /* Sorting */ static int cmp_struct(const void *a, const void *b) @@ -2340,10 +2416,10 @@ static void rna_generate_header_cpp(BlenderRNA *brna, FILE *f) fprintf(f, "}\n\n#endif /* __RNA_BLENDER_CPP_H__ */\n\n"); } -static void make_bad_file(char *file) +static void make_bad_file(char *file, int line) { FILE *fp= fopen(file, "w"); - fprintf(fp, "ERROR! Cannot make correct RNA file, STUPID!\n"); + fprintf(fp, "#error \"Error! can't make correct RNA file from %s:%d, STUPID!\"\n", __FILE__, line); fclose(fp); } @@ -2373,12 +2449,12 @@ static int rna_preprocess(char *outfile) /* create RNA_blender_cpp.h */ strcpy(deffile, outfile); - strcat(deffile, "RNA_blender_cpp.h"); + strcat(deffile, "RNA_blender_cpp.h" TMP_EXT); status= (DefRNA.error != 0); if(status) { - make_bad_file(deffile); + make_bad_file(deffile, __LINE__); } else { file = fopen(deffile, "w"); @@ -2390,11 +2466,12 @@ static int rna_preprocess(char *outfile) else { rna_generate_header_cpp(brna, file); fclose(file); - status= (DefRNA.error != 0); } } + replace_if_different(deffile); + rna_sort(brna); /* create rna_gen_*.c files */ @@ -2402,10 +2479,10 @@ static int rna_preprocess(char *outfile) strcpy(deffile, outfile); strcat(deffile, PROCESS_ITEMS[i].filename); deffile[strlen(deffile)-2] = '\0'; - strcat(deffile, "_gen.c"); + strcat(deffile, "_gen.c" TMP_EXT); if(status) { - make_bad_file(deffile); + make_bad_file(deffile, __LINE__); } else { file = fopen(deffile, "w"); @@ -2417,18 +2494,19 @@ static int rna_preprocess(char *outfile) else { rna_generate(brna, file, PROCESS_ITEMS[i].filename, PROCESS_ITEMS[i].api_filename); fclose(file); - status= (DefRNA.error != 0); } } + + replace_if_different(deffile); } /* create RNA_blender.h */ strcpy(deffile, outfile); - strcat(deffile, "RNA_blender.h"); + strcat(deffile, "RNA_blender.h" TMP_EXT); if(status) { - make_bad_file(deffile); + make_bad_file(deffile, __LINE__); } else { file = fopen(deffile, "w"); @@ -2440,11 +2518,12 @@ static int rna_preprocess(char *outfile) else { rna_generate_header(brna, file); fclose(file); - status= (DefRNA.error != 0); } } + replace_if_different(deffile); + /* free RNA */ RNA_define_free(brna); RNA_free(brna); From 870df309c52a582d94f847c13a6166699e3b781c Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Sun, 17 Jan 2010 14:47:14 +0000 Subject: [PATCH 172/202] MSVC 9 projectfiles * update for animviz.c * updated glew dependency for ghost. --- intern/ghost/make/msvc_9_0/ghost.vcproj | 8 ++++---- projectfiles_vc9/blender/makesrna/RNA_makesrna.vcproj | 4 ++++ projectfiles_vc9/blender/makesrna/RNA_rna.vcproj | 8 ++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/intern/ghost/make/msvc_9_0/ghost.vcproj b/intern/ghost/make/msvc_9_0/ghost.vcproj index 4e4d9bb6598..bf41e4e566e 100644 --- a/intern/ghost/make/msvc_9_0/ghost.vcproj +++ b/intern/ghost/make/msvc_9_0/ghost.vcproj @@ -44,7 +44,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\lib\windows\wintab\INCLUDE" + AdditionalIncludeDirectories="..\..;..\..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\..\lib\windows\wintab\INCLUDE;..\..\..\..\..\build\msvc_9\extern\glew\include" PreprocessorDefinitions="WIN32,NDEBUG,_LIB" StringPooling="true" RuntimeLibrary="0" @@ -120,7 +120,7 @@ + + diff --git a/projectfiles_vc9/blender/makesrna/RNA_rna.vcproj b/projectfiles_vc9/blender/makesrna/RNA_rna.vcproj index 315d32ae94c..44267be7ba5 100644 --- a/projectfiles_vc9/blender/makesrna/RNA_rna.vcproj +++ b/projectfiles_vc9/blender/makesrna/RNA_rna.vcproj @@ -182,6 +182,10 @@ RelativePath="..\..\..\source\blender\makesrna\intern\rna_animation_gen.c" > + + @@ -350,6 +354,10 @@ RelativePath="..\..\..\source\blender\makesrna\intern\rna_space_gen.c" > + + From e682febe24fdf73e92ab59ad9938f77d821097bf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Jan 2010 16:00:54 +0000 Subject: [PATCH 173/202] fix for own bug in name flipping, was modifying the original name (very bad!). --- source/blender/blenkernel/intern/deform.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 620e114bad2..c4d5f4952b6 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -285,7 +285,7 @@ void unique_vertexgroup_name (bDeformGroup *dg, Object *ob) /* finds the best possible flipped name. For renaming; check for unique names afterwards */ /* if strip_number: removes number extensions */ -void flip_vertexgroup_name (char *name_r, const char *name, int strip_number) +void flip_vertexgroup_name (char *name, const char *from_name, int strip_number) { int len; char prefix[sizeof((bDeformGroup *)NULL)->name]={""}; /* The part before the facing */ @@ -294,9 +294,11 @@ void flip_vertexgroup_name (char *name_r, const char *name, int strip_number) char number[sizeof((bDeformGroup *)NULL)->name]={""}; /* The number extension string */ char *index=NULL; - len= strlen(name); + len= strlen(from_name); if(len<3) return; // we don't do names like .R or .L + strcpy(name, from_name); + /* We first check the case with a .### extension, let's find the last period */ if(isdigit(name[len-1])) { index= strrchr(name, '.'); // last occurrence @@ -392,7 +394,7 @@ void flip_vertexgroup_name (char *name_r, const char *name, int strip_number) #undef IS_SEPARATOR - sprintf (name_r, "%s%s%s%s", prefix, replace, suffix, number); + sprintf (name, "%s%s%s%s", prefix, replace, suffix, number); } From 50b35842d9d4645f8fcab9800539117070c2343a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Jan 2010 17:36:11 +0000 Subject: [PATCH 174/202] bugfix [#20712] wavefront obj import fails with default import settings --- release/scripts/io/import_scene_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/io/import_scene_obj.py b/release/scripts/io/import_scene_obj.py index ecd45f54946..5d2d475c7c6 100644 --- a/release/scripts/io/import_scene_obj.py +++ b/release/scripts/io/import_scene_obj.py @@ -481,7 +481,7 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_ context_material.specular_hardness = int((float(line_split[1])*0.51)) # context_material.setHardness( int((float(line_split[1])*0.51)) ) elif line_lower.startswith('ni'): # Refraction index - context_material.ior = max(1, min(float(line_split[1]), 3)) + context_material.raytrace_transparency.ior = max(1, min(float(line_split[1]), 3)) # context_material.setIOR( max(1, min(float(line_split[1]), 3))) # Between 1 and 3 elif line_lower.startswith('d') or line_lower.startswith('tr'): context_material.alpha = float(line_split[1]) From 42baabba5da44505bbd94a845a96bb1c6fe18eda Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 17 Jan 2010 19:19:15 +0000 Subject: [PATCH 175/202] Fix link libraries for Win32 Cmake debug build. Unfortunately, debug builds are still crashing at startup - need to investigate further. --- CMake/macros.cmake | 28 ++++++++++++++++++++++++---- source/creator/CMakeLists.txt | 1 + 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CMake/macros.cmake b/CMake/macros.cmake index 258cbdf57b6..1e8fe391918 100644 --- a/CMake/macros.cmake +++ b/CMake/macros.cmake @@ -135,15 +135,35 @@ MACRO(SETUP_LIBLINKS TARGET_LINK_LIBRARIES(${target} ${QUICKTIME_LIB}) ENDIF(WITH_QUICKTIME) IF(WITH_OPENEXR) - TARGET_LINK_LIBRARIES(${target} ${OPENEXR_LIB}) + IF(WIN32) + FOREACH(loop_var ${OPENEXR_LIB}) + TARGET_LINK_LIBRARIES(${target} debug ${loop_var}_d) + TARGET_LINK_LIBRARIES(${target} optimized ${loop_var}) + ENDFOREACH(loop_var) + ELSEIF(WIN32) + TARGET_LINK_LIBRARIES(${target} ${OPENEXR_LIB}) + ENDIF(WIN32) ENDIF(WITH_OPENEXR) IF(WITH_FFMPEG) TARGET_LINK_LIBRARIES(${target} ${FFMPEG_LIB}) ENDIF(WITH_FFMPEG) IF(WITH_OPENCOLLADA) - TARGET_LINK_LIBRARIES(${target} ${OPENCOLLADA_LIB}) - TARGET_LINK_LIBRARIES(${target} ${PCRE_LIB}) - TARGET_LINK_LIBRARIES(${target} ${EXPAT_LIB}) + IF(WIN32) + FOREACH(loop_var ${OPENCOLLADA_LIB}) + TARGET_LINK_LIBRARIES(${target} debug ${loop_var}_d) + TARGET_LINK_LIBRARIES(${target} optimized ${loop_var}) + ENDFOREACH(loop_var) + TARGET_LINK_LIBRARIES(${target} debug ${PCRE_LIB}_d) + TARGET_LINK_LIBRARIES(${target} optimized ${PCRE_LIB}) + IF(EXPAT_LIB) + TARGET_LINK_LIBRARIES(${target} debug ${EXPAT_LIB}_d) + TARGET_LINK_LIBRARIES(${target} optimized ${EXPAT_LIB}) + ENDIF(EXPAT_LIB) + ELSE(WIN32) + TARGET_LINK_LIBRARIES(${target} ${OPENCOLLADA_LIB}) + TARGET_LINK_LIBRARIES(${target} ${PCRE_LIB}) + TARGET_LINK_LIBRARIES(${target} ${EXPAT_LIB}) + ENDIF(WIN32) ENDIF(WITH_OPENCOLLADA) IF(WIN32) TARGET_LINK_LIBRARIES(${target} ${PTHREADS_LIB}) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index a11e83c9312..55d567fbdaa 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -273,6 +273,7 @@ IF(WITH_INSTALL) POST_BUILD MAIN_DEPENDENCY blender COMMAND copy /Y \"${WIN_LIBDIR}\\release\\python31.zip\" \"${TARGETDIR}\\\" + COMMAND copy /Y \"${WIN_LIBDIR}\\release\\python31.zip\" \"${TARGETDIR}\\python31_d.zip\" COMMAND copy /Y \"${WIN_LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\" COMMAND copy /Y \"${WIN_LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\" COMMAND copy /Y \"${WIN_LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\" From de59a6c9430088905e928c4113e663b3a7d301fe Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 17 Jan 2010 19:19:33 +0000 Subject: [PATCH 176/202] Update MSVC project files --- intern/ghost/make/msvc_9_0/ghost.vcproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/intern/ghost/make/msvc_9_0/ghost.vcproj b/intern/ghost/make/msvc_9_0/ghost.vcproj index bf41e4e566e..1bb52ba16b6 100644 --- a/intern/ghost/make/msvc_9_0/ghost.vcproj +++ b/intern/ghost/make/msvc_9_0/ghost.vcproj @@ -388,6 +388,10 @@ RelativePath="..\..\intern\GHOST_EventPrinter.h" > + + From 4c49c95ab4ea06d0aa4638932421034ff5441c35 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 17 Jan 2010 19:20:05 +0000 Subject: [PATCH 177/202] Add more stub functions for blenderplayer. --- source/blenderplayer/bad_level_call_stubs/stubs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 190b64781e2..cb5cd7bf284 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -169,6 +169,7 @@ struct bDeformGroup *ED_vgroup_add_name(struct Object *ob, char *name){return (s void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, float weight, int assignmode){} void ED_sequencer_update_view(struct bContext *C, int view){} float ED_rollBoneToVector(struct EditBone *bone, float new_up_axis[3]){return 0.0f;} +int ED_mesh_color_add(struct bContext *C, struct Scene *scene, struct Object *ob, struct Mesh *me) {return 0;} void EM_selectmode_set(struct EditMesh *em){} void make_editMesh(struct Scene *scene, struct Object *ob){} @@ -221,7 +222,9 @@ void uiTemplateHeader3D(struct uiLayout *layout, struct bContext *C){} void uiTemplateTextureImage(struct uiLayout *layout, struct bContext *C, struct Tex *tex){} void uiTemplateImage(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, struct PointerRNA *userptr, int compact){} void uiTemplateDopeSheetFilter(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr){} +void uiTemplateIDPreview(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, int rows, int cols) {} void uiTemplateColorWheel(struct uiLayout *layout, struct PointerRNA *ptr, char *propname, int value_slider){} + /* rna render */ struct RenderResult *RE_engine_begin_result(struct RenderEngine *engine, int x, int y, int w, int h){return (struct RenderResult *) NULL;} struct RenderResult *RE_AcquireResultRead(struct Render *re){return (struct RenderResult *) NULL;} From 55756719fbebf4ffdf0485de58532c73f84ecaac Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sun, 17 Jan 2010 19:34:01 +0000 Subject: [PATCH 178/202] cmake fix for Windows: link OpenCollada _d.lib in debug builds and .lib in release builds this prevents crashing at startup of Blender in debug builds with cmake. See bugreport by Andrea in the mailinglist here: http://www.mail-archive.com/bf-committers@blender.org/msg00668.html Also enabled WITH_OPENCOLLADA in cmake by default so the feature gets tested. If other devs like to keep OpenCollada it disabled, please revert the ON to OFF again. --- CMakeLists.txt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a926b486746..a8c6e66678a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ OPTION(WITH_LZMA "Enable best LZMA compression, used for pointcache" ON OPTION(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation" OFF) OPTION(WITH_BUILDINFO "Include extra build details" ON) OPTION(WITH_INSTALL "Install accompanying scripts and language files needed to run blender" ON) -OPTION(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org/)" OFF) +OPTION(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org/)" ON) # Unix defaults to OpenMP On IF (UNIX) @@ -414,7 +414,23 @@ IF(WIN32) SET(OPENCOLLADA ${LIBDIR}/opencollada) SET(OPENCOLLADA_INC ${OPENCOLLADA}/include) SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib) - SET(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2 ) + SET(OPENCOLLADA_LIB + debug OpenCOLLADASaxFrameworkLoader_d + debug OpenCOLLADAFramework_d + debug OpenCOLLADABaseUtils_d + debug OpenCOLLADAStreamWriter_d + debug MathMLSolver_d + debug GeneratedSaxParser_d + debug UTF_d + debug xml2_d + optimized OpenCOLLADASaxFrameworkLoader + optimized OpenCOLLADAFramework + optimized OpenCOLLADABaseUtils + optimized OpenCOLLADAStreamWriter + optimized MathMLSolver + optimized GeneratedSaxParser + optimized UTF + optimized xml2 ) #pcre is bundled with openCollada #SET(PCRE ${LIBDIR}/pcre) #SET(PCRE_LIBPATH ${PCRE}/lib) From c7dfa96aeac0940b093efed9b818e0c0d3c9feba Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Jan 2010 20:06:34 +0000 Subject: [PATCH 179/202] bugfix [#20639] BF25_SVN_25888 and below - OBJ and 3DS import fails blender supports type changing for textures in a way that python doesnt. add a new general function. Example usage: tex = bpy.data.textures.new("Foo") tex.type = 'IMAGE' tex = tex.recast_type() Macro to give the number of users accounting for fake user. ID_REAL_USERS(id) Use this so you can remove a datablock if it has a fake users as well as apply transformations to it in the 3D view. Move api function bpy.data.add_texture() --> bpy.data.textures.new()/remove() --- release/scripts/io/import_scene_3ds.py | 3 +- release/scripts/io/import_scene_obj.py | 3 +- source/blender/blenkernel/BKE_deform.h | 2 +- .../blender/editors/object/object_transform.c | 8 +-- source/blender/makesdna/DNA_ID.h | 2 + source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/RNA_enum_types.h | 2 + source/blender/makesrna/RNA_types.h | 1 + source/blender/makesrna/intern/rna_access.c | 24 +++++++ source/blender/makesrna/intern/rna_main_api.c | 71 +++++++++++++------ source/blender/makesrna/intern/rna_texture.c | 40 +++++------ source/blender/python/intern/bpy_rna.c | 8 +++ 12 files changed, 116 insertions(+), 49 deletions(-) diff --git a/release/scripts/io/import_scene_3ds.py b/release/scripts/io/import_scene_3ds.py index ed94d133ccb..971d62d8e15 100644 --- a/release/scripts/io/import_scene_3ds.py +++ b/release/scripts/io/import_scene_3ds.py @@ -507,8 +507,9 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH): return [float(col)/255 for col in struct.unpack('<3B', temp_data)] # data [0,1,2] == rgb def read_texture(new_chunk, temp_chunk, name, mapto): - new_texture = bpy.data.add_texture('Diffuse') + new_texture = bpy.data.textures.new('Diffuse') new_texture.type = 'IMAGE' + new_texture = new_texture.recast_type() img = None while (new_chunk.bytes_read < new_chunk.length): diff --git a/release/scripts/io/import_scene_obj.py b/release/scripts/io/import_scene_obj.py index 5d2d475c7c6..c703a9789bf 100644 --- a/release/scripts/io/import_scene_obj.py +++ b/release/scripts/io/import_scene_obj.py @@ -367,8 +367,9 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_ #==================================================================================# def load_material_image(blender_material, context_material_name, imagepath, type): - texture= bpy.data.add_texture(type) + texture= bpy.data.textures.new(type) texture.type= 'IMAGE' + texture = texture.recast_type() # Workaround for limitation in rna api. # texture= bpy.data.textures.new(type) # texture.setType('Image') diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index d9cf6bc8feb..59acea3c552 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -47,7 +47,7 @@ int get_defgroup_num (struct Object *ob, struct bDeformGroup *dg); int *get_defgroup_flip_map(struct Object *ob); int get_named_vertexgroup_num (Object *ob, const char *name); void unique_vertexgroup_name (struct bDeformGroup *dg, struct Object *ob); -void flip_vertexgroup_name (char *name_r, const char *name, int strip_number); +void flip_vertexgroup_name (char *name, const char *from_name, int strip_number); float deformvert_get_weight(const struct MDeformVert *dvert, int group_num); float vertexgroup_get_vertex_weight(const struct MDeformVert *dvert, int index, int group_num); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 9e4cc012171..15ed20c783e 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -411,7 +411,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo if(ob->type==OB_MESH) { me= ob->data; - if(me->id.us>1) { + if(ID_REAL_USERS(me) > 1) { BKE_report(reports, RPT_ERROR, "Can't apply to a multi user mesh, doing nothing."); return OPERATOR_CANCELLED; } @@ -419,7 +419,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo else if(ob->type==OB_ARMATURE) { arm= ob->data; - if(arm->id.us>1) { + if(ID_REAL_USERS(arm) > 1) { BKE_report(reports, RPT_ERROR, "Can't apply to a multi user armature, doing nothing."); return OPERATOR_CANCELLED; } @@ -427,7 +427,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { cu= ob->data; - if(cu->id.us>1) { + if(ID_REAL_USERS(cu) > 1) { BKE_report(reports, RPT_ERROR, "Can't apply to a multi user curve, doing nothing."); return OPERATOR_CANCELLED; } @@ -984,7 +984,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (arm->id.lib) { tot_lib_error++; - } else if(arm->id.us>1) { + } else if(ID_REAL_USERS(arm) > 1) { /*BKE_report(op->reports, RPT_ERROR, "Can't apply to a multi user armature"); return;*/ tot_multiuser_arm_error++; diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 8c835dd7ca7..1abc9cd4514 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -198,6 +198,8 @@ typedef struct PreviewImage { /* fluidsim Ipo */ #define ID_FLUIDSIM MAKE_ID2('F', 'S') +#define ID_REAL_USERS(id) (((ID *)id)->us - ((((ID *)id)->flag & LIB_FAKEUSER) ? 1:0)) + /* id->flag: set frist 8 bits always at zero while reading */ #define LIB_LOCAL 0 #define LIB_EXTERN 1 diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 3be97710dd5..d8e045f8c80 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -569,6 +569,7 @@ void RNA_id_pointer_create(struct ID *id, PointerRNA *r_ptr); void RNA_pointer_create(struct ID *id, StructRNA *type, void *data, PointerRNA *r_ptr); void RNA_blender_rna_pointer_create(PointerRNA *r_ptr); +void RNA_pointer_recast(PointerRNA *ptr, PointerRNA *r_ptr); extern PointerRNA PointerRNA_NULL; diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 55ebf014b64..88be81fb691 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -64,6 +64,8 @@ extern EnumPropertyItem operator_return_items[]; extern EnumPropertyItem brush_sculpt_tool_items[]; +extern EnumPropertyItem texture_type_items[]; + extern EnumPropertyItem unpack_method_items[]; extern EnumPropertyItem object_type_items[]; diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index b5f3abf8b25..913c387c824 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -335,6 +335,7 @@ typedef struct ExtensionRNA { #define MainTexts Main #define MainActions Main #define MainGroups Main +#define MainTextures Main #ifdef __cplusplus } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 9dcd6eb81fa..1fdbb3f9a15 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -191,6 +191,30 @@ PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *da return result; } +/**/ +void RNA_pointer_recast(PointerRNA *ptr, PointerRNA *r_ptr) +{ +#if 0 // works but this case if covered by more general code below. + if(RNA_struct_is_ID(ptr->type)) { + /* simple case */ + RNA_id_pointer_create(ptr->id.data, r_ptr); + } + else +#endif + { + StructRNA *base; + PointerRNA t_ptr; + *r_ptr= *ptr; /* initialize as the same incase cant recast */ + + for(base=ptr->type->base; base; base=base->base) { + t_ptr= rna_pointer_inherit_refine(ptr, base, ptr->data); + if(t_ptr.type && t_ptr.type != ptr->type) { + *r_ptr= t_ptr; + } + } + } +} + /* ID Properties */ /* return a UI local ID prop definition for this prop */ diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index fdb192055b3..5eadcd54774 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -57,6 +57,7 @@ #include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_text_types.h" +#include "DNA_texture_types.h" #include "DNA_group_types.h" #include "ED_screen.h" @@ -66,8 +67,6 @@ Tex *rna_Main_add_texture(Main *bmain, char *name) return add_texture(name); } -/* TODO: remove texture? */ - Image *rna_Main_add_image(Main *bmain, char *filename) { return BKE_add_image_file(filename, 0); @@ -79,10 +78,10 @@ Camera *rna_Main_cameras_new(Main *bmain, char* name) } void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera) { - if(camera->id.us == 0) + if(ID_REAL_USERS(camera) == 0) free_libblock(&bmain->camera, camera); else - BKE_reportf(reports, RPT_ERROR, "Camera \"%s\" must have zero users to be removed, found %d.", camera->id.name+2, camera->id.us); + BKE_reportf(reports, RPT_ERROR, "Camera \"%s\" must have zero users to be removed, found %d.", camera->id.name+2, ID_REAL_USERS(camera)); /* XXX python now has invalid pointer? */ } @@ -130,10 +129,10 @@ void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *ob # don't do this since ob is already freed! bpy.data.remove_object(ob) */ - if(object->id.us == 0) + if(ID_REAL_USERS(object) == 0) free_libblock(&bmain->object, object); else - BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d.", object->id.name+2, object->id.us); + BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d.", object->id.name+2, ID_REAL_USERS(object)); } struct Material *rna_Main_materials_new(Main *bmain, char* name) @@ -142,10 +141,10 @@ struct Material *rna_Main_materials_new(Main *bmain, char* name) } void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material) { - if(material->id.us == 0) + if(ID_REAL_USERS(material) == 0) free_libblock(&bmain->mat, material); else - BKE_reportf(reports, RPT_ERROR, "Material \"%s\" must have zero users to be removed, found %d.", material->id.name+2, material->id.us); + BKE_reportf(reports, RPT_ERROR, "Material \"%s\" must have zero users to be removed, found %d.", material->id.name+2, ID_REAL_USERS(material)); /* XXX python now has invalid pointer? */ } @@ -158,10 +157,10 @@ Mesh *rna_Main_meshes_new(Main *bmain, char* name) } void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) { - if(mesh->id.us == 0) + if(ID_REAL_USERS(mesh) == 0) free_libblock(&bmain->mesh, mesh); else - BKE_reportf(reports, RPT_ERROR, "Mesh \"%s\" must have zero users to be removed, found %d.", mesh->id.name+2, mesh->id.us); + BKE_reportf(reports, RPT_ERROR, "Mesh \"%s\" must have zero users to be removed, found %d.", mesh->id.name+2, ID_REAL_USERS(mesh)); /* XXX python now has invalid pointer? */ } @@ -174,14 +173,28 @@ Lamp *rna_Main_lamps_new(Main *bmain, char* name) } void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) { - if(lamp->id.us == 0) + if(ID_REAL_USERS(lamp) == 0) free_libblock(&bmain->lamp, lamp); else - BKE_reportf(reports, RPT_ERROR, "Lamp \"%s\" must have zero users to be removed, found %d.", lamp->id.name+2, lamp->id.us); + BKE_reportf(reports, RPT_ERROR, "Lamp \"%s\" must have zero users to be removed, found %d.", lamp->id.name+2, ID_REAL_USERS(lamp)); /* XXX python now has invalid pointer? */ } +Tex *rna_Main_textures_new(Main *bmain, char* name) +{ + Tex *tex= add_texture(name); + tex->id.us--; + return tex; +} +void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex) +{ + if(ID_REAL_USERS(tex) == 0) + free_libblock(&bmain->tex, tex); + else + BKE_reportf(reports, RPT_ERROR, "Texture \"%s\" must have zero users to be removed, found %d.", tex->id.name+2, ID_REAL_USERS(tex)); +} + Group *rna_Main_groups_new(Main *bmain, char* name) { return add_group(name); @@ -221,10 +234,10 @@ bArmature *rna_Main_armatures_new(Main *bmain, char* name) } void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm) { - if(arm->id.us == 0) + if(ID_REAL_USERS(arm) == 0) free_libblock(&bmain->armature, arm); else - BKE_reportf(reports, RPT_ERROR, "Armature \"%s\" must have zero users to be removed, found %d.", arm->id.name+2, arm->id.us); + BKE_reportf(reports, RPT_ERROR, "Armature \"%s\" must have zero users to be removed, found %d.", arm->id.name+2, ID_REAL_USERS(arm)); /* XXX python now has invalid pointer? */ } @@ -238,10 +251,10 @@ bAction *rna_Main_actions_new(Main *bmain, char* name) } void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act) { - if(act->id.us == 0) + if(ID_REAL_USERS(act) == 0) free_libblock(&bmain->action, act); else - BKE_reportf(reports, RPT_ERROR, "Action \"%s\" must have zero users to be removed, found %d.", act->id.name+2, act->id.us); + BKE_reportf(reports, RPT_ERROR, "Action \"%s\" must have zero users to be removed, found %d.", act->id.name+2, ID_REAL_USERS(act)); /* XXX python now has invalid pointer? */ } @@ -253,12 +266,6 @@ void RNA_api_main(StructRNA *srna) FunctionRNA *func; PropertyRNA *parm; - func= RNA_def_function(srna, "add_texture", "rna_Main_add_texture"); - RNA_def_function_ui_description(func, "Add a new texture."); - parm= RNA_def_string(func, "name", "Tex", 0, "", "New name for the datablock."); /* optional */ - parm= RNA_def_pointer(func, "texture", "Texture", "", "New texture."); - RNA_def_function_return(func, parm); - func= RNA_def_function(srna, "add_image", "rna_Main_add_image"); RNA_def_function_ui_description(func, "Add a new image."); parm= RNA_def_string(func, "filename", "", 0, "", "Filename to load image from."); @@ -457,7 +464,27 @@ void RNA_def_main_vfonts(BlenderRNA *brna, PropertyRNA *cprop) } void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop) { + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + RNA_def_property_srna(cprop, "MainTextures"); + srna= RNA_def_struct(brna, "MainTextures", NULL); + RNA_def_struct_ui_text(srna, "Main Textures", "Collection of groups."); + + func= RNA_def_function(srna, "new", "rna_Main_textures_new"); + RNA_def_function_ui_description(func, "Add a new texture to the main database"); + parm= RNA_def_string(func, "name", "Texture", 0, "", "New name for the datablock."); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm= RNA_def_pointer(func, "texture", "Texture", "", "New texture datablock."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "rna_Main_textures_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a texture from the current blendfile."); + parm= RNA_def_pointer(func, "texture", "Texture", "", "Texture to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop) { diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 11d99b6f356..c352ec79735 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -51,6 +51,25 @@ static EnumPropertyItem texture_filter_items[] = { {TXF_SAT, "SAT", 0, "SAT (4x mem)", ""}, {0, NULL, 0, NULL, NULL}}; +EnumPropertyItem texture_type_items[] = { + {0, "NONE", 0, "None", ""}, + {TEX_BLEND, "BLEND", ICON_TEXTURE, "Blend", ""}, + {TEX_CLOUDS, "CLOUDS", ICON_TEXTURE, "Clouds", ""}, + {TEX_DISTNOISE, "DISTORTED_NOISE", ICON_TEXTURE, "Distorted Noise", ""}, + {TEX_ENVMAP, "ENVIRONMENT_MAP", ICON_IMAGE_DATA, "Environment Map", ""}, + {TEX_IMAGE, "IMAGE", ICON_IMAGE_DATA, "Image or Movie", ""}, + {TEX_MAGIC, "MAGIC", ICON_TEXTURE, "Magic", ""}, + {TEX_MARBLE, "MARBLE", ICON_TEXTURE, "Marble", ""}, + {TEX_MUSGRAVE, "MUSGRAVE", ICON_TEXTURE, "Musgrave", ""}, + {TEX_NOISE, "NOISE", ICON_TEXTURE, "Noise", ""}, + {TEX_PLUGIN, "PLUGIN", ICON_PLUGIN, "Plugin", ""}, + {TEX_POINTDENSITY, "POINT_DENSITY", ICON_TEXTURE, "Point Density", ""}, + {TEX_STUCCI, "STUCCI", ICON_TEXTURE, "Stucci", ""}, + {TEX_VORONOI, "VORONOI", ICON_TEXTURE, "Voronoi", ""}, + {TEX_VOXELDATA, "VOXEL_DATA", ICON_TEXTURE, "Voxel Data", ""}, + {TEX_WOOD, "WOOD", ICON_TEXTURE, "Wood", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME #include "MEM_guardedalloc.h" @@ -1791,25 +1810,6 @@ static void rna_def_texture(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem prop_type_items[] = { - {0, "NONE", 0, "None", ""}, - {TEX_BLEND, "BLEND", ICON_TEXTURE, "Blend", ""}, - {TEX_CLOUDS, "CLOUDS", ICON_TEXTURE, "Clouds", ""}, - {TEX_DISTNOISE, "DISTORTED_NOISE", ICON_TEXTURE, "Distorted Noise", ""}, - {TEX_ENVMAP, "ENVIRONMENT_MAP", ICON_IMAGE_DATA, "Environment Map", ""}, - {TEX_IMAGE, "IMAGE", ICON_IMAGE_DATA, "Image or Movie", ""}, - {TEX_MAGIC, "MAGIC", ICON_TEXTURE, "Magic", ""}, - {TEX_MARBLE, "MARBLE", ICON_TEXTURE, "Marble", ""}, - {TEX_MUSGRAVE, "MUSGRAVE", ICON_TEXTURE, "Musgrave", ""}, - {TEX_NOISE, "NOISE", ICON_TEXTURE, "Noise", ""}, - {TEX_PLUGIN, "PLUGIN", ICON_PLUGIN, "Plugin", ""}, - {TEX_POINTDENSITY, "POINT_DENSITY", ICON_TEXTURE, "Point Density", ""}, - {TEX_STUCCI, "STUCCI", ICON_TEXTURE, "Stucci", ""}, - {TEX_VORONOI, "VORONOI", ICON_TEXTURE, "Voronoi", ""}, - {TEX_VOXELDATA, "VOXEL_DATA", ICON_TEXTURE, "Voxel Data", ""}, - {TEX_WOOD, "WOOD", ICON_TEXTURE, "Wood", ""}, - {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "Texture", "ID"); RNA_def_struct_sdna(srna, "Tex"); RNA_def_struct_ui_text(srna, "Texture", "Texture datablock used by materials, lamps, worlds and brushes."); @@ -1819,7 +1819,7 @@ static void rna_def_texture(BlenderRNA *brna) prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); //RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); + RNA_def_property_enum_items(prop, texture_type_items); RNA_def_property_enum_funcs(prop, NULL, "rna_Texture_type_set", NULL); RNA_def_property_ui_text(prop, "Type", ""); RNA_def_property_update(prop, 0, "rna_Texture_update"); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index a4f61b7292d..bee6c4f70da 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1713,6 +1713,13 @@ static PyObject *pyrna_struct_path_to_id(BPy_StructRNA *self, PyObject *args) return ret; } +static PyObject *pyrna_struct_recast_type(BPy_StructRNA *self, PyObject *args) +{ + PointerRNA r_ptr; + RNA_pointer_recast(&self->ptr, &r_ptr); + return pyrna_struct_CreatePyObject(&r_ptr); +} + static PyObject *pyrna_prop_path_to_id(BPy_PropertyRNA *self) { char *path; @@ -2537,6 +2544,7 @@ static struct PyMethodDef pyrna_struct_methods[] = { {"is_property_hidden", (PyCFunction)pyrna_struct_is_property_hidden, METH_VARARGS, NULL}, {"path_resolve", (PyCFunction)pyrna_struct_path_resolve, METH_O, NULL}, {"path_to_id", (PyCFunction)pyrna_struct_path_to_id, METH_VARARGS, NULL}, + {"recast_type", (PyCFunction)pyrna_struct_recast_type, METH_NOARGS, NULL}, {"__dir__", (PyCFunction)pyrna_struct_dir, METH_NOARGS, NULL}, {NULL, NULL, 0, NULL} }; From f50ec12d9f1193a2f511f193734c800d750e0897 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sun, 17 Jan 2010 20:25:28 +0000 Subject: [PATCH 180/202] cmake fix broken OSX build: those openmp flags break OSX build, it might only work on other unixes that way --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8c6e66678a..81528e431a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,11 +82,11 @@ OPTION(WITH_INSTALL "Install accompanying scripts and language files neede OPTION(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org/)" ON) # Unix defaults to OpenMP On -IF (UNIX) +IF(UNIX AND NOT APPLE) OPTION(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" ON) -ELSE(UNIX) +ELSE() OPTION(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" OFF) -ENDIF(UNIX) +ENDIF() IF (APPLE) OPTION(WITH_COCOA "Use Cocoa framework instead of deprecated Carbon" ON) From 381e926600adde8271ddec79affbe4ef0d7faaf0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Jan 2010 20:59:35 +0000 Subject: [PATCH 181/202] fixed sphinx doc generator - arguments, return values indentation means they get correctly interpreted by sphinx - functions with no return values were displaying return as () - return values were getting the '(optional)' added in some cases. Example: http://www.blender.org/documentation/250PythonDoc/bpy.ops.object.html --- release/scripts/modules/rna_info.py | 6 ++++-- source/blender/python/sphinx_doc_gen.py | 20 ++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py index 5d7bd5af70a..1cdae79f439 100644 --- a/release/scripts/modules/rna_info.py +++ b/release/scripts/modules/rna_info.py @@ -201,7 +201,7 @@ class InfoPropertyRNA: return "%s=%s" % (self.identifier, default) return self.identifier - def get_type_description(self, as_arg=False, class_fmt="%s"): + def get_type_description(self, as_ret=False, as_arg=False, class_fmt="%s"): type_str = "" if self.fixed_type is None: type_str += self.type @@ -223,7 +223,9 @@ class InfoPropertyRNA: type_str += collection_str + (class_fmt % self.fixed_type.identifier) - if as_arg: + if as_ret: + pass + elif as_arg: if not self.is_required: type_str += ", (optional)" else: # readonly is only useful for selfs, not args diff --git a/source/blender/python/sphinx_doc_gen.py b/source/blender/python/sphinx_doc_gen.py index afa117ea60f..1b761a6d73d 100644 --- a/source/blender/python/sphinx_doc_gen.py +++ b/source/blender/python/sphinx_doc_gen.py @@ -29,10 +29,6 @@ Generate html docs by running... sphinx-build source/blender/python/doc/sphinx-in source/blender/python/doc/sphinx-out ''' -# if you dont have graphvis installed ommit the --graph arg. - -# GLOBALS['BASEDIR'] = './source/blender/python/doc' - import os import inspect import bpy @@ -108,8 +104,8 @@ def rna2sphinx(BASEPATH): type_descr = prop.get_type_description(as_arg=True, class_fmt=":class:`%s`") if prop.name or prop.description: - fw(ident + " :%s %s: %s\n" % (id_name, prop.identifier, ", ".join([val for val in (prop.name, prop.description) if val]))) - fw(ident + " :%s %s: %s\n" % (id_type, prop.identifier, type_descr)) + fw(ident + ":%s %s: %s\n" % (id_name, prop.identifier, ", ".join([val for val in (prop.name, prop.description) if val]))) + fw(ident + ":%s %s: %s\n" % (id_type, prop.identifier, type_descr)) def write_struct(struct): #if not struct.identifier.startswith("Sc") and not struct.identifier.startswith("I"): @@ -160,7 +156,7 @@ def rna2sphinx(BASEPATH): fw(" .. attribute:: %s\n\n" % prop.identifier) if prop.description: fw(" %s\n\n" % prop.description) - type_descr = prop.get_type_description(as_arg=False, class_fmt=":class:`%s`") + type_descr = prop.get_type_description(class_fmt=":class:`%s`") fw(" *type* %s\n\n" % type_descr) # python attributes @@ -184,14 +180,14 @@ def rna2sphinx(BASEPATH): if len(func.return_values) == 1: write_param(" ", fw, func.return_values[0], is_return=True) - else: # multiple return values - fw(" :return (%s):\n" % ", ".join([prop.identifier for prop in func.return_values])) + elif func.return_values: # multiple return values + fw(" :return (%s):\n" % ", ".join([prop.identifier for prop in func.return_values])) for prop in func.return_values: - type_descr = prop.get_type_description(as_arg=True, class_fmt=":class:`%s`") + type_descr = prop.get_type_description(as_ret=True, class_fmt=":class:`%s`") descr = prop.description if not descr: descr = prop.name - fw(" `%s`, %s, %s\n\n" % (prop.identifier, descr, type_descr)) + fw(" `%s`, %s, %s\n\n" % (prop.identifier, descr, type_descr)) fw("\n") @@ -257,7 +253,7 @@ def rna2sphinx(BASEPATH): if op.description: fw(" %s\n\n" % op.description) for prop in op.args: - write_param(" ", fw, prop) + write_param(" ", fw, prop) if op.args: fw("\n") From 7d2b40c862de0bca8a12984f79771b0d68db392e Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sun, 17 Jan 2010 21:00:07 +0000 Subject: [PATCH 182/202] undo previous cmake fixes, Benoit already fixed it in cmake/macros.cmake --- CMakeLists.txt | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81528e431a5..96df995f2e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -414,23 +414,7 @@ IF(WIN32) SET(OPENCOLLADA ${LIBDIR}/opencollada) SET(OPENCOLLADA_INC ${OPENCOLLADA}/include) SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib) - SET(OPENCOLLADA_LIB - debug OpenCOLLADASaxFrameworkLoader_d - debug OpenCOLLADAFramework_d - debug OpenCOLLADABaseUtils_d - debug OpenCOLLADAStreamWriter_d - debug MathMLSolver_d - debug GeneratedSaxParser_d - debug UTF_d - debug xml2_d - optimized OpenCOLLADASaxFrameworkLoader - optimized OpenCOLLADAFramework - optimized OpenCOLLADABaseUtils - optimized OpenCOLLADAStreamWriter - optimized MathMLSolver - optimized GeneratedSaxParser - optimized UTF - optimized xml2 ) + SET(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2 ) #pcre is bundled with openCollada #SET(PCRE ${LIBDIR}/pcre) #SET(PCRE_LIBPATH ${PCRE}/lib) From 9356b1b7ee99d86853589a51dfe89c490b7d2a57 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sun, 17 Jan 2010 21:46:34 +0000 Subject: [PATCH 183/202] BGE: Mouse Sensor type defaults to 1 (MOUSELEFT ) + remove camera attribute from Camera objects. (if you want to mark your camera objects create a property manually ;) That way object.getPropertyNames() works consistently across all object types. --- source/blender/blenkernel/intern/sca.c | 2 +- source/blender/editors/space_logic/logic_window.c | 2 ++ source/gameengine/Ketsji/KX_Camera.cpp | 3 --- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 5cd554725ff..1bef60f984c 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -139,7 +139,7 @@ void init_sensor(bSensor *sens) break; case SENS_MOUSE: ms=sens->data= MEM_callocN(sizeof(bMouseSensor), "mousesens"); - //XXX ms->type= LEFTMOUSE; + ms->type= 1; // LEFTMOUSE workaround because Mouse Sensor types enum starts in 1 break; case SENS_COLLISION: sens->data= MEM_callocN(sizeof(bCollisionSensor), "colsens"); diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 3e4c76f993f..d9bfa43bd41 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -1436,6 +1436,8 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short /* Line 2: type selection. The number are a bit mangled to get * proper compatibility with older .blend files. */ + /* Any sensor type default is 0 but the ms enum starts in 1. + * Therefore the mosue sensor is initialized to 1 in sca.c */ str= "Type %t|Left button %x1|Middle button %x2|" "Right button %x4|Wheel Up %x5|Wheel Down %x6|Movement %x8|Mouse over %x16|Mouse over any%x32"; uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, (width*0.8f)-20, 19, diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 384125119a9..ce13b9912a8 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -57,9 +57,6 @@ KX_Camera::KX_Camera(void* sgReplicationInfo, m_name = "cam"; m_projection_matrix.setIdentity(); m_modelview_matrix.setIdentity(); - CValue* val = new CIntValue(1); - SetProperty("camera",val); - val->Release(); } From 280df5dd470b02c40eb7254efcfea0d617a76075 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sun, 17 Jan 2010 22:12:00 +0000 Subject: [PATCH 184/202] Fix linking cmake on non-windows platforms (ELSEIF -> ELSE ) :) --- CMake/macros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/macros.cmake b/CMake/macros.cmake index 1e8fe391918..73458d7312e 100644 --- a/CMake/macros.cmake +++ b/CMake/macros.cmake @@ -140,7 +140,7 @@ MACRO(SETUP_LIBLINKS TARGET_LINK_LIBRARIES(${target} debug ${loop_var}_d) TARGET_LINK_LIBRARIES(${target} optimized ${loop_var}) ENDFOREACH(loop_var) - ELSEIF(WIN32) + ELSE(WIN32) TARGET_LINK_LIBRARIES(${target} ${OPENEXR_LIB}) ENDIF(WIN32) ENDIF(WITH_OPENEXR) From 90e95d896c964bd17b9f46e5f41bcb3ba47618c4 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 18 Jan 2010 00:35:28 +0000 Subject: [PATCH 185/202] NLA (Un)Mapping Fixes: Hopefully this time I've finally found the proper fix for this. At least in the mini test-suite I made for this, the new inverse process seemed stable enough. --- Also, tweaked the keyframe drawing code so that it doesn't convert the handles too when performing NLA mapping. This should provide some minor speed boosts when drawing keyframes under these conditions... --- source/blender/blenkernel/intern/nla.c | 18 ++---------------- .../blender/editors/animation/keyframes_draw.c | 4 ++-- source/blender/makesrna/intern/rna_nla.c | 2 +- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 3979586fb19..c9008e91646 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -369,14 +369,7 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short return strip->end - scale*(cframe - strip->actstart); } else if (mode == NLATIME_CONVERT_UNMAP) { - int repeatsNum = (int)((cframe - strip->start) / (actlength * scale)); - - /* this method doesn't clip the values to lie within the action range only - * - the '(repeatsNum * actlength * scale)' compensates for the fmod(...) - * - the fmod(...) works in the same way as for eval - */ - return strip->actend - (repeatsNum * actlength * scale) - - (fmod(cframe - strip->start, actlength*scale) / scale); + return strip->actend - (strip->end - cframe) / scale; } else /* if (mode == NLATIME_CONVERT_EVAL) */{ if (IS_EQ(cframe, strip->end) && IS_EQ(strip->repeat, ((int)strip->repeat))) { @@ -399,14 +392,7 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short return strip->start + scale*(cframe - strip->actstart); } else if (mode == NLATIME_CONVERT_UNMAP) { - int repeatsNum = (int)((cframe - strip->start) / (actlength * scale)); - - /* this method doesn't clip the values to lie within the action range only - * - the '(repeatsNum * actlength * scale)' compensates for the fmod(...) - * - the fmod(...) works in the same way as for eval - */ - return strip->actstart + (repeatsNum * actlength * scale) - + (fmod(cframe - strip->start, actlength*scale) / scale); + return strip->actstart + (cframe - strip->start) / scale; } else /* if (mode == NLATIME_CONVERT_EVAL) */{ if (IS_EQ(cframe, strip->end) && IS_EQ(strip->repeat, ((int)strip->repeat))) { diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 3a48aa0b063..da1233c17f1 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -855,7 +855,7 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree if (fcu && fcu->totvert && fcu->bezt) { /* apply NLA-mapping (if applicable) */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0); /* if getting long keyframes too, grab the BezTriples in a BST for * accelerated searching... @@ -892,7 +892,7 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree /* unapply NLA-mapping if applicable */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0); } } diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 79b34a4cfe3..79e6d52766e 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -187,7 +187,7 @@ static void rna_NlaStrip_repeat_set(PointerRNA *ptr, float value) NlaStrip *data= (NlaStrip*)ptr->data; float actlen, mapping; - /* set scale value */ + /* set repeat value */ CLAMP(value, 0.01f, 1000.0f); /* NOTE: these need to be synced with the values in the property definition in rna_def_nlastrip() */ data->repeat= value; From 1e983a931816b7c601bb6641039de0414640d969 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 18 Jan 2010 00:45:33 +0000 Subject: [PATCH 186/202] DopeSheet Keyframe/NLA Strip Scaling Tool: Scaling behaviour relative to mouse movement was inverted. Made the this transform tool now use the standard input mechanism for scaling inputs so that the behaviour is now correct. Martin: In my tests, the responsiveness of the scale tool is now not sensitive enough though. If you have some time, could you look into whether this can be made to work a bit freer? --- source/blender/editors/transform/transform.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index e8e7e323496..09fce29cbc7 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -5451,9 +5451,9 @@ void initTimeScale(TransInfo *t) { t->mode = TFM_TIME_SCALE; t->transform = TimeScale; - - initMouseInputMode(t, &t->mouse, INPUT_NONE); - t->helpline = HLP_SPRING; /* set manually because we don't use a predefined input */ + + // TODO: the scaling ratios obtained here aren't rapid enough + initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); t->flag |= T_NULL_ONE; t->num.flag |= NUM_NULL_ONE; @@ -5521,19 +5521,8 @@ static void applyTimeScale(TransInfo *t) { int TimeScale(TransInfo *t, short mval[2]) { - float cval, sval; - float deltax, startx; - float width= 0.0f; char str[200]; - - sval= t->imval[0]; - cval= mval[0]; - - /* calculate scaling factor */ - startx= sval-(width/2+(t->ar->winx)/2); - deltax= cval-(width/2+(t->ar->winx)/2); - t->values[0] = deltax / startx; - + /* handle numeric-input stuff */ t->vec[0] = t->values[0]; applyNumInput(&t->num, &t->vec[0]); From 969aa8fe6f535e59fd48ae6ae5e1a0535f95b621 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 18 Jan 2010 01:59:16 +0000 Subject: [PATCH 187/202] Fix for window not redrawing properly on resize (on osx at least), add a NC_WINDOW notifier as well as NC_SCREEN, since both have changed. --- source/blender/windowmanager/intern/wm_window.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 94248fb392c..294f9204ab2 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -704,6 +704,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) wm_window_make_drawable(C, win); wm_draw_window_clear(win); WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_WINDOW|NA_EDITED, NULL); } } break; From ffd035db62ba34135911ba267442345bba6e95cf Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 18 Jan 2010 02:10:55 +0000 Subject: [PATCH 188/202] Fix [#20702] Problems with Colormanagement Own bug in previous fix here.. --- source/blender/render/intern/source/pipeline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 8a608feebec..ff7d0d90a06 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2804,7 +2804,8 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R /* float factor for random dither, imbuf takes care of it */ ibuf->dither= scene->r.dither_intensity; /* prepare to gamma correct to sRGB color space */ - ibuf->profile = IB_PROFILE_LINEAR_RGB; + if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) + ibuf->profile = IB_PROFILE_LINEAR_RGB; ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); From 009ed7dc269e97653fd1db3f36fdd79fc7565cda Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 18 Jan 2010 03:36:19 +0000 Subject: [PATCH 189/202] Fix [#20703] Minor UI bug in file browser --- source/blender/editors/space_file/file_draw.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 93bedd0b866..6a3cc040c97 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -133,7 +133,6 @@ static void do_file_buttons(bContext *C, void *arg, int event) void file_draw_buttons(const bContext *C, ARegion *ar) { /* Button layout. */ - const int min_x = 10; const int max_x = ar->winx - 10; const int line1_y = IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN*2; const int line2_y = IMASEL_BUTTONS_MARGIN; @@ -148,6 +147,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) char name[20]; int loadbutton; int fnumbuttons; + int min_x = 10; int available_w = max_x - min_x; int line1_w = available_w; int line2_w = available_w; @@ -156,11 +156,20 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiBlock* block; SpaceFile* sfile = CTX_wm_space_file(C); FileSelectParams* params = ED_fileselect_get_params(sfile); + ARegion* artmp; /* Initialize UI block. */ sprintf(name, "win %p", ar); block = uiBeginBlock(C, ar, name, UI_EMBOSS); uiBlockSetHandleFunc(block, do_file_buttons, NULL); + + /* exception to make space for collapsed region icon */ + for (artmp=CTX_wm_area(C)->regionbase.first; artmp; artmp=artmp->next) { + if (artmp->regiontype == RGN_TYPE_CHANNELS && artmp->flag & RGN_FLAG_HIDDEN) { + min_x += 16; + available_w -= 16; + } + } /* Is there enough space for the execute / cancel buttons? */ loadbutton = UI_GetStringWidth(sfile->params->title) + btn_margin; From 4ab4abe98b0b7e505751a35e6335dd40fe76e4c2 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 18 Jan 2010 07:40:21 +0000 Subject: [PATCH 190/202] Fix [#19914] spacebar menu text stays on screen after click and drag Button wasn't getting freed correctly after exiting immediately after text selection --- source/blender/editors/interface/interface_handlers.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 75b03e0069d..29eeba970ed 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4079,6 +4079,8 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s ui_textedit_begin(C, but, data); else if(data->state == BUTTON_STATE_TEXT_EDITING && state != BUTTON_STATE_TEXT_SELECTING) ui_textedit_end(C, but, data); + else if(data->state == BUTTON_STATE_TEXT_SELECTING && state != BUTTON_STATE_TEXT_EDITING) + ui_textedit_end(C, but, data); /* number editing */ if(state == BUTTON_STATE_NUM_EDITING) { From 7195345c03f74680fa5e911e1acd217724140fee Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 18 Jan 2010 08:38:53 +0000 Subject: [PATCH 191/202] Fix for part of [#20251] Some Node UI problems Tweaked the padding around sockets when dragging connections. --- source/blender/editors/space_node/node_edit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 8166cfa9513..9e10feb898d 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -964,10 +964,10 @@ static int find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket ** /* check if we click in a socket */ for(node= snode->edittree->nodes.first; node; node= node->next) { - rect.xmin = snode->mx - NODE_SOCKSIZE+3; - rect.ymin = snode->my - NODE_SOCKSIZE+3; - rect.xmax = rect.xmin + 2*NODE_SOCKSIZE+6; - rect.ymax = rect.ymin + 2*NODE_SOCKSIZE+6; + rect.xmin = snode->mx - (NODE_SOCKSIZE+4); + rect.ymin = snode->my - (NODE_SOCKSIZE+4); + rect.xmax = snode->mx + (NODE_SOCKSIZE+4); + rect.ymax = snode->my + (NODE_SOCKSIZE+4); if (!(node->flag & NODE_HIDDEN)) { /* extra padding inside and out - allow dragging on the text areas too */ From e723b060fc596876ec4778589a5d6c88027187db Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Jan 2010 10:02:55 +0000 Subject: [PATCH 192/202] python script reloading (f8) - reload modules from types that are not directly included. for example wm.py uses classes from modules/rna_prop_ui.py which wasnt reloaded. - script paths were being added to sys.path multiple times. note: now the second reload gives a crash right away but this is a bug elsewhere. --- release/scripts/modules/bpy/__init__.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py index c760268d6f7..28f082c9bd1 100644 --- a/release/scripts/modules/bpy/__init__.py +++ b/release/scripts/modules/bpy/__init__.py @@ -46,7 +46,11 @@ def load_scripts(reload_scripts=False): t_main = time.time() + loaded_modules = set() + def test_import(module_name): + if module_name in loaded_modules: + return None if "." in module_name: print("Ignoring '%s', can't import files containing multiple periods." % module_name) return None @@ -61,12 +65,25 @@ def load_scripts(reload_scripts=False): traceback.print_exc() return None + if reload_scripts: + # reload modules that may not be directly included + for type_class_name in dir(types): + type_class = getattr(types, type_class_name) + module_name = getattr(type_class, "__module__", "") + + if module_name and module_name != "bpy.types": # hard coded for C types + loaded_modules.add(module_name) + + for module_name in loaded_modules: + print("Reloading:", module_name) + reload(sys.modules[module_name]) for base_path in utils.script_paths(): for path_subdir in ("ui", "op", "io"): path = os.path.join(base_path, path_subdir) if os.path.isdir(path): - sys.path.insert(0, path) + if path not in sys.path: # reloading would add twice + sys.path.insert(0, path) for f in sorted(os.listdir(path)): if f.endswith(".py"): # python module From fe67b9d6f2c8c3b4e3de61e013024639ffcba844 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Jan 2010 10:45:54 +0000 Subject: [PATCH 193/202] reference docs: include type info with function return values --- source/blender/python/sphinx_doc_gen.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/blender/python/sphinx_doc_gen.py b/source/blender/python/sphinx_doc_gen.py index 1b761a6d73d..ec17139b843 100644 --- a/source/blender/python/sphinx_doc_gen.py +++ b/source/blender/python/sphinx_doc_gen.py @@ -98,14 +98,18 @@ def rna2sphinx(BASEPATH): if is_return: id_name = "return" id_type = "rtype" + kwargs = {"as_ret": True, "class_fmt": ":class:`%s`"} + identifier = "" else: id_name = "arg" id_type = "type" + kwargs = {"as_arg": True, "class_fmt": ":class:`%s`"} + identifier = " %s" % prop.identifier - type_descr = prop.get_type_description(as_arg=True, class_fmt=":class:`%s`") + type_descr = prop.get_type_description(**kwargs) if prop.name or prop.description: - fw(ident + ":%s %s: %s\n" % (id_name, prop.identifier, ", ".join([val for val in (prop.name, prop.description) if val]))) - fw(ident + ":%s %s: %s\n" % (id_type, prop.identifier, type_descr)) + fw(ident + ":%s%s: %s\n" % (id_name, identifier, ", ".join([val for val in (prop.name, prop.description) if val]))) + fw(ident + ":%s%s: %s\n" % (id_type, identifier, type_descr)) def write_struct(struct): #if not struct.identifier.startswith("Sc") and not struct.identifier.startswith("I"): From 04230ae5921126103ebc4726ed452fdcd5183bb3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Jan 2010 11:22:32 +0000 Subject: [PATCH 194/202] fix for movie files sequence strip names not working unless the first frame of the movie was shown. --- source/blender/blenkernel/intern/sequencer.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 36c6e074d4e..83bea02895e 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1066,17 +1066,19 @@ static TStripElem *give_tstripelem(Sequence *seq, int cfra) StripElem *give_stripelem(Sequence *seq, int cfra) { - StripElem *se; - int nr; + StripElem *se= seq->strip->stripdata; - se = seq->strip->stripdata; - nr = give_stripelem_index(seq, cfra); + if(seq->type == SEQ_MOVIE) { + /* use the first */ + } + else { + int nr = give_stripelem_index(seq, cfra); - if (nr == -1) return 0; - if (se == 0) return 0; - - se += nr + seq->anim_startofs; + if (nr == -1) return 0; + if (se == 0) return 0; + se += nr + seq->anim_startofs; + } return se; } From b9fd903e8e4f2ad8892ec37b78dce8ef47eb0169 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Jan 2010 11:46:19 +0000 Subject: [PATCH 195/202] make the animation read error message say if the file wasnt found. --- source/blender/blenkernel/intern/image.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 464f4a2875f..b9be4602345 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1449,7 +1449,10 @@ struct anim *openanim(char *name, int flags) ibuf = IMB_anim_absolute(anim, 0); if (ibuf == NULL) { - printf("not an anim; %s\n", name); + if(BLI_exists(name)) + printf("not an anim: %s\n", name); + else + printf("anim file doesn't exist: %s\n", name); IMB_free_anim(anim); return(0); } From dc589a33ddbe5effed136750b37c18441d490f64 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Mon, 18 Jan 2010 14:08:40 +0000 Subject: [PATCH 196/202] OSX/scons : fix cross-build issue during linking phase with dynlibs --- config/darwin-config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/darwin-config.py b/config/darwin-config.py index a2ce9c3331a..53b75d455bf 100644 --- a/config/darwin-config.py +++ b/config/darwin-config.py @@ -321,7 +321,7 @@ if MAC_MIN_VERS == '10.3': if USE_SDK==True: SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE] - PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-syslibroot '+MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS + PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS CCFLAGS=SDK_FLAGS+CCFLAGS CXXFLAGS=SDK_FLAGS+CXXFLAGS From 9ae90efc8e87bf646e356f0f0d0e40b536798207 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Jan 2010 14:40:06 +0000 Subject: [PATCH 197/202] - opengl render anim exec function so python can render opengl animations without and have it block until its done. - timeline rna camera access. - new textblocks have tabs as spaces enabled by default since this is blenders default. --- source/blender/blenkernel/intern/text.c | 4 +- source/blender/editors/screen/screen_ops.c | 155 ++++++++++++------ source/blender/makesrna/intern/rna_timeline.c | 7 + 3 files changed, 118 insertions(+), 48 deletions(-) diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 50f7f6682f1..e948ffdbaf2 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -190,7 +190,7 @@ Text *add_empty_text(char *name) init_undo_text(ta); ta->nlines=1; - ta->flags= TXT_ISDIRTY | TXT_ISMEM; + ta->flags= TXT_ISDIRTY | TXT_ISMEM | TXT_TABSTOSPACES; ta->lines.first= ta->lines.last= NULL; ta->markers.first= ta->markers.last= NULL; @@ -355,6 +355,8 @@ Text *add_text(char *file, const char *relpath) ta->markers.first= ta->markers.last= NULL; ta->curl= ta->sell= NULL; + ta->flags= TXT_TABSTOSPACES; + fseek(fp, 0L, SEEK_END); len= ftell(fp); fseek(fp, 0L, SEEK_SET); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4461549aa28..f837409ca4a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3260,7 +3260,7 @@ typedef struct OGLRender { bMovieHandle *mh; int cfrao, nfra; - wmTimer *timer; + wmTimer *timer; /* use to check if running modal or not (invoke'd or exec'd)*/ } OGLRender; static void screen_opengl_render_apply(OGLRender *oglrender) @@ -3378,8 +3378,8 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) if(BKE_imtype_is_movie(scene->r.imtype)) oglrender->mh->end_movie(); } - - if(oglrender->timer) { + + if(oglrender->timer) { /* exec will not have a timer */ scene->r.cfra= oglrender->cfrao; scene_update_for_newframe(scene, scene->lay); @@ -3401,7 +3401,32 @@ static int screen_opengl_render_cancel(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } -static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *event) +/* share between invoke and exec */ +static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op) +{ + /* initialize animation */ + OGLRender *oglrender; + Scene *scene; + + oglrender= op->customdata; + scene= oglrender->scene; + + oglrender->reports= op->reports; + oglrender->mh= BKE_get_movie_handle(scene->r.imtype); + if(BKE_imtype_is_movie(scene->r.imtype)) { + if(!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) { + screen_opengl_render_end(C, oglrender); + return 0; + } + } + + oglrender->cfrao= scene->r.cfra; + oglrender->nfra= SFRA; + scene->r.cfra= SFRA; + + return 1; +} +static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) { OGLRender *oglrender= op->customdata; Scene *scene= oglrender->scene; @@ -3410,32 +3435,18 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *even char name[FILE_MAXDIR+FILE_MAXFILE]; unsigned int lay; int ok= 0; - - switch(event->type) { - case ESCKEY: - /* cancel */ - screen_opengl_render_end(C, op->customdata); - return OPERATOR_FINISHED; - case TIMER: - /* render frame? */ - if(oglrender->timer == event->customdata) - break; - default: - /* nothing to do */ - return OPERATOR_RUNNING_MODAL; - } - + /* go to next frame */ while(CFRAnfra) { if(scene->lay & 0xFF000000) lay= scene->lay & 0xFF000000; else lay= scene->lay; - + scene_update_for_newframe(scene, lay); CFRA++; } - + scene_update_for_newframe(scene, scene->lay); if(oglrender->rv3d->persp==RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) { @@ -3446,7 +3457,7 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *even if(camera) oglrender->v3d->camera= scene->camera= camera; } - + /* render into offscreen buffer */ screen_opengl_render_apply(oglrender); @@ -3477,11 +3488,42 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *even oglrender->nfra += scene->r.frame_step; scene->r.cfra++; - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, oglrender->scene); - /* stop at the end or on error */ if(scene->r.cfra > EFRA || !ok) { screen_opengl_render_end(C, op->customdata); + return 0; + } + + return 1; +} + + +static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + OGLRender *oglrender= op->customdata; + + int ret; + + switch(event->type) { + case ESCKEY: + /* cancel */ + screen_opengl_render_end(C, op->customdata); + return OPERATOR_FINISHED; + case TIMER: + /* render frame? */ + if(oglrender->timer == event->customdata) + break; + default: + /* nothing to do */ + return OPERATOR_RUNNING_MODAL; + } + + ret= screen_opengl_render_anim_step(C, op); + + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, oglrender->scene); + + /* stop at the end or on error */ + if(ret == 0) { return OPERATOR_FINISHED; } @@ -3504,35 +3546,53 @@ static int screen_opengl_render_invoke(bContext *C, wmOperator *op, wmEvent *eve return OPERATOR_FINISHED; } else { - /* initialize animation */ - OGLRender *oglrender; - Scene *scene; - - oglrender= op->customdata; - scene= oglrender->scene; - - oglrender->reports= op->reports; - oglrender->mh= BKE_get_movie_handle(scene->r.imtype); - if(BKE_imtype_is_movie(scene->r.imtype)) { - if(!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) { - screen_opengl_render_end(C, oglrender); - return OPERATOR_CANCELLED; - } - } - - oglrender->cfrao= scene->r.cfra; - oglrender->nfra= SFRA; - scene->r.cfra= SFRA; - + OGLRender *oglrender= op->customdata; + + if(!screen_opengl_render_anim_initialize(C, op)) + return OPERATOR_CANCELLED; + + screen_set_image_output(C, event->x, event->y); + WM_event_add_modal_handler(C, op); oglrender->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f); - - screen_set_image_output(C, event->x, event->y); - + return OPERATOR_RUNNING_MODAL; } } +/* executes blocking render */ +static int screen_opengl_render_exec(bContext *C, wmOperator *op) +{ + int anim= RNA_boolean_get(op->ptr, "animation"); + + if(!screen_opengl_render_init(C, op)) + return OPERATOR_CANCELLED; + + if(!anim) { /* same as invoke */ + /* render image */ + screen_opengl_render_apply(op->customdata); + screen_opengl_render_end(C, op->customdata); + + return OPERATOR_FINISHED; + } + else { + int ret= 1; + + if(!screen_opengl_render_anim_initialize(C, op)) + return OPERATOR_CANCELLED; + + while(ret) { + ret= screen_opengl_render_anim_step(C, op); + } + } + + // no redraw needed, we leave state as we entered it +// ED_update_for_newframe(C, 1); + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, CTX_data_scene(C)); + + return OPERATOR_FINISHED; +} + static void SCREEN_OT_opengl_render(wmOperatorType *ot) { /* identifiers */ @@ -3542,6 +3602,7 @@ static void SCREEN_OT_opengl_render(wmOperatorType *ot) /* api callbacks */ ot->invoke= screen_opengl_render_invoke; + ot->exec= screen_opengl_render_exec; /* blocking */ ot->modal= screen_opengl_render_modal; ot->cancel= screen_opengl_render_cancel; diff --git a/source/blender/makesrna/intern/rna_timeline.c b/source/blender/makesrna/intern/rna_timeline.c index 5e20fca15f0..26021687f0d 100644 --- a/source/blender/makesrna/intern/rna_timeline.c +++ b/source/blender/makesrna/intern/rna_timeline.c @@ -51,6 +51,13 @@ static void rna_def_timeline_marker(BlenderRNA *brna) prop= RNA_def_property(srna, "frame", PROP_INT, PROP_TIME); RNA_def_property_ui_text(prop, "Frame", "The frame on which the timeline marker appears."); + +#ifdef DURIAN_CAMERA_SWITCH + prop= RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); + RNA_def_property_ui_text(prop, "Camera", "Camera this timeline sets to active."); +#endif } void RNA_def_timeline_marker(BlenderRNA *brna) From 8cf6b390e3888c77265b9b34740fb52599a96d7f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Jan 2010 15:33:43 +0000 Subject: [PATCH 198/202] fix for weight painting bug, weight painting would fail when entering weight pait mode in some cases. --- source/blender/editors/object/object_vgroup.c | 2 +- source/blender/makesdna/DNA_object_types.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 4e31dffd3da..a9904ee7f1e 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -464,7 +464,7 @@ void ED_vgroup_select_by_name(Object *ob, char *name) } } - ob->actdef=0; // this signals on painting to create a new one, if a bone in posemode is selected */ + ob->actdef= 1; // this signals on painting to create a new one, if a bone in posemode is selected */ } /********************** Operator Implementations *********************/ diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index dbb7294f108..09b8ac01a45 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -196,7 +196,7 @@ typedef struct Object { float bbsize[3]; short index; /* custom index, for renderpasses */ - unsigned short actdef; /* current deformation group */ + unsigned short actdef; /* current deformation group, note: index starts at 1 */ float col[4]; /* object color, adjusted via IPO's only */ /** * Settings for game objects From 13f28b6fa4dfe933231213d0a0920bf9fbd2e205 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Jan 2010 16:21:23 +0000 Subject: [PATCH 199/202] revert for last commit, this should fix the proplem properly. - selected bones on hidden layers would be selected for weight painting (confusing to the user). use the 'active' bone instead. - when no weight group was set, the index used for the bone group was off by 1. --- source/blender/blenkernel/intern/deform.c | 2 ++ source/blender/editors/object/object_vgroup.c | 2 +- .../editors/sculpt_paint/paint_vertex.c | 24 ++++++++++--------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index c4d5f4952b6..38d4d722a46 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -166,6 +166,8 @@ int get_defgroup_num (Object *ob, bDeformGroup *dg) * (this number is stored in the deform * weights of the deform verts to link them * to this deform group). + * + * note: this is zero based, ob->actdef starts at 1. */ bDeformGroup *eg; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index a9904ee7f1e..23411d2219f 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -464,7 +464,7 @@ void ED_vgroup_select_by_name(Object *ob, char *name) } } - ob->actdef= 1; // this signals on painting to create a new one, if a bone in posemode is selected */ + ob->actdef= 0; // this signals on painting to create a new one, if a bone in posemode is selected */ } /********************** Operator Implementations *********************/ diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 52a71352768..470cda91b45 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -66,6 +66,7 @@ #include "RNA_define.h" #include "BKE_armature.h" +#include "BKE_action.h" #include "BKE_brush.h" #include "BKE_DerivedMesh.h" #include "BKE_cloth.h" @@ -1380,22 +1381,23 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *event) if(ob->actdef<=0) { Object *modob; if((modob = modifiers_isDeformedByArmature(ob))) { - bPoseChannel *pchan; - for(pchan= modob->pose->chanbase.first; pchan; pchan= pchan->next) - if(pchan->bone->flag & SELECT) - break; - if(pchan) { - bDeformGroup *dg= get_named_vertexgroup(ob, pchan->name); - if(dg==NULL) - dg= ED_vgroup_add_name(ob, pchan->name); /* sets actdef */ - else - ob->actdef= get_defgroup_num(ob, dg); + Bone *actbone= ((bArmature *)modob->data)->act_bone; + if(actbone) { + bPoseChannel *pchan= get_pose_channel(modob->pose, actbone->name); + + if(pchan) { + bDeformGroup *dg= get_named_vertexgroup(ob, pchan->name); + if(dg==NULL) + dg= ED_vgroup_add_name(ob, pchan->name); /* sets actdef */ + else + ob->actdef= 1 + get_defgroup_num(ob, dg); + } } } } if(ob->defbase.first==NULL) { ED_vgroup_add(ob); - } + } // if(ob->lay & v3d->lay); else error("Active object is not in this layer"); From eedc3c09d112e85f346897875c851d2793da465c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Jan 2010 16:47:26 +0000 Subject: [PATCH 200/202] append/prepend class methods for the header and panels (previously only worked for menus) Example of adding a button to the view header; def draw_custom(self, context): self.layout.operator("some.operator") bpy.types.VIEW3D_HT_header.append(draw_custom) --- release/scripts/modules/bpy_types.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 731757668bd..a1278f4f7cd 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -436,11 +436,11 @@ class Macro(StructRNA, metaclass=OrderedMeta): return ops.macro_define(self, opname) -class Menu(StructRNA): +class _GenericUI: __slots__ = () @classmethod - def _dyn_menu_initialize(cls): + def _dyn_ui_initialize(cls): draw_funcs = getattr(cls.draw, "_draw_funcs", None) if draw_funcs is None: @@ -457,14 +457,26 @@ class Menu(StructRNA): @classmethod def append(cls, draw_func): """Prepend an draw function to this menu, takes the same arguments as the menus draw function.""" - draw_funcs = cls._dyn_menu_initialize() + draw_funcs = cls._dyn_ui_initialize() draw_funcs.append(draw_func) @classmethod def prepend(cls, draw_func): """Prepend a draw function to this menu, takes the same arguments as the menus draw function.""" - draw_funcs = cls._dyn_menu_initialize() - draw_funcs.insert(0, draw_func) + draw_funcs = cls._dyn_ui_initialize() + draw_funcs.insert(0, draw_func) + + +class Panel(StructRNA, _GenericUI): + __slots__ = () + + +class Header(StructRNA, _GenericUI): + __slots__ = () + + +class Menu(StructRNA, _GenericUI): + __slots__ = () def path_menu(self, searchpaths, operator): layout = self.layout From 20fb87ac3213df2353e63f0fe39fb5eaa082a1cf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Jan 2010 17:14:54 +0000 Subject: [PATCH 201/202] cmake was missing openal include path --- intern/audaspace/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt index 0965a467201..7a3cb88db9c 100644 --- a/intern/audaspace/CMakeLists.txt +++ b/intern/audaspace/CMakeLists.txt @@ -20,7 +20,7 @@ # # ***** END LGPL LICENSE BLOCK ***** -SET(INC . intern FX SRC ${PTHREADS_INC} ${LIBSAMPLERATE_INC}) +SET(INC . intern FX SRC ${PTHREADS_INC} ${LIBSAMPLERATE_INC} ${OPENAL_INCLUDE_DIR}) FILE(GLOB SRC intern/*.cpp intern/*.h FX/*.cpp SRC/*.cpp) From 161ae41c6d3d63f4b444f83bd6e64f6cbb214983 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Jan 2010 18:52:03 +0000 Subject: [PATCH 202/202] load the user prefs before python so the python userdir is read. --- .../blender/windowmanager/intern/wm_init_exit.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index a83b6c3609a..48164b5ac16 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -129,18 +129,23 @@ void WM_init(bContext *C, int argc, char **argv) init_builtin_keyingsets(); /* editors/animation/keyframing.c */ - /* python needs initializing before loading the .B.blend - * because it may contain PyDrivers. It also needs to be after - * initializing space types and other internal data */ + /* get the default database, plus a wm */ + WM_read_homefile(C, NULL); + + /* note: there is a bug where python needs initializing before loading the + * .B25.blend because it may contain PyDrivers. It also needs to be after + * initializing space types and other internal data. + * + * However cant redo this at the moment. Solution is to load python + * before WM_read_homefile() or make py-drivers check if python is running. + * Will try fix when the crash can be repeated. - campbell. */ + #ifndef DISABLE_PYTHON BPY_set_context(C); /* necessary evil */ BPY_start_python(argc, argv); BPY_load_user_modules(C); #endif - /* get the default database, plus a wm */ - WM_read_homefile(C, NULL); - wm_init_reports(C); /* reports cant be initialized before the wm */ if (!G.background) {