@ -20,15 +20,15 @@ namespace
void insertCellRefList ( MWRender : : RenderingManager & rendering ,
T & cellRefList , MWWorld : : CellStore & cell , MWWorld : : PhysicsSystem & physics )
{
if ( ! cellRefList . l ist. empty ( ) )
if ( ! cellRefList . mL ist. empty ( ) )
{
const MWWorld : : Class & class_ =
MWWorld : : Class : : get ( MWWorld : : Ptr ( & * cellRefList . l ist. begin ( ) , & cell ) ) ;
MWWorld : : Class : : get ( MWWorld : : Ptr ( & * cellRefList . mL ist. begin ( ) , & cell ) ) ;
int numRefs = cellRefList . l ist. size ( ) ;
int numRefs = cellRefList . mL ist. size ( ) ;
int current = 0 ;
for ( typename T : : List : : iterator it = cellRefList . l ist. begin ( ) ;
it ! = cellRefList . l ist. end ( ) ; it + + )
for ( typename T : : List : : iterator it = cellRefList . mL ist. begin ( ) ;
it ! = cellRefList . mL ist. end ( ) ; it + + )
{
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > setLoadingProgress ( " Loading cells " , 1 , current , numRefs ) ;
+ + current ;
@ -80,11 +80,15 @@ namespace MWWorld
mPhysics - > removeObject ( node - > getName ( ) ) ;
}
if ( ! ( ( * iter ) - > cell- > mData . mFlags & ESM : : Cell : : Interior ) )
if ( ( * iter ) - > mCell- > isExterior ( ) )
{
ESM : : Land * land = MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . lands . search ( ( * iter ) - > cell - > mData . mX , ( * iter ) - > cell - > mData . mY ) ;
ESM : : Land * land =
MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . lands . search (
( * iter ) - > mCell - > getGridX ( ) ,
( * iter ) - > mCell - > getGridY ( )
) ;
if ( land )
mPhysics - > removeHeightField ( ( * iter ) - > cell - > mData . mX , ( * iter ) - > cell - > mData . mY ) ;
mPhysics - > removeHeightField ( ( * iter ) - > mCell- > getGridX ( ) , ( * iter ) - > mCell - > getGridY ( ) ) ;
}
}
@ -111,13 +115,23 @@ namespace MWWorld
float verts = ESM : : Land : : LAND_SIZE ;
float worldsize = ESM : : Land : : REAL_SIZE ;
if ( ! ( cell - > cell - > mData . mFlags & ESM : : Cell : : Interior ) )
if ( cell - > mCell - > isExterior ( ) )
{
ESM : : Land * land = MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . lands . search ( cell - > cell - > mData . mX , cell - > cell - > mData . mY ) ;
if ( land )
mPhysics - > addHeightField ( land - > mLandData - > mHeights ,
cell - > cell - > mData . mX , cell - > cell - > mData . mY ,
0 , ( worldsize / ( verts - 1 ) ) , verts ) ;
ESM : : Land * land =
MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . lands . search (
cell - > mCell - > getGridX ( ) ,
cell - > mCell - > getGridY ( )
) ;
if ( land ) {
mPhysics - > addHeightField (
land - > mLandData - > mHeights ,
cell - > mCell - > getGridX ( ) ,
cell - > mCell - > getGridY ( ) ,
0 ,
worldsize / ( verts - 1 ) ,
verts )
;
}
}
mRendering . configureAmbient ( * cell ) ;
@ -128,8 +142,8 @@ namespace MWWorld
void Scene : : playerCellChange ( MWWorld : : CellStore * cell , const ESM : : Position & pos , bool adjustPlayerPos )
{
bool hasWater = cell - > cell- > mData . mFlags & cell - > cell - > HasWater ;
mPhysics - > setCurrentWater ( hasWater , cell - > c ell- > mWater ) ;
bool hasWater = cell - > mCell- > mData . mFlags & ESM : : Cell : : HasWater ;
mPhysics - > setCurrentWater ( hasWater , cell - > mC ell- > mWater ) ;
MWBase : : World * world = MWBase : : Environment : : get ( ) . getWorld ( ) ;
world - > getPlayer ( ) . setCell ( cell ) ;
@ -167,10 +181,10 @@ namespace MWWorld
int numUnload = 0 ;
while ( active ! = mActiveCells . end ( ) )
{
if ( ! ( ( * active ) - > cell- > mData . mFlags & ESM : : Cell : : Interior ) )
if ( ( * active ) - > mCell- > isExterior ( ) )
{
if ( std : : abs ( X - ( * active ) - > cell- > mData . mX ) < = 1 & &
std : : abs ( Y - ( * active ) - > cell- > mData . mY ) < = 1 )
if ( std : : abs ( X - ( * active ) - > mCell- > getGridX ( ) ) < = 1 & &
std : : abs ( Y - ( * active ) - > mCell- > getGridY ( ) ) < = 1 )
{
// keep cells within the new 3x3 grid
+ + active ;
@ -185,10 +199,10 @@ namespace MWWorld
active = mActiveCells . begin ( ) ;
while ( active ! = mActiveCells . end ( ) )
{
if ( ! ( ( * active ) - > cell- > mData . mFlags & ESM : : Cell : : Interior ) )
if ( ( * active ) - > mCell- > isExterior ( ) )
{
if ( std : : abs ( X - ( * active ) - > cell- > mData . mX ) < = 1 & &
std : : abs ( Y - ( * active ) - > cell- > mData . mY ) < = 1 )
if ( std : : abs ( X - ( * active ) - > mCell- > getGridX ( ) ) < = 1 & &
std : : abs ( Y - ( * active ) - > mCell- > getGridY ( ) ) < = 1 )
{
// keep cells within the new 3x3 grid
+ + active ;
@ -210,10 +224,10 @@ namespace MWWorld
while ( iter ! = mActiveCells . end ( ) )
{
assert ( ! ( ( * iter ) - > cell- > mData . mFlags & ESM : : Cell : : Interior ) ) ;
assert ( ( * iter ) - > mCell- > isExterior ( ) ) ;
if ( x = = ( * iter ) - > cell- > mData . mX & &
y = = ( * iter ) - > cell- > mData . mY )
if ( x = = ( * iter ) - > mCell- > getGridX ( ) & &
y = = ( * iter ) - > mCell- > getGridY ( ) )
break ;
+ + iter ;
@ -232,10 +246,10 @@ namespace MWWorld
while ( iter ! = mActiveCells . end ( ) )
{
assert ( ! ( ( * iter ) - > cell- > mData . mFlags & ESM : : Cell : : Interior ) ) ;
assert ( ( * iter ) - > mCell- > isExterior ( ) ) ;
if ( x = = ( * iter ) - > cell- > mData . mX & &
y = = ( * iter ) - > cell- > mData . mY )
if ( x = = ( * iter ) - > mCell- > getGridX ( ) & &
y = = ( * iter ) - > mCell- > getGridY ( ) )
break ;
+ + iter ;
@ -256,10 +270,10 @@ namespace MWWorld
while ( iter ! = mActiveCells . end ( ) )
{
assert ( ! ( ( * iter ) - > cell- > mData . mFlags & ESM : : Cell : : Interior ) ) ;
assert ( ( * iter ) - > mCell- > isExterior ( ) ) ;
if ( X = = ( * iter ) - > cell- > mData . mX & &
Y = = ( * iter ) - > cell- > mData . mY )
if ( X = = ( * iter ) - > mCell- > getGridX ( ) & &
Y = = ( * iter ) - > mCell- > getGridY ( ) )
break ;
+ + iter ;
@ -376,26 +390,26 @@ namespace MWWorld
void Scene : : insertCell ( Ptr : : CellStore & cell )
{
// Loop through all references in the cell
insertCellRefList ( mRendering , cell . a ctivators, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . p otions, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . a ppas, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . a rmors, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . b ooks, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . c lothes, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . c ontainers, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . c reatures, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . d oors, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . i ngreds, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . c reatureLists, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . i temLists, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . l ights, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . l ockpicks, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . m iscItems, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . n pcs, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . p robes, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . r epairs, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . s tatics, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . w eapons, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mA ctivators, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mP otions, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mA ppas, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mA rmors, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mB ooks, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mC lothes, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mC ontainers, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mC reatures, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mD oors, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mI ngreds, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mC reatureLists, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mI temLists, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mL ights, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mL ockpicks, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . m M iscItems, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mN pcs, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mP robes, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mR epairs, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mS tatics, cell , * mPhysics ) ;
insertCellRefList ( mRendering , cell . mW eapons, cell , * mPhysics ) ;
}
void Scene : : addObjectToScene ( const Ptr & ptr )