changeset 448:0ef430eff384

test_render fixed.. test_render fixed...
author kazz@henri.cr.ie.u-ryukyu.ac.jp
date Fri, 25 Sep 2009 16:49:49 +0900
parents 6dd11969f8b2
children 4f11245e3504
files TaskManager/Test/test_render/spe/ChainCal.cc TaskManager/Test/test_render/spe/spe-main.cc
diffstat 2 files changed, 49 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/test_render/spe/ChainCal.cc	Fri Sep 25 07:40:09 2009 +0900
+++ b/TaskManager/Test/test_render/spe/ChainCal.cc	Fri Sep 25 16:49:49 2009 +0900
@@ -26,67 +26,64 @@
     uint32 parent;
     int id;
     //int parent;
-} CHAIN_VARS;
+} ChainProperty;
 
 int
 ChainCal::run(void *rbuf, void *wbuf)
 {
-    CHAIN_VARS *property = (CHAIN_VARS*)get_input(rbuf, 0);
-    CHAIN_VARS *update_property = (CHAIN_VARS*)get_output(wbuf, 0);
+    ChainProperty *property = (ChainProperty*)get_input(rbuf, 0);
+    ChainProperty *update_property = (ChainProperty*)get_output(wbuf, 0);
  
-    CHAIN_VARS* property = (CHAIN_VARS*)rbuf;
-    int id = get_param(0);
-    
     for(int cnt = 0; cnt < 600; cnt++) {
-	for(int i = 0; i < CHAIN_LEN; i++) {
-	    if(property[i].can_move) {
-		double dx = property[i-1].x - property[i].x;
-		double dy = property[i-1].y - property[i].y;
-		double l = sqrt(dx * dx + dy * dy);
-		double a = k * (l - chain_width) / m;
-		double ax = a * dx / l;
-		double ay = a * dy / l;
-		if(i < CHAIN_LEN - 1) {
-		    dx = property[i+1].x - property[i].x;
-		    dy = property[i+1].y - property[i].y;
-		    l = sqrt(dx * dx + dy * dy);
-		    a = k * (l - chain_width) / m;
-		    ax += a * dx / l;
-		    ay += a * dy / l;
+		for(int i = 0; i < CHAIN_LEN; i++) {
+			if(property[i].can_move) {
+				double dx = property[i-1].x - property[i].x;
+				double dy = property[i-1].y - property[i].y;
+				double l = sqrt(dx * dx + dy * dy);
+				double a = k * (l - chain_width) / m;
+				double ax = a * dx / l;
+				double ay = a * dy / l;
+				if(i < CHAIN_LEN - 1) {
+					dx = property[i+1].x - property[i].x;
+					dy = property[i+1].y - property[i].y;
+					l = sqrt(dx * dx + dy * dy);
+					a = k * (l - chain_width) / m;
+					ax += a * dx / l;
+					ay += a * dy / l;
+				}
+				ay += g;
+				property[i].vx *= safe;
+				property[i].vy *= safe;
+				property[i].next_vx = property[i].vx + ax * dt;
+				property[i].next_vy = property[i].vy + ay * dt;
+				property[i].next_x = property[i].x + property[i].vx * dt;
+				property[i].next_y = property[i].y + property[i].vy * dt;
+			} else {
+				property[i].next_x = property[i].x;
+				property[i].next_y = property[i].y;
+			}
 		}
-		ay += g;
-		property[i].vx *= safe;
-		property[i].vy *= safe;
-		property[i].next_vx = property[i].vx + ax * dt;
-		property[i].next_vy = property[i].vy + ay * dt;
-		property[i].next_x = property[i].x + property[i].vx * dt;
-		property[i].next_y = property[i].y + property[i].vy * dt;
-	    } else {
-		property[i].next_x = property[i].x;
-		property[i].next_y = property[i].y;
-	    }
-	}
-	for(int i = 0; i < CHAIN_LEN; i++) {
-	    property[i].vx = property[i].next_vx;
-	    property[i].vy = property[i].next_vy;
-	    property[i].x = property[i].next_x;
-	    property[i].y = property[i].next_y;
-	}
+		for(int i = 0; i < CHAIN_LEN; i++) {
+			property[i].vx = property[i].next_vx;
+			property[i].vy = property[i].next_vy;
+			property[i].x = property[i].next_x;
+			property[i].y = property[i].next_y;
+		}
     }
 	
     for (int j = 0; j < CHAIN_LEN; j++) {
-	int p, n;
-	id = property[j].id;
-	p = n = id;
-	if(p != 0) {
-	    p--;
-	}
-	if(n != CHAIN_LEN - 1) {
-	    n++;
-	}
-	property[j].angle[2-(id%2)*2]
-	    = 90 + atan((property[p].next_y - property[n].next_y) / (property[p].next_x - property[n].next_x)) * 180 / M_PI;
+		int p, n;
+		int id = property[j].id;
+		p = n = id;
+		if(p != 0) {
+			p--;
+		}
+		if(n != CHAIN_LEN - 1) {
+			n++;
+		}
+		property[j].angle[2-(id%2)*2]
+			= 90 + atan((property[p].next_y - property[n].next_y) / (property[p].next_x - property[n].next_x)) * 180 / M_PI;
     }
-    memcpy((void*)update_property, (void*)property, sizeof(CHAIN_VARS) * CHAIN_LEN);
+    memcpy((void*)update_property, (void*)property, sizeof(ChainProperty) * CHAIN_LEN);
     return 0;
 }
--- a/TaskManager/Test/test_render/spe/spe-main.cc	Fri Sep 25 07:40:09 2009 +0900
+++ b/TaskManager/Test/test_render/spe/spe-main.cc	Fri Sep 25 16:49:49 2009 +0900
@@ -16,7 +16,7 @@
 SchedExternTask(ShowTime);
 
 void
-task_init(void)
+task_init(Scheduler *s)
 {
     SchedRegisterTask(TASK_INIT_TEXTURE, LoadTexture);
     SchedRegisterTask(TASK_SET_TEXTURE, SetTexture);