[Bf-blender-cvs] [77df327fa8] cloth-improvements: Implement normal override for the new collision function
Luca Rood
noreply at git.blender.org
Sat Mar 4 06:22:39 CET 2017
Commit: 77df327fa80a722a96db8ae29133d51c6451c07f
Author: Luca Rood
Date: Sat Mar 4 01:12:11 2017 -0300
Branches: cloth-improvements
https://developer.blender.org/rB77df327fa80a722a96db8ae29133d51c6451c07f
Implement normal override for the new collision function
===================================================================
M source/blender/blenkernel/intern/collision.c
===================================================================
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 64215a2b63..24294dadce 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -273,6 +273,9 @@ static float compute_collision_point(float a1[3], float a2[3], float a3[3], floa
}
}
}
+ else if (use_normal) {
+ normal_tri_v3(normal, b[0], b[1], b[2]);
+ }
if (isect_count == 1) {
/* Edge intersection */
@@ -281,6 +284,10 @@ static float compute_collision_point(float a1[3], float a2[3], float a3[3], floa
sub_v3_v3v3(r_vec, r_b, r_a);
+ if (use_normal) {
+ copy_v3_v3(r_vec, normal);
+ }
+
return 0.0f;
}
else if (backside) {
@@ -344,6 +351,15 @@ static float compute_collision_point(float a1[3], float a2[3], float a3[3], floa
if (found) {
sub_v3_v3v3(r_vec, r_b, r_a);
+ if (use_normal) {
+ if (dot_v3v3(normal, r_vec) >= 0.0f) {
+ copy_v3_v3(r_vec, normal);
+ }
+ else {
+ negate_v3_v3(r_vec, normal);
+ }
+ }
+
return 0.0f;
}
}
@@ -397,7 +413,18 @@ static float compute_collision_point(float a1[3], float a2[3], float a3[3], floa
dist = 0.0f;
}
- if (culling && (dot_v3v3(r_vec, normal) < 0.0f)) {
+ if (culling && use_normal) {
+ copy_v3_v3(r_vec, normal);
+ }
+ else if (use_normal) {
+ if (dot_v3v3(normal, r_vec) >= 0.0f) {
+ copy_v3_v3(r_vec, normal);
+ }
+ else {
+ negate_v3_v3(r_vec, normal);
+ }
+ }
+ else if (culling && (dot_v3v3(r_vec, normal) < 0.0f)) {
return FLT_MAX;
}
More information about the Bf-blender-cvs
mailing list