-
Notifications
You must be signed in to change notification settings - Fork 1
/
rt_debug_output.c
170 lines (142 loc) · 3.53 KB
/
rt_debug_output.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include "rt_debug_output.h"
void rt_dout_matrix4( rt_matrix4 *pM )
{
printf( "%f, %f, %f, %f\n",
pM->_11, pM->_12, pM->_13, pM->_14 );
printf( "%f, %f, %f, %f\n",
pM->_21, pM->_22, pM->_23, pM->_24 );
printf( "%f, %f, %f, %f\n",
pM->_31, pM->_32, pM->_33, pM->_34 );
printf( "%f, %f, %f, %f",
pM->_41, pM->_42, pM->_43, pM->_44 );
}
void rt_dout_vector3( rt_vector3 *pV )
{
printf( "%f, %f, %f", pV->x, pV->y, pV->z );
}
void tabulation( int count )
{
int i;
for ( i = 0; i < count; ++i )
printf( "\t" );
}
void rt_dout_kdtree( rt_vertex *pV, rt_triangle *pTr,
rt_render_pipe *pRp, rt_kdtree_node *pNode, int depth )
{
tabulation( depth );
printf( "{\n" );
if ( pNode->isLast )
{
int i;
tabulation( depth + 1 );
printf( "prims count: %lu", pNode->primsCount );;
printf( "\n" );
for ( i = 0; i < pNode->primsCount; ++i )
{
tabulation( depth + 1 );
printf( "%luth triangle:", pNode->prims[i] );
printf( "\n" );
tabulation( depth + 1 );
printf( "{\n" );
tabulation( depth + 2 );
rt_dout_vector3( &(pV[pTr[pNode->prims[i]].pV0].pos) );
printf( "\n" );
tabulation( depth + 2 );
rt_dout_vector3( &(pV[pTr[pNode->prims[i]].pV1].pos) );
printf( "\n" );
tabulation( depth + 2 );
rt_dout_vector3( &(pV[pTr[pNode->prims[i]].pV2].pos) );
printf( "\n" );
tabulation( depth + 1 );
printf( "}\n" );
}
}
else
{
tabulation( depth + 1 );
printf( "separation axis: " );
switch ( pNode->axis )
{
case RT_AXIS_X:
printf( "X" );
break;
case RT_AXIS_Y:
printf( "Y" );
break;
case RT_AXIS_Z:
printf( "Z" );
break;
}
printf( "\n" );
tabulation( depth + 1 );
printf( "separation value: %f\n", pNode->sep );
tabulation( depth + 1 );
printf( "left node:\n" );
rt_dout_kdtree( pV, pTr, pRp, pNode->leftNode, depth + 1 );
tabulation( depth + 1 );
printf( "right node:\n" );
rt_dout_kdtree( pV, pTr, pRp, pNode->rightNode, depth + 1 );
}
tabulation( depth );
printf( "}\n\n" );
}
void rt_cl_dout_kdtree( rt_vertex *pV, rt_triangle *pTr, rt_cl_kdtree_node *pN,
rt_ulong *pP, rt_render_pipe *pRp, rt_ulong nodeN, int depth )
{
tabulation( depth );
printf( "node %lu {\n", nodeN );
if ( pN[nodeN].isLast )
{
int i;
tabulation( depth + 1 );
printf( "prims count: %lu", pN[nodeN].primsCount );;
printf( "\n" );
for ( i = 0; i < pN[nodeN].primsCount; ++i )
{
tabulation( depth + 1 );
printf( "%luth triangle:", pP[pN[nodeN].prims + i] );
printf( "\n" );
tabulation( depth + 1 );
printf( "{\n" );
tabulation( depth + 2 );
rt_dout_vector3( &(pV[pTr[pP[pN[nodeN].prims + i]].pV0].pos) );
printf( "\n" );
tabulation( depth + 2 );
rt_dout_vector3( &(pV[pTr[pP[pN[nodeN].prims + i]].pV1].pos) );
printf( "\n" );
tabulation( depth + 2 );
rt_dout_vector3( &(pV[pTr[pP[pN[nodeN].prims + i]].pV2].pos) );
printf( "\n" );
tabulation( depth + 1 );
printf( "}\n" );
}
}
else
{
tabulation( depth + 1 );
printf( "separation axis: " );
switch ( pN[nodeN].axis )
{
case RT_AXIS_X:
printf( "X" );
break;
case RT_AXIS_Y:
printf( "Y" );
break;
case RT_AXIS_Z:
printf( "Z" );
break;
}
printf( "\n" );
tabulation( depth + 1 );
printf( "separation value: %f\n", pN[nodeN].sep );
tabulation( depth + 1 );
printf( "left node:\n" );
rt_cl_dout_kdtree( pV, pTr, pN, pP, pRp, pN[nodeN].leftNode, depth + 1 );
tabulation( depth + 1 );
printf( "right node:\n" );
rt_cl_dout_kdtree( pV, pTr, pN, pP, pRp, pN[nodeN].rightNode, depth + 1 );
}
tabulation( depth );
printf( "}\n\n" );
}