[Bf-blender-cvs] [afc6142] alembic: Fix for deflector force fields in cache simulation.
Lukas Tönne
noreply at git.blender.org
Thu Apr 30 12:16:08 CEST 2015
Commit: afc6142b9169e2b530da352458e9f990ceb7820a
Author: Lukas Tönne
Date: Thu Apr 30 12:14:51 2015 +0200
Branches: alembic
https://developer.blender.org/rBafc6142b9169e2b530da352458e9f990ceb7820a
Fix for deflector force fields in cache simulation.
Make sure forces always push outward when not using "double sided"
deflectors (default).
===================================================================
M source/blender/blenkernel/BKE_cache_library.h
M source/blender/blenkernel/intern/cache_library.c
M source/blender/physics/intern/BPH_mass_spring.cpp
===================================================================
diff --git a/source/blender/blenkernel/BKE_cache_library.h b/source/blender/blenkernel/BKE_cache_library.h
index bc48b60..dab8fe9 100644
--- a/source/blender/blenkernel/BKE_cache_library.h
+++ b/source/blender/blenkernel/BKE_cache_library.h
@@ -202,6 +202,7 @@ typedef enum eCacheEffector_Type {
} eCacheEffector_Type;
typedef struct CacheEffectorPoint {
+ int index;
float x[3], v[3];
} CacheEffectorPoint;
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index fd21635..849e57b 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -780,6 +780,7 @@ static bool cache_effector_deflect(CacheEffector *eff, CacheEffectorInstance *in
{
float vec[3], dist;
+ bool inside = false;
float factor;
sub_v3_v3v3(vec, point->x, nearest.co);
@@ -789,13 +790,17 @@ static bool cache_effector_deflect(CacheEffector *eff, CacheEffectorInstance *in
/* dm normal also needed in world space */
mul_mat3_m4_v3(inst->mat, nearest.no);
- if (dot_v3v3(vec, nearest.no) < 0.0f)
+ if (dot_v3v3(vec, nearest.no) < 0.0f) {
dist = -dist;
+ inside = true;
+ }
}
factor = cache_effector_falloff(eff, dist);
mul_v3_v3fl(result->f, vec, eff->strength * factor);
+ if (inside)
+ negate_v3(result->f);
}
return true;
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index 37b1fdc..8a6e8e1 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -1449,6 +1449,7 @@ static void strands_calc_force(Strands *strands, float space[4][4], HairSimParam
if (cache_effectors && tot_cache_effectors > 0) {
for (i = 0; i < numverts; ++i) {
CacheEffectorPoint point;
+ point.index = i;
BPH_mass_spring_get_motion_state(data, i, point.x, point.v);
CacheEffectorResult result;
More information about the Bf-blender-cvs
mailing list