예제 #1
0
bool ZFileSectorLoader::LoadSector(Long x, Long y, Long z)
{
  ZVoxelSector * NewSector;
  bool Redo, TryLoad;

  if ( !RequestTag.find(x,y,z) )
  {
    NewSector = SectorRecycling->PullFromList(); // Try recycling some old used sector.
    if (!NewSector) {
		NewSector = new ZVoxelSector( GameEnv->Basic_Renderer->GetCuller() ); 
	}

    TryLoad = true;
    do
    {
      Redo = false;

      NewSector->Pos_x = x; NewSector->Pos_y = y; NewSector->Pos_z = z;
      NewSector->SetVoxelTypeManager(VoxelTypeManager);

      if (TryLoad && NewSector->Load(UniverseNum))
      {
        // Does this sector must be regenerated ?
        if ( 0==(NewSector->Flag_IsModified & ZVoxelSector::CHANGE_SAVEMASK) )
        {
          if (COMPILEOPTION_ALLOWSAVE) NewSector->DeleteSave(UniverseNum);
          NewSector->ReinitSector();
		  Redo = true;
          TryLoad = false;
          continue;
        }
      }
      else
      {
        SectorCreator->GenerateSector(NewSector);
      }
    } while (Redo);

    // Set the options for further edge faceculling.

    NewSector->Flag_NeedFullCulling = false;
    NewSector->PartialCulling = DRAWFACE_ALL;

    // Add it in the tag

    RequestTag.Add(x,y,z);

    // Partial face culling on the sector. Edges must be completed later when other sectors will be availlable.

    LimitedUpdateFaceCulling(NewSector );
    //NoDrawFaceCulling(NewSector);

    // Push it to the list for integration in the world on the main thread.

    ReadySectorList->PushToList(NewSector);
    return(true);
  }
  return(false);
}
예제 #2
0
void ZFileSectorLoader::MakeTasks()
{
  Long x,y,z;
  UByte Pri;

  // Sector Loading

  while (1)
  {
    if      (RequestList[5].PullFromList(x,y,z)) {Pri = 4; }
    else if (RequestList[4].PullFromList(x,y,z)) {Pri = 4; }
    else if (RequestList[3].PullFromList(x,y,z)) {Pri = 3; }
    else if (RequestList[2].PullFromList(x,y,z)) {Pri = 2; }
    else if (RequestList[1].PullFromList(x,y,z)) {Pri = 1; }
    else if (RequestList[0].PullFromList(x,y,z)) {Pri = 0; }
    else break;

    if (LoadSector(x,y,z) /*&& Pri<4*/) break;
  }

  // Sector Unloading

  ZVoxelSector * Sector;

  while ( (Sector = EjectedSectorList->PullFromList()) )
  {
    RequestTag.Remove(Sector->Pos_x, Sector->Pos_y, Sector->Pos_z);
    printf("Deleted : %lx, %lu L2 Start:%lu End:%lu nEntries:%lu\n", Sector,++debug_deletecount,EjectedSectorList->debug_getstart(),EjectedSectorList->debug_GetEnd(),EjectedSectorList->debug_GetnEntries() );
    if (COMPILEOPTION_ALLOWSAVE)
    {
#if COMPILEOPTION_SAVEONLYMODIFIED==1
      if (Sector->IsMustBeSaved())
#endif
      {
        Sector->Save(UniverseNum);
      }
    }
    //delete Sector;

     Sector->ReinitSector();
     SectorRecycling->PushToList(Sector);
  }

  return;

}