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-18 18:31:32 +0300
committerJanne Karhu <jhkarh@gmail.com>2011-03-18 18:31:32 +0300
commit60ce95f5622d3947e30fe960eda22ea305660619 (patch)
tree20a322ff834993f9794ebb5c110437da41273812 /source/blender/blenkernel/BKE_particle.h
parent7e53769d09863b59beae4155ea0ad13c6ab2fac2 (diff)
New particle collisions code:
* The old collisions code detected particle collisions by calculating the collision times analytically from the collision mesh faces. This was pretty accurate, but didn't support rotating/deforming faces at all, as the equations for these quickly become quite nasty. * The new code uses a simple "distance to plane/edge/vert" function and iterates this with the Newton-Rhapson method to find the closest particle distance during a simulation step. * The advantage in this is that the collision object can now move, rotate, scale or even deform freely and collisions are still detected reliably. * For some extreme movements the calculation errors could stack up so much that the detection fails, but this can be easily fixed by increasing the particle size or simulation substeps. * As a side note the algorithm doesn't really do point particles anymore, but uses a very small radius as the particle size when "size deflect" isn't selected. * I've also updated the collision response code a bit, so now the particles shouldn't leak even from tight corners. All in all the collisions code is now much cleaner and more robust than before!
Diffstat (limited to 'source/blender/blenkernel/BKE_particle.h')
-rw-r--r--source/blender/blenkernel/BKE_particle.h60
1 files changed, 48 insertions, 12 deletions
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index e4fbd5603f2..9b1651b12cd 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -155,19 +155,57 @@ typedef struct ParticleBillboardData
short align, uv_split, anim, split_offset;
} ParticleBillboardData;
+typedef struct ParticleCollisionElement
+{
+ Object *ob;
+
+ /* pointers to original data */
+ float *x[4], *v[4];
+
+ /* values interpolated from original data*/
+ float x0[3], x1[3], x2[3], p[3];
+
+ /* results for found intersection point */
+ float nor[3], vel[3], uv[2];
+
+ /* count of original data (1-4) */
+ int tot;
+
+ /* flags for inversed normal / particle already inside element at start */
+ short inv_nor, inside;
+} ParticleCollisionElement;
+
/* container for moving data between deflet_particle and particle_intersect_face */
typedef struct ParticleCollision
{
- struct Object *ob, *hit_ob; // collided and current objects
- struct CollisionModifierData *md, *hit_md; // collision modifiers for current and hit object;
- float nor[3]; // normal at collision point
- float vel[3]; // velocity of collision point
- float co1[3], co2[3]; // ray start and end points
- float ve1[3], ve2[3]; // particle velocities
- float ray_len; // original length of co2-co1, needed for collision time evaluation
+ struct Object *current;
+ struct Object *hit;
+ struct Object *prev;
+ struct Object *skip;
+ struct Object *emitter;
+
+ struct CollisionModifierData *md; // collision modifier for current object;
+
float f; // time factor of previous collision, needed for substracting face velocity
- float cfra; // start of the timestep (during frame change, since previous integer frame)
- float dfra; // duration of timestep in frames
+ float fac1, fac2;
+
+ float cfra, old_cfra;
+
+ float original_ray_length; //original length of co2-co1, needed for collision time evaluation
+
+ int prev_index;
+
+ ParticleCollisionElement pce;
+
+ float total_time, inv_timestep;
+
+ float radius;
+ float co1[3], co2[3];
+ float ve1[3], ve2[3];
+
+ float acc[3], boid_z;
+
+ int boid;
} ParticleCollision;
typedef struct ParticleDrawData {
@@ -289,10 +327,8 @@ void psys_interpolate_face(struct MVert *mvert, struct MFace *mface, struct MTFa
float psys_particle_value_from_verts(struct DerivedMesh *dm, short from, struct ParticleData *pa, float *values);
void psys_get_from_key(struct ParticleKey *key, float *loc, float *vel, float *rot, float *time);
-/* only in edisparticle.c*/
-int psys_intersect_dm(struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float *vert_cos, float *co1, float* co2, float *min_d, int *min_face, float *min_uv, float *face_minmax, float *pa_minmax, float radius, float *ipoint);
/* BLI_bvhtree_ray_cast callback */
-void particle_intersect_face(void *userdata, int index, const struct BVHTreeRay *ray, struct BVHTreeRayHit *hit);
+void BKE_psys_collision_neartest_cb(void *userdata, int index, const struct BVHTreeRay *ray, struct BVHTreeRayHit *hit);
void psys_particle_on_dm(struct DerivedMesh *dm, int from, int index, int index_dmcache, float *fw, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor);
/* particle_system.c */