changeset 908:830bcfbde3bc

fix
author Yutaka_Kinjyo
date Tue, 20 Jul 2010 04:05:07 +0900
parents 62838c1cd4b0
children 2683838396c6
files Renderer/Engine/Makefile.def Renderer/Engine/SceneGraph.cc Renderer/Engine/SceneGraphRoot.cc Renderer/Engine/polygon.h Renderer/Engine/viewer.cc TaskManager/Makefile.def
diffstat 6 files changed, 80 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Makefile.def	Tue Jul 20 02:33:48 2010 +0900
+++ b/Renderer/Engine/Makefile.def	Tue Jul 20 04:05:07 2010 +0900
@@ -5,7 +5,7 @@
 ABIBIT = 32 
 ABI = -m$(ABIBIT)
 CC      = g++
-OPT	= -g -O9 -DSPE_CREATE_POLYGON_CHECK #-DSPE_CREATE_POLYGON=1
+OPT	= -g -DSPE_CREATE_POLYGON_CHECK #-DSPE_CREATE_POLYGON=1
 CFLAGS  = -g -Wall $(ABI) $(OPT)  #  -DDEBUG
 
 INCLUDE = -I$(CERIUM)/include/TaskManager -I.
--- a/Renderer/Engine/SceneGraph.cc	Tue Jul 20 02:33:48 2010 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Tue Jul 20 04:05:07 2010 +0900
@@ -117,6 +117,7 @@
  */
 SceneGraph::SceneGraph(SceneGraphPtr orig)
 {
+
     init();
     memcpy(this, orig, sizeof(SceneGraph));
 
@@ -150,12 +151,19 @@
     //texture_info = (texture_list_ptr)manager->allocate(sizeof(texture_list));
     //data = new float[size*3*3];
 
-#if SPE_CREATE_POLYGON
-    
-    coord_pack_size = sizeof(float)*8*size*3;
-    coord_pack = (flaat*)manager->allocate(coord_pack_size);
-    
-#else 
+    for (int i = 0; i < 16; i++) {
+      matrix[i] = 0;
+      real_matrix[i] = 0;
+    }
+
+#if SPE_CREATE_POLYGON_CHECK
+
+    for (int i = 0; i < 16; i++) {
+      printf("%f\n",matrix[i]);
+      printf("r %f\n",real_matrix[i]);
+    }
+
+#endif
 
     coord_xyz = (float*)manager->allocate(sizeof(float)*size*3);
     coord_tex = (float*)manager->allocate(sizeof(float)*size*3);
@@ -164,11 +172,6 @@
     coord_pack_size = sizeof(float)*8*size*3;     // coord_pack_vertex size is 32byte. vertex num 3.
     coord_pack = (float*)manager->allocate(coord_pack_size);
 
-    int sg_matrix_size = 32; // matrix 16 + real_matrix 32.
-    sg_matrix = (float*)manager->allocate(sg_matrix_size);
-
-#endif
-
     get_data(manager, surface->children);
 
     finalize = &SceneGraph::finalize_original;
@@ -195,7 +198,7 @@
 
     size = 0;
     //data = NULL;
-
+  
 #if SPE_CREATE_POLYGON
 
     //tri_pack = NULL;
--- a/Renderer/Engine/SceneGraphRoot.cc	Tue Jul 20 02:33:48 2010 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Tue Jul 20 04:05:07 2010 +0900
@@ -412,7 +412,7 @@
 	    /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
 	    get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix);
 	    //get_matrix(c->real_matrix, c->angle, c->xyz, camera->real_matrix);
-	    
+
 	} 
 	
 	if (t->children != NULL && c != NULL) {
--- a/Renderer/Engine/polygon.h	Tue Jul 20 02:33:48 2010 +0900
+++ b/Renderer/Engine/polygon.h	Tue Jul 20 04:05:07 2010 +0900
@@ -15,17 +15,7 @@
 
     //float *data;    //"vertex" and "normal" and "texture"
     int coord_pack_size;
-    float *sg_matrix;
-
-#if SPE_CREATE_POLYGON
-
-    TrianglePackPtr tri_pack;
-    float *sg_matrix;
-    float *matrix;
-    float *real_matrix;
-    texture_list *texture_info;
-
-#else
+    float sg_matrix[32];
 
     float *coord_pack; //coord_xyz(4*3*size), coord_tex(4*3*size), normal(4*3*size), 
     float *coord_xyz; // vertex coordinate array
@@ -35,8 +25,6 @@
     float real_matrix[16];
     texture_list texture_info;
 
-#endif
-
     float xyz[4];     // position
     float angle[4];   // angle
     float c_xyz[4];   // center of rotation
--- a/Renderer/Engine/viewer.cc	Tue Jul 20 02:33:48 2010 +0900
+++ b/Renderer/Engine/viewer.cc	Tue Jul 20 04:05:07 2010 +0900
@@ -478,13 +478,42 @@
   MatrixListInfo *next;
 };
 
