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>2008-09-13 22:09:41 +0400
committerJanne Karhu <jhkarh@gmail.com>2008-09-13 22:09:41 +0400
commitd2186508da224805db8d2fe299738a94e1a5e750 (patch)
tree7c93d7d69b3d055ceeb5dca0c4d8b4d1bb6174db /source/blender/blenlib
parent8925ae60428ed213fd8cb1271671e6ca56fda70e (diff)
Particle collisions upgrade:
- Particle now use the deflector objects collision modifier data to collide with deflectors and as a result can now use the velocity of the colliding object for more realistic collisions. - Dynamic rotations are also quite a bit more realistic and are related to the friction setting of the deflector (to get any dynamic rotations there has to be some friction). This is largely due to the separate handling of rolling friction (approximated to be 1% of normal sliding friction). - Collisions should be a bit faster on complex deflectors due to the tree structure used by the collision modifier. - Collision should also generally be a bit more accurate. To be noted: Only the average velocity of individual deflector faces is used, so collisions with rotating or deforming objects can't be handled accurately - this would require much more complex calculations. Subdividing the deflector object surface to smaller faces can help with this as the individual face velocities become more linear.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_kdopbvh.h3
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c11
2 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h
index 6d9a17efebf..e3591a84e98 100644
--- a/source/blender/blenlib/BLI_kdopbvh.h
+++ b/source/blender/blenlib/BLI_kdopbvh.h
@@ -54,6 +54,7 @@ typedef struct BVHTreeRay
{
float origin[3]; /* ray origin */
float direction[3]; /* ray direction */
+ float radius; /* radius around ray */
} BVHTreeRay;
typedef struct BVHTreeRayHit
@@ -90,7 +91,7 @@ float BLI_bvhtree_getepsilon(BVHTree *tree);
/* find nearest node to the given coordinates (if nearest is given it will only search nodes where square distance is smaller than nearest->dist) */
int BLI_bvhtree_find_nearest(BVHTree *tree, const float *co, BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata);
-int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata);
+int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata);
#endif // BLI_KDOPBVH_H
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 9f82a816147..30472beb3e6 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -1414,14 +1414,14 @@ static float ray_nearest_hit(BVHRayCastData *data, BVHNode *node)
if(data->ray_dot_axis[i] == 0.0f)
{
//axis aligned ray
- if(data->ray.origin[i] < bv[0]
- || data->ray.origin[i] > bv[1])
+ if(data->ray.origin[i] < bv[0] - data->ray.radius
+ || data->ray.origin[i] > bv[1] + data->ray.radius)
return FLT_MAX;
}
else
{
- float ll = (bv[0] - data->ray.origin[i]) / data->ray_dot_axis[i];
- float lu = (bv[1] - data->ray.origin[i]) / data->ray_dot_axis[i];
+ float ll = (bv[0] - data->ray.radius - data->ray.origin[i]) / data->ray_dot_axis[i];
+ float lu = (bv[1] + data->ray.radius - data->ray.origin[i]) / data->ray_dot_axis[i];
if(data->ray_dot_axis[i] > 0.0f)
{
@@ -1480,7 +1480,7 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node)
}
}
-int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
+int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
{
int i;
BVHRayCastData data;
@@ -1493,6 +1493,7 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, BVHTr
VECCOPY(data.ray.origin, co);
VECCOPY(data.ray.direction, dir);
+ data.ray.radius = radius;
Normalize(data.ray.direction);