Revision: 15513
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15513
Author:   theeth
Date:     2008-07-10 02:09:43 +0200 (Thu, 10 Jul 2008)

Log Message:
-----------
Snappiness merged from trunk:
        15455
        15323
        15322
        15279
        15243
        15235
        15180
        15179
        15178
        15177
        15176

Modified Paths:
--------------
    branches/blender-2.47/release/datafiles/blenderbuttons
    branches/blender-2.47/source/blender/blenkernel/BKE_object.h
    branches/blender-2.47/source/blender/blenkernel/intern/object.c
    branches/blender-2.47/source/blender/blenlib/BLI_arithb.h
    branches/blender-2.47/source/blender/blenlib/intern/arithb.c
    branches/blender-2.47/source/blender/include/BIF_resources.h
    branches/blender-2.47/source/blender/include/BSE_view.h
    branches/blender-2.47/source/blender/include/transform.h
    branches/blender-2.47/source/blender/makesdna/DNA_scene_types.h
    branches/blender-2.47/source/blender/python/api2_2x/Mathutils.c
    branches/blender-2.47/source/blender/src/blenderbuttons.c
    branches/blender-2.47/source/blender/src/editparticle.c
    branches/blender-2.47/source/blender/src/header_view3d.c
    branches/blender-2.47/source/blender/src/transform.c
    branches/blender-2.47/source/blender/src/transform_generics.c
    branches/blender-2.47/source/blender/src/transform_snap.c
    branches/blender-2.47/source/blender/src/view.c

Modified: branches/blender-2.47/release/datafiles/blenderbuttons
===================================================================
(Binary files differ)

Modified: branches/blender-2.47/source/blender/blenkernel/BKE_object.h
===================================================================
--- branches/blender-2.47/source/blender/blenkernel/BKE_object.h        
2008-07-09 21:32:25 UTC (rev 15512)
+++ branches/blender-2.47/source/blender/blenkernel/BKE_object.h        
2008-07-10 00:09:43 UTC (rev 15513)
@@ -108,6 +108,7 @@
 void minmax_object(struct Object *ob, float *min, float *max);
 void minmax_object_duplis(struct Object *ob, float *min, float *max);
 void solve_tracking (struct Object *ob, float targetmat[][4]);
+int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float 
ray_normal[3]);
 
 void object_handle_update(struct Object *ob);
 

Modified: branches/blender-2.47/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/blender-2.47/source/blender/blenkernel/intern/object.c     
2008-07-09 21:32:25 UTC (rev 15512)
+++ branches/blender-2.47/source/blender/blenkernel/intern/object.c     
2008-07-10 00:09:43 UTC (rev 15513)
@@ -2382,3 +2382,31 @@
        }
        return 1;
 }
+
+/*
+ * Test a bounding box for ray intersection
+ * assumes the ray is already local to the boundbox space
+ */
+int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float 
ray_normal[3])
+{
+       static int triangle_indexes[12][3] = {{0, 1, 2}, {0, 2, 3},
+                                                                               
  {3, 2, 6}, {3, 6, 7},
+                                                                               
  {1, 2, 6}, {1, 6, 5}, 
+                                                                               
  {5, 6, 7}, {4, 5, 7},
+                                                                               
  {0, 3, 7}, {0, 4, 7},
+                                                                               
  {0, 1, 5}, {0, 4, 5}};
+       int result = 0;
+       int i;
+       
+       for (i = 0; i < 12 && result == 0; i++)
+       {
+               float lambda;
+               int v1, v2, v3;
+               v1 = triangle_indexes[i][0];
+               v2 = triangle_indexes[i][1];
+               v3 = triangle_indexes[i][2];
+               result = RayIntersectsTriangle(ray_start, ray_normal, 
bb->vec[v1], bb->vec[v2], bb->vec[v3], &lambda, NULL);
+       }
+       
+       return result;
+}

Modified: branches/blender-2.47/source/blender/blenlib/BLI_arithb.h
===================================================================
--- branches/blender-2.47/source/blender/blenlib/BLI_arithb.h   2008-07-09 
21:32:25 UTC (rev 15512)
+++ branches/blender-2.47/source/blender/blenlib/BLI_arithb.h   2008-07-10 
00:09:43 UTC (rev 15513)
@@ -261,6 +261,7 @@
 void Vec2Subf(float *v, float *v1, float *v2);
 void Vec2Copyf(float *v1, float *v2);
 
+void AxisAngleToQuat(float *q, float *axis, float angle);
 void vectoquat(float *vec, short axis, short upflag, float *q);
 
 float VecAngle2(float *v1, float *v2);
@@ -272,6 +273,8 @@
 
 void euler_rot(float *beul, float ang, char axis);
        
+void NormalShortToFloat(float *out, short *in);
+void NormalFloatToShort(short *out, float *in);
 
 float DistVL2Dfl(float *v1, float *v2, float *v3);
 float PdistVL2Dfl(float *v1, float *v2, float *v3);