+// 完全にMac仕様。。sg_matrix を allocate してやらないといけないよ。
+void
+copy_matrix(SceneGraphPtr sg) {
+
+  float *matrix = sg->matrix;
+  float *real_matrix = sg->real_matrix;
+
+  for (int i = 0; i < 16; i++) {
+    sg->sg_matrix[i] = matrix[i];
+    sg->sg_matrix[i+16] = real_matrix[i];
+  }
+
+}
+
+void
+print_matrix(float *matrix) {
+
+  for (int i = 0; i < 32; i++) {
+    printf("%f\n",matrix[i]);
+  }
+
+}
 
 void
 add_matrix_list(SceneGraphPtr sg, TaskManager *manager, MatrixListInfo* info) {
 
     MatrixList *matrix_list = (MatrixList*)manager->allocate(sizeof(MatrixList));
+
+    copy_matrix(sg);
+#if SPE_CREATE_POLYGON_CHECK
+    print_matrix(sg->sg_matrix);
+#endif    
+
     matrix_list->matrix = sg->sg_matrix;
     matrix_list->next = NULL;
+
     
     if (info->last != NULL) {
         info->last->next = matrix_list;
@@ -519,7 +548,11 @@
   }
 
     MatrixList *new_list = (MatrixList*)manager->allocate(sizeof(MatrixList));
+    copy_matrix(sg);
     new_list->matrix = sg->sg_matrix;
+#if SPE_CREATE_POLYGON_CHECK
+    print_matrix(sg->sg_matrix);
+#endif
     new_list->next = NULL;
 
     next->first = new_list;
@@ -576,33 +609,45 @@
   }
 }
 
-HTaskPtr
+void
+check_matrix(MatrixListInfo *matrix_info,SceneGraphPtr sg) {
+
+  for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) {
+    for (MatrixList* u = t->first; u != NULL; u = u->next) {
+      print_matrix(u->matrix);
+    }
+  }
+
+}
+
+//HTaskPtr
+void
 create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next,
 	       MatrixListInfo *matrix_info)
 {
 
-  HTaskPtr create_pp_wait = manager->create_task(Dummy);
+  //HTaskPtr create_pp_wait = manager->create_task(Dummy);
   // どれくらい allocate するかわ、よくわからないけど。
   // とりあえず、16k ぐらいにしておく。
-  int sg_size = 16*1024;
+  // int sg_size = 16*1024;
   
-  for (int i = 0; i < spe_num; i++) {
+//   for (int i = 0; i < spe_num; i++) {
     
-    HTaskPtr data_load = manager->create_task(DataLoad);
-    data_load->set_param(0,(memaddr)sg_size);
-    data_load->set_param(1,(memaddr)SG_COORD);
-    task_next->wait_for(data_load);
-    data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
-    data_load->spawn();
+//     HTaskPtr data_load = manager->create_task(DataLoad);
+//     data_load->set_param(0,(memaddr)sg_size);
+//     data_load->set_param(1,(memaddr)SG_COORD);
+//     task_next->wait_for(data_load);
+//     data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
+//     data_load->spawn();
 	  
-  }
+//   }
 
   float *cur_coord_pack = sg->coord_pack;
   int coord_pack_size = sg->coord_pack_size;
 
   collect_matrix(sg, matrix_info, manager);  
 
-  return create_pp_wait;
+  //return create_pp_wait;
 
 }
 
@@ -611,8 +656,6 @@
 {
 
 #if SPE_CREATE_POLYGON
-
-
   
 #else
 
@@ -621,6 +664,10 @@
     MatrixListInfo *matrix_info = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo));
     create_pp_task(sg, manager, spe_num, task_next, matrix_info);
 
+#if SPE_CREATE_POLYGON_CHECK
+    check_matrix(matrix_info,sg);
+#endif
+
 
     
     HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph);
--- a/TaskManager/Makefile.def	Tue Jul 20 02:33:48 2010 +0900
+++ b/TaskManager/Makefile.def	Tue Jul 20 04:05:07 2010 +0900
@@ -30,7 +30,7 @@
 ABIBIT = 32
 
 #OPT = -O9
-OPT =  -g -O9  -DTASK_LIST_MAIL
+OPT =  -g -DTASK_LIST_MAIL #-O9
 
 CC     = g++   
 CFLAGS = -Wall `sdl-config --cflags` -m$(ABIBIT)   $(OPT)