# HG changeset patch # User koba # Date 1290713579 -32400 # Node ID 431936c0cc9694b467c9bfc7509247691fcd577e # Parent 44b2c4cb539d1612bc31d039518a401c9b05f449 add application main method and task. diff -r 44b2c4cb539d -r 431936c0cc96 Renderer/Engine/Application.cc --- a/Renderer/Engine/Application.cc Thu Oct 28 17:40:13 2010 +0900 +++ b/Renderer/Engine/Application.cc Fri Nov 26 04:32:59 2010 +0900 @@ -3,5 +3,3 @@ Application::Application(){} Application::~Application(){} - - diff -r 44b2c4cb539d -r 431936c0cc96 Renderer/Engine/Application.h --- a/Renderer/Engine/Application.h Thu Oct 28 17:40:13 2010 +0900 +++ b/Renderer/Engine/Application.h Fri Nov 26 04:32:59 2010 +0900 @@ -14,7 +14,9 @@ public: Application(); virtual ~Application(); - + + virtual void app_main(Viewer *viewer){}; + virtual HTaskPtr application_task(HTaskPtr next, Viewer* viewer){return next;}; virtual MainLoopPtr init(Viewer *viewer, int w, int h) = 0; }; diff -r 44b2c4cb539d -r 431936c0cc96 Renderer/Engine/SceneGraph.cc --- a/Renderer/Engine/SceneGraph.cc Thu Oct 28 17:40:13 2010 +0900 +++ b/Renderer/Engine/SceneGraph.cc Fri Nov 26 04:32:59 2010 +0900 @@ -601,6 +601,17 @@ (*create_sg)(this->sgroot, property, update_property); } +void +SceneGraph::set_move_collision(move_func new_move) +{ + this->move = new_move; +} + +void +SceneGraph::set_move_collision(collision_func new_collision) +{ + this->collision = new_collision; +} void SceneGraph::set_move_collision(move_func new_move, diff -r 44b2c4cb539d -r 431936c0cc96 Renderer/Engine/SceneGraph.h --- a/Renderer/Engine/SceneGraph.h Thu Oct 28 17:40:13 2010 +0900 +++ b/Renderer/Engine/SceneGraph.h Fri Nov 26 04:32:59 2010 +0900 @@ -35,11 +35,11 @@ // とりあえず動かしたいので追加 int seq, seq_rd, resend_flag; + // task 生成用の情報 int property_size; void *propertyptr; int move_id; int coll_id; - PostFunction post_func; memaddr property; memaddr update_property; @@ -92,6 +92,8 @@ SceneGraphPtr clone(void); SceneGraphPtr clone(void *buf); SceneGraphPtr searchSceneGraph(const char *name); + void set_move_collision(move_func new_move); + void set_move_collision(collision_func new_collision); void set_move_collision(move_func new_move, collision_func new_collision); void set_move_collision(move_func new_move, collision_func new_collision, void *sgroot); void set_move_collision(move_func new_move, collision_func new_collision, create_sg_func new_create_sg); diff -r 44b2c4cb539d -r 431936c0cc96 Renderer/Engine/SceneGraphRoot.cc --- a/Renderer/Engine/SceneGraphRoot.cc Thu Oct 28 17:40:13 2010 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Fri Nov 26 04:32:59 2010 +0900 @@ -8,7 +8,6 @@ #include "texture.h" #include "Application.h" - static int cnt = 0; static const int SGLIST_LENGTH = 138; static int sg_src_size = SGLIST_LENGTH ; @@ -409,7 +408,7 @@ while (t) { SceneGraphPtr c = NULL; if (!t->isRemoved()) { - c = t->clone(); + c = t->clone(); addNext(c); cur_parent->addChild(c); c->frame = t->frame; @@ -723,7 +722,7 @@ } void -SceneGraphRoot::set_game_task(int id, void *property, int size, PostFunction post_func) +SceneGraphRoot::set_gtask_array(int id, void *property, int size, PostFunction post_func) { gtask_array->next_task_array(id); @@ -733,7 +732,7 @@ } void -SceneGraphRoot::set_game_task(int id, void *property, void *pad, int size, PostFunction post_func) +SceneGraphRoot::set_gtask_array(int id, void *property, void *pad, int size, PostFunction post_func) { gtask_array->next_task_array(id); @@ -744,20 +743,40 @@ } void +SceneGraphRoot::set_game_task(int id, void *property, int size) +{ + HTask *task = sgroot->tmanager->create_task(id); + task->set_cpu(SPE_ANY); + task->add_inData(property, size); + task->add_outData(property, size); + task->spawn(); +} + +void +SceneGraphRoot::set_game_task(int id, void *property, void *pad, int size) +{ + HTask *task = sgroot->tmanager->create_task(id); + task->set_cpu(SPE_ANY); + task->add_inData(property, size); + task->add_inData(pad, sizeof(Pad)); + task->add_outData(property, size); + task->spawn(); +} + + +void main_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { int size = node->property_size; void *e = node->propertyptr; int move = node->move_id; - PostFunction post_func = node->post_func; + SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; /* - ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; - property->root = node; + ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; + node->xyz[0] = property->x; + node->xyz[1] = property->y; */ - - SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; - - sgroottmp->set_game_task(move, (void*)e, size, post_func); + sgroottmp->set_game_task(move, (void*)e, size); } void @@ -766,35 +785,32 @@ int size = node->property_size; void *e = node->propertyptr; int move = node->move_id; - PostFunction post_func = node->post_func; -/* - ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; - property->root = node; -*/ - SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; void *pad = (void*)sgroottmp->getController(); - sgroottmp->set_game_task(move, (void*)e, pad, size, post_func); +/* + ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; + property->root = node; + node->xyz[0] = property->x; + node->xyz[1] = property->y; +*/ + + sgroottmp->set_game_task(move, (void*)e, pad, size); } void -SceneGraphRoot::set_move_task(SceneGraphPtr node, int move, void *property, int size, - PostFunction post_func) +SceneGraphRoot::set_move_task(SceneGraphPtr node, int move, void *property, int size) { node->move = main_task_move; - node->post_func = post_func; node->move_id = move; node->propertyptr = property; node->property_size = size; } void -SceneGraphRoot::set_pad_task(SceneGraphPtr node, int move, void *property, int size, - PostFunction post_func) +SceneGraphRoot::set_pad_task(SceneGraphPtr node, int move, void *property, int size) { node->move = pad_task_move; - node->post_func = post_func; node->move_id = move; node->propertyptr = property; node->property_size = size; diff -r 44b2c4cb539d -r 431936c0cc96 Renderer/Engine/SceneGraphRoot.h --- a/Renderer/Engine/SceneGraphRoot.h Thu Oct 28 17:40:13 2010 +0900 +++ b/Renderer/Engine/SceneGraphRoot.h Fri Nov 26 04:32:59 2010 +0900 @@ -112,10 +112,12 @@ void task_array_init(int id, int task_num, int param, int inData_num, int outData_num); void create_task_array(); void task_array_finish(); - void set_game_task(int id, void *property, int size, PostFunction post_func); - void set_game_task(int id, void *property, void* pad, int size, PostFunction post_func); - void set_move_task(SceneGraphPtr node, int move, void *property, int size, PostFunction post_func); - void set_pad_task(SceneGraphPtr node, int move, void *property, int size, PostFunction post_func); + void set_gtask_array(int id, void *property, int size, PostFunction post_func); + void set_gtask_array(int id, void *property, void* pad, int size, PostFunction post_func); + void set_game_task(int id, void *property, int size); + void set_game_task(int id, void *property, void *pad, int size); + void set_move_task(SceneGraphPtr node, int move, void *property, int size); + void set_pad_task(SceneGraphPtr node, int move, void *property, int size); /* Other System API */ void allExecute(int screen_w, int screen_h); diff -r 44b2c4cb539d -r 431936c0cc96 Renderer/Engine/viewer.cc --- a/Renderer/Engine/viewer.cc Thu Oct 28 17:40:13 2010 +0900 +++ b/Renderer/Engine/viewer.cc Fri Nov 26 04:32:59 2010 +0900 @@ -142,6 +142,7 @@ this_time = 0; frames = 0; + this->app = app; MainLoop *mainloop = app->init(this, this->width, this->height); mainloop->mainLoop(); } @@ -292,6 +293,7 @@ { HTaskPtr task_next = initLoop(); + task_next = app->application_task(task_next, this); task_next->set_post(&post2runLoop, (void *)this, (void*)pixels); // set_post(function(this->run_loop()), NULL) task_next->spawn(); } @@ -312,8 +314,8 @@ dev->clean_pixels(); pixels = dev->flip_screen(pixels); - sgroot->updateControllerState(); + app->app_main(this); //TaskArray を使うか使わないか if (sgroot->gtask_array != NULL) { diff -r 44b2c4cb539d -r 431936c0cc96 Renderer/Engine/viewer.h --- a/Renderer/Engine/viewer.h Thu Oct 28 17:40:13 2010 +0900 +++ b/Renderer/Engine/viewer.h Fri Nov 26 04:32:59 2010 +0900 @@ -108,21 +108,13 @@ { sgroot->task_array_init(id, task_num, param, inData_num, outData_num); } - void set_game_task(int id, void *property, int size, PostFunction post_func) + void set_move_task(SceneGraphPtr node, int move, void *titlep, int size) { - sgroot->set_game_task(id, property, size, post_func); - } - void set_game_task(int id, void *property, void *pad, int size, PostFunction post_func) - { - sgroot->set_game_task(id, property, pad, size, post_func); + sgroot->set_move_task(node, move, titlep, size); } - void set_move_task(SceneGraphPtr node, int move, void *titlep, int size, PostFunction post_func) + void set_pad_task(SceneGraphPtr node, int move, void *property, int size) { - sgroot->set_move_task(node, move, titlep, size, post_func); - } - void set_pad_task(SceneGraphPtr node, int move, void *property, int size, PostFunction post_func) - { - sgroot->set_pad_task(node, move, property, size, post_func); + sgroot->set_pad_task(node, move, property, size); } void createFromXMLmemory(SceneGraph * node, char *data, int len)