コード例 #1
0
ファイル: WorldCSG.cpp プロジェクト: DrItanium/Serious-Engine
/*
 * Substract a brush from another world to a brush in this world.
 */
void CWorld::CSGRemove(CEntity &enThis, CWorld &woOther, CEntity &enOther,
  const CPlacement3D &plOther)
{
  _pfWorldEditingProfile.StartTimer(CWorldEditingProfile::PTI_CSGTOTAL);
  _pfWorldEditingProfile.IncrementAveragingCounter();
  // assure that floating point precision is 53 bits
  AssureFPT_53();

  // get relevant brush mip in other brush
  CBrushMip &bmOther = *GetBrushMip(enOther);
  if (&bmOther==NULL) {
    return;
  }

  // if other brush has more than one sector
  if (bmOther.bm_abscSectors.Count()>1) {
    // join all sectors of the other brush together
    CBrushSectorSelection selbscOtherAll;
    bmOther.SelectAllSectors(selbscOtherAll);
    woOther.JoinSectors(selbscOtherAll);
  }

  // do 'remove material' with joined brush
  DoCSGOperation(enThis, woOther, enOther, plOther,
    &CObject3D::CSGRemoveMaterial, &CObject3D::CSGRemoveMaterial);

  // if the world doesn't have all portal-sector links updated
  if (!wo_bPortalLinksUpToDate) {
    // update the links
    wo_baBrushes.LinkPortalsAndSectors();
    wo_bPortalLinksUpToDate = TRUE;
  }
  _pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL);
}
コード例 #2
0
ファイル: WorldCSG.cpp プロジェクト: DrItanium/Serious-Engine
/*
 * Split selected sectors in a brush in this world with one brush in other world.
 * (other brush must have only one sector)
 */
void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsToSplit,
  CWorld &woOther, CEntity &enOther, const CPlacement3D &plOther)
{
  _pfWorldEditingProfile.StartTimer(CWorldEditingProfile::PTI_CSGTOTAL);
  _pfWorldEditingProfile.IncrementAveragingCounter();
  // assure that floating point precision is 53 bits
  AssureFPT_53();

  // get relevant brush mip in this brush
  CBrushMip &bmThis = *GetBrushMip(enThis);
  if (&bmThis==NULL) {
    _pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL);
    return;
  }

  // get relevant brush mip in other brush
  CBrushMip &bmOther = *GetBrushMip(enOther);
  if (&bmOther==NULL) {
    _pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL);
    return;
  }

  /* Assure that the other brush has only one sector. */

  // if other brush has more than one sector
  if (bmOther.bm_abscSectors.Count()>1) {
    // join all sectors of the other brush together
    CBrushSectorSelection selbscOtherAll;
    bmOther.SelectAllSectors(selbscOtherAll);
    woOther.JoinSectors(selbscOtherAll);
  }

  /* Split selected sectors with the one sector in the other brush. */

  // get the sector of the other brush to object
  CBrushSectorSelectionForCSG selbscOther;
  bmOther.SelectAllSectors(selbscOther);
  CObject3D obOther;
  DOUBLEaabbox3D boxOther;
  woOther.CopySourceBrushSectorsToObject(enOther, selbscOther, plOther,
    obOther, enThis.en_plPlacement, boxOther);

  // if the selection is empty
  if (selbscSectorsToSplit.Count()==0) {
    // select all sectors near the splitting tool
    bmThis.SelectSectorsInRange(selbscSectorsToSplit, DOUBLEtoFLOAT(boxOther));
  }
  // for all sectors in the selection
  FOREACHINDYNAMICCONTAINER(selbscSectorsToSplit, CBrushSector, itbsc) {
    // split the sector using the copy of other object
    CObject3D obj(obOther);
    SplitOneSector(*itbsc, obj);
  }