diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-26 02:31:02 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-26 02:31:02 +0400 |
commit | 756488fbe2c0beaf205cb28d6f4ca1e62a64588a (patch) | |
tree | 488e0c746833e1eccea3c2488a2198b9b5aa688e /source/blender/editors | |
parent | 5d240af42b0199a7832aa2acbc866283cfab49cb (diff) |
2.5: Painting
Various fixes for painting, sculpting and particle edit, still
much to be done...
* Move RNA paint and sculpt structs into rna_sculpt_paint.c,
* Added Particle Edit RNA.
* Some tweaks to existing Paint RNA.
* Put texture paint and particle edit object in context.
* Fix some errors in the brush layout, properly doing None
checks, fixing some wrong property identifiers.
* Added tool enum for texture paint and particle edit in panels.
* Allow editing brush textures in the texture buttons, still with
a stupid toggle, ideas for how to make the connection better are
welcome.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/physics/editparticle.c | 23 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 21 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 79 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_toolbar.c | 12 |
4 files changed, 101 insertions, 34 deletions
diff --git a/source/blender/editors/physics/editparticle.c b/source/blender/editors/physics/editparticle.c index f414297dab4..20033c747f9 100644 --- a/source/blender/editors/physics/editparticle.c +++ b/source/blender/editors/physics/editparticle.c @@ -271,6 +271,7 @@ typedef struct PEData { float smoothfac; float weightfac; float growfac; + int totrekey; int invert; int tot; @@ -1748,7 +1749,6 @@ static void rekey_particle(PEData *data, int pa_index) ParticleSystem *psys= data->psys; ParticleData *pa= &psys->particles[pa_index]; ParticleEdit *edit= psys->edit; - ParticleEditSettings *pset= PE_settings(data->scene); ParticleKey state; HairKey *key, *new_keys; ParticleEditKey *ekey; @@ -1757,19 +1757,19 @@ static void rekey_particle(PEData *data, int pa_index) pa->flag |= PARS_REKEY; - key= new_keys= MEM_callocN(pset->totrekey * sizeof(HairKey),"Hair re-key keys"); + key= new_keys= MEM_callocN(data->totrekey * sizeof(HairKey),"Hair re-key keys"); /* root and tip stay the same */ VECCOPY(key->co, pa->hair->co); - VECCOPY((key + pset->totrekey - 1)->co, (pa->hair + pa->totkey - 1)->co); + VECCOPY((key + data->totrekey - 1)->co, (pa->hair + pa->totkey - 1)->co); sta= key->time= pa->hair->time; - end= (key + pset->totrekey - 1)->time= (pa->hair + pa->totkey - 1)->time; - dval= (end - sta) / (float)(pset->totrekey - 1); + end= (key + data->totrekey - 1)->time= (pa->hair + pa->totkey - 1)->time; + dval= (end - sta) / (float)(data->totrekey - 1); /* interpolate new keys from old ones */ - for(k=1,key++; k<pset->totrekey-1; k++,key++) { - state.time= (float)k / (float)(pset->totrekey-1); + for(k=1,key++; k<data->totrekey-1; k++,key++) { + state.time= (float)k / (float)(data->totrekey-1); psys_get_particle_on_path(data->scene, data->ob, psys, pa_index, &state, 0); VECCOPY(key->co, state.co); key->time= sta + k * dval; @@ -1780,7 +1780,7 @@ static void rekey_particle(PEData *data, int pa_index) MEM_freeN(pa->hair); pa->hair= new_keys; - pa->totkey=pset->totrekey; + pa->totkey=data->totrekey; if(edit->keys[pa_index]) MEM_freeN(edit->keys[pa_index]); @@ -1798,14 +1798,11 @@ static void rekey_particle(PEData *data, int pa_index) static int rekey_exec(bContext *C, wmOperator *op) { PEData data; - ParticleEditSettings *pset; PE_set_data(C, &data); - pset= PE_settings(data.scene); - pset->totrekey= RNA_int_get(op->ptr, "keys"); - - data.dval= 1.0f / (float)(pset->totrekey-1); + data.dval= 1.0f / (float)(data.totrekey-1); + data.totrekey= RNA_int_get(op->ptr, "keys"); foreach_selected_particle(&data, rekey_particle); diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 2dc2cf9f293..3842dd3d62f 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -50,7 +50,8 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult "scene", "selected_objects", "selected_bases", "selected_editable_objects", "selected_editable_bases" "active_base", "active_object", "edit_object", - "sculpt_object", "vpaint_object", "wpaint_object", NULL}; + "sculpt_object", "vertex_paint_object", "weight_paint_object", + "texture_paint_object", "brush", "particle_edit_object", NULL}; CTX_data_dir_set(result, dir); return 1; @@ -116,19 +117,31 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } - else if(CTX_data_equals(member, "vpaint_object")) { + else if(CTX_data_equals(member, "vertex_paint_object")) { if(G.f & G_VERTEXPAINT && scene->basact) CTX_data_id_pointer_set(result, &scene->basact->object->id); return 1; } - else if(CTX_data_equals(member, "wpaint_object")) { + else if(CTX_data_equals(member, "weight_paint_object")) { if(G.f & G_WEIGHTPAINT && scene->basact) CTX_data_id_pointer_set(result, &scene->basact->object->id); return 1; } - + else if(CTX_data_equals(member, "texture_paint_object")) { + if(G.f & G_TEXTUREPAINT && scene->basact) + CTX_data_id_pointer_set(result, &scene->basact->object->id); + + return 1; + } + else if(CTX_data_equals(member, "particle_edit_object")) { + if(G.f & G_PARTICLEEDIT && scene->basact) + CTX_data_id_pointer_set(result, &scene->basact->object->id); + + return 1; + } + return 0; } diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 3a3f5bd83ee..1bc663a789b 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" #include "DNA_armature_types.h" +#include "DNA_brush_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_modifier_types.h" @@ -45,6 +46,7 @@ #include "BLI_listbase.h" #include "BKE_context.h" +#include "BKE_global.h" #include "BKE_material.h" #include "BKE_modifier.h" #include "BKE_particle.h" @@ -65,7 +67,7 @@ typedef struct ButsContextPath { PointerRNA ptr[8]; int len; - int worldtex; + int flag; } ButsContextPath; static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type) @@ -302,10 +304,48 @@ static int buttons_context_path_particle(ButsContextPath *path) return 0; } +static int buttons_context_path_brush(ButsContextPath *path) +{ + Scene *scene; + ToolSettings *ts; + Brush *br= NULL; + PointerRNA *ptr= &path->ptr[path->len-1]; + + /* if we already have a (pinned) brush, we're done */ + if(RNA_struct_is_a(ptr->type, &RNA_Brush)) { + return 1; + } + /* if we have a scene, use the toolsettings brushes */ + else if(buttons_context_path_scene(path)) { + scene= path->ptr[path->len-1].data; + ts= scene->toolsettings; + + if(G.f & G_SCULPTMODE) + br= ts->sculpt->brush; + else if(G.f & G_VERTEXPAINT) + br= ts->vpaint->brush; + else if(G.f & G_WEIGHTPAINT) + br= ts->wpaint->brush; + else if(G.f & G_TEXTUREPAINT) + br= ts->imapaint.brush; + + if(br) { + RNA_id_pointer_create(&br->id, &path->ptr[path->len]); + path->len++; + + return 1; + } + } + + /* no path to a world possible */ + return 0; +} + static int buttons_context_path_texture(ButsContextPath *path) { Material *ma; Lamp *la; + Brush *br; World *wo; MTex *mtex; Tex *tex; @@ -315,8 +355,21 @@ static int buttons_context_path_texture(ButsContextPath *path) if(RNA_struct_is_a(ptr->type, &RNA_Texture)) { return 1; } + /* try brush */ + else if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(path)) { + br= path->ptr[path->len-1].data; + + if(br) { + mtex= br->mtex[(int)br->texact]; + tex= (mtex)? mtex->tex: NULL; + + RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); + path->len++; + return 1; + } + } /* try world */ - else if(path->worldtex && buttons_context_path_world(path)) { + else if((path->flag & SB_WORLD_TEX) && buttons_context_path_world(path)) { wo= path->ptr[path->len-1].data; if(wo) { @@ -354,21 +407,21 @@ static int buttons_context_path_texture(ButsContextPath *path) return 1; } } - /* TODO: material nodes, brush */ + /* TODO: material nodes */ - /* no path to a particle system possible */ + /* no path to a texture possible */ return 0; } -static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int worldtex) +static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag) { SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C); ID *id; int found; memset(path, 0, sizeof(*path)); - path->worldtex= worldtex; + path->flag= flag; /* if some ID datablock is pinned, set the root pointer */ if(sbuts->pinid) { @@ -431,18 +484,18 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) { ButsContextPath *path; PointerRNA *ptr; - int a, worldtex, flag= 0; + int a, pflag, flag= 0; if(!sbuts->path) sbuts->path= MEM_callocN(sizeof(ButsContextPath), "ButsContextPath"); path= sbuts->path; - worldtex= (sbuts->flag & SB_WORLD_TEX); + pflag= (sbuts->flag & (SB_WORLD_TEX|SB_BRUSH_TEX)); /* for each context, see if we can compute a valid path to it, if * this is the case, we know we have to display the button */ for(a=0; a<BCONTEXT_TOT; a++) { - if(buttons_context_path(C, path, a, worldtex)) { + if(buttons_context_path(C, path, a, pflag)) { flag |= (1<<a); /* setting icon for data context */ @@ -477,7 +530,7 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) } } - buttons_context_path(C, path, sbuts->mainb, worldtex); + buttons_context_path(C, path, sbuts->mainb, pflag); if(!(flag & (1 << sbuts->mainb))) { if(flag & (1 << BCONTEXT_OBJECT)) @@ -505,7 +558,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r "world", "object", "mesh", "armature", "lattice", "curve", "meta_ball", "lamp", "camera", "material", "material_slot", "texture", "texture_slot", "bone", "edit_bone", "particle_system", - "cloth", "soft_body", "fluid", "collision", NULL}; + "cloth", "soft_body", "fluid", "collision", "brush", NULL}; CTX_data_dir_set(result, dir); return 1; @@ -648,6 +701,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } } + else if(CTX_data_equals(member, "brush")) { + set_pointer_type(path, result, &RNA_Brush); + return 1; + } return 0; } diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 89a6d659d67..1564fcb169b 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -175,12 +175,12 @@ char *view3d_context_string(const bContext *C) else { Object *ob = CTX_data_active_object(C); - if(ob && (ob->flag & OB_POSEMODE)) return "posemode"; - else if (G.f & G_SCULPTMODE) return "sculptmode"; - else if (G.f & G_WEIGHTPAINT) return "weightpaint"; - else if (G.f & G_VERTEXPAINT) return "vertexpaint"; - else if (G.f & G_TEXTUREPAINT) return "texturepaint"; - else if(G.f & G_PARTICLEEDIT) return "particlemode"; + if(ob && (ob->flag & OB_POSEMODE)) return "pose_mode"; + else if (G.f & G_SCULPTMODE) return "sculpt_mode"; + else if (G.f & G_WEIGHTPAINT) return "weight_paint"; + else if (G.f & G_VERTEXPAINT) return "vertex_paint"; + else if (G.f & G_TEXTUREPAINT) return "texture_paint"; + else if(G.f & G_PARTICLEEDIT) return "particle_mode"; } return "objectmode"; |