[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12936] branches/cloth/blender/source/ blender: Some User UI changes: a) Don' t ask the user anymore if he wants to overwrite the file when he' s doing a simple ctrl-s/ctrl-w; b) Ask for saving on exit when a file has changed, ontheless quit. blend is saved anyway.

Daniel Genrich daniel.genrich at gmx.net
Tue Dec 18 17:54:17 CET 2007


Revision: 12936
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12936
Author:   genscher
Date:     2007-12-18 17:54:12 +0100 (Tue, 18 Dec 2007)

Log Message:
-----------
Some User UI changes: a) Don't ask the user anymore if he wants to overwrite the file when he's doing a simple ctrl-s/ctrl-w; b) Ask for saving on exit when a file has changed, ontheless quit.blend is saved anyway. --> All branch changes, not likely to go into trunk

Modified Paths:
--------------
    branches/cloth/blender/source/blender/blenkernel/BKE_blender.h
    branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
    branches/cloth/blender/source/blender/blenkernel/intern/blender.c
    branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
    branches/cloth/blender/source/blender/blenkernel/intern/implicit.c
    branches/cloth/blender/source/blender/blenkernel/intern/kdop.c
    branches/cloth/blender/source/blender/blenkernel/intern/modifier.c
    branches/cloth/blender/source/blender/makesdna/DNA_userdef_types.h
    branches/cloth/blender/source/blender/src/blenderbuttons.c
    branches/cloth/blender/source/blender/src/header_info.c
    branches/cloth/blender/source/blender/src/toets.c
    branches/cloth/blender/source/blender/src/toolbox.c
    branches/cloth/blender/source/blender/src/usiblender.c

Modified: branches/cloth/blender/source/blender/blenkernel/BKE_blender.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_blender.h	2007-12-18 00:18:04 UTC (rev 12935)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_blender.h	2007-12-18 16:54:12 UTC (rev 12936)
@@ -70,6 +70,7 @@
 extern char *BKE_undo_menu_string(void);
 extern void BKE_undo_number(int nr);
 extern void BKE_undo_save_quit(void);
+extern int BKE_undo_there(void);
 
 #ifdef __cplusplus
 }

Modified: branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h	2007-12-18 00:18:04 UTC (rev 12935)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h	2007-12-18 16:54:12 UTC (rev 12936)
@@ -60,7 +60,19 @@
 
 #define CLOTH_MAX_THREAD 2
 
+typedef struct fc
+{
+	float *d, *d0;			// density
+	float *T, *T0;			// temperature
+	float *u, *u0;			// velocity in x direction
+	float *v, *v0;			// velocity in y direction
+	float *w, *w0;			// velocity in z direction
+} fc;
+fc *f_init(void);
+void f_free(fc *m_fc);
+void step(fc *m_fc, float dt);
 
+
 typedef struct ClothVertex {
 	int	flags;		/* General flags per vertex.		*/
 	float 	mass;		/* mass / weight of the vertex		*/
@@ -69,6 +81,7 @@
 	unsigned int impulse_count; /* same as above */
 	float collball;
 	char octantflag;
+	float weight;
 } ClothVertex;
 
 typedef struct ClothSpring {
@@ -104,6 +117,7 @@
 	float 			(*v)[4]; /* the current velocity of all vertices */
 	float			(*current_v)[3];
 	float			(*xconst)[3];
+	struct fc		*m_fc;
 } Cloth;
 
 /* goal defines */

Modified: branches/cloth/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/blender.c	2007-12-18 00:18:04 UTC (rev 12935)
+++ branches/cloth/blender/source/blender/blenkernel/intern/blender.c	2007-12-18 16:54:12 UTC (rev 12936)
@@ -85,6 +85,7 @@
 #include "BKE_bad_level_calls.h" // for freeAllRad editNurb free_editMesh free_editText free_editArmature
 #include "BKE_utildefines.h" // O_BINARY FALSE
 #include "BIF_mainqueue.h" // mainqenter for onload script
+#include "BIF_toolbox.h"
 #include "mydevice.h"
 #include "nla.h"
 #include "blendef.h"
