[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44977] trunk/blender: "Fix" for [#30098] Particle rotation wrong / explode modifier
Janne Karhu
jhkarh at gmail.com
Sun Mar 18 22:33:02 CET 2012
Revision: 44977
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44977
Author: jhk
Date: 2012-03-18 21:33:00 +0000 (Sun, 18 Mar 2012)
Log Message:
-----------
"Fix" for [#30098] Particle rotation wrong / explode modifier
- The main problem was that in order to be accurate all particle
rotations have to be calculated incrementally so the only working
solution is to store rotations to the point cache (previously
this was only done for dynamic rotations). This can nearly double
the point cache size so it's not ideal to have this as a default
as in many cases you don't care about particle rotations.
- Particle rotation panel now has a new "enable" checkbox that
enables rotation calculations and the storing of rotations to
point cache.
- Old files will have rotations enabled via do_versions so that in
the worst case old files will only get bigger point caches, but no
sudden loss of particle rotations.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_ui/properties_particle.py
trunk/blender/source/blender/blenkernel/intern/particle_system.c
trunk/blender/source/blender/blenkernel/intern/pointcache.c
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/makesdna/DNA_particle_types.h
trunk/blender/source/blender/makesrna/intern/rna_particle.c
Modified: trunk/blender/release/scripts/startup/bl_ui/properties_particle.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_particle.py 2012-03-18 20:10:58 UTC (rev 44976)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_particle.py 2012-03-18 21:33:00 UTC (rev 44977)
@@ -380,6 +380,7 @@
class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
bl_label = "Rotation"
+ bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER'}
@classmethod
@@ -394,6 +395,15 @@
else:
return False
+ def draw_header(self, context):
+ psys = context.particle_system
+ if psys:
+ part = psys.settings
+ else:
+ part = context.space_data.pin_id
+
+ self.layout.prop(part, "use_rotations", text="")
+
def draw(self, context):
layout = self.layout
@@ -403,7 +413,7 @@
else:
part = context.space_data.pin_id
- layout.enabled = particle_panel_enabled(context, psys)
+ layout.enabled = particle_panel_enabled(context, psys) and part.use_rotations
layout.prop(part, "use_dynamic_rotation")
Modified: trunk/blender/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle_system.c 2012-03-18 20:10:58 UTC (rev 44976)
+++ trunk/blender/source/blender/blenkernel/intern/particle_system.c 2012-03-18 21:33:00 UTC (rev 44977)
@@ -2684,6 +2684,12 @@
{
float rotfac, rot1[4], rot2[4]={1.0,0.0,0.0,0.0}, dtime=dfra*timestep;
+ if((part->flag & PART_ROTATIONS)==0) {
+ pa->state.rot[0]=1.0f;
+ pa->state.rot[1]=pa->state.rot[2]=pa->state.rot[3]=0;
+ return;
+ }
+
if((part->flag & PART_ROT_DYN)==0) {
if(part->avemode==PART_AVE_SPIN) {
float angle;
Modified: trunk/blender/source/blender/blenkernel/intern/pointcache.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pointcache.c 2012-03-18 20:10:58 UTC (rev 44976)
+++ trunk/blender/source/blender/blenkernel/intern/pointcache.c 2012-03-18 21:33:00 UTC (rev 44977)
@@ -315,9 +315,10 @@
}
}
- /* determine rotation from velocity */
+ /* default to no rotation */
if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) {
- vec_to_quat( pa->state.rot,pa->state.vel, OB_NEGX, OB_POSZ);
+ pa->state.rot[0]=1.0f;
+ pa->state.rot[1]=pa->state.rot[2]=pa->state.rot[3]=0;
}
}
static void ptcache_particle_interpolate(int index, void *psys_v, void **data, float cfra, float cfra1, float cfra2, float *old_data)
@@ -815,13 +816,14 @@
pid->read_extra_data = ptcache_particle_extra_read;
}
- if(psys->part->rotmode!=PART_ROT_VEL
- || psys->part->avemode!=PART_AVE_SPIN || psys->part->avefac!=0.0f)
- pid->data_types|= (1<<BPHYS_DATA_AVELOCITY) | (1<<BPHYS_DATA_ROTATION);
-
- if(psys->part->flag & PART_ROT_DYN)
+ if(psys->part->flag & PART_ROTATIONS) {
pid->data_types|= (1<<BPHYS_DATA_ROTATION);
+ if(psys->part->rotmode!=PART_ROT_VEL
+ || psys->part->avemode!=PART_AVE_SPIN || psys->part->avefac!=0.0f)
+ pid->data_types|= (1<<BPHYS_DATA_AVELOCITY);
+ }
+
pid->info_types= (1<<BPHYS_DATA_TIMES);
pid->default_step = 10;
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2012-03-18 20:10:58 UTC (rev 44976)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2012-03-18 21:33:00 UTC (rev 44977)
@@ -13292,6 +13292,13 @@
}
}
+ {
+ /* Default for old files is to save particle rotations to pointcache */
+ ParticleSettings *part;
+ for (part = main->particle.first; part; part = part->id.next)
+ part->flag |= PART_ROTATIONS;
+ }
+
/* put compatibility code here until next subversion bump */
{
Modified: trunk/blender/source/blender/makesdna/DNA_particle_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_particle_types.h 2012-03-18 20:10:58 UTC (rev 44976)
+++ trunk/blender/source/blender/makesdna/DNA_particle_types.h 2012-03-18 21:33:00 UTC (rev 44977)
@@ -321,7 +321,7 @@
#define PART_TRAND 128
#define PART_EDISTR 256 /* particle/face from face areas */
-//#define PART_STICKY 512 /*collided particles can stick to collider*/
+#define PART_ROTATIONS 512 /* calculate particle rotations (and store them in pointcache) */
#define PART_DIE_ON_COL (1<<12)
#define PART_SIZE_DEFL (1<<13) /* swept sphere deflections */
#define PART_ROT_DYN (1<<14) /* dynamic rotation */
Modified: trunk/blender/source/blender/makesrna/intern/rna_particle.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_particle.c 2012-03-18 20:10:58 UTC (rev 44976)
+++ trunk/blender/source/blender/makesrna/intern/rna_particle.c 2012-03-18 21:33:00 UTC (rev 44977)
@@ -1661,6 +1661,12 @@
RNA_def_property_ui_text(prop, "Size Deflect", "Use particle's size in deflection");
RNA_def_property_update(prop, 0, "rna_Particle_reset");
+ prop = RNA_def_property(srna, "use_rotations", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ROTATIONS);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Rotations", "Calculate particle rotations");
+ RNA_def_property_update(prop, 0, "rna_Particle_reset");
+
prop = RNA_def_property(srna, "use_dynamic_rotation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ROT_DYN);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
More information about the Bf-blender-cvs
mailing list