[Bf-blender-cvs] [0ab2bb5] alembic: Added effector weights for cache hair simulation.

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


Commit: 0ab2bb586e6ca29570c91332e6d66ef379f0dde1
Author: Lukas Tönne
Date:   Fri Apr 3 14:20:33 2015 +0200
Branches: alembic
https://developer.blender.org/rB0ab2bb586e6ca29570c91332e6d66ef379f0dde1

Added effector weights for cache hair simulation.

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

M	release/scripts/startup/bl_ui/properties_object.py
M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/makesdna/DNA_cache_library_types.h
M	source/blender/makesrna/intern/rna_cache_library.c

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

diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index b767492..0aa7569 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -20,6 +20,7 @@
 import bpy
 from bpy.types import Panel, Menu
 from rna_prop_ui import PropertyPanel
+from bl_ui.properties_physics_common import effector_weights_ui
 
 
 class ObjectButtonsPanel:
@@ -320,7 +321,7 @@ class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
         row.operator("cachelibrary.remove_modifier", icon='X', text="", emboss=False)
 
         # match enum type to our functions, avoids a lookup table.
-        getattr(self, md.type)(layout, cachelib, md)
+        getattr(self, md.type)(layout, context, cachelib, md)
 
     def draw_cachelib(self, context, layout, ob, cachelib, objects):
         col = layout.column()
@@ -418,8 +419,9 @@ class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
                 cache_objects = cachelib_objects(ob.cache_library, ob.dupli_group)
                 self.draw_cachelib(context, layout, ob, ob.cache_library, cache_objects)
 
-    def HAIR_SIMULATION(self, layout, cachelib, md):
-        pass
+    def HAIR_SIMULATION(self, context, layout, cachelib, md):
+        params = md.parameters
+        effector_weights_ui(self, context, params.effector_weights, 'HAIR')
 
 
 class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel):
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index f0148d6..5de4968 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -51,6 +51,7 @@
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
 #include "BKE_DerivedMesh.h"
+#include "BKE_effect.h"
 #include "BKE_global.h"
 #include "BKE_group.h"
 #include "BKE_library.h"
@@ -561,6 +562,8 @@ static void hairsim_params_init(HairSimParams *params)
 {
 	params->timescale = 1.0f;
 	params->substeps = 5;
+	
+	params->effector_weights = BKE_add_effector_weights(NULL);
 }
 
 static void hairsim_init(HairSimCacheModifier *hsmd)
@@ -570,6 +573,14 @@ static void hairsim_init(HairSimCacheModifier *hsmd)
 
 static void hairsim_copy(HairSimCacheModifier *hsmd, HairSimCacheModifier *thsmd)
 {
+	if (hsmd->sim_params.effector_weights)
+		thsmd->sim_params.effector_weights = MEM_dupallocN(hsmd->sim_params.effector_weights);
+}
+
+static void hairsim_free(HairSimCacheModifier *hsmd)
+{
+	if (hsmd->sim_params.effector_weights)
+		MEM_freeN(hsmd->sim_params.effector_weights);
 }
 
 static void hairsim_process(HairSimCacheModifier *hsmd, CacheProcessContext *ctx, CacheProcessData *data, int frame, int frame_prev)
@@ -608,7 +619,7 @@ CacheModifierTypeInfo cacheModifierType_HairSimulation = {
     /* foreachIDLink */     (CacheModifier_ForeachIDLinkFunc)NULL,
     /* process */           (CacheModifier_ProcessFunc)hairsim_process,
     /* init */              (CacheModifier_InitFunc)hairsim_init,
-    /* free */              (CacheModifier_FreeFunc)NULL,
+    /* free */              (CacheModifier_FreeFunc)hairsim_free,
 };
 
 void BKE_cache_modifier_init(void)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 0cec435..013dc6c 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2023,7 +2023,11 @@ static void direct_link_cache_modifiers(FileData *fd, ListBase *modifiers)
 		
 		
 		switch (md->type) {
-			// TODO
+			case eCacheModifierType_HairSimulation: {
+				HairSimCacheModifier *hsmd = (HairSimCacheModifier *)md;
+				hsmd->sim_params.effector_weights = newdataadr(fd, hsmd->sim_params.effector_weights);
+				break;
+			}
 		}
 	}
 }
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 9ad1d81..c8670d0 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -3497,7 +3497,11 @@ static void write_cache_modifiers(WriteData *wd, CacheLibrary *cachelib)
 		writestruct(wd, DATA, struct_name, 1, md);
 		
 		switch (md->type) {
-			// TODO add specifics here
+			case eCacheModifierType_HairSimulation: {
+				HairSimCacheModifier *hsmd = (HairSimCacheModifier *)md;
+				writestruct(wd, DATA, "EffectorWeights", 1, hsmd->sim_params.effector_weights);
+				break;
+			}
 		}
 	}
 }
diff --git a/source/blender/makesdna/DNA_cache_library_types.h b/source/blender/makesdna/DNA_cache_library_types.h
index 8958ed6..600175a 100644
--- a/source/blender/makesdna/DNA_cache_library_types.h
+++ b/source/blender/makesdna/DNA_cache_library_types.h
@@ -116,6 +116,8 @@ typedef enum eCacheModifier_Type {
 typedef struct HairSimParams {
 	float timescale;
 	int substeps;
+	
+	struct EffectorWeights *effector_weights;
 } HairSimParams;
 
 typedef struct HairSimCacheModifier {
diff --git a/source/blender/makesrna/intern/rna_cache_library.c b/source/blender/makesrna/intern/rna_cache_library.c
index 1afae09..aa18e4c 100644
--- a/source/blender/makesrna/intern/rna_cache_library.c
+++ b/source/blender/makesrna/intern/rna_cache_library.c
@@ -175,6 +175,11 @@ static void rna_def_hair_sim_params(BlenderRNA *brna)
 	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);
+	
+	prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
+	RNA_def_property_struct_type(prop, "EffectorWeights");
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Effector Weights", "");
 }
 
 static void rna_def_cache_modifier_hair_simulation(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list