Revision: 35721
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35721
Author:   jhk
Date:     2011-03-23 10:57:45 +0000 (Wed, 23 Mar 2011)
Log Message:
-----------
Fix for 1. in [#26212] ParticleSystem.particles issues
* Exposed dynamic hair data in rna to allow exporting hair dynamics.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_particle.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_particle.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_particle.c 2011-03-23 
10:33:06 UTC (rev 35720)
+++ trunk/blender/source/blender/makesrna/intern/rna_particle.c 2011-03-23 
10:57:45 UTC (rev 35721)
@@ -37,6 +37,7 @@
 #include "rna_internal.h"
 
 #include "DNA_material_types.h"
+#include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_cloth_types.h"
 #include "DNA_particle_types.h"
@@ -121,6 +122,8 @@
 #include "BKE_cloth.h"
 #include "BKE_deform.h"
 #include "BKE_depsgraph.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_cdderivedmesh.h"
 #include "BKE_effect.h"
 #include "BKE_modifier.h"
 #include "BKE_particle.h"
@@ -213,6 +216,58 @@
        }
 }
 
+static void rna_ParticleHairKey_dynamic_location_object_get(PointerRNA *ptr, 
float *values)
+{
+       HairKey *hkey= (HairKey *)ptr->data;
+       Object *ob = (Object *)ptr->id.data;
+       ParticleSystemModifierData *psmd;
+       ParticleData *pa;
+
+       rna_ParticleHairKey_location_object_info(ptr, &psmd, &pa);
+
+       if(pa) {
+               ParticleSystem *psys = psmd->psys;
+               DerivedMesh *hairdm = (psys->flag & PSYS_HAIR_DYNAMICS) ? 
psys->hair_out_dm : NULL;
+
+               if(hairdm) {
+                       MVert *mvert = CDDM_get_vert(hairdm, pa->hair_index + 
(hkey - pa->hair));
+                       copy_v3_v3(values, mvert->co);
+               }
+               else {
+                       rna_ParticleHairKey_dynamic_location_object_get(ptr, 
values);
+               }
+       }
+       else {
+               zero_v3(values);
+       }
+}
+
+static void rna_ParticleHairKey_dynamic_location_object_set(PointerRNA *ptr, 
const float *values)
+{
+       HairKey *hkey= (HairKey *)ptr->data;
+       Object *ob = (Object *)ptr->id.data;
+       ParticleSystemModifierData *psmd;
+       ParticleData *pa;
+
+       rna_ParticleHairKey_location_object_info(ptr, &psmd, &pa);
+
+       if(pa) {
+               ParticleSystem *psys = psmd->psys;
+               DerivedMesh *hairdm = (psys->flag & PSYS_HAIR_DYNAMICS) ? 
psys->hair_out_dm : NULL;
+
+               if(hairdm) {
+                       MVert *mvert = CDDM_get_vert(hairdm, pa->hair_index + 
(hkey - pa->hair));
+                       copy_v3_v3(mvert->co, values);
+               }
+               else {
+                       rna_ParticleHairKey_dynamic_location_object_set(ptr, 
values);
+               }
+       }
+       else {
+               zero_v3(hkey->co);
+       }
+}
+
 /* property update functions */
 static void particle_recalc(Main *bmain, Scene *scene, PointerRNA *ptr, short 
flag)
 {
@@ -886,6 +941,11 @@
        prop= RNA_def_property(srna, "co_hair_space", PROP_FLOAT, 
PROP_TRANSLATION);
        RNA_def_property_float_sdna(prop, NULL, "co");
        RNA_def_property_ui_text(prop, "Location", "Location of the hair key in 
its internal coordinate system, relative to the emitting face");
+
+       prop= RNA_def_property(srna, "co_dynamic", PROP_FLOAT, 
PROP_TRANSLATION);
+       RNA_def_property_array(prop, 3);
+       RNA_def_property_ui_text(prop, "Location (Dynamic)", "Location of the 
hair key for the current frame with hair dynamics applied");
+       RNA_def_property_float_funcs(prop, 
"rna_ParticleHairKey_dynamic_location_object_get", 
"rna_ParticleHairKey_dynamic_location_object_set", NULL);
 }
 
 static void rna_def_particle_key(BlenderRNA *brna)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to