r_main.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. // Emacs style mode select -*- C++ -*-
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // $Log:$
  18. //
  19. // DESCRIPTION:
  20. // Rendering main loop and setup functions,
  21. // utility functions (BSP, geometry, trigonometry).
  22. // See tables.c, too.
  23. //
  24. //-----------------------------------------------------------------------------
  25. static const char rcsid[] = "$Id: r_main.c,v 1.5 1997/02/03 22:45:12 b1 Exp $";
  26. #include <stdlib.h>
  27. #include <math.h>
  28. #include "doomdef.h"
  29. #include "d_net.h"
  30. #include "m_bbox.h"
  31. #include "r_local.h"
  32. #include "r_sky.h"
  33. // Fineangles in the SCREENWIDTH wide window.
  34. #define FIELDOFVIEW 2048
  35. int viewangleoffset;
  36. // increment every time a check is made
  37. int validcount = 1;
  38. lighttable_t* fixedcolormap;
  39. extern lighttable_t** walllights;
  40. int centerx;
  41. int centery;
  42. fixed_t centerxfrac;
  43. fixed_t centeryfrac;
  44. fixed_t projection;
  45. // just for profiling purposes
  46. int framecount;
  47. int sscount;
  48. int linecount;
  49. int loopcount;
  50. fixed_t viewx;
  51. fixed_t viewy;
  52. fixed_t viewz;
  53. angle_t viewangle;
  54. fixed_t viewcos;
  55. fixed_t viewsin;
  56. player_t* viewplayer;
  57. // 0 = high, 1 = low
  58. int detailshift;
  59. //
  60. // precalculated math tables
  61. //
  62. angle_t clipangle;
  63. // The viewangletox[viewangle + FINEANGLES/4] lookup
  64. // maps the visible view angles to screen X coordinates,
  65. // flattening the arc to a flat projection plane.
  66. // There will be many angles mapped to the same X.
  67. int viewangletox[FINEANGLES/2];
  68. // The xtoviewangleangle[] table maps a screen pixel
  69. // to the lowest viewangle that maps back to x ranges
  70. // from clipangle to -clipangle.
  71. angle_t xtoviewangle[SCREENWIDTH+1];
  72. // UNUSED.
  73. // The finetangentgent[angle+FINEANGLES/4] table
  74. // holds the fixed_t tangent values for view angles,
  75. // ranging from MININT to 0 to MAXINT.
  76. // fixed_t finetangent[FINEANGLES/2];
  77. // fixed_t finesine[5*FINEANGLES/4];
  78. fixed_t* finecosine = &finesine[FINEANGLES/4];
  79. lighttable_t* scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
  80. lighttable_t* scalelightfixed[MAXLIGHTSCALE];
  81. lighttable_t* zlight[LIGHTLEVELS][MAXLIGHTZ];
  82. // bumped light from gun blasts
  83. int extralight;
  84. void (*colfunc) (void);
  85. void (*basecolfunc) (void);
  86. void (*fuzzcolfunc) (void);
  87. void (*transcolfunc) (void);
  88. void (*spanfunc) (void);
  89. //
  90. // R_AddPointToBox
  91. // Expand a given bbox
  92. // so that it encloses a given point.
  93. //
  94. void
  95. R_AddPointToBox
  96. ( int x,
  97. int y,
  98. fixed_t* box )
  99. {
  100. if (x< box[BOXLEFT])
  101. box[BOXLEFT] = x;
  102. if (x> box[BOXRIGHT])
  103. box[BOXRIGHT] = x;
  104. if (y< box[BOXBOTTOM])
  105. box[BOXBOTTOM] = y;
  106. if (y> box[BOXTOP])
  107. box[BOXTOP] = y;
  108. }
  109. //
  110. // R_PointOnSide
  111. // Traverse BSP (sub) tree,
  112. // check point against partition plane.
  113. // Returns side 0 (front) or 1 (back).
  114. //
  115. int
  116. R_PointOnSide
  117. ( fixed_t x,
  118. fixed_t y,
  119. node_t* node )
  120. {
  121. fixed_t dx;
  122. fixed_t dy;
  123. fixed_t left;
  124. fixed_t right;
  125. if (!node->dx)
  126. {
  127. if (x <= node->x)
  128. return node->dy > 0;
  129. return node->dy < 0;
  130. }
  131. if (!node->dy)
  132. {
  133. if (y <= node->y)
  134. return node->dx < 0;
  135. return node->dx > 0;
  136. }
  137. dx = (x - node->x);
  138. dy = (y - node->y);
  139. // Try to quickly decide by looking at sign bits.
  140. if ( (node->dy ^ node->dx ^ dx ^ dy)&0x80000000 )
  141. {
  142. if ( (node->dy ^ dx) & 0x80000000 )
  143. {
  144. // (left is negative)
  145. return 1;
  146. }
  147. return 0;
  148. }
  149. left = FixedMul ( node->dy>>FRACBITS , dx );
  150. right = FixedMul ( dy , node->dx>>FRACBITS );
  151. if (right < left)
  152. {
  153. // front side
  154. return 0;
  155. }
  156. // back side
  157. return 1;
  158. }
  159. int
  160. R_PointOnSegSide
  161. ( fixed_t x,
  162. fixed_t y,
  163. seg_t* line )
  164. {
  165. fixed_t lx;
  166. fixed_t ly;
  167. fixed_t ldx;
  168. fixed_t ldy;
  169. fixed_t dx;
  170. fixed_t dy;
  171. fixed_t left;
  172. fixed_t right;
  173. lx = line->v1->x;
  174. ly = line->v1->y;
  175. ldx = line->v2->x - lx;
  176. ldy = line->v2->y - ly;
  177. if (!ldx)
  178. {
  179. if (x <= lx)
  180. return ldy > 0;
  181. return ldy < 0;
  182. }
  183. if (!ldy)
  184. {
  185. if (y <= ly)
  186. return ldx < 0;
  187. return ldx > 0;
  188. }
  189. dx = (x - lx);
  190. dy = (y - ly);
  191. // Try to quickly decide by looking at sign bits.
  192. if ( (ldy ^ ldx ^ dx ^ dy)&0x80000000 )
  193. {
  194. if ( (ldy ^ dx) & 0x80000000 )
  195. {
  196. // (left is negative)
  197. return 1;
  198. }
  199. return 0;
  200. }
  201. left = FixedMul ( ldy>>FRACBITS , dx );
  202. right = FixedMul ( dy , ldx>>FRACBITS );
  203. if (right < left)
  204. {
  205. // front side
  206. return 0;
  207. }
  208. // back side
  209. return 1;
  210. }
  211. //
  212. // R_PointToAngle
  213. // To get a global angle from cartesian coordinates,
  214. // the coordinates are flipped until they are in
  215. // the first octant of the coordinate system, then
  216. // the y (<=x) is scaled and divided by x to get a
  217. // tangent (slope) value which is looked up in the
  218. // tantoangle[] table.
  219. //
  220. angle_t
  221. R_PointToAngle
  222. ( fixed_t x,
  223. fixed_t y )
  224. {
  225. x -= viewx;
  226. y -= viewy;
  227. if ( (!x) && (!y) )
  228. return 0;
  229. if (x>= 0)
  230. {
  231. // x >=0
  232. if (y>= 0)
  233. {
  234. // y>= 0
  235. if (x>y)
  236. {
  237. // octant 0
  238. return tantoangle[ SlopeDiv(y,x)];
  239. }
  240. else
  241. {
  242. // octant 1
  243. return ANG90-1-tantoangle[ SlopeDiv(x,y)];
  244. }
  245. }
  246. else
  247. {
  248. // y<0
  249. y = -y;
  250. if (x>y)
  251. {
  252. // octant 8
  253. return -tantoangle[SlopeDiv(y,x)];
  254. }
  255. else
  256. {
  257. // octant 7
  258. return ANG270+tantoangle[ SlopeDiv(x,y)];
  259. }
  260. }
  261. }
  262. else
  263. {
  264. // x<0
  265. x = -x;
  266. if (y>= 0)
  267. {
  268. // y>= 0
  269. if (x>y)
  270. {
  271. // octant 3
  272. return ANG180-1-tantoangle[ SlopeDiv(y,x)];
  273. }
  274. else
  275. {
  276. // octant 2
  277. return ANG90+ tantoangle[ SlopeDiv(x,y)];
  278. }
  279. }
  280. else
  281. {
  282. // y<0
  283. y = -y;
  284. if (x>y)
  285. {
  286. // octant 4
  287. return ANG180+tantoangle[ SlopeDiv(y,x)];
  288. }
  289. else
  290. {
  291. // octant 5
  292. return ANG270-1-tantoangle[ SlopeDiv(x,y)];
  293. }
  294. }
  295. }
  296. return 0;
  297. }
  298. angle_t
  299. R_PointToAngle2
  300. ( fixed_t x1,
  301. fixed_t y1,
  302. fixed_t x2,
  303. fixed_t y2 )
  304. {
  305. viewx = x1;
  306. viewy = y1;
  307. return R_PointToAngle (x2, y2);
  308. }
  309. fixed_t
  310. R_PointToDist
  311. ( fixed_t x,
  312. fixed_t y )
  313. {
  314. int angle;
  315. fixed_t dx;
  316. fixed_t dy;
  317. fixed_t temp;
  318. fixed_t dist;
  319. dx = abs(x - viewx);
  320. dy = abs(y - viewy);
  321. if (dy>dx)
  322. {
  323. temp = dx;
  324. dx = dy;
  325. dy = temp;
  326. }
  327. angle = (tantoangle[ FixedDiv(dy,dx)>>DBITS ]+ANG90) >> ANGLETOFINESHIFT;
  328. // use as cosine
  329. dist = FixedDiv (dx, finesine[angle] );
  330. return dist;
  331. }
  332. //
  333. // R_InitPointToAngle
  334. //
  335. void R_InitPointToAngle (void)
  336. {
  337. // UNUSED - now getting from tables.c
  338. #if 0
  339. int i;
  340. long t;
  341. float f;
  342. //
  343. // slope (tangent) to angle lookup
  344. //
  345. for (i=0 ; i<=SLOPERANGE ; i++)
  346. {
  347. f = atan( (float)i/SLOPERANGE )/(3.141592657*2);
  348. t = 0xffffffff*f;
  349. tantoangle[i] = t;
  350. }
  351. #endif
  352. }
  353. //
  354. // R_ScaleFromGlobalAngle
  355. // Returns the texture mapping scale
  356. // for the current line (horizontal span)
  357. // at the given angle.
  358. // rw_distance must be calculated first.
  359. //
  360. fixed_t R_ScaleFromGlobalAngle (angle_t visangle)
  361. {
  362. fixed_t scale;
  363. int anglea;
  364. int angleb;
  365. int sinea;
  366. int sineb;
  367. fixed_t num;
  368. int den;
  369. // UNUSED
  370. #if 0
  371. {
  372. fixed_t dist;
  373. fixed_t z;
  374. fixed_t sinv;
  375. fixed_t cosv;
  376. sinv = finesine[(visangle-rw_normalangle)>>ANGLETOFINESHIFT];
  377. dist = FixedDiv (rw_distance, sinv);
  378. cosv = finecosine[(viewangle-visangle)>>ANGLETOFINESHIFT];
  379. z = abs(FixedMul (dist, cosv));
  380. scale = FixedDiv(projection, z);
  381. return scale;
  382. }
  383. #endif
  384. anglea = ANG90 + (visangle-viewangle);
  385. angleb = ANG90 + (visangle-rw_normalangle);
  386. // both sines are allways positive
  387. sinea = finesine[anglea>>ANGLETOFINESHIFT];
  388. sineb = finesine[angleb>>ANGLETOFINESHIFT];
  389. num = FixedMul(projection,sineb)<<detailshift;
  390. den = FixedMul(rw_distance,sinea);
  391. if (den > num>>16)
  392. {
  393. scale = FixedDiv (num, den);
  394. if (scale > 64*FRACUNIT)
  395. scale = 64*FRACUNIT;
  396. else if (scale < 256)
  397. scale = 256;
  398. }
  399. else
  400. scale = 64*FRACUNIT;
  401. return scale;
  402. }
  403. //
  404. // R_InitTables
  405. //
  406. void R_InitTables (void)
  407. {
  408. // UNUSED: now getting from tables.c
  409. #if 0
  410. int i;
  411. float a;
  412. float fv;
  413. int t;
  414. // viewangle tangent table
  415. for (i=0 ; i<FINEANGLES/2 ; i++)
  416. {
  417. a = (i-FINEANGLES/4+0.5)*PI*2/FINEANGLES;
  418. fv = FRACUNIT*tan (a);
  419. t = fv;
  420. finetangent[i] = t;
  421. }
  422. // finesine table
  423. for (i=0 ; i<5*FINEANGLES/4 ; i++)
  424. {
  425. // OPTIMIZE: mirror...
  426. a = (i+0.5)*PI*2/FINEANGLES;
  427. t = FRACUNIT*sin (a);
  428. finesine[i] = t;
  429. }
  430. #endif
  431. }
  432. //
  433. // R_InitTextureMapping
  434. //
  435. void R_InitTextureMapping (void)
  436. {
  437. int i;
  438. int x;
  439. int t;
  440. fixed_t focallength;
  441. // Use tangent table to generate viewangletox:
  442. // viewangletox will give the next greatest x
  443. // after the view angle.
  444. //
  445. // Calc focallength
  446. // so FIELDOFVIEW angles covers SCREENWIDTH.
  447. focallength = FixedDiv (centerxfrac,
  448. finetangent[FINEANGLES/4+FIELDOFVIEW/2] );
  449. for (i=0 ; i<FINEANGLES/2 ; i++)
  450. {
  451. if (finetangent[i] > FRACUNIT*2)
  452. t = -1;
  453. else if (finetangent[i] < -FRACUNIT*2)
  454. t = viewwidth+1;
  455. else
  456. {
  457. t = FixedMul (finetangent[i], focallength);
  458. t = (centerxfrac - t+FRACUNIT-1)>>FRACBITS;
  459. if (t < -1)
  460. t = -1;
  461. else if (t>viewwidth+1)
  462. t = viewwidth+1;
  463. }
  464. viewangletox[i] = t;
  465. }
  466. // Scan viewangletox[] to generate xtoviewangle[]:
  467. // xtoviewangle will give the smallest view angle
  468. // that maps to x.
  469. for (x=0;x<=viewwidth;x++)
  470. {
  471. i = 0;
  472. while (viewangletox[i]>x)
  473. i++;
  474. xtoviewangle[x] = (i<<ANGLETOFINESHIFT)-ANG90;
  475. }
  476. // Take out the fencepost cases from viewangletox.
  477. for (i=0 ; i<FINEANGLES/2 ; i++)
  478. {
  479. t = FixedMul (finetangent[i], focallength);
  480. t = centerx - t;
  481. if (viewangletox[i] == -1)
  482. viewangletox[i] = 0;
  483. else if (viewangletox[i] == viewwidth+1)
  484. viewangletox[i] = viewwidth;
  485. }
  486. clipangle = xtoviewangle[0];
  487. }
  488. //
  489. // R_InitLightTables
  490. // Only inits the zlight table,
  491. // because the scalelight table changes with view size.
  492. //
  493. #define DISTMAP 2
  494. void R_InitLightTables (void)
  495. {
  496. int i;
  497. int j;
  498. int level;
  499. int startmap;
  500. int scale;
  501. // Calculate the light levels to use
  502. // for each level / distance combination.
  503. for (i=0 ; i< LIGHTLEVELS ; i++)
  504. {
  505. startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS;
  506. for (j=0 ; j<MAXLIGHTZ ; j++)
  507. {
  508. scale = FixedDiv ((SCREENWIDTH/2*FRACUNIT), (j+1)<<LIGHTZSHIFT);
  509. scale >>= LIGHTSCALESHIFT;
  510. level = startmap - scale/DISTMAP;
  511. if (level < 0)
  512. level = 0;
  513. if (level >= NUMCOLORMAPS)
  514. level = NUMCOLORMAPS-1;
  515. zlight[i][j] = colormaps + level*256;
  516. }
  517. }
  518. }
  519. //
  520. // R_SetViewSize
  521. // Do not really change anything here,
  522. // because it might be in the middle of a refresh.
  523. // The change will take effect next refresh.
  524. //
  525. boolean setsizeneeded;
  526. int setblocks;
  527. int setdetail;
  528. void
  529. R_SetViewSize
  530. ( int blocks,
  531. int detail )
  532. {
  533. setsizeneeded = true;
  534. setblocks = blocks;
  535. setdetail = detail;
  536. }
  537. //
  538. // R_ExecuteSetViewSize
  539. //
  540. void R_ExecuteSetViewSize (void)
  541. {
  542. fixed_t cosadj;
  543. fixed_t dy;
  544. int i;
  545. int j;
  546. int level;
  547. int startmap;
  548. setsizeneeded = false;
  549. if (setblocks == 11)
  550. {
  551. scaledviewwidth = SCREENWIDTH;
  552. viewheight = SCREENHEIGHT;
  553. }
  554. else
  555. {
  556. scaledviewwidth = setblocks*32;
  557. viewheight = (setblocks*168/10)&~7;
  558. }
  559. detailshift = setdetail;
  560. viewwidth = scaledviewwidth>>detailshift;
  561. centery = viewheight/2;
  562. centerx = viewwidth/2;
  563. centerxfrac = centerx<<FRACBITS;
  564. centeryfrac = centery<<FRACBITS;
  565. projection = centerxfrac;
  566. if (!detailshift)
  567. {
  568. colfunc = basecolfunc = R_DrawColumn;
  569. fuzzcolfunc = R_DrawFuzzColumn;
  570. transcolfunc = R_DrawTranslatedColumn;
  571. spanfunc = R_DrawSpan;
  572. }
  573. else
  574. {
  575. colfunc = basecolfunc = R_DrawColumnLow;
  576. fuzzcolfunc = R_DrawFuzzColumn;
  577. transcolfunc = R_DrawTranslatedColumn;
  578. spanfunc = R_DrawSpanLow;
  579. }
  580. R_InitBuffer (scaledviewwidth, viewheight);
  581. R_InitTextureMapping ();
  582. // psprite scales
  583. pspritescale = FRACUNIT*viewwidth/SCREENWIDTH;
  584. pspriteiscale = FRACUNIT*SCREENWIDTH/viewwidth;
  585. // thing clipping
  586. for (i=0 ; i<viewwidth ; i++)
  587. screenheightarray[i] = viewheight;
  588. // planes
  589. for (i=0 ; i<viewheight ; i++)
  590. {
  591. dy = ((i-viewheight/2)<<FRACBITS)+FRACUNIT/2;
  592. dy = abs(dy);
  593. yslope[i] = FixedDiv ( (viewwidth<<detailshift)/2*FRACUNIT, dy);
  594. }
  595. for (i=0 ; i<viewwidth ; i++)
  596. {
  597. cosadj = abs(finecosine[xtoviewangle[i]>>ANGLETOFINESHIFT]);
  598. distscale[i] = FixedDiv (FRACUNIT,cosadj);
  599. }
  600. // Calculate the light levels to use
  601. // for each level / scale combination.
  602. for (i=0 ; i< LIGHTLEVELS ; i++)
  603. {
  604. startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS;
  605. for (j=0 ; j<MAXLIGHTSCALE ; j++)
  606. {
  607. level = startmap - j*SCREENWIDTH/(viewwidth<<detailshift)/DISTMAP;
  608. if (level < 0)
  609. level = 0;
  610. if (level >= NUMCOLORMAPS)
  611. level = NUMCOLORMAPS-1;
  612. scalelight[i][j] = colormaps + level*256;
  613. }
  614. }
  615. }
  616. //
  617. // R_Init
  618. //
  619. extern int detailLevel;
  620. extern int screenblocks;
  621. void R_Init (void)
  622. {
  623. R_InitData ();
  624. printf ("\nR_InitData");
  625. R_InitPointToAngle ();
  626. printf ("\nR_InitPointToAngle");
  627. R_InitTables ();
  628. // viewwidth / viewheight / detailLevel are set by the defaults
  629. printf ("\nR_InitTables");
  630. R_SetViewSize (screenblocks, detailLevel);
  631. R_InitPlanes ();
  632. printf ("\nR_InitPlanes");
  633. R_InitLightTables ();
  634. printf ("\nR_InitLightTables");
  635. R_InitSkyMap ();
  636. printf ("\nR_InitSkyMap");
  637. R_InitTranslationTables ();
  638. printf ("\nR_InitTranslationsTables");
  639. framecount = 0;
  640. }
  641. //
  642. // R_PointInSubsector
  643. //
  644. subsector_t*
  645. R_PointInSubsector
  646. ( fixed_t x,
  647. fixed_t y )
  648. {
  649. node_t* node;
  650. int side;
  651. int nodenum;
  652. // single subsector is a special case
  653. if (!numnodes)
  654. return subsectors;
  655. nodenum = numnodes-1;
  656. while (! (nodenum & NF_SUBSECTOR) )
  657. {
  658. node = &nodes[nodenum];
  659. side = R_PointOnSide (x, y, node);
  660. nodenum = node->children[side];
  661. }
  662. return &subsectors[nodenum & ~NF_SUBSECTOR];
  663. }
  664. //
  665. // R_SetupFrame
  666. //
  667. void R_SetupFrame (player_t* player)
  668. {
  669. int i;
  670. viewplayer = player;
  671. viewx = player->mo->x;
  672. viewy = player->mo->y;
  673. viewangle = player->mo->angle + viewangleoffset;
  674. extralight = player->extralight;
  675. viewz = player->viewz;
  676. viewsin = finesine[viewangle>>ANGLETOFINESHIFT];
  677. viewcos = finecosine[viewangle>>ANGLETOFINESHIFT];
  678. sscount = 0;
  679. if (player->fixedcolormap)
  680. {
  681. fixedcolormap =
  682. colormaps
  683. + player->fixedcolormap*256*sizeof(lighttable_t);
  684. walllights = scalelightfixed;
  685. for (i=0 ; i<MAXLIGHTSCALE ; i++)
  686. scalelightfixed[i] = fixedcolormap;
  687. }
  688. else
  689. fixedcolormap = 0;
  690. framecount++;
  691. validcount++;
  692. }
  693. //
  694. // R_RenderView
  695. //
  696. void R_RenderPlayerView (player_t* player)
  697. {
  698. R_SetupFrame (player);
  699. // Clear buffers.
  700. R_ClearClipSegs ();
  701. R_ClearDrawSegs ();
  702. R_ClearPlanes ();
  703. R_ClearSprites ();
  704. // check for new console commands.
  705. NetUpdate ();
  706. // The head node is the last node output.
  707. R_RenderBSPNode (numnodes-1);
  708. // Check for new console commands.
  709. NetUpdate ();
  710. R_DrawPlanes ();
  711. // Check for new console commands.
  712. NetUpdate ();
  713. R_DrawMasked ();
  714. // Check for new console commands.
  715. NetUpdate ();
  716. }