@@ -617,6 +618,10 @@
 		success= BLO_write_file_mem(prevfile, &curundo->memfile, G.fileflags, &err);
 		
 	}
+	
+	/* signals "file needs save" on exit */
+	if(curundo!=NULL && curundo->prev!=NULL)
+		U.uiflag |= USER_UNDOSAVE;
 }
 
 /* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */
@@ -694,7 +699,7 @@
 	return menu;
 }
 
-	/* saves quit.blend */
+/* saves quit.blend */
 void BKE_undo_save_quit(void)
 {
 	UndoElem *uel;

Modified: branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2007-12-18 00:18:04 UTC (rev 12935)
+++ branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2007-12-18 16:54:12 UTC (rev 12936)
@@ -78,6 +78,22 @@
 #include "BIF_space.h"
 #include "mydevice.h"
 
+#ifdef WIN32
+#include <windows.h>
+#endif // WIN32
+#ifdef __APPLE__
+#define GL_GLEXT_LEGACY 1
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#else
+#include <GL/gl.h>
+#if defined(__sun__) && !defined(__sparc__)
+#include <mesa/glu.h>
+#else
+#include <GL/glu.h>
+#endif
+#endif
+
 #ifdef _WIN32
 void tstart ( void )
 {}
@@ -482,6 +498,309 @@
 	return ret;
 }
 
