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>2011-03-23 13:57:45 +0300
committerJanne Karhu <jhkarh@gmail.com>2011-03-23 13:57:45 +0300
commitf35c3966766ad62a90a00b4473c79766be9b2139 (patch)
tree4d5d5bdace23023b5889faa34b477d4ffa35a252 /source/blender/makesrna/intern/rna_particle.c
parentf64f979a10c5c5007a0b14c2f134970023cb7e15 (diff)
Fix for 1. in [#26212] ParticleSystem.particles issues
* Exposed dynamic hair data in rna to allow exporting hair dynamics.
Diffstat (limited to 'source/blender/makesrna/intern/rna_particle.c')
-rw-r--r--source/blender/makesrna/intern/rna_particle.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 73030b00328..f48a575951f 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -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 @@ EnumPropertyItem part_hair_ren_as_items[] = {
#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_location_object_set(PointerRNA *ptr, const float
}
}
+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 @@ static void rna_def_particle_hair_key(BlenderRNA *brna)
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)