[Bf-blender-cvs] [93c4960] alembic: RNA for modifier struct subtypes.

Lukas Tönne noreply at git.blender.org
Fri Apr 3 15:21:54 CEST 2015


Commit: 93c49605fdd9f6f731e2e4becbf08bdc1b59e70f
Author: Lukas Tönne
Date:   Fri Apr 3 14:18:46 2015 +0200
Branches: alembic
https://developer.blender.org/rB93c49605fdd9f6f731e2e4becbf08bdc1b59e70f

RNA for modifier struct subtypes.

Also renamed StrandSimParams to HairSimParams, since strands are only
the agnostic data structure, while these parameters are specifically
used to simulate hair-like behavior. Other simulations could use strands
but implement completely different kinds of physics (e.g. grass, ropes).

===================================================================

M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/makesdna/DNA_cache_library_types.h
M	source/blender/makesrna/intern/rna_cache_library.c
M	source/blender/physics/BPH_mass_spring.h
M	source/blender/physics/intern/BPH_mass_spring.cpp

===================================================================

diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 6f4d49c..f0148d6 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -557,7 +557,7 @@ void BKE_cache_process_dupli_cache(CacheLibrary *cachelib, CacheProcessData *dat
 
 /* ------------------------------------------------------------------------- */
 
-static void hairsim_params_init(StrandSimParams *params)
+static void hairsim_params_init(HairSimParams *params)
 {
 	params->timescale = 1.0f;
 	params->substeps = 5;
@@ -568,7 +568,7 @@ static void hairsim_init(HairSimCacheModifier *hsmd)
 	hairsim_params_init(&hsmd->sim_params);
 }
 
-static void hairsim_copy(HairSimCacheModifier *UNUSED(md), HairSimCacheModifier *UNUSED(tmd))
+static void hairsim_copy(HairSimCacheModifier *hsmd, HairSimCacheModifier *thsmd)
 {
 }
 
diff --git a/source/blender/makesdna/DNA_cache_library_types.h b/source/blender/makesdna/DNA_cache_library_types.h
index 4e1f4fc..8958ed6 100644
--- a/source/blender/makesdna/DNA_cache_library_types.h
+++ b/source/blender/makesdna/DNA_cache_library_types.h
@@ -113,15 +113,15 @@ typedef enum eCacheModifier_Type {
 	NUM_CACHE_MODIFIER_TYPES
 } eCacheModifier_Type;
 
-typedef struct StrandSimParams {
+typedef struct HairSimParams {
 	float timescale;
 	int substeps;
-} StrandSimParams;
+} HairSimParams;
 
 typedef struct HairSimCacheModifier {
 	CacheModifier modifier;
 	
-	StrandSimParams sim_params;
+	HairSimParams sim_params;
 } HairSimCacheModifier;
 
 #endif
diff --git a/source/blender/makesrna/intern/rna_cache_library.c b/source/blender/makesrna/intern/rna_cache_library.c
index 3647545..1afae09 100644
--- a/source/blender/makesrna/intern/rna_cache_library.c
+++ b/source/blender/makesrna/intern/rna_cache_library.c
@@ -71,6 +71,7 @@ EnumPropertyItem cache_modifier_type_items[] = {
 
 #include "BKE_animsys.h"
 #include "BKE_cache_library.h"
+#include "BKE_depsgraph.h"
 #include "BKE_main.h"
 
 #include "RNA_access.h"
@@ -79,12 +80,40 @@ EnumPropertyItem cache_modifier_type_items[] = {
 
 /* ========================================================================= */
 
-static void rna_CacheLibrary_update(Main *UNUSED(main), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+static void rna_CacheLibrary_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
 {
 }
 
 /* ========================================================================= */
 
+static void rna_CacheModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+{
+}
+
+static void rna_CacheModifier_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+	rna_CacheModifier_update(bmain, scene, ptr);
+	DAG_relations_tag_update(bmain);
+}
+
+
+static StructRNA *rna_CacheModifier_refine(struct PointerRNA *ptr)
+{
+	CacheModifier *md = (CacheModifier *)ptr->data;
+
+	switch ((eCacheModifier_Type)md->type) {
+		case eCacheModifierType_HairSimulation:
+			return &RNA_HairSimulationCacheModifier;
+			
+		/* Default */
+		case eCacheModifierType_None:
+		case NUM_CACHE_MODIFIER_TYPES:
+			return &RNA_CacheLibraryModifier;
+	}
+
+	return &RNA_CacheLibraryModifier;
+}
+
 static void rna_CacheLibraryModifier_name_set(PointerRNA *ptr, const char *value)
 {
 	CacheModifier *md = ptr->data;
@@ -137,6 +166,36 @@ static void rna_CacheLibrary_modifier_clear(CacheLibrary *cachelib, bContext *UN
 
 #else
 
+static void rna_def_hair_sim_params(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+	
+	srna = RNA_def_struct(brna, "HairSimulationParameters", NULL);
+	RNA_def_struct_sdna(srna, "HairSimParams");
+	RNA_def_struct_ui_text(srna, "Hair Simulation Parameters", "Simulation parameters for hair simulation");
+	RNA_def_struct_ui_icon(srna, ICON_HAIR);
+}
+
+static void rna_def_cache_modifier_hair_simulation(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+	
+	rna_def_hair_sim_params(brna);
+	
+	srna = RNA_def_struct(brna, "HairSimulationCacheModifier", "CacheLibraryModifier");
+	RNA_def_struct_sdna(srna, "HairSimCacheModifier");
+	RNA_def_struct_ui_text(srna, "Hair Simulation Cache Modifier", "Apply hair dynamics simulation to the cache");
+	RNA_def_struct_ui_icon(srna, ICON_HAIR);
+	
+	prop = RNA_def_property(srna, "parameters", PROP_POINTER, PROP_NONE);
+	RNA_def_property_pointer_sdna(prop, NULL, "sim_params");
+	RNA_def_property_struct_type(prop, "HairSimulationParameters");
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Simulation Parameters", "Parameters of the simulation");
+}
+
 static void rna_def_cache_modifier(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -145,6 +204,7 @@ static void rna_def_cache_modifier(BlenderRNA *brna)
 	srna = RNA_def_struct(brna, "CacheLibraryModifier", NULL);
 	RNA_def_struct_sdna(srna, "CacheModifier");
 	RNA_def_struct_path_func(srna, "rna_CacheLibraryModifier_path");
+	RNA_def_struct_refine_func(srna, "rna_CacheModifier_refine");
 	RNA_def_struct_ui_text(srna, "Cache Modifier", "Cache Modifier");
 	RNA_def_struct_ui_icon(srna, ICON_PHYSICS);
 	
@@ -159,6 +219,8 @@ static void rna_def_cache_modifier(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Name", "Modifier name");
 	RNA_def_property_update(prop, NC_ID | NA_RENAME, NULL);
 	RNA_def_struct_name_property(srna, prop);
+	
+	rna_def_cache_modifier_hair_simulation(brna);
 }
 
 static void rna_def_cache_library_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
diff --git a/source/blender/physics/BPH_mass_spring.h b/source/blender/physics/BPH_mass_spring.h
index 1eaa20a..0ff6e96 100644
--- a/source/blender/physics/BPH_mass_spring.h
+++ b/source/blender/physics/BPH_mass_spring.h
@@ -37,7 +37,7 @@ struct Object;
 struct ClothModifierData;
 struct ListBase;
 struct Strands;
-struct StrandSimParams;
+struct HairSimParams;
 struct VoxelData;
 
 typedef enum eMassSpringSolverStatus {
@@ -57,8 +57,8 @@ void BKE_cloth_solver_set_positions(struct ClothModifierData *clmd);
 
 bool BPH_cloth_solver_get_texture_data(struct Object *ob, struct ClothModifierData *clmd, struct VoxelData *vd);
 
-struct Implicit_Data *BPH_strands_solver_create(struct Strands *strands, struct StrandSimParams *params);
-bool BPH_strands_solve(struct Strands *strands, struct Implicit_Data *id, struct StrandSimParams *params, float frame, float frame_prev, struct Scene *scene, struct ListBase *effectors);
+struct Implicit_Data *BPH_strands_solver_create(struct Strands *strands, struct HairSimParams *params);
+bool BPH_strands_solve(struct Strands *strands, struct Implicit_Data *id, struct HairSimParams *params, float frame, float frame_prev, struct Scene *scene, struct ListBase *effectors);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index 22eeaad0..0bb0b63 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -1120,7 +1120,7 @@ bool BPH_cloth_solver_get_texture_data(Object *UNUSED(ob), ClothModifierData *cl
 
 /* ========================================================================= */
 
-struct Implicit_Data *BPH_strands_solver_create(struct Strands *strands, struct StrandSimParams *UNUSED(params))
+struct Implicit_Data *BPH_strands_solver_create(struct Strands *strands, struct HairSimParams *UNUSED(params))
 {
 	static float I3[3][3] = { {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 1.0f} };
 	
@@ -1200,7 +1200,7 @@ static void strands_setup_constraints(Strands *strands, Implicit_Data *data, Col
 }
 
 /* Collect forces and derivatives:  F, dFdX, dFdV */
-static void strands_calc_force(Strands *strands, StrandSimParams *params, Implicit_Data *data, float UNUSED(frame), Scene *scene, ListBase *effectors, float step)
+static void strands_calc_force(Strands *strands, HairSimParams *params, Implicit_Data *data, float UNUSED(frame), Scene *scene, ListBase *effectors, float step)
 {
 	unsigned int numverts = strands->totverts;
 	
@@ -1280,7 +1280,7 @@ static void strands_calc_force(Strands *strands, StrandSimParams *params, Implic
 	}
 }
 
-bool BPH_strands_solve(Strands *strands, Implicit_Data *id, StrandSimParams *params, float frame, float frame_prev, Scene *scene, ListBase *effectors)
+bool BPH_strands_solve(Strands *strands, Implicit_Data *id, HairSimParams *params, float frame, float frame_prev, Scene *scene, ListBase *effectors)
 {
 	if (params->timescale == 0.0f || params->substeps < 1)
 		return false;




More information about the Bf-blender-cvs mailing list