Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanne Karhu <jhkarh@gmail.com>2009-08-29 19:20:36 +0400
committerJanne Karhu <jhkarh@gmail.com>2009-08-29 19:20:36 +0400
commit874d38eeb401a75f849cc36c7d7b911129c3aa75 (patch)
treef9d1ad815e40cfd27668dae5be83de72b385c650 /source/blender/makesrna/intern
parentc03004f93eb94d4af10acaf0b7e8ca7adb097dd0 (diff)
Point cache editing:
- Baked point caches for particles, cloth and softbody can now be edited in particle mode. * This overwrites the old cloth/sb cache editmode editing. * The type of editable system is chosen from a menu. * For particles the current particle system and it's current cache are used. - Currently this only works for caches that are in memory, but some automatic conversion from disk to memory and back can be implemented later. - All tools from hair editing can't be applied to point caches and are hidden in the tool panel and specials menu. Some functionality like subdividing paths can be later implemented in a slightly different way from how it works for hair. - Code is not yet optimized for speed, so editing might be slow sometimes. Known issues: - Cloth doesn't update properly while in particle mode, due to the way cloth modifier currently works. Daniel can you check on this? - As "particle mode" is not only for particles any more some other name would be in place? - Better icons are needed for the path, point, and tip-modes as the current icons from mesh edit mode are quite misleading. - Direct editing of point velocities is not yet implemented, but will be in the future. Other changes: - Hair editing doesn't require a "make editable" button press any more. - Multiple caches in single particle system disables changing emission properties. - Unified ui code for all point cache panels. * Defined in buttons_particle.py and imported for cloth, smoke & softbody. - Proper disabling of properties in ui after baking point caches. (Daniel could you please make needed disable code for smoke panels as their functionality is not familiar to me.) - Hair weight brush has been removed. Once hair dynamics is re-implemented I'll code a more useable alternative to the functionality. Bug fixes: - Unlinking particle settings crashed. - Deleting the active object with particles in the scene crashed. - Softbody didn't write point caches correctly on save.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r--source/blender/makesrna/intern/rna_particle.c62
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c158
2 files changed, 180 insertions, 40 deletions
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index e0dbc232e06..a1f35eca3c2 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -98,6 +98,7 @@ EnumPropertyItem part_hair_ren_as_items[] = {
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_particle.h"
+#include "BKE_pointcache.h"
#include "BLI_arithb.h"
@@ -436,7 +437,30 @@ static void rna_ParticleTarget_name_get(PointerRNA *ptr, char *str)
else
strcpy(str, "Invalid target!");
}
+static int rna_ParticleSystem_multiple_caches_get(PointerRNA *ptr)
+{
+ ParticleSystem *psys= (ParticleSystem*)ptr->data;
+
+ return (psys->ptcaches.first != psys->ptcaches.last);
+}
+static int rna_ParticleSystem_editable_get(PointerRNA *ptr)
+{
+ ParticleSystem *psys= (ParticleSystem*)ptr->data;
+
+ if(psys->part && psys->part->type==PART_HAIR)
+ return (psys->flag & PSYS_HAIR_DONE);
+ else
+ return (psys->pointcache->flag & PTCACHE_BAKED);
+}
+static int rna_ParticleSystem_edited_get(PointerRNA *ptr)
+{
+ ParticleSystem *psys= (ParticleSystem*)ptr->data;
+ if(psys->part && psys->part->type==PART_HAIR)
+ return (psys->edit && psys->edit->edited);
+ else
+ return (psys->pointcache->edit && psys->pointcache->edit->edited);
+}
EnumPropertyItem from_items[] = {
{PART_FROM_VERT, "VERT", 0, "Vertexes", ""},
{PART_FROM_FACE, "FACE", 0, "Faces", ""},
@@ -725,27 +749,10 @@ static void rna_def_particle(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", PARS_STICKY);
RNA_def_property_ui_text(prop, "sticky", "");
- prop= RNA_def_property(srna, "transform", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PARS_TRANSFORM);
- RNA_def_property_ui_text(prop, "transform", "");
-
- prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PARS_HIDE);
- RNA_def_property_ui_text(prop, "hide", "");
-
- prop= RNA_def_property(srna, "tag", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PARS_TAG);
- RNA_def_property_ui_text(prop, "tag", "");
-
prop= RNA_def_property(srna, "rekey", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PARS_REKEY);
RNA_def_property_ui_text(prop, "rekey", "");
- prop= RNA_def_property(srna, "edit_recalc", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PARS_EDIT_RECALC);
- RNA_def_property_ui_text(prop, "edit_recalc", "");
-
-
prop= RNA_def_property(srna, "alive_state", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "alive");
RNA_def_property_enum_items(prop, alive_items);
@@ -1907,11 +1914,6 @@ static void rna_def_particle_system(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "softflag", OB_SB_ENABLE);
RNA_def_property_ui_text(prop, "Use Soft Body", "Enable use of soft body for hair physics simulation.");
- prop= RNA_def_property(srna, "editable", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PSYS_EDITED);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* various checks needed */
- RNA_def_property_ui_text(prop, "Editable", "For hair particle systems, finalize the hair to enable editing.");
-
/* reactor */
prop= RNA_def_property(srna, "reactor_target_object", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "target_ob");
@@ -2089,12 +2091,28 @@ static void rna_def_particle_system(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "PointCache");
RNA_def_property_ui_text(prop, "Point Cache", "");
+ prop= RNA_def_property(srna, "multiple_caches", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_ParticleSystem_multiple_caches_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Multiple Caches", "Particle system has multiple point caches");
+
/* offset ob */
prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "parent");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Parent", "Use this object's coordinate system instead of global coordinate system.");
RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo");
+
+ /* hair or cache editing */
+ prop= RNA_def_property(srna, "editable", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_ParticleSystem_editable_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Editable", "Particle system can be edited in particle mode");
+
+ prop= RNA_def_property(srna, "edited", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_ParticleSystem_edited_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Edited", "Particle system has been edited in particle mode");
}
void RNA_def_particle(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index c2c906e38f2..fabe0b647ea 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -33,8 +33,34 @@
#include "BKE_paint.h"
+#include "WM_types.h"
+
+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."},
+ {PE_BRUSH_ADD, "ADD", 0, "Add", "Add hairs."},
+ {PE_BRUSH_LENGTH, "LENGTH", 0, "Length", "Make hairs longer or shorter."},
+ {PE_BRUSH_PUFF, "PUFF", 0, "Puff", "Make hairs stand up."},
+ {PE_BRUSH_CUT, "CUT", 0, "Cut", "Cut hairs."},
+ {0, NULL, 0, NULL, NULL}};
+
+static EnumPropertyItem particle_edit_cache_brush_items[] = {
+ {PE_BRUSH_NONE, "NONE", 0, "None", "Don't use any brush."},
+ {PE_BRUSH_COMB, "COMB", 0, "Comb", "Comb paths."},
+ {PE_BRUSH_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth paths."},
+ {PE_BRUSH_LENGTH, "LENGTH", 0, "Length", "Make paths longer or shorter."},
+ {0, NULL, 0, NULL, NULL}};
+
#ifdef RNA_RUNTIME
+#include "BKE_context.h"
+#include "BKE_pointcache.h"
+#include "BKE_particle.h"
+#include "BKE_depsgraph.h"
+
+#include "ED_particle.h"
+
static PointerRNA rna_ParticleEdit_brush_get(PointerRNA *ptr)
{
ParticleEditSettings *pset= (ParticleEditSettings*)ptr->data;
@@ -46,6 +72,7 @@ static PointerRNA rna_ParticleEdit_brush_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_ParticleBrush, brush);
}
+
static PointerRNA rna_ParticleBrush_curve_get(PointerRNA *ptr)
{
return rna_pointer_inherit_refine(ptr, &RNA_CurveMapping, NULL);
@@ -74,6 +101,65 @@ static void rna_Paint_active_brush_set(PointerRNA *ptr, PointerRNA value)
paint_brush_set(ptr->data, value.data);
}
+static void rna_ParticleEdit_redo(bContext *C, PointerRNA *ptr)
+{
+ PTCacheEdit *edit = PE_get_current(CTX_data_scene(C), CTX_data_active_object(C));
+
+ if(!edit)
+ return;
+
+ psys_free_path_cache(NULL, edit);
+}
+
+static void rna_ParticleEdit_update(bContext *C, PointerRNA *ptr)
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+
+ if(ob)
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+}
+
+static EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PointerRNA *ptr, int *free)
+{
+ Scene *scene= CTX_data_scene(C);
+ PTCacheEdit *edit;
+
+ if(C==NULL) {
+ EnumPropertyItem *item= NULL;
+ int totitem= 0;
+
+ /* needed for doc generation */
+ RNA_enum_items_add(&item, &totitem, particle_edit_hair_brush_items);
+ RNA_enum_item_end(&item, &totitem);
+
+ *free= 1;
+
+ return item;
+ }
+
+ edit = PE_get_current(scene, CTX_data_active_object(C));
+
+ if(edit && edit->psys)
+ return particle_edit_hair_brush_items;
+
+ return particle_edit_cache_brush_items;
+}
+
+static int rna_ParticleEdit_editable_get(PointerRNA *ptr)
+{
+ ParticleEditSettings *pset= (ParticleEditSettings*)ptr->data;
+
+ return (pset->object && PE_get_current(pset->scene, pset->object));
+}
+static int rna_ParticleEdit_hair_get(PointerRNA *ptr)
+{
+ ParticleEditSettings *pset= (ParticleEditSettings*)ptr->data;
+
+ PTCacheEdit *edit = PE_get_current(pset->scene, pset->object);
+
+ return (edit && edit->psys);
+}
#else
static void rna_def_paint(BlenderRNA *brna)
@@ -266,17 +352,6 @@ static void rna_def_particle_edit(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static EnumPropertyItem tool_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."},
- {PE_BRUSH_WEIGHT, "WEIGHT", 0, "Weight", "Assign weight to hairs."},
- {PE_BRUSH_ADD, "ADD", 0, "Add", "Add hairs."},
- {PE_BRUSH_LENGTH, "LENGTH", 0, "Length", "Make hairs longer or shorter."},
- {PE_BRUSH_PUFF, "PUFF", 0, "Puff", "Make hairs stand up."},
- {PE_BRUSH_CUT, "CUT", 0, "Cut", "Cut hairs."},
- {0, NULL, 0, NULL, NULL}};
-
static EnumPropertyItem select_mode_items[] = {
{SCE_SELECT_PATH, "PATH", ICON_EDGESEL, "Path", ""}, // XXX icon
{SCE_SELECT_POINT, "POINT", ICON_VERTEXSEL, "Point", ""}, // XXX icon
@@ -293,6 +368,14 @@ static void rna_def_particle_edit(BlenderRNA *brna)
{1, "SHRINK", 0, "Shrink", "Make hairs shorter."},
{0, NULL, 0, NULL, NULL}};
+ static EnumPropertyItem edit_type_items[]= {
+ {PE_TYPE_PARTICLES, "PARTICLES", 0, "Particles", ""},
+ {PE_TYPE_SOFTBODY, "SOFT_BODY", 0, "Soft body", ""},
+ {PE_TYPE_CLOTH, "CLOTH", 0, "Cloth", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+
/* edit */
srna= RNA_def_struct(brna, "ParticleEdit", NULL);
@@ -301,13 +384,15 @@ static void rna_def_particle_edit(BlenderRNA *brna)
prop= RNA_def_property(srna, "tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "brushtype");
- RNA_def_property_enum_items(prop, tool_items);
+ RNA_def_property_enum_items(prop, particle_edit_hair_brush_items);
+ RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_ParticleEdit_tool_itemf");
RNA_def_property_ui_text(prop, "Tool", "");
prop= RNA_def_property(srna, "selection_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "selectmode");
RNA_def_property_enum_items(prop, select_mode_items);
RNA_def_property_ui_text(prop, "Selection Mode", "Particle select and display mode.");
+ RNA_def_property_update(prop, NC_OBJECT, "rna_ParticleEdit_update");
prop= RNA_def_property(srna, "keep_lengths", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_KEEP_LENGTHS);
@@ -326,13 +411,19 @@ static void rna_def_particle_edit(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.0f, 10.0f, 10, 3);
RNA_def_property_ui_text(prop, "Emitter Distance", "Distance to keep particles away from the emitter.");
- prop= RNA_def_property(srna, "show_time", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_SHOW_TIME);
- RNA_def_property_ui_text(prop, "Show Time", "Show time values of the baked keys.");
+ prop= RNA_def_property(srna, "fade_time", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_FADE_TIME);
+ RNA_def_property_ui_text(prop, "Fade Time", "Fade paths and keys further away from current frame.");
+ RNA_def_property_update(prop, NC_OBJECT, "rna_ParticleEdit_update");
- prop= RNA_def_property(srna, "show_children", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_SHOW_CHILD);
- RNA_def_property_ui_text(prop, "Show Children", "Show child particles.");
+ prop= RNA_def_property(srna, "auto_velocity", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_AUTO_VELOCITY);
+ RNA_def_property_ui_text(prop, "Auto Velocity", "Calculate point velocities automatically.");
+
+ prop= RNA_def_property(srna, "draw_particles", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_DRAW_PART);
+ RNA_def_property_ui_text(prop, "Draw Particles", "Draw actual particles.");
+ RNA_def_property_update(prop, NC_OBJECT, NULL);
prop= RNA_def_property(srna, "mirror_x", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_X_MIRROR);
@@ -353,6 +444,37 @@ static void rna_def_particle_edit(BlenderRNA *brna)
RNA_def_property_pointer_funcs(prop, "rna_ParticleEdit_brush_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Brush", "");
+ prop= RNA_def_property(srna, "draw_step", PROP_INT, PROP_NONE);
+ RNA_def_property_range(prop, 2, 10);
+ RNA_def_property_ui_text(prop, "Steps", "How many steps to draw the path with.");
+ RNA_def_property_update(prop, NC_OBJECT, "rna_ParticleEdit_redo");
+
+ prop= RNA_def_property(srna, "fade_frames", PROP_INT, PROP_NONE);
+ RNA_def_property_range(prop, 2, 100);
+ RNA_def_property_ui_text(prop, "Frames", "How many frames to fade.");
+ RNA_def_property_update(prop, NC_OBJECT, "rna_ParticleEdit_update");
+
+ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "edittype");
+ RNA_def_property_enum_items(prop, edit_type_items);
+ RNA_def_property_ui_text(prop, "Type", "");
+ RNA_def_property_update(prop, NC_OBJECT, "rna_ParticleEdit_redo");
+
+ prop= RNA_def_property(srna, "editable", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_ParticleEdit_editable_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Editable", "A valid edit mode exists");
+
+ prop= RNA_def_property(srna, "hair", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_ParticleEdit_hair_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Hair", "Editing hair");
+
+ prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Object", "The edited object");
+
+
/* brush */
srna= RNA_def_struct(brna, "ParticleBrush", NULL);