annotate TaskManager/Test/test_render/spe/CreateSpan.cpp @ 164:38cbb7aecc70

TilePtr は SPE で計算した方がいいと判断して変更。
author gongo@gendarme.cr.ie.u-ryukyu.ac.jp
date Tue, 09 Dec 2008 10:48:49 +0900
parents 1f4c3f3238e6
children cd1c289f952d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include "CreateSpan.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include "viewer_types.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
4 static const int SPAN_PACK_LOAD = 5;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
5 static const int SPAN_PACK_STORE = 6;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
6 static const int POLYGON_PACK_LOAD = 7;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
7 static const int TILE_ALLOCATE = 8;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
8 static const int TILE_LOAD = 9;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
9 static const int TILE_STORE = 10;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
10
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
11 static SpanPackPtr spack = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12 static SpanPackPtr send_spack = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13 static int prev_index = 0;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
14
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
15 SchedDefineTask(CreateSpan);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
16
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
17 static float
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
18 calc(float f1, float f2,int i, float base)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
19 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20 float ans;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21 ans = f1/f2*i + base;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 return ans;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
24
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
25
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
26 /**
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
27 * TrianglePack から、vMin, vMid, vMax を求める
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
28 *
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29 * @param [triPack] TrianglePack
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
30 * @param [vMin] [vMid] [vMax]
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
31 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
32 static void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
33 make_vertex(TrianglePack *triPack,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34 VertexPackPtr *vMin, VertexPackPtr *vMid, VertexPackPtr *vMax)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36 if (triPack->ver1.y <= triPack->ver2.y) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
37 if (triPack->ver2.y <= triPack->ver3.y) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
38 *vMin = &triPack->ver1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
39 *vMid = &triPack->ver2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
40 *vMax = &triPack->ver3;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41 } else if (triPack->ver3.y <= triPack->ver1.y) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42 *vMin = &triPack->ver3;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
43 *vMid = &triPack->ver1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
44 *vMax = &triPack->ver2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
45 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46 *vMin = &triPack->ver1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
47 *vMid = &triPack->ver3;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
48 *vMax = &triPack->ver2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
49 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
50 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
51 if (triPack->ver1.y <= triPack->ver3.y) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
52 *vMin = &triPack->ver2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
53 *vMid = &triPack->ver1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
54 *vMax = &triPack->ver3;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
55 } else if (triPack->ver3.y <= triPack->ver2.y) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56 *vMin = &triPack->ver3;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
57 *vMid = &triPack->ver2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
58 *vMax = &triPack->ver1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
59 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
60 *vMin = &triPack->ver2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
61 *vMid = &triPack->ver3;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
62 *vMax = &triPack->ver1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
63 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
64 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
65 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
66
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
67 static void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
68 make_vMid10(VertexPack *v, VertexPack *vMin,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
69 VertexPack *vMid, VertexPack *vMax)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
70 {
146
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
71 //int d, d1;
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
72 float d;
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
73 int d1;
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
74
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
75 d = vMax->y - vMin->y;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
76 d1 = (int)(vMid->y - vMin->y);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
77
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
78 v->tex_x = calc(vMax->tex_x - vMin->tex_x, d, d1, vMin->tex_x);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
79 v->tex_y = calc(vMax->tex_y - vMin->tex_y, d, d1, vMin->tex_y);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
80 v->x = calc(vMax->x - vMin->x, d, d1, vMin->x);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
81 v->y = vMid->y;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
82 v->z = calc(vMax->z - vMin->z, d, d1, vMin->z);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
83 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
84
156
gongo@gendarme.local
parents: 155
diff changeset
85 /**
161
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
86 * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する
156
gongo@gendarme.local
parents: 155
diff changeset
87 *
161
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
88 * +---+---+---+---+---+---+
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
89 * | 0 | 1 | 2 | 3 | 4 | 5 |
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
90 * +---+---+---+---+---+---+
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
91 * | | | | | |11 |
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
92 * +---+---+---+---+---+---+
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
93 * | | | | | |17 |
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
94 * +---+---+---+---+---+---+
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
95 * | | | | | |23 |
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
96 * +---+---+---+---+---+---+
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
97 * | | | | | |29 |
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
98 * +---+---+---+---+---+---+
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
99 * | | | | | |35 |
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
100 * +---+---+---+---+---+---+
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
101 *
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
102 * 一辺を TEXTURE_SPLIT とする
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
103 * 各ブロックの数字がブロックIDとなる。
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
104 */
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
105
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
106 /**
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
107 * テクスチャの座標から、
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
108 * テクスチャのどのブロックかを求める
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
109 *
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
110 * @param[in] tx X coordinates of texture
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
111 * @param[in] tx Y coordinates of texture
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
112 * @param[in] twidth Width of texture
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
113 * @return block ID
156
gongo@gendarme.local
parents: 155
diff changeset
114 */
gongo@gendarme.local
parents: 155
diff changeset
115 static int
161
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
116 get_tex_block(int tx, int ty, int twidth)
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
117 {
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
118 int blockX, blockY;
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
119
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
120 blockX = tx / TEXTURE_SPLIT_PIXEL;
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
121 blockY = ty / TEXTURE_SPLIT_PIXEL;
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
122
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
123 return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY;
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
124 }
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
125
141
fc314f28b66e TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
126 /**
133
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
127 * x軸に水平な辺を持つ三角形ポリゴンから、
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
128 * Span を抜き出す
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
129 */
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
130 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
131 CreateSpan::half_triangle(SpanPackPtr *spackList,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
132 int charge_y_top, int charge_y_end,
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
133 uint32 *tex_addr, int tex_width, int tex_height,
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
134 VertexPack *vMin,VertexPack *vMid,VertexPack *vMid10)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
135 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
136 float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
137 float tmp_xpos,tmp_end,tmp_zpos;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
138 float start_z, end_z;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
139 float start_tex_x, end_tex_x, start_tex_y, end_tex_y;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
140 int x, y, length;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
141
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
142 #if 1
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
143 // これじゃないと
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
144 // テクスチャの貼りに微妙に隙間が。謎だ
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
145 int start_y = (int)vMid->y;
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
146 int end_y = (int)vMin->y;
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
147 #else
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
148 float start_y = vMid->y;
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
149 float end_y = vMin->y;
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
150 #endif
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
151 float div_y = start_y - end_y;
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
152 int k = 0;
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
153 int l = 1;
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
154
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
155 SpanPackPtr tmp_spack;
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
156
135
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
157 /**
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
158 * 三角形ポリゴンをx軸に水平に二つに分けようとして
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
159 * ある一辺がすでに水平だった場合、つまり
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
160 * (環境によっては、back slash が 円マークかも)
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
161 *
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
162 * |\
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
163 * | \
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
164 * | \
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
165 * -----
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
166 *
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
167 *
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
168 * 上のようなポリゴンだった場合は、本来なら上の部分の三角形にだけ
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
169 * half_triangle の処理をするべきだが、現在の処理だと
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
170 * この half_triangle に「上の部分の三角形」と、
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
171 * 「『下の部分の三角形と判断してしまった』直線」が来てしまう。
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
172 * 直線の部分が来ると、calc() で 0 除算とかで、値不定で暴走するので
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
173 * 現在はこれで代用。
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
174 * half_triangle 呼ぶ前にこれを判断できれば良いかもしれない。
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
175 * てかこんなんでいいのかよ。。。
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
176 *
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
177 */
137
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
178 #if 1
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
179 if ((int)div_y == 0) {
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
180 return;
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
181 }
6cf991f28c6c SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 135
diff changeset
182 #else
135
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
183 if (vMid10->x == vMin->x && vMid10->y == vMin->y) {
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
184 return;
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
185 }
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
186 #endif
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
187
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
188 if (div_y < 0) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
189 div_y = -div_y;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
190 k = 1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
191 l = -1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
192 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
193
135
c65aee1528ef remove xml file
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
194 for (int i = k; i < (int)div_y+1; i++) {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
195 y = (int)vMin->y + i*l;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
196
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
197 /**
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
198 * 担当 y 範囲内
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
199 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
200 if (charge_y_top <= y && y <= charge_y_end) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
201 // 1..8 を index0, 9..16 を index1 にするために y を -1
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
202 int index = (y-1) / split_screen_h;
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
203
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
204 /**
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
205 * 違う SpanPack を扱う場合、
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
206 * 現在の SpanPack をメインメモリに送り、
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
207 * 新しい SpanPack を取ってくる
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
208 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
209 if (index != prev_index) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
210 tmp_spack = spack;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
211 spack = send_spack;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
212 send_spack = tmp_spack;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
213
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
214 smanager->dma_wait(SPAN_PACK_STORE);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
215 smanager->dma_store(send_spack, (uint32)spackList[prev_index],
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
216 sizeof(SpanPack), SPAN_PACK_STORE);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
217
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
218 smanager->dma_load(spack, (uint32)spackList[index],
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
219 sizeof(SpanPack), SPAN_PACK_LOAD);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
220 prev_index = index;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
221 smanager->dma_wait(SPAN_PACK_LOAD);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
222 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
223
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
224 /**
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
225 * 書き込む SpanPack が満杯だったら
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
226 * メインメモリで allocate した領域 (next) を持ってきて
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
227 * 現在の spack->next につなぎ、next を次の spack とする。
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
228 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
229 if (spack->info.size >= MAX_SIZE_SPAN) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
230 SpanPackPtr next;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
231
141
fc314f28b66e TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
232 smanager->mainMem_alloc(0, sizeof(SpanPack));
fc314f28b66e TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
233 smanager->mainMem_wait();
fc314f28b66e TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
234 next = (SpanPackPtr)smanager->mainMem_get(0);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
235
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
236 spack->next = next;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
237
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
238 tmp_spack = spack;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
239 spack = send_spack;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
240 send_spack = tmp_spack;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
241
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
242 smanager->dma_wait(SPAN_PACK_STORE);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
243 smanager->dma_store(send_spack, (uint32)spackList[index],
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
244 sizeof(SpanPack), SPAN_PACK_STORE);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
245
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
246 spackList[index] = next;
141
fc314f28b66e TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
247
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
248 smanager->dma_load(spack, (uint32)spackList[index],
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
249 sizeof(SpanPack), SPAN_PACK_LOAD);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
250 smanager->dma_wait(SPAN_PACK_LOAD);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
251 spack->init((index+1)*split_screen_h);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
252 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
253 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
254 /**
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
255 * 担当範囲外だったら無視
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
256 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
257 continue;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
258 }
146
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
259
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
260 tmp_xpos = calc(vMid10->x - vMin->x ,div_y, i, vMin->x);
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
261 tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x);
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
262 tmp_z = calc(vMid10->z - vMin->z ,div_y, i, vMin->z);
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
263 tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z);
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
264
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
265 length = (tmp_xpos > tmp_end)
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
266 ? (int)tmp_xpos - (int)tmp_end : (int)tmp_end - (int)tmp_xpos;
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
267 if (length == 0) {
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
268 continue;
2284efc89f63 TileList の生成の修正
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
269 }
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
270
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
271 tmp_tex1 =((i/(div_y)) * vMid10->tex_x) +
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
272 ( ((div_y - i)/(div_y)) * vMin->tex_x);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
273 tmp_tex2 =( (i/(div_y)) * vMid->tex_x) +
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
274 ( ((div_y - i)/(div_y)) * vMin->tex_x);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
275
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
276 tmp_tey1 =( (i/(div_y)) * vMid10->tex_y) +
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
277 ( ((div_y - i)/(div_y)) * vMin->tex_y);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
278 tmp_tey2 =( (i/(div_y)) * vMid->tex_y) +
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
279 ( ((div_y - i)/(div_y)) * vMin->tex_y);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
280
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
281 if (tmp_xpos > tmp_end) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
282 x = (int)tmp_end;
133
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
283 /**
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
284 * +1 は要らない気がする・・・
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
285 */
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
286 //length = (int)(tmp_xpos)-(int)(tmp_end)+1;
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
287 length = (int)(tmp_xpos)-(int)(tmp_end);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
288 start_z = tmp_zpos;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
289 end_z = tmp_z;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
290 start_tex_x = tmp_tex2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
291 end_tex_x = tmp_tex1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
292 start_tex_y = tmp_tey2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
293 end_tex_y = tmp_tey1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
294 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
295 x = (int)tmp_xpos;
133
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
296 //length = (int)(tmp_end)-(int)(tmp_xpos)+1;
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
297 length = (int)(tmp_end)-(int)(tmp_xpos);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
298 start_z = tmp_z;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
299 end_z = tmp_zpos;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
300 start_tex_x = tmp_tex1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
301 end_tex_x = tmp_tex2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
302 start_tex_y = tmp_tey1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
303 end_tex_y = tmp_tey2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
304 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
305
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
306 smanager->dma_wait(SPAN_PACK_LOAD);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
307
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
308 Span *span = &spack->span[spack->info.size++];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
309
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
310 span->tex_addr = tex_addr;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
311 span->tex_width = tex_width;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
312 span->tex_height = tex_height;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
313 span->x = x;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
314 span->y = y;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
315 span->length_x = length;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
316 span->start_z = start_z;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
317 span->end_z = end_z;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
318 span->tex_x1 = start_tex_x;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
319 span->tex_x2 = end_tex_x;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
320 span->tex_y1 = start_tex_y;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
321 span->tex_y2 = end_tex_y;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
322 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
323 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
324
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
325
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
326 int
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
327 CreateSpan::run(void *rbuf, void *wbuf)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
328 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
329 PolygonPack *pp = (PolygonPack*)smanager->get_input(0);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
330 PolygonPack *next_pp =
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
331 (PolygonPack*)smanager->allocate(sizeof(PolygonPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
332 PolygonPack *free_pp = next_pp;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
333 PolygonPack *tmp_pp;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
334
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
335 TrianglePackPtr triPack;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
336 VertexPackPtr vMin, vMid, vMax;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
337 VertexPackPtr vMid10
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
338 = (VertexPackPtr)smanager->allocate(sizeof(VertexPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
339
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
340 SpanPackPtr *spackList = (SpanPackPtr*)smanager->get_input(1);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
341 spack = (SpanPackPtr)smanager->get_input(2);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
342 send_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
343 prev_index = get_param(0);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
344
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
345 // spack と send_spack は swap しながら DMA を繰り返すので
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
346 // 自分で allocate した send_spack を覚えてないといけない
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
347 SpanPackPtr free_spack = send_spack;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
348
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
349 int charge_y_top = get_param(1);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
350 int charge_y_end = get_param(2);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
351
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
352 do {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
353 if (pp->next != NULL) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
354 smanager->dma_load(next_pp, (uint32)pp->next,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
355 sizeof(PolygonPack), POLYGON_PACK_LOAD);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
356 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
357 next_pp = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
358 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
359
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
360 for (int i = 0; i < pp->info.size; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
361 triPack = &pp->tri[i];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
362
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
363 #if 0
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
364 make_vertex(triPack, &vMin, &vMid, &vMax);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
365 #else
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
366 if (triPack->ver1.y <= triPack->ver2.y) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
367 if (triPack->ver2.y <= triPack->ver3.y) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
368 vMin = &triPack->ver1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
369 vMid = &triPack->ver2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
370 vMax = &triPack->ver3;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
371 } else if (triPack->ver3.y <= triPack->ver1.y) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
372 vMin = &triPack->ver3;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
373 vMid = &triPack->ver1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
374 vMax = &triPack->ver2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
375 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
376 vMin = &triPack->ver1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
377 vMid = &triPack->ver3;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
378 vMax = &triPack->ver2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
379 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
380 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
381 if (triPack->ver1.y <= triPack->ver3.y) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
382 vMin = &triPack->ver2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
383 vMid = &triPack->ver1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
384 vMax = &triPack->ver3;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
385 } else if (triPack->ver3.y <= triPack->ver2.y) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
386 vMin = &triPack->ver3;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
387 vMid = &triPack->ver2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
388 vMax = &triPack->ver1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
389 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
390 vMin = &triPack->ver2;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
391 vMid = &triPack->ver3;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
392 vMax = &triPack->ver1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
393 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
394 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
395 #endif
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
396 make_vMid10(vMid10, vMin, vMid, vMax);
133
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
397
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
398 /**
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
399 * ポリゴンを、x軸に水平に分割して二つの三角形を作り、
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
400 * それぞれから Span を求める
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 113
diff changeset
401 */
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
402 half_triangle(spackList, charge_y_top, charge_y_end,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
403 triPack->tex_addr, triPack->tex_width,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
404 triPack->tex_height, vMin, vMid, vMid10);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
405 half_triangle(spackList, charge_y_top, charge_y_end,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
406 pp->tri[0].tex_addr, pp->tri[0].tex_width,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
407 pp->tri[0].tex_height, vMax, vMid, vMid10);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
408 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
409
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
410 smanager->dma_wait(POLYGON_PACK_LOAD);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
411
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
412 tmp_pp = pp;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
413 pp = next_pp;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
414 next_pp = tmp_pp;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
415 } while (pp);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
416
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
417 smanager->dma_wait(SPAN_PACK_STORE);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
418 smanager->dma_store(spack, (uint32)spackList[prev_index],
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
419 sizeof(SpanPack), SPAN_PACK_STORE);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
420 smanager->dma_wait(SPAN_PACK_STORE);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
421
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
422 free(free_pp);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
423 free(free_spack);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
424 free(vMid10);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
425
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
426 return 0;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
427 }