@@ -374,7 +377,9 @@
 void tubemap(float x, float y, float z, float *u, float *v);
 void spheremap(float x, float y, float z, float *u, float *v);
 
+int LineIntersectLine(float v1[3], float v2[3], float v3[3], float v4[3], 
float i1[3], float i2[3]);
 int LineIntersectsTriangle(float p1[3], float p2[3], float v0[3], float v1[3], 
float v2[3], float *lambda, float *uv);
+int RayIntersectsTriangle(float p1[3], float d[3], float v0[3], float v1[3], 
float v2[3], float *lambda, float *uv);
 int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, 
float v0[3], float v1[3], float v2[3], float *lambda, float *ipoint);
 int AxialLineIntersectsTriangle(int axis, float co1[3], float co2[3], float 
v0[3], float v1[3], float v2[3], float *lambda);
 int AabbIntersectAabb(float min1[3], float max1[3], float min2[3], float 
max2[3]);

Modified: branches/blender-2.47/source/blender/blenlib/intern/arithb.c
===================================================================
--- branches/blender-2.47/source/blender/blenlib/intern/arithb.c        
2008-07-09 21:32:25 UTC (rev 15512)
+++ branches/blender-2.47/source/blender/blenlib/intern/arithb.c        
2008-07-10 00:09:43 UTC (rev 15513)
@@ -1335,6 +1335,22 @@
        }
 }
 
+void AxisAngleToQuat(float *q, float *axis, float angle)
+{
+       float nor[3];
+       float si;
+       
+       VecCopyf(nor, axis);
+       Normalize(nor);
+       
+       angle /= 2;
+       si = (float)sin(angle);
+       q[0] = (float)cos(angle);
+       q[1] = nor[0] * si;
+       q[2] = nor[1] * si;
+       q[3] = nor[2] * si;     
+}
+
 void vectoquat(float *vec, short axis, short upflag, float *q)
 {
        float q2[4], nor[3], *fp, mat[3][3], angle, si, co, x2, y2, z2, len1;
@@ -2258,6 +2274,20 @@
        else return exp(log(d)/3);
 }
 
+void NormalShortToFloat(float *out, short *in)
+{
+       out[0] = in[0] / 32767.0;
+       out[1] = in[1] / 32767.0;
+       out[2] = in[2] / 32767.0;
+}
+
+void NormalFloatToShort(short *out, float *in)
+{
+       out[0] = (short)(in[0] * 32767.0);
+       out[1] = (short)(in[1] * 32767.0);
+       out[2] = (short)(in[2] * 32767.0);
+}
+
 /* distance v1 to line v2-v3 */
 /* using Hesse formula, NO LINE PIECE! */
 float DistVL2Dfl( float *v1, float *v2, float *v3)  {
@@ -3671,6 +3701,43 @@
        return 1;
 }
 
+/* moved from effect.c
+   test if the ray starting at p1 going in d direction intersects the triangle 
v0..v2
+   return non zero if it does 
+*/
+int RayIntersectsTriangle(float p1[3], float d[3], float v0[3], float v1[3], 
float v2[3], float *lambda, float *uv)
+{
+       float p[3], s[3], e1[3], e2[3], q[3];
+       float a, f, u, v;
+       
+       VecSubf(e1, v1, v0);
+       VecSubf(e2, v2, v0);
+       
+       Crossf(p, d, e2);
+       a = Inpf(e1, p);
+       if ((a > -0.000001) && (a < 0.000001)) return 0;
+       f = 1.0f/a;
+       
+       VecSubf(s, p1, v0);
+       
+       Crossf(q, s, e1);
+       *lambda = f * Inpf(e2, q);
+       if ((*lambda < 0.0)) return 0;
+       
+       u = f * Inpf(s, p);
+       if ((u < 0.0)||(u > 1.0)) return 0;
+       
+       v = f * Inpf(d, q);
+       if ((v < 0.0)||((u + v) > 1.0)) return 0;
+
+       if(uv) {
+               uv[0]= u;
+               uv[1]= v;
+       }
+       
+       return 1;
+}
+
 /* Adapted from the paper by Kasper Fauerby */
 /* "Improved Collision detection and Response" */
 int SweepingSphereIntersectsTriangleUV(float p1[3], float p2[3], float radius, 
float v0[3], float v1[3], float v2[3], float *lambda, float *ipoint)
@@ -3965,6 +4032,74 @@
        return 1;
 }
 
