Revision: 41803
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41803
Author:   campbellbarton
Date:     2011-11-13 16:28:52 +0000 (Sun, 13 Nov 2011)
Log Message:
-----------
new math utility function isect_plane_plane_v3

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_geom.h
    trunk/blender/source/blender/blenlib/intern/math_geom.c
    trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
    trunk/blender/source/blender/makesrna/intern/rna_modifier.c
    trunk/blender/source/blender/python/mathutils/mathutils_geometry.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_geom.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_geom.h        2011-11-13 
16:24:15 UTC (rev 41802)
+++ trunk/blender/source/blender/blenlib/BLI_math_geom.h        2011-11-13 
16:28:52 UTC (rev 41803)
@@ -60,7 +60,7 @@
 float dist_to_line_segment_v2(const float p[2], const float l1[2], const float 
l2[2]);
 void closest_to_line_segment_v2(float closest[2], const float p[2], const 
float l1[2], const float l2[2]);
 
-float dist_to_plane_v3(const float p[2], const float plane_co[3], const float 
plane_no[2]);
+float dist_to_plane_v3(const float p[3], const float plane_co[3], const float 
plane_no[3]);
 float dist_to_line_segment_v3(const float p[3], const float l1[3], const float 
l2[3]);
 float closest_to_line_v3(float r[3], const float p[3], const float l1[3], 
const float l2[3]);
 float closest_to_line_v2(float r[2], const float p[2], const float l1[2], 
const float l2[2]);
@@ -92,9 +92,11 @@
  * */
 
 int isect_line_line_v3(const float v1[3], const float v2[3],
-       const float v3[3], const float v4[3], float i1[3], float i2[3]);
+                       const float v3[3], const float v4[3],
+                       float i1[3], float i2[3]);
 int isect_line_line_strict_v3(const float v1[3], const float v2[3],
-       const float v3[3], const float v4[3], float vi[3], float *lambda);
+                              const float v3[3], const float v4[3],
+                              float vi[3], float *lambda);
 
 /*if clip is nonzero, will only return true if lambda is >= 0.0
   (i.e. intersection point is along positive d)*/
@@ -113,6 +115,21 @@
 int isect_line_plane_v3(float out[3], const float l1[3], const float l2[3],
                         const float plane_co[3], const float plane_no[3], 
const short no_flip);
 
+/**
+ * Intersect two planes, return a point on the intersection and a vector
+ * that runs on the direction of the intersection.
+ * Return error code is the same as 'isect_line_line_v3'.
+ * @param r_isect_co The resulting intersection point.
+ * @param r_isect_no The resulting vector of the intersection.
+ * @param plane_a_co The point on the first plane.
+ * @param plane_a_no The normal of the first plane.
+ * @param plane_b_co The point on the second plane.
+ * @param plane_b_no The normal of the second plane.
+ */
+int isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3],
+                         const float plane_a_co[3], const float plane_a_no[3],
+                         const float plane_b_co[3], const float plane_b_no[3]);
+
 /* line/ray triangle */
 int isect_line_tri_v3(const float p1[3], const float p2[3],
        const float v0[3], const float v1[3], const float v2[3], float *lambda, 
float uv[2]);

Modified: trunk/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom.c     2011-11-13 
16:24:15 UTC (rev 41802)
+++ trunk/blender/source/blender/blenlib/intern/math_geom.c     2011-11-13 
16:28:52 UTC (rev 41803)
@@ -238,7 +238,7 @@
 }
 
 /* signed distance from the point to the plane in 3D */
-float dist_to_plane_v3(const float p[2], const float plane_co[3], const float 
plane_no[2])
+float dist_to_plane_v3(const float p[3], const float plane_co[3], const float 
plane_no[3])
 {
        float plane_no_unit[3];
        float plane_co_other[3];
@@ -833,6 +833,27 @@
        }
 }
 
