/* ================ idRenderWorldLocal::ParseInterAreaPortals ================ */ void idRenderWorldLocal::ReadBinaryAreaPortals( idFile* file ) { file->ReadBig( numPortalAreas ); file->ReadBig( numInterAreaPortals ); portalAreas = ( portalArea_t* )R_ClearedStaticAlloc( numPortalAreas * sizeof( portalAreas[0] ) ); areaScreenRect = ( idScreenRect* ) R_ClearedStaticAlloc( numPortalAreas * sizeof( idScreenRect ) ); // set the doubly linked lists SetupAreaRefs(); doublePortals = ( doublePortal_t* )R_ClearedStaticAlloc( numInterAreaPortals * sizeof( doublePortals [0] ) ); for( int i = 0; i < numInterAreaPortals; i++ ) { int numPoints, a1, a2; idWinding* w; portal_t* p; file->ReadBig( numPoints ); file->ReadBig( a1 ); file->ReadBig( a2 ); w = new( TAG_RENDER_WINDING ) idWinding( numPoints ); w->SetNumPoints( numPoints ); for( int j = 0; j < numPoints; j++ ) { file->ReadBig( ( *w )[ j ][ 0 ] ); file->ReadBig( ( *w )[ j ][ 1 ] ); file->ReadBig( ( *w )[ j ][ 2 ] ); // no texture coordinates ( *w )[ j ][ 3 ] = 0; ( *w )[ j ][ 4 ] = 0; } // add the portal to a1 p = ( portal_t* )R_ClearedStaticAlloc( sizeof( *p ) ); p->intoArea = a2; p->doublePortal = &doublePortals[i]; p->w = w; p->w->GetPlane( p->plane ); p->next = portalAreas[a1].portals; portalAreas[a1].portals = p; doublePortals[i].portals[0] = p; // reverse it for a2 p = ( portal_t* )R_ClearedStaticAlloc( sizeof( *p ) ); p->intoArea = a1; p->doublePortal = &doublePortals[i]; p->w = w->Reverse(); p->w->GetPlane( p->plane ); p->next = portalAreas[a2].portals; portalAreas[a2].portals = p; doublePortals[i].portals[1] = p; } }
/* ================= idRenderWorldLocal::ClearWorld Sets up for a single area world ================= */ void idRenderWorldLocal::ClearWorld() { numPortalAreas = 1; portalAreas = (portalArea_t *)R_ClearedStaticAlloc( sizeof( portalAreas[0] ) ); areaScreenRect = (idScreenRect *) R_ClearedStaticAlloc( sizeof( idScreenRect ) ); SetupAreaRefs(); // even though we only have a single area, create a node // that has both children pointing at it so we don't need to // areaNodes = (areaNode_t *)R_ClearedStaticAlloc( sizeof( areaNodes[0] ) ); areaNodes[0].plane[3] = 1; areaNodes[0].children[0] = -1; areaNodes[0].children[1] = -1; }
/* ================ idRenderWorldLocal::ParseInterAreaPortals ================ */ void idRenderWorldLocal::ParseInterAreaPortals( idLexer* src, idFile* fileOut ) { src->ExpectTokenString( "{" ); numPortalAreas = src->ParseInt(); if( numPortalAreas < 0 ) { src->Error( "R_ParseInterAreaPortals: bad numPortalAreas" ); return; } if( fileOut != NULL ) { // write out the type so the binary reader knows what to instantiate fileOut->WriteString( "interAreaPortals" ); } portalAreas = ( portalArea_t* )R_ClearedStaticAlloc( numPortalAreas * sizeof( portalAreas[0] ) ); areaScreenRect = ( idScreenRect* ) R_ClearedStaticAlloc( numPortalAreas * sizeof( idScreenRect ) ); // set the doubly linked lists SetupAreaRefs(); numInterAreaPortals = src->ParseInt(); if( numInterAreaPortals < 0 ) { src->Error( "R_ParseInterAreaPortals: bad numInterAreaPortals" ); return; } if( fileOut != NULL ) { fileOut->WriteBig( numPortalAreas ); fileOut->WriteBig( numInterAreaPortals ); } doublePortals = ( doublePortal_t* )R_ClearedStaticAlloc( numInterAreaPortals * sizeof( doublePortals [0] ) ); for( int i = 0; i < numInterAreaPortals; i++ ) { int numPoints, a1, a2; idWinding* w; portal_t* p; numPoints = src->ParseInt(); a1 = src->ParseInt(); a2 = src->ParseInt(); if( fileOut != NULL ) { fileOut->WriteBig( numPoints ); fileOut->WriteBig( a1 ); fileOut->WriteBig( a2 ); } w = new( TAG_RENDER_WINDING ) idWinding( numPoints ); w->SetNumPoints( numPoints ); for( int j = 0; j < numPoints; j++ ) { src->Parse1DMatrix( 3, ( *w )[j].ToFloatPtr() ); if( fileOut != NULL ) { fileOut->WriteBig( ( *w )[j].x ); fileOut->WriteBig( ( *w )[j].y ); fileOut->WriteBig( ( *w )[j].z ); } // no texture coordinates ( *w )[j][3] = 0; ( *w )[j][4] = 0; } // add the portal to a1 p = ( portal_t* )R_ClearedStaticAlloc( sizeof( *p ) ); p->intoArea = a2; p->doublePortal = &doublePortals[i]; p->w = w; p->w->GetPlane( p->plane ); p->next = portalAreas[a1].portals; portalAreas[a1].portals = p; doublePortals[i].portals[0] = p; // reverse it for a2 p = ( portal_t* )R_ClearedStaticAlloc( sizeof( *p ) ); p->intoArea = a1; p->doublePortal = &doublePortals[i]; p->w = w->Reverse(); p->w->GetPlane( p->plane ); p->next = portalAreas[a2].portals; portalAreas[a2].portals = p; doublePortals[i].portals[1] = p; } src->ExpectTokenString( "}" ); }
/* ================ idRenderWorldLocal::ParseInterAreaPortals ================ */ void idRenderWorldLocal::ParseInterAreaPortals( idLexer *src ) { int i, j; src->ExpectTokenString( "{" ); numPortalAreas = src->ParseInt(); if ( numPortalAreas < 0 ) { src->Error( "R_ParseInterAreaPortals: bad numPortalAreas" ); return; } portalAreas = (portalArea_t *)R_ClearedStaticAlloc( numPortalAreas * sizeof( portalAreas[0] ) ); areaScreenRect = (idScreenRect *) R_ClearedStaticAlloc( numPortalAreas * sizeof( idScreenRect ) ); // set the doubly linked lists SetupAreaRefs(); numInterAreaPortals = src->ParseInt(); if ( numInterAreaPortals < 0 ) { src->Error( "R_ParseInterAreaPortals: bad numInterAreaPortals" ); return; } doublePortals = (doublePortal_t *)R_ClearedStaticAlloc( numInterAreaPortals * sizeof( doublePortals [0] ) ); for ( i = 0 ; i < numInterAreaPortals ; i++ ) { int numPoints, a1, a2; idWinding *w; portal_t *p; numPoints = src->ParseInt(); a1 = src->ParseInt(); a2 = src->ParseInt(); w = new idWinding( numPoints ); w->SetNumPoints( numPoints ); for ( j = 0 ; j < numPoints ; j++ ) { src->Parse1DMatrix( 3, (*w)[j].ToFloatPtr() ); // no texture coordinates (*w)[j][3] = 0; (*w)[j][4] = 0; } // add the portal to a1 p = (portal_t *)R_ClearedStaticAlloc( sizeof( *p ) ); p->intoArea = a2; p->doublePortal = &doublePortals[i]; p->w = w; p->w->GetPlane( p->plane ); p->next = portalAreas[a1].portals; portalAreas[a1].portals = p; doublePortals[i].portals[0] = p; // reverse it for a2 p = (portal_t *)R_ClearedStaticAlloc( sizeof( *p ) ); p->intoArea = a1; p->doublePortal = &doublePortals[i]; p->w = w->Reverse(); p->w->GetPlane( p->plane ); p->next = portalAreas[a2].portals; portalAreas[a2].portals = p; doublePortals[i].portals[1] = p; } src->ExpectTokenString( "}" ); }