+/* Returns the number of point of interests
+ * 0 - lines are colinear
+ * 1 - lines are coplanar, i1 is set to intersection
+ * 2 - i1 and i2 are the nearest points on line 1 (v1, v2) and line 2 (v3, v4) 
respectively 
+ * */
+int LineIntersectLine(float v1[3], float v2[3], float v3[3], float v4[3], 
float i1[3], float i2[3])
+{
+       float a[3], b[3], c[3], ab[3], cb[3], dir1[3], dir2[3];
+       float d;
+       
+       VecSubf(c, v3, v1);
+       VecSubf(a, v2, v1);
+       VecSubf(b, v4, v3);
+
+       VecCopyf(dir1, a);
+       Normalize(dir1);
+       VecCopyf(dir2, b);
+       Normalize(dir2);
+       d = Inpf(dir1, dir2);
+       if (d == 1.0f || d == -1.0f) {
+               /* colinear */
+               return 0;
+       }
+
+       Crossf(ab, a, b);
+       d = Inpf(c, ab);
+
+       /* test if the two lines are coplanar */
+       if (d > -0.000001f && d < 0.000001f) {
+               Crossf(cb, c, b);
+
+               VecMulf(a, Inpf(cb, ab) / Inpf(ab, ab));
+               VecAddf(i1, v1, a);
+               VecCopyf(i2, i1);
+               
+               return 1; /* one intersection only */
+       }
+       /* if not */
+       else {
+               float n[3], t[3];
+               float v3t[3], v4t[3];
+               VecSubf(t, v1, v3);
+
+               /* offset between both plane where the lines lies */
+               Crossf(n, a, b);
+               Projf(t, t, n);
+
+               /* for the first line, offset the second line until it is 
coplanar */
+               VecAddf(v3t, v3, t);
+               VecAddf(v4t, v4, t);
+               
+               VecSubf(c, v3t, v1);
+               VecSubf(a, v2, v1);
+               VecSubf(b, v4t, v3);
+
+               Crossf(ab, a, b);
+               Crossf(cb, c, b);
+
+               VecMulf(a, Inpf(cb, ab) / Inpf(ab, ab));
+               VecAddf(i1, v1, a);
+
+               /* for the second line, just substract the offset from the 
first intersection point */
+               VecSubf(i2, i1, t);
+               
+               return 2; /* two nearest points */
+       }
+} 
+
 int AabbIntersectAabb(float min1[3], float max1[3], float min2[3], float 
max2[3])
 {
        return (min1[0]<max2[0] && min1[1]<max2[1] && min1[2]<max2[2] &&

Modified: branches/blender-2.47/source/blender/include/BIF_resources.h
===================================================================
--- branches/blender-2.47/source/blender/include/BIF_resources.h        
2008-07-09 21:32:25 UTC (rev 15512)
+++ branches/blender-2.47/source/blender/include/BIF_resources.h        
2008-07-10 00:09:43 UTC (rev 15513)
@@ -293,7 +293,7 @@
        ICON_ARMATURE_DEHLT,
        ICON_SNAP_GEAR,
        ICON_SNAP_GEO,
-       ICON_BLANK41,
+       ICON_SNAP_NORMAL,
        ICON_BLANK42,
        
        ICON_SMOOTHCURVE,

Modified: branches/blender-2.47/source/blender/include/BSE_view.h
===================================================================
--- branches/blender-2.47/source/blender/include/BSE_view.h     2008-07-09 
21:32:25 UTC (rev 15512)
+++ branches/blender-2.47/source/blender/include/BSE_view.h     2008-07-10 
00:09:43 UTC (rev 15513)
@@ -66,6 +66,8 @@
 void project_int_noclip(float *vec, int *adr);
 void project_float(float *vec, float *adr);
 void project_float_noclip(float *vec, float *adr);
+void viewray(short mval[2], float ray_start[3], float ray_normal[3]);
+void viewline(short mval[2], float ray_start[3], float ray_end[3]);
 
 int boundbox_clip(float obmat[][4], struct BoundBox *bb);
 void fdrawline(float x1, float y1, float x2, float y2);

Modified: branches/blender-2.47/source/blender/include/transform.h
===================================================================
--- branches/blender-2.47/source/blender/include/transform.h    2008-07-09 
21:32:25 UTC (rev 15512)
+++ branches/blender-2.47/source/blender/include/transform.h    2008-07-10 
00:09:43 UTC (rev 15513)
@@ -75,6 +75,8 @@
        int     status;
        float   snapPoint[3];
        float   snapTarget[3];
+       float   snapNormal[3];
+       float   snapTangent[3];
        float   dist; // Distance from snapPoint to snapTarget
        double  last;
        void  (*applySnap)(struct TransInfo *, float *);
@@ -457,6 +459,8 @@
 void resetSnapping(TransInfo *t);
 int  handleSnapping(TransInfo *t, int event);
 void drawSnapping(TransInfo *t);
+int usingSnappingNormal(TransInfo *t);
+int validSnappingNormal(TransInfo *t);
 
 /*********************** Generics ********************************/
 
@@ -487,6 +491,7 @@
 void calculatePropRatio(TransInfo *t);
 
 void getViewVector(float coord[3], float vec[3]);
+void getViewRay(short mval[2], float p[3], float d[3]);
 
 TransInfo * BIF_GetTransInfo(void);
 

Modified: branches/blender-2.47/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/blender-2.47/source/blender/makesdna/DNA_scene_types.h     
2008-07-09 21:32:25 UTC (rev 15512)

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to