+#define AMBIENT 50
+#define DECAY 0.04f
+#define ALMOST_EQUAL(a, b) ((fabs(a-b)<0.00001f)?1:0)
+
+	// cube vertices
+GLfloat cv[][3] = {
+	{1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f}, {-1.0f, -1.0f, 1.0f}, {1.0f, -1.0f, 1.0f},
+ {1.0f, 1.0f, -1.0f}, {-1.0f, 1.0f, -1.0f}, {-1.0f, -1.0f, -1.0f}, {1.0f, -1.0f, -1.0f}
+};
+
+	// edges have the form edges[n][0][xyz] + t*edges[n][1][xyz]
+float edges[12][2][3] = {
+	{{1.0f, 1.0f, -1.0f}, {0.0f, 0.0f, 1.0f}},
+ {{-1.0f, 1.0f, -1.0f}, {0.0f, 0.0f, 1.0f}},
+ {{-1.0f, -1.0f, -1.0f}, {0.0f, 0.0f, 1.0f}},
+ {{1.0f, -1.0f, -1.0f}, {0.0f, 0.0f, 1.0f}},
+
+ {{1.0f, -1.0f, 1.0f}, {0.0f, 1.0f, 0.0f}},
+ {{-1.0f, -1.0f, 1.0f}, {0.0f, 1.0f, 0.0f}},
+ {{-1.0f, -1.0f, -1.0f}, {0.0f, 1.0f, 0.0f}},
+ {{1.0f, -1.0f, -1.0f}, {0.0f, 1.0f, 0.0f}},
+
+ {{-1.0f, 1.0f, 1.0f}, {1.0f, 0.0f, 0.0f}},
+ {{-1.0f, -1.0f, 1.0f}, {1.0f, 0.0f, 0.0f}},
+ {{-1.0f, -1.0f, -1.0f}, {1.0f, 0.0f, 0.0f}},
+ {{-1.0f, 1.0f, -1.0f}, {1.0f, 0.0f, 0.0f}}
+};
+
+void light_ray(unsigned char* _texture_data, int _ray_templ[4096][3], int x, int y, int z, int n, float decay)
+{
+	int xx = x, yy = y, zz = z, i = 0;
+	int offset;
+
+	int l = 255;
+	float d;
+
+	do {
+		offset = ((((zz*n) + yy)*n + xx) << 2);
+		if (_texture_data[offset + 2] > 0)
+			_texture_data[offset + 2] = (unsigned char) ((_texture_data[offset + 2] + l)*0.5f);
+		else
+			_texture_data[offset + 2] = (unsigned char) l;
+		d = _texture_data[offset+1];
+		if (l > AMBIENT) {
+			l -= d*decay;
+			if (l < AMBIENT)
+				l = AMBIENT;
+		}
+
+		i++;
+		xx = x + _ray_templ[i][0];
+		yy = y + _ray_templ[i][1];
+		zz = z + _ray_templ[i][2];
+		
+	} while ((xx>=0)&&(xx<n)&&(yy>=0)&&(yy<n)&&(zz>=0)&&(zz<n));
+}
+
+void cast_light(unsigned char* _texture_data, int _ray_templ[4096][3], float *_light_dir, int n /*edgelen*/)
+{
+	int i,j;
+	int sx = (_light_dir[0]>0) ? 0 : n-1;
+	int sy = (_light_dir[1]>0) ? 0 : n-1;
+	int sz = (_light_dir[2]>0) ? 0 : n-1;
+
+	float decay = 1.0f/(n*DECAY);
+
+	for (i=0; i<n; i++)
+		for (j=0; j<n; j++) {
+		if (!ALMOST_EQUAL(_light_dir[0], 0))
+			light_ray(_texture_data, _ray_templ, sx,i,j,n,decay);
+		if (!ALMOST_EQUAL(_light_dir[1], 0))
+			light_ray(_texture_data, _ray_templ, i,sy,j,n,decay);
+		if (!ALMOST_EQUAL(_light_dir[2], 0))
+			light_ray(_texture_data, _ray_templ, i,j,sz,n,decay);
+		}
+}
+
+void gen_ray_templ(int _ray_templ[4096][3], float *_light_dir, int edgelen)
+{
+	float fx = 0.0f, fy = 0.0f, fz = 0.0f;
+	int x = 0, y = 0, z = 0;
+	float lx = _light_dir[0] + 0.000001f, ly = _light_dir[1] + 0.000001f, lz = _light_dir[2] + 0.000001f;
+	int xinc = (lx > 0) ? 1 : -1;
+	int yinc = (ly > 0) ? 1 : -1;
+	int zinc = (lz > 0) ? 1 : -1;
+	float tx, ty, tz;
+	int i = 1;
+	int len = 0;
+	int maxlen = 3*edgelen*edgelen;
+	_ray_templ[0][0] = _ray_templ[0][2] = _ray_templ[0][2] = 0;
+	
+	while (len <= maxlen)
+	{
+		// fx + t*lx = (x+1)   ->   t = (x+1-fx)/lx
+		tx = (x+xinc-fx)/lx;
+		ty = (y+yinc-fy)/ly;
+		tz = (z+zinc-fz)/lz;
+
+		if ((tx<=ty)&&(tx<=tz)) {
+			_ray_templ[i][0] = _ray_templ[i-1][0] + xinc;
+			x =+ xinc;
+			fx = x;
+
+			if (ALMOST_EQUAL(ty,tx)) {
+				_ray_templ[i][1] = _ray_templ[i-1][1] + yinc;
+				y += yinc;
+				fy = y;
+			} else {
+				_ray_templ[i][1] = _ray_templ[i-1][1];
+				fy += tx*ly;
+			}
+
+			if (ALMOST_EQUAL(tz,tx)) {
+				_ray_templ[i][2] = _ray_templ[i-1][2] + zinc;
+				z += zinc;
+				fz = z;
+			} else {
+				_ray_templ[i][2] = _ray_templ[i-1][2];
+				fz += tx*lz;
+			}
+		} else if ((ty<tx)&&(ty<=tz)) {
+			_ray_templ[i][0] = _ray_templ[i-1][0];
+			fx += ty*lx;
+
+			_ray_templ[i][1] = _ray_templ[i-1][1] + yinc;
+			y += yinc;
+			fy = y;
+
+			if (ALMOST_EQUAL(tz,ty)) {
+				_ray_templ[i][2] = _ray_templ[i-1][2] + zinc;
+				z += zinc;
+				fz = z;
+			} else {
+				_ray_templ[i][2] = _ray_templ[i-1][2];
+				fz += ty*lz;
+			}
+		} else {
+			// assert((tz<tx)&&(tz<ty));
+			if((tz<tx)&&(tz<ty))
+				break;
+			
+			_ray_templ[i][0] = _ray_templ[i-1][0];
+			fx += tz*lx;
+			_ray_templ[i][1] = _ray_templ[i-1][1];
+			fy += tz*ly;
+			_ray_templ[i][2] = _ray_templ[i-1][2] + zinc;
+			z += zinc;
+			fz = z;
+		}
+
+		len = _ray_templ[i][0]*_ray_templ[i][0]
+				+ _ray_templ[i][1]*_ray_templ[i][1]
+				+ _ray_templ[i][2]*_ray_templ[i][2];
+		i++;
+	}
+}
+/*
+int intersect_edges(float ret[12][3], float a, float b, float c, float d)
+{
+	int i;
+	float t;
+	Vec3 p;
+	int num = 0;
+
+	for (i=0; i<12; i++) {
+		t = -(a*edges[i][0][0] + b*edges[i][0][1] + c*edges[i][0][2] + d)
+			/ (a*edges[i][1][0] + b*edges[i][1][1] + c*edges[i][1][2]);
+		if ((t>0)&&(t<2)) {
+			ret[num][0] = edges[i][0][0] + edges[i][1][0]*t;
+			ret[num][1] = edges[i][0][1] + edges[i][1][1]*t;
+			ret[num][2] = edges[i][0][2] + edges[i][1][2]*t;
+			num++;
+		}
+	}
+
+	return num;
+}
+
+void draw_slices(float m[][4])
+{
+	int i;
+
+	Vec3 viewdir(m[0][2], m[1][2], m[2][2]);
+	viewdir.Normalize();
+		// find cube vertex that is closest to the viewer
+	for (i=0; i<8; i++) {
+		float x = cv[i][0] + viewdir[0];
+		float y = cv[i][1] + viewdir[1];
+		float z = cv[i][2] + viewdir[2];
+		if ((x>=-1.0f)&&(x<=1.0f)
+				   &&(y>=-1.0f)&&(y<=1.0f)
+				   &&(z>=-1.0f)&&(z<=1.0f))
+		{
+			break;
+		}
+	}
+	if(i != 8) return;
+
+	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+	glDisable(GL_DEPTH_TEST);
+		// our slices are defined by the plane equation a*x + b*y +c*z + d = 0
+		// (a,b,c), the plane normal, are given by viewdir
+		// d is the parameter along the view direction. the first d is given by
+		// inserting previously found vertex into the plane equation
+	float d0 = -(viewdir[0]*cv[i][0] + viewdir[1]*cv[i][1] + viewdir[2]*cv[i][2]);
+	float dd = 2*d0/64.0f;
+	int n = 0;
+	for (float d = -d0; d < d0; d += dd) {
+					// intersect_edges returns the intersection points of all cube edges with
+			// the given plane that lie within the cube
+		float pt[12][3];
+		int num = intersect_edges(pt, viewdir[0], viewdir[1], viewdir[2], d);
+
+		if (num > 2) {
+			// sort points to get a convex polygon
+			// std::sort(pt.begin()+1, pt.end(), Convexcomp(pt[0], viewdir));
+			int shuffled = 1;
+			
+			while(shuffled)
+			{
+				int j;
+				shuffled = 0;
+				
+				for(j = 0; j < num-1; j++)
+				{
+					// Vec3 va = a-p0, vb = b-p0;
+					// return dot(up, cross(va, vb)) >= 0;
+					float va[3], vb[3], vc[3];
+					
+					VECSUB(va, pt[j], pt[0]);
+					VECSUB(vb, pt[j+1], pt[0]);
+					Crossf(vc, va, vb);
+					
+					if(INPR(viewdir, vc)>= 0)
+					{
+						float temp[3];
+						
+						VECCOPY(temp, pt[j]);
+						VECCOPY(pt[j], pt[j+1]);
+						VECCOPY(pt[j+1], temp);
+						
+						shuffled = 1;
+					}
+				}
+			}
+
+			glEnable(GL_TEXTURE_3D);
+			glEnable(GL_FRAGMENT_PROGRAM_ARB);
+			glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, _prog[0]);
+			glActiveTextureARB(GL_TEXTURE0_ARB);
+			glBindTexture(GL_TEXTURE_3D, _txt[0]);
+			glBegin(GL_POLYGON);
+			for (i=0; i<num; i++){
+				glColor3f(1.0, 1.0, 1.0);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list