Mercurial > hg > Members > kono > Cerium
changeset 773:8dd9fe36e206
add chain_move.h
author | hiroki@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 16 Feb 2010 14:56:11 +0900 |
parents | e53ae444ac6f |
children | 5102e1751d6f |
files | Renderer/Engine/spe/chain_move.cc Renderer/Engine/spe/chain_move.h Renderer/Test/property_chain.cc |
diffstat | 3 files changed, 52 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/spe/chain_move.cc Mon Feb 15 13:33:29 2010 +0900 +++ b/Renderer/Engine/spe/chain_move.cc Tue Feb 16 14:56:11 2010 +0900 @@ -9,12 +9,12 @@ SchedDefineTask(ChainTask); static const int PROPERTY_LENGTH = 50; -static double m = 100.0; -static double k = 7000.0; -static double g = 9.8; -static double dt = 0.003; -static double chain_width = 10; -static double safe = 0.995; +static float m = 100.0; +static float k = 7000.0; +static float g = 9.8; +static float dt = 0.003; +static float chain_width = 10; +static float safe = 0.995; typedef struct { float xyz[3]; @@ -40,16 +40,42 @@ PropertyPtr update_property = (PropertyPtr)s->get_output(wbuf, 0); property[0].can_move = 0; + //property[1].can_move = 0; for(int cnt = 0; cnt < 600; cnt++) { for(int i = 0; i < PROPERTY_LENGTH; i++) { if(property[i].can_move) { - double dx = property[i-1].xyz[0] - property[i].xyz[0]; - double dy = property[i-1].xyz[1] - property[i].xyz[1]; - 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 0 + vector float v_x1 __attribute__((aligned(16))) = { property[i-1].xyz[0], + property[i].xyz[0], + property[i+1].xyz[0], + property[i+2].xyz[0]}; + vector float v_x2 __attribute__((aligned(16))) = { property[i].xyz[0], + property[i+1].xyz[0], + property[i+2].xyz[0], + property[i+3].xyz[0]}; + vector float v_dx __attribute__((aligned(16))) = spu_sub(v_x1, v_x2); + + vector float v_y1 __attribute__((aligned(16))) = { property[i-1].xyz[1], + property[i].xyz[1], + property[i+1].xyz[1], + property[i+2].xyz[1]}; + vector float v_y2 __attribute__((aligned(16))) = { property[i].xyz[1], + property[i+1].xyz[1], + property[i+2].xyz[1], + property[i+3].xyz[1]}; + vector float v_dy __attribute__((aligned(16))) = spu_sub(v_x1, v_x2); + + dx = spu_mule(dx, dx); + vector float v_l __attribute__((aligned(16))); + +#else + float dx = property[i-1].xyz[0] - property[i].xyz[0]; + float dy = property[i-1].xyz[1] - property[i].xyz[1]; + float l = sqrt(dx * dx + dy * dy); + float a = k * (l - chain_width) / m; + float ax = a * dx / l; + float ay = a * dy / l; if(i < PROPERTY_LENGTH - 1) { dx = property[i+1].xyz[0] - property[i].xyz[0]; dy = property[i+1].xyz[1] - property[i].xyz[1]; @@ -69,7 +95,9 @@ property[i].next_xyz[0] = property[i].xyz[0]; property[i].next_xyz[1] = property[i].xyz[1]; } +#endif } + for(int i = 0; i < PROPERTY_LENGTH; i++) { property[i].v_xyz[0] = property[i].next_v_xyz[0]; property[i].v_xyz[1] = property[i].next_v_xyz[1];
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/chain_move.h Tue Feb 16 14:56:11 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_TASK_CHAIN +#define INCLUDED_TASK_CHAIN + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif + + +#endif
--- a/Renderer/Test/property_chain.cc Mon Feb 15 13:33:29 2010 +0900 +++ b/Renderer/Test/property_chain.cc Tue Feb 16 14:56:11 2010 +0900 @@ -199,7 +199,9 @@ SceneGraphPtr root_chain, chain; sgroot->createFromXMLfile("xml_file/chain.xml"); root_chain = sgroot->createSceneGraph("CHAIN"); - root_chain->xyz[0] = screen_w / 2; + //root_chain->xyz[0] = screen_w / 2; + //root_chain->xyz[0] = screen_w / 4; + root_chain->xyz[0] = 300.0f; root_chain->xyz[1] = 0.0f; root_chain->set_move_collision(move, collision); set_property(&property[0], root_chain, 0);