diff Renderer/Engine/SceneGraph.cc @ 656:d0b8860c17f8

remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
author hiroki@henri.cr.ie.u-ryukyu.ac.jp
date Wed, 25 Nov 2009 21:56:14 +0900
parents da82a47ece92
children 6d11ecef3b74
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraph.cc	Sat Nov 21 11:20:29 2009 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Wed Nov 25 21:56:14 2009 +0900
@@ -21,10 +21,10 @@
 extern int decode(char *cont, FILE *outfile);
 
 static void
-no_move(SceneGraphPtr self, int screen_w, int screen_h) {}
+no_move(SceneGraphPtr self, void *sgroot_, int screen_w, int screen_h) {}
 
 static void
-no_collision(SceneGraphPtr self, int screen_w, int screen_h,
+no_collision(SceneGraphPtr self, void *sgroot_, int screen_w, int screen_h,
              SceneGraphPtr tree) {}
 
 /**
@@ -522,16 +522,17 @@
     }
 }
 
+/* move_func 実行 sgroot 渡す */
 void
 SceneGraph::move_execute(int w, int h)
 {
-    (*move)(this, w, h);
+    (*move)(this, this->sgroot, w, h);
 }
 
 void
 SceneGraph::collision_check(int w, int h, SceneGraphPtr tree)
 {
-    (*collision)(this, w, h, tree);
+    (*collision)(this, this->sgroot, w, h, tree);
 }
 
 void
@@ -590,6 +591,17 @@
     this->collision = new_collision;
 }
 
+
+void
+SceneGraph::set_move_collision(move_func new_move,
+                               collision_func new_collision, void *sgroot_)
+{
+    this->move = new_move;
+    this->collision = new_collision;
+    // add
+    this->sgroot = sgroot_;
+}
+
 void
 SceneGraph::add_next(SceneGraphPtr next)
 {