+int isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3],
+                          const float plane_a_co[3], const float plane_a_no[3],
+                          const float plane_b_co[3], const float plane_b_no[3])
+{
+       float p1_co_other[3], p2_co_other[3];
+       float isect_co_dummy[3];
+
+       cross_v3_v3v3(r_isect_no, plane_a_no, plane_b_no);
+       cross_v3_v3v3(p1_co_other, plane_a_no, r_isect_no);
+       cross_v3_v3v3(p2_co_other, plane_b_no, r_isect_no);
+
+       add_v3_v3(p1_co_other, plane_a_co);
+       add_v3_v3(p2_co_other, plane_b_co);
+
+       /* we could use either ix_1, ix_2 - doesnt matter in this case */
+       return isect_line_line_v3(plane_a_co, p1_co_other,
+                                 plane_b_co, p2_co_other,
+                                 r_isect_co, isect_co_dummy);
+}
+
+
 /* Adapted from the paper by Kasper Fauerby */
 /* "Improved Collision detection and Response" */
 static int getLowestRoot(const float a, const float b, const float c, const 
float maxR, float *root)

Modified: trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_vector_inline.c    
2011-11-13 16:24:15 UTC (rev 41802)
+++ trunk/blender/source/blender/blenlib/intern/math_vector_inline.c    
2011-11-13 16:28:52 UTC (rev 41803)
@@ -181,19 +181,19 @@
        r[3] += f;
 }
 
-MINLINE void add_v2_v2(float *r, const float *a)
+MINLINE void add_v2_v2(float r[2], const float a[2])
 {
        r[0] += a[0];
        r[1] += a[1];
 }
 
-MINLINE void add_v2_v2v2(float *r, const float *a, const float *b)
+MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
 {
        r[0]= a[0] + b[0];
        r[1]= a[1] + b[1];
 }
 
-MINLINE void add_v3_v3(float *r, const float *a)
+MINLINE void add_v3_v3(float r[3], const float a[3])
 {
        r[0] += a[0];
        r[1] += a[1];

Modified: trunk/blender/source/blender/makesrna/intern/rna_modifier.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_modifier.c 2011-11-13 
16:24:15 UTC (rev 41802)
+++ trunk/blender/source/blender/makesrna/intern/rna_modifier.c 2011-11-13 
16:28:52 UTC (rev 41803)
@@ -695,8 +695,8 @@
        
        omd->chop_amount = value;
        
-       if ((old_value == 0.0 && value > 0.0) ||
-               (old_value > 0.0 && value == 0.0))
+       if ((old_value == 0.0f && value > 0.0f) ||
+               (old_value > 0.0f && value == 0.0f))
        {
                omd->refresh |= MOD_OCEAN_REFRESH_RESET;
                omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE;

Modified: trunk/blender/source/blender/python/mathutils/mathutils_geometry.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_geometry.c  
2011-11-13 16:24:15 UTC (rev 41802)
+++ trunk/blender/source/blender/python/mathutils/mathutils_geometry.c  
2011-11-13 16:28:52 UTC (rev 41803)
@@ -1213,6 +1213,7 @@
        {"intersect_line_line", (PyCFunction) M_Geometry_intersect_line_line, 
METH_VARARGS, M_Geometry_intersect_line_line_doc},
        {"intersect_line_line_2d", (PyCFunction) 
M_Geometry_intersect_line_line_2d, METH_VARARGS, 
M_Geometry_intersect_line_line_2d_doc},
        {"intersect_line_plane", (PyCFunction) M_Geometry_intersect_line_plane, 
METH_VARARGS, M_Geometry_intersect_line_plane_doc},
+       /* TODO: isect_plane_plane_v3 --> intersect_plane_plane */
        {"intersect_line_sphere", (PyCFunction) 
M_Geometry_intersect_line_sphere, METH_VARARGS, 
M_Geometry_intersect_line_sphere_doc},
        {"intersect_line_sphere_2d", (PyCFunction) 
M_Geometry_intersect_line_sphere_2d, METH_VARARGS, 
M_Geometry_intersect_line_sphere_2d_doc},
        {"distance_point_to_plane", (PyCFunction) 
M_Geometry_distance_point_to_plane, METH_VARARGS, 
M_Geometry_distance_point_to_plane_doc},

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to