if ( colsLeft > 0 && boxInVCone ( nodes [node].rightBox )) drawNode ( nodes [nodeJ.rightNode );
}
}
void drawSubSector (int s ) {
int firstSeg = subSectors [sJ.firstSeg; // get segments, forming ssect
int numSegs = subSectors [sj.numSegs;
Segment * seg = &segs [firstSeg]; // pointer to current segment
if ( curSector == NULL ) //1st ssector to be drawn usin
{ // front-to-back will contain viewer
SideDef * side = &sides [lines [seg->lineDef].sideDefs
[seg->lineSide]J;
curSector = &subSectors [sj; // so remember it & adjust height
locZ = 40 + sectors [side -> sector].floorHeight;
}
for (int i = 0; i < numSegs; i++, seg++ ) // draw all front-facing segments if (frontFacing ( seg -> from, seg -> to ))
13. Элементы виртуальной реальност
drawSeg (seg );
}
void drawSeg ( Segment * seg ) {
if ( vertexCache [seg -> from].frame != totalFrames ) // vertex has { // not been projected this frame
int x1 = vertices [seg->from].x - locX;
int y1 = vertices [seg->from].y - locY;
VertexCache * ptr = &vertexCache [seg -> from];
ptr -> frame = totalFrames;
ptr -> u = fixed2lnt (-x1*sine(angle) +y1*cosine(angle));
ptr -> v = fixed2lnt ( x1 *cosine(angle)+y1 *sine(angle));
if ( ptr -> v >= VJvllN )
ptr -> c = (int) (1601 - (ptr->u*HSCALE) / ptr->v);
}
if ( vertexCache [seg -> toj.frame != totalFrames ) {
int x2 = vertices [seg->to].x - locX;
int y2 = vertices [seg->to].y - locY;
VertexCache * ptr = &vertexCache [seg -> to];
ptr -> frame = totalFrames;
ptr -> u = fixed2lnt (-x2*sine(angle) +y2*cosine(angle));
ptr -> v = fixed2lnt ( x2*cosine(angle)+y2*sine(angle));
if ( ptr -> v >= VJvllN )
ptr -> c = (int) (1601 - (ptr->u*HSCALE) / ptr->v);
}
// convert to local coords int v1 = vertexCache [seg -> from].v; int v2 = vertexCache [seg -> to].v;
if ( v1 < V_MIN && v2 < V_MIN ) // segment behind the return;