aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_Add.cpp
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 18:54:10 +1000
committerDavid Walter Seikel2013-01-13 18:54:10 +1000
commit959831f4ef5a3e797f576c3de08cd65032c997ad (patch)
treee7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_Add.cpp
parentAdd info about changes to Irrlicht. (diff)
downloadSledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_Add.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_Add.cpp1344
1 files changed, 672 insertions, 672 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_Add.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_Add.cpp
index 82f39f3..676eba1 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_Add.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_Add.cpp
@@ -1,672 +1,672 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten 1// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten
2// This file is part of the "Irrlicht Engine". 2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h 3// For conditions of distribution and use, see copyright notice in irrlicht.h
4 4
5#include "IrrCompileConfig.h" 5#include "IrrCompileConfig.h"
6#include "IBurningShader.h" 6#include "IBurningShader.h"
7 7
8#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ 8#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
9 9
10// compile flag for this file 10// compile flag for this file
11#undef USE_ZBUFFER 11#undef USE_ZBUFFER
12#undef IPOL_Z 12#undef IPOL_Z
13#undef CMP_Z 13#undef CMP_Z
14#undef WRITE_Z 14#undef WRITE_Z
15 15
16#undef IPOL_W 16#undef IPOL_W
17#undef CMP_W 17#undef CMP_W
18#undef WRITE_W 18#undef WRITE_W
19 19
20#undef SUBTEXEL 20#undef SUBTEXEL
21#undef INVERSE_W 21#undef INVERSE_W
22 22
23#undef IPOL_C0 23#undef IPOL_C0
24#undef IPOL_T0 24#undef IPOL_T0
25#undef IPOL_T1 25#undef IPOL_T1
26 26
27// define render case 27// define render case
28#define SUBTEXEL 28#define SUBTEXEL
29#define INVERSE_W 29#define INVERSE_W
30 30
31#define USE_ZBUFFER 31#define USE_ZBUFFER
32#define IPOL_W 32#define IPOL_W
33#define CMP_W 33#define CMP_W
34#define WRITE_W 34#define WRITE_W
35 35
36//#define IPOL_C0 36//#define IPOL_C0
37#define IPOL_T0 37#define IPOL_T0
38#define IPOL_T1 38#define IPOL_T1
39 39
40// apply global override 40// apply global override
41#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT 41#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
42 #undef INVERSE_W 42 #undef INVERSE_W
43#endif 43#endif
44 44
45#ifndef SOFTWARE_DRIVER_2_SUBTEXEL 45#ifndef SOFTWARE_DRIVER_2_SUBTEXEL
46 #undef SUBTEXEL 46 #undef SUBTEXEL
47#endif 47#endif
48 48
49#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR 49#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR
50 #undef IPOL_C0 50 #undef IPOL_C0
51#endif 51#endif
52 52
53#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) 53#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER )
54 #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT 54 #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
55 #undef IPOL_W 55 #undef IPOL_W
56 #endif 56 #endif
57 #define IPOL_Z 57 #define IPOL_Z
58 58
59 #ifdef CMP_W 59 #ifdef CMP_W
60 #undef CMP_W 60 #undef CMP_W
61 #define CMP_Z 61 #define CMP_Z
62 #endif 62 #endif
63 63
64 #ifdef WRITE_W 64 #ifdef WRITE_W
65 #undef WRITE_W 65 #undef WRITE_W
66 #define WRITE_Z 66 #define WRITE_Z
67 #endif 67 #endif
68 68
69#endif 69#endif
70 70
71namespace irr 71namespace irr
72{ 72{
73 73
74namespace video 74namespace video
75{ 75{
76 76
77class CTRTextureLightMap2_Add : public IBurningShader 77class CTRTextureLightMap2_Add : public IBurningShader
78{ 78{
79public: 79public:
80 80
81 //! constructor 81 //! constructor
82 CTRTextureLightMap2_Add(CBurningVideoDriver* driver); 82 CTRTextureLightMap2_Add(CBurningVideoDriver* driver);
83 83
84 //! draws an indexed triangle list 84 //! draws an indexed triangle list
85 virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); 85 virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c );
86 86
87 87
88private: 88private:
89 void scanline_bilinear (); 89 void scanline_bilinear ();
90 90
91 sScanConvertData scan; 91 sScanConvertData scan;
92 sScanLineData line; 92 sScanLineData line;
93 93
94}; 94};
95 95
96//! constructor 96//! constructor
97CTRTextureLightMap2_Add::CTRTextureLightMap2_Add(CBurningVideoDriver* driver) 97CTRTextureLightMap2_Add::CTRTextureLightMap2_Add(CBurningVideoDriver* driver)
98: IBurningShader(driver) 98: IBurningShader(driver)
99{ 99{
100 #ifdef _DEBUG 100 #ifdef _DEBUG
101 setDebugName("CTRTextureLightMap2_Add"); 101 setDebugName("CTRTextureLightMap2_Add");
102 #endif 102 #endif
103} 103}
104 104
105 105
106 106
107/*! 107/*!
108*/ 108*/
109REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear () 109REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear ()
110{ 110{
111 tVideoSample *dst; 111 tVideoSample *dst;
112 112
113#ifdef USE_ZBUFFER 113#ifdef USE_ZBUFFER
114 fp24 *z; 114 fp24 *z;
115#endif 115#endif
116 116
117 s32 xStart; 117 s32 xStart;
118 s32 xEnd; 118 s32 xEnd;
119 s32 dx; 119 s32 dx;
120 120
121 121
122#ifdef SUBTEXEL 122#ifdef SUBTEXEL
123 f32 subPixel; 123 f32 subPixel;
124#endif 124#endif
125 125
126#ifdef IPOL_Z 126#ifdef IPOL_Z
127 f32 slopeZ; 127 f32 slopeZ;
128#endif 128#endif
129#ifdef IPOL_W 129#ifdef IPOL_W
130 fp24 slopeW; 130 fp24 slopeW;
131#endif 131#endif
132#ifdef IPOL_C0 132#ifdef IPOL_C0
133 sVec4 slopeC; 133 sVec4 slopeC;
134#endif 134#endif
135#ifdef IPOL_T0 135#ifdef IPOL_T0
136 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; 136 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES];
137#endif 137#endif
138 138
139 // apply top-left fill-convention, left 139 // apply top-left fill-convention, left
140 xStart = core::ceil32( line.x[0] ); 140 xStart = core::ceil32( line.x[0] );
141 xEnd = core::ceil32( line.x[1] ) - 1; 141 xEnd = core::ceil32( line.x[1] ) - 1;
142 142
143 dx = xEnd - xStart; 143 dx = xEnd - xStart;
144 144
145 if ( dx < 0 ) 145 if ( dx < 0 )
146 return; 146 return;
147 147
148 // slopes 148 // slopes
149 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); 149 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
150 150
151#ifdef IPOL_Z 151#ifdef IPOL_Z
152 slopeZ = (line.z[1] - line.z[0]) * invDeltaX; 152 slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
153#endif 153#endif
154#ifdef IPOL_W 154#ifdef IPOL_W
155 slopeW = (line.w[1] - line.w[0]) * invDeltaX; 155 slopeW = (line.w[1] - line.w[0]) * invDeltaX;
156#endif 156#endif
157#ifdef IPOL_C0 157#ifdef IPOL_C0
158 slopeC = (line.c[1] - line.c[0]) * invDeltaX; 158 slopeC = (line.c[1] - line.c[0]) * invDeltaX;
159#endif 159#endif
160#ifdef IPOL_T0 160#ifdef IPOL_T0
161 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; 161 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
162#endif 162#endif
163#ifdef IPOL_T1 163#ifdef IPOL_T1
164 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; 164 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX;
165#endif 165#endif
166 166
167#ifdef SUBTEXEL 167#ifdef SUBTEXEL
168 subPixel = ( (f32) xStart ) - line.x[0]; 168 subPixel = ( (f32) xStart ) - line.x[0];
169#ifdef IPOL_Z 169#ifdef IPOL_Z
170 line.z[0] += slopeZ * subPixel; 170 line.z[0] += slopeZ * subPixel;
171#endif 171#endif
172#ifdef IPOL_W 172#ifdef IPOL_W
173 line.w[0] += slopeW * subPixel; 173 line.w[0] += slopeW * subPixel;
174#endif 174#endif
175#ifdef IPOL_C0 175#ifdef IPOL_C0
176 line.c[0] += slopeC * subPixel; 176 line.c[0] += slopeC * subPixel;
177#endif 177#endif
178#ifdef IPOL_T0 178#ifdef IPOL_T0
179 line.t[0][0] += slopeT[0] * subPixel; 179 line.t[0][0] += slopeT[0] * subPixel;
180#endif 180#endif
181#ifdef IPOL_T1 181#ifdef IPOL_T1
182 line.t[1][0] += slopeT[1] * subPixel; 182 line.t[1][0] += slopeT[1] * subPixel;
183#endif 183#endif
184#endif 184#endif
185 185
186 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 186 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
187 187
188#ifdef USE_ZBUFFER 188#ifdef USE_ZBUFFER
189 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 189 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
190#endif 190#endif
191 191
192 192
193 193
194 194
195#ifdef BURNINGVIDEO_RENDERER_FAST 195#ifdef BURNINGVIDEO_RENDERER_FAST
196 u32 dIndex = ( line.y & 3 ) << 2; 196 u32 dIndex = ( line.y & 3 ) << 2;
197 197
198 198
199#else 199#else
200 // 200 //
201 tFixPoint r0, g0, b0; 201 tFixPoint r0, g0, b0;
202 tFixPoint r1, g1, b1; 202 tFixPoint r1, g1, b1;
203#endif 203#endif
204 204
205 205
206 for ( s32 i = 0; i <= dx; i++ ) 206 for ( s32 i = 0; i <= dx; i++ )
207 { 207 {
208#ifdef CMP_Z 208#ifdef CMP_Z
209 if ( line.z[0] < z[i] ) 209 if ( line.z[0] < z[i] )
210#endif 210#endif
211#ifdef CMP_W 211#ifdef CMP_W
212 if ( line.w[0] >= z[i] ) 212 if ( line.w[0] >= z[i] )
213#endif 213#endif
214 { 214 {
215 215
216#ifdef WRITE_Z 216#ifdef WRITE_Z
217 z[i] = line.z[0]; 217 z[i] = line.z[0];
218#endif 218#endif
219#ifdef WRITE_W 219#ifdef WRITE_W
220 z[i] = line.w[0]; 220 z[i] = line.w[0];
221#endif 221#endif
222 222
223#ifdef BURNINGVIDEO_RENDERER_FAST 223#ifdef BURNINGVIDEO_RENDERER_FAST
224 224
225#ifdef INVERSE_W 225#ifdef INVERSE_W
226 226
227 const f32 inversew = fix_inverse32 ( line.w[0] ); 227 const f32 inversew = fix_inverse32 ( line.w[0] );
228 228
229 const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; 229 const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];
230 230
231 dst[i] = PixelAdd32 ( 231 dst[i] = PixelAdd32 (
232 getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew), 232 getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew),
233 d + tofix ( line.t[0][0].y,inversew) ), 233 d + tofix ( line.t[0][0].y,inversew) ),
234 getTexel_plain ( &IT[1], d + tofix ( line.t[1][0].x,inversew), 234 getTexel_plain ( &IT[1], d + tofix ( line.t[1][0].x,inversew),
235 d + tofix ( line.t[1][0].y,inversew) ) 235 d + tofix ( line.t[1][0].y,inversew) )
236 ); 236 );
237#else 237#else
238 const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; 238 const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];
239 239
240 dst[i] = PixelAdd32 ( 240 dst[i] = PixelAdd32 (
241 getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x), 241 getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x),
242 d + tofix ( line.t[0][0].y) ), 242 d + tofix ( line.t[0][0].y) ),
243 getTexel_plain ( &IT[1], d + tofix ( line.t[1][0].x), 243 getTexel_plain ( &IT[1], d + tofix ( line.t[1][0].x),
244 d + tofix ( line.t[1][0].y) ) 244 d + tofix ( line.t[1][0].y) )
245 ); 245 );
246 246
247#endif 247#endif
248 248
249#else 249#else
250 const f32 inversew = fix_inverse32 ( line.w[0] ); 250 const f32 inversew = fix_inverse32 ( line.w[0] );
251 251
252 getSample_texture ( r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,inversew), tofix ( line.t[0][0].y,inversew) ); 252 getSample_texture ( r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,inversew), tofix ( line.t[0][0].y,inversew) );
253 getSample_texture ( r1, g1, b1, &IT[1], tofix ( line.t[0][1].x,inversew), tofix ( line.t[0][1].y,inversew) ); 253 getSample_texture ( r1, g1, b1, &IT[1], tofix ( line.t[0][1].x,inversew), tofix ( line.t[0][1].y,inversew) );
254 254
255 dst[i] = fix_to_color ( clampfix_maxcolor ( r0 + r1 ), 255 dst[i] = fix_to_color ( clampfix_maxcolor ( r0 + r1 ),
256 clampfix_maxcolor ( g0 + g1 ), 256 clampfix_maxcolor ( g0 + g1 ),
257 clampfix_maxcolor ( b0 + b1 ) 257 clampfix_maxcolor ( b0 + b1 )
258 ); 258 );
259#endif 259#endif
260 260
261 } 261 }
262 262
263#ifdef IPOL_Z 263#ifdef IPOL_Z
264 line.z[0] += slopeZ; 264 line.z[0] += slopeZ;
265#endif 265#endif
266#ifdef IPOL_W 266#ifdef IPOL_W
267 line.w[0] += slopeW; 267 line.w[0] += slopeW;
268#endif 268#endif
269#ifdef IPOL_C0 269#ifdef IPOL_C0
270 line.c[0] += slopeC; 270 line.c[0] += slopeC;
271#endif 271#endif
272#ifdef IPOL_T0 272#ifdef IPOL_T0
273 line.t[0][0] += slopeT[0]; 273 line.t[0][0] += slopeT[0];
274#endif 274#endif
275#ifdef IPOL_T1 275#ifdef IPOL_T1
276 line.t[1][0] += slopeT[1]; 276 line.t[1][0] += slopeT[1];
277#endif 277#endif
278 } 278 }
279 279
280} 280}
281 281
282void CTRTextureLightMap2_Add::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) 282void CTRTextureLightMap2_Add::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c )
283{ 283{
284 // sort on height, y 284 // sort on height, y
285 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); 285 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
286 if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); 286 if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
287 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); 287 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
288 288
289 const f32 ca = c->Pos.y - a->Pos.y; 289 const f32 ca = c->Pos.y - a->Pos.y;
290 const f32 ba = b->Pos.y - a->Pos.y; 290 const f32 ba = b->Pos.y - a->Pos.y;
291 const f32 cb = c->Pos.y - b->Pos.y; 291 const f32 cb = c->Pos.y - b->Pos.y;
292 // calculate delta y of the edges 292 // calculate delta y of the edges
293 scan.invDeltaY[0] = core::reciprocal( ca ); 293 scan.invDeltaY[0] = core::reciprocal( ca );
294 scan.invDeltaY[1] = core::reciprocal( ba ); 294 scan.invDeltaY[1] = core::reciprocal( ba );
295 scan.invDeltaY[2] = core::reciprocal( cb ); 295 scan.invDeltaY[2] = core::reciprocal( cb );
296 296
297 if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) 297 if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
298 return; 298 return;
299 299
300 // find if the major edge is left or right aligned 300 // find if the major edge is left or right aligned
301 f32 temp[4]; 301 f32 temp[4];
302 302
303 temp[0] = a->Pos.x - c->Pos.x; 303 temp[0] = a->Pos.x - c->Pos.x;
304 temp[1] = -ca; 304 temp[1] = -ca;
305 temp[2] = b->Pos.x - a->Pos.x; 305 temp[2] = b->Pos.x - a->Pos.x;
306 temp[3] = ba; 306 temp[3] = ba;
307 307
308 scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; 308 scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
309 scan.right = 1 - scan.left; 309 scan.right = 1 - scan.left;
310 310
311 // calculate slopes for the major edge 311 // calculate slopes for the major edge
312 scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; 312 scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0];
313 scan.x[0] = a->Pos.x; 313 scan.x[0] = a->Pos.x;
314 314
315#ifdef IPOL_Z 315#ifdef IPOL_Z
316 scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; 316 scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0];
317 scan.z[0] = a->Pos.z; 317 scan.z[0] = a->Pos.z;
318#endif 318#endif
319 319
320#ifdef IPOL_W 320#ifdef IPOL_W
321 scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; 321 scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0];
322 scan.w[0] = a->Pos.w; 322 scan.w[0] = a->Pos.w;
323#endif 323#endif
324 324
325#ifdef IPOL_C0 325#ifdef IPOL_C0
326 scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; 326 scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0];
327 scan.c[0] = a->Color[0]; 327 scan.c[0] = a->Color[0];
328#endif 328#endif
329 329
330#ifdef IPOL_T0 330#ifdef IPOL_T0
331 scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; 331 scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0];
332 scan.t[0][0] = a->Tex[0]; 332 scan.t[0][0] = a->Tex[0];
333#endif 333#endif
334 334
335#ifdef IPOL_T1 335#ifdef IPOL_T1
336 scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; 336 scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0];
337 scan.t[1][0] = a->Tex[1]; 337 scan.t[1][0] = a->Tex[1];
338#endif 338#endif
339 339
340 // top left fill convention y run 340 // top left fill convention y run
341 s32 yStart; 341 s32 yStart;
342 s32 yEnd; 342 s32 yEnd;
343 343
344#ifdef SUBTEXEL 344#ifdef SUBTEXEL
345 f32 subPixel; 345 f32 subPixel;
346#endif 346#endif
347 347
348 // rasterize upper sub-triangle 348 // rasterize upper sub-triangle
349 if ( (f32) 0.0 != scan.invDeltaY[1] ) 349 if ( (f32) 0.0 != scan.invDeltaY[1] )
350 { 350 {
351 // calculate slopes for top edge 351 // calculate slopes for top edge
352 scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; 352 scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1];
353 scan.x[1] = a->Pos.x; 353 scan.x[1] = a->Pos.x;
354 354
355#ifdef IPOL_Z 355#ifdef IPOL_Z
356 scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; 356 scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1];
357 scan.z[1] = a->Pos.z; 357 scan.z[1] = a->Pos.z;
358#endif 358#endif
359 359
360#ifdef IPOL_W 360#ifdef IPOL_W
361 scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; 361 scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1];
362 scan.w[1] = a->Pos.w; 362 scan.w[1] = a->Pos.w;
363#endif 363#endif
364 364
365#ifdef IPOL_C0 365#ifdef IPOL_C0
366 scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; 366 scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1];
367 scan.c[1] = a->Color[0]; 367 scan.c[1] = a->Color[0];
368#endif 368#endif
369 369
370#ifdef IPOL_T0 370#ifdef IPOL_T0
371 scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; 371 scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1];
372 scan.t[0][1] = a->Tex[0]; 372 scan.t[0][1] = a->Tex[0];
373#endif 373#endif
374 374
375#ifdef IPOL_T1 375#ifdef IPOL_T1
376 scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; 376 scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1];
377 scan.t[1][1] = a->Tex[1]; 377 scan.t[1][1] = a->Tex[1];
378#endif 378#endif
379 379
380 // apply top-left fill convention, top part 380 // apply top-left fill convention, top part
381 yStart = core::ceil32( a->Pos.y ); 381 yStart = core::ceil32( a->Pos.y );
382 yEnd = core::ceil32( b->Pos.y ) - 1; 382 yEnd = core::ceil32( b->Pos.y ) - 1;
383 383
384#ifdef SUBTEXEL 384#ifdef SUBTEXEL
385 subPixel = ( (f32) yStart ) - a->Pos.y; 385 subPixel = ( (f32) yStart ) - a->Pos.y;
386 386
387 // correct to pixel center 387 // correct to pixel center
388 scan.x[0] += scan.slopeX[0] * subPixel; 388 scan.x[0] += scan.slopeX[0] * subPixel;
389 scan.x[1] += scan.slopeX[1] * subPixel; 389 scan.x[1] += scan.slopeX[1] * subPixel;
390 390
391#ifdef IPOL_Z 391#ifdef IPOL_Z
392 scan.z[0] += scan.slopeZ[0] * subPixel; 392 scan.z[0] += scan.slopeZ[0] * subPixel;
393 scan.z[1] += scan.slopeZ[1] * subPixel; 393 scan.z[1] += scan.slopeZ[1] * subPixel;
394#endif 394#endif
395 395
396#ifdef IPOL_W 396#ifdef IPOL_W
397 scan.w[0] += scan.slopeW[0] * subPixel; 397 scan.w[0] += scan.slopeW[0] * subPixel;
398 scan.w[1] += scan.slopeW[1] * subPixel; 398 scan.w[1] += scan.slopeW[1] * subPixel;
399#endif 399#endif
400 400
401#ifdef IPOL_C0 401#ifdef IPOL_C0
402 scan.c[0] += scan.slopeC[0] * subPixel; 402 scan.c[0] += scan.slopeC[0] * subPixel;
403 scan.c[1] += scan.slopeC[1] * subPixel; 403 scan.c[1] += scan.slopeC[1] * subPixel;
404#endif 404#endif
405 405
406#ifdef IPOL_T0 406#ifdef IPOL_T0
407 scan.t[0][0] += scan.slopeT[0][0] * subPixel; 407 scan.t[0][0] += scan.slopeT[0][0] * subPixel;
408 scan.t[0][1] += scan.slopeT[0][1] * subPixel; 408 scan.t[0][1] += scan.slopeT[0][1] * subPixel;
409#endif 409#endif
410 410
411#ifdef IPOL_T1 411#ifdef IPOL_T1
412 scan.t[1][0] += scan.slopeT[1][0] * subPixel; 412 scan.t[1][0] += scan.slopeT[1][0] * subPixel;
413 scan.t[1][1] += scan.slopeT[1][1] * subPixel; 413 scan.t[1][1] += scan.slopeT[1][1] * subPixel;
414#endif 414#endif
415 415
416#endif 416#endif
417 417
418 // rasterize the edge scanlines 418 // rasterize the edge scanlines
419 for( line.y = yStart; line.y <= yEnd; ++line.y) 419 for( line.y = yStart; line.y <= yEnd; ++line.y)
420 { 420 {
421 line.x[scan.left] = scan.x[0]; 421 line.x[scan.left] = scan.x[0];
422 line.x[scan.right] = scan.x[1]; 422 line.x[scan.right] = scan.x[1];
423 423
424#ifdef IPOL_Z 424#ifdef IPOL_Z
425 line.z[scan.left] = scan.z[0]; 425 line.z[scan.left] = scan.z[0];
426 line.z[scan.right] = scan.z[1]; 426 line.z[scan.right] = scan.z[1];
427#endif 427#endif
428 428
429#ifdef IPOL_W 429#ifdef IPOL_W
430 line.w[scan.left] = scan.w[0]; 430 line.w[scan.left] = scan.w[0];
431 line.w[scan.right] = scan.w[1]; 431 line.w[scan.right] = scan.w[1];
432#endif 432#endif
433 433
434#ifdef IPOL_C0 434#ifdef IPOL_C0
435 line.c[scan.left] = scan.c[0]; 435 line.c[scan.left] = scan.c[0];
436 line.c[scan.right] = scan.c[1]; 436 line.c[scan.right] = scan.c[1];
437#endif 437#endif
438 438
439#ifdef IPOL_T0 439#ifdef IPOL_T0
440 line.t[0][scan.left] = scan.t[0][0]; 440 line.t[0][scan.left] = scan.t[0][0];
441 line.t[0][scan.right] = scan.t[0][1]; 441 line.t[0][scan.right] = scan.t[0][1];
442#endif 442#endif
443 443
444#ifdef IPOL_T1 444#ifdef IPOL_T1
445 line.t[1][scan.left] = scan.t[1][0]; 445 line.t[1][scan.left] = scan.t[1][0];
446 line.t[1][scan.right] = scan.t[1][1]; 446 line.t[1][scan.right] = scan.t[1][1];
447#endif 447#endif
448 448
449 // render a scanline 449 // render a scanline
450 scanline_bilinear (); 450 scanline_bilinear ();
451 451
452 scan.x[0] += scan.slopeX[0]; 452 scan.x[0] += scan.slopeX[0];
453 scan.x[1] += scan.slopeX[1]; 453 scan.x[1] += scan.slopeX[1];
454 454
455#ifdef IPOL_Z 455#ifdef IPOL_Z
456 scan.z[0] += scan.slopeZ[0]; 456 scan.z[0] += scan.slopeZ[0];
457 scan.z[1] += scan.slopeZ[1]; 457 scan.z[1] += scan.slopeZ[1];
458#endif 458#endif
459 459
460#ifdef IPOL_W 460#ifdef IPOL_W
461 scan.w[0] += scan.slopeW[0]; 461 scan.w[0] += scan.slopeW[0];
462 scan.w[1] += scan.slopeW[1]; 462 scan.w[1] += scan.slopeW[1];
463#endif 463#endif
464 464
465#ifdef IPOL_C0 465#ifdef IPOL_C0
466 scan.c[0] += scan.slopeC[0]; 466 scan.c[0] += scan.slopeC[0];
467 scan.c[1] += scan.slopeC[1]; 467 scan.c[1] += scan.slopeC[1];
468#endif 468#endif
469 469
470#ifdef IPOL_T0 470#ifdef IPOL_T0
471 scan.t[0][0] += scan.slopeT[0][0]; 471 scan.t[0][0] += scan.slopeT[0][0];
472 scan.t[0][1] += scan.slopeT[0][1]; 472 scan.t[0][1] += scan.slopeT[0][1];
473#endif 473#endif
474 474
475#ifdef IPOL_T1 475#ifdef IPOL_T1
476 scan.t[1][0] += scan.slopeT[1][0]; 476 scan.t[1][0] += scan.slopeT[1][0];
477 scan.t[1][1] += scan.slopeT[1][1]; 477 scan.t[1][1] += scan.slopeT[1][1];
478#endif 478#endif
479 479
480 } 480 }
481 } 481 }
482 482
483 // rasterize lower sub-triangle 483 // rasterize lower sub-triangle
484 if ( (f32) 0.0 != scan.invDeltaY[2] ) 484 if ( (f32) 0.0 != scan.invDeltaY[2] )
485 { 485 {
486 // advance to middle point 486 // advance to middle point
487 if( (f32) 0.0 != scan.invDeltaY[1] ) 487 if( (f32) 0.0 != scan.invDeltaY[1] )
488 { 488 {
489 temp[0] = b->Pos.y - a->Pos.y; // dy 489 temp[0] = b->Pos.y - a->Pos.y; // dy
490 490
491 scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; 491 scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0];
492#ifdef IPOL_Z 492#ifdef IPOL_Z
493 scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; 493 scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0];
494#endif 494#endif
495#ifdef IPOL_W 495#ifdef IPOL_W
496 scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; 496 scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0];
497#endif 497#endif
498#ifdef IPOL_C0 498#ifdef IPOL_C0
499 scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; 499 scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0];
500#endif 500#endif
501#ifdef IPOL_T0 501#ifdef IPOL_T0
502 scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; 502 scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0];
503#endif 503#endif
504#ifdef IPOL_T1 504#ifdef IPOL_T1
505 scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; 505 scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0];
506#endif 506#endif
507 507
508 } 508 }
509 509
510 // calculate slopes for bottom edge 510 // calculate slopes for bottom edge
511 scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; 511 scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2];
512 scan.x[1] = b->Pos.x; 512 scan.x[1] = b->Pos.x;
513 513
514#ifdef IPOL_Z 514#ifdef IPOL_Z
515 scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; 515 scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2];
516 scan.z[1] = b->Pos.z; 516 scan.z[1] = b->Pos.z;
517#endif 517#endif
518 518
519#ifdef IPOL_W 519#ifdef IPOL_W
520 scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; 520 scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2];
521 scan.w[1] = b->Pos.w; 521 scan.w[1] = b->Pos.w;
522#endif 522#endif
523 523
524#ifdef IPOL_C0 524#ifdef IPOL_C0
525 scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; 525 scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2];
526 scan.c[1] = b->Color[0]; 526 scan.c[1] = b->Color[0];
527#endif 527#endif
528 528
529#ifdef IPOL_T0 529#ifdef IPOL_T0
530 scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; 530 scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2];
531 scan.t[0][1] = b->Tex[0]; 531 scan.t[0][1] = b->Tex[0];
532#endif 532#endif
533 533
534#ifdef IPOL_T1 534#ifdef IPOL_T1
535 scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; 535 scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2];
536 scan.t[1][1] = b->Tex[1]; 536 scan.t[1][1] = b->Tex[1];
537#endif 537#endif
538 538
539 // apply top-left fill convention, top part 539 // apply top-left fill convention, top part
540 yStart = core::ceil32( b->Pos.y ); 540 yStart = core::ceil32( b->Pos.y );
541 yEnd = core::ceil32( c->Pos.y ) - 1; 541 yEnd = core::ceil32( c->Pos.y ) - 1;
542 542
543#ifdef SUBTEXEL 543#ifdef SUBTEXEL
544 544
545 subPixel = ( (f32) yStart ) - b->Pos.y; 545 subPixel = ( (f32) yStart ) - b->Pos.y;
546 546
547 // correct to pixel center 547 // correct to pixel center
548 scan.x[0] += scan.slopeX[0] * subPixel; 548 scan.x[0] += scan.slopeX[0] * subPixel;
549 scan.x[1] += scan.slopeX[1] * subPixel; 549 scan.x[1] += scan.slopeX[1] * subPixel;
550 550
551#ifdef IPOL_Z 551#ifdef IPOL_Z
552 scan.z[0] += scan.slopeZ[0] * subPixel; 552 scan.z[0] += scan.slopeZ[0] * subPixel;
553 scan.z[1] += scan.slopeZ[1] * subPixel; 553 scan.z[1] += scan.slopeZ[1] * subPixel;
554#endif 554#endif
555 555
556#ifdef IPOL_W 556#ifdef IPOL_W
557 scan.w[0] += scan.slopeW[0] * subPixel; 557 scan.w[0] += scan.slopeW[0] * subPixel;
558 scan.w[1] += scan.slopeW[1] * subPixel; 558 scan.w[1] += scan.slopeW[1] * subPixel;
559#endif 559#endif
560 560
561#ifdef IPOL_C0 561#ifdef IPOL_C0
562 scan.c[0] += scan.slopeC[0] * subPixel; 562 scan.c[0] += scan.slopeC[0] * subPixel;
563 scan.c[1] += scan.slopeC[1] * subPixel; 563 scan.c[1] += scan.slopeC[1] * subPixel;
564#endif 564#endif
565 565
566#ifdef IPOL_T0 566#ifdef IPOL_T0
567 scan.t[0][0] += scan.slopeT[0][0] * subPixel; 567 scan.t[0][0] += scan.slopeT[0][0] * subPixel;
568 scan.t[0][1] += scan.slopeT[0][1] * subPixel; 568 scan.t[0][1] += scan.slopeT[0][1] * subPixel;
569#endif 569#endif
570 570
571#ifdef IPOL_T1 571#ifdef IPOL_T1
572 scan.t[1][0] += scan.slopeT[1][0] * subPixel; 572 scan.t[1][0] += scan.slopeT[1][0] * subPixel;
573 scan.t[1][1] += scan.slopeT[1][1] * subPixel; 573 scan.t[1][1] += scan.slopeT[1][1] * subPixel;
574#endif 574#endif
575 575
576#endif 576#endif
577 577
578 // rasterize the edge scanlines 578 // rasterize the edge scanlines
579 for( line.y = yStart; line.y <= yEnd; ++line.y) 579 for( line.y = yStart; line.y <= yEnd; ++line.y)
580 { 580 {
581 line.x[scan.left] = scan.x[0]; 581 line.x[scan.left] = scan.x[0];
582 line.x[scan.right] = scan.x[1]; 582 line.x[scan.right] = scan.x[1];
583 583
584#ifdef IPOL_Z 584#ifdef IPOL_Z
585 line.z[scan.left] = scan.z[0]; 585 line.z[scan.left] = scan.z[0];
586 line.z[scan.right] = scan.z[1]; 586 line.z[scan.right] = scan.z[1];
587#endif 587#endif
588 588
589#ifdef IPOL_W 589#ifdef IPOL_W
590 line.w[scan.left] = scan.w[0]; 590 line.w[scan.left] = scan.w[0];
591 line.w[scan.right] = scan.w[1]; 591 line.w[scan.right] = scan.w[1];
592#endif 592#endif
593 593
594#ifdef IPOL_C0 594#ifdef IPOL_C0
595 line.c[scan.left] = scan.c[0]; 595 line.c[scan.left] = scan.c[0];
596 line.c[scan.right] = scan.c[1]; 596 line.c[scan.right] = scan.c[1];
597#endif 597#endif
598 598
599#ifdef IPOL_T0 599#ifdef IPOL_T0
600 line.t[0][scan.left] = scan.t[0][0]; 600 line.t[0][scan.left] = scan.t[0][0];
601 line.t[0][scan.right] = scan.t[0][1]; 601 line.t[0][scan.right] = scan.t[0][1];
602#endif 602#endif
603 603
604#ifdef IPOL_T1 604#ifdef IPOL_T1
605 line.t[1][scan.left] = scan.t[1][0]; 605 line.t[1][scan.left] = scan.t[1][0];
606 line.t[1][scan.right] = scan.t[1][1]; 606 line.t[1][scan.right] = scan.t[1][1];
607#endif 607#endif
608 608
609 // render a scanline 609 // render a scanline
610 scanline_bilinear (); 610 scanline_bilinear ();
611 611
612 scan.x[0] += scan.slopeX[0]; 612 scan.x[0] += scan.slopeX[0];
613 scan.x[1] += scan.slopeX[1]; 613 scan.x[1] += scan.slopeX[1];
614 614
615#ifdef IPOL_Z 615#ifdef IPOL_Z
616 scan.z[0] += scan.slopeZ[0]; 616 scan.z[0] += scan.slopeZ[0];
617 scan.z[1] += scan.slopeZ[1]; 617 scan.z[1] += scan.slopeZ[1];
618#endif 618#endif
619 619
620#ifdef IPOL_W 620#ifdef IPOL_W
621 scan.w[0] += scan.slopeW[0]; 621 scan.w[0] += scan.slopeW[0];
622 scan.w[1] += scan.slopeW[1]; 622 scan.w[1] += scan.slopeW[1];
623#endif 623#endif
624 624
625#ifdef IPOL_C0 625#ifdef IPOL_C0
626 scan.c[0] += scan.slopeC[0]; 626 scan.c[0] += scan.slopeC[0];
627 scan.c[1] += scan.slopeC[1]; 627 scan.c[1] += scan.slopeC[1];
628#endif 628#endif
629 629
630#ifdef IPOL_T0 630#ifdef IPOL_T0
631 scan.t[0][0] += scan.slopeT[0][0]; 631 scan.t[0][0] += scan.slopeT[0][0];
632 scan.t[0][1] += scan.slopeT[0][1]; 632 scan.t[0][1] += scan.slopeT[0][1];
633#endif 633#endif
634 634
635#ifdef IPOL_T1 635#ifdef IPOL_T1
636 scan.t[1][0] += scan.slopeT[1][0]; 636 scan.t[1][0] += scan.slopeT[1][0];
637 scan.t[1][1] += scan.slopeT[1][1]; 637 scan.t[1][1] += scan.slopeT[1][1];
638#endif 638#endif
639 639
640 } 640 }
641 } 641 }
642 642
643 643
644} 644}
645 645
646 646
647} // end namespace video 647} // end namespace video
648} // end namespace irr 648} // end namespace irr
649 649
650#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ 650#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
651 651
652namespace irr 652namespace irr
653{ 653{
654namespace video 654namespace video
655{ 655{
656 656
657//! creates a flat triangle renderer 657//! creates a flat triangle renderer
658IBurningShader* createTriangleRendererTextureLightMap2_Add(CBurningVideoDriver* driver) 658IBurningShader* createTriangleRendererTextureLightMap2_Add(CBurningVideoDriver* driver)
659{ 659{
660 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ 660 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
661 return new CTRTextureLightMap2_Add(driver); 661 return new CTRTextureLightMap2_Add(driver);
662 #else 662 #else
663 return 0; 663 return 0;
664 #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ 664 #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
665} 665}
666 666
667 667
668} // end namespace video 668} // end namespace video
669} // end namespace irr 669} // end namespace irr
670 670
671 671
672 672