1
+ #include < array>
1
2
#include " StdAfxRD.h"
2
3
#include " PoolManager.h"
3
4
#include " TileMap.h"
12
13
13
14
int cInterfaceRenderDevice::CreateTilemap (cTileMap *TileMap)
14
15
{
15
- cTileMapRender* p = new cTileMapRender (TileMap);
16
- TileMap->SetTilemapRender (p);
17
- p->RestoreTilemapPool ();
16
+ for (auto type : cTileMap::RenderTypes)
17
+ {
18
+ cTileMapRender* p = new cTileMapRender (TileMap);
19
+ TileMap->SetTilemapRender (type, p);
20
+ p->RestoreTilemapPool ();
21
+ }
22
+
18
23
return 0 ;
19
24
}
20
25
21
26
int cInterfaceRenderDevice::DeleteTilemap (cTileMap *TileMap)
22
27
{
23
- cTileMapRender* p = TileMap->GetTilemapRender ();
28
+ for (auto type : cTileMap::RenderTypes)
29
+ {
30
+ cTileMapRender* p = TileMap->GetTilemapRender (type);
24
31
25
- if (p) {
26
- p->ClearTilemapPool ();
27
- TileMap->SetTilemapRender (nullptr );
28
- delete p;
32
+ if (p) {
33
+ p->ClearTilemapPool ();
34
+ TileMap->SetTilemapRender (type, nullptr );
35
+ delete p;
36
+ }
29
37
}
30
38
31
39
return true ;
@@ -41,6 +49,8 @@ cTileMapRender::cTileMapRender(cTileMap *pTileMap)
41
49
for (int i=0 ;i<dxy;i++)
42
50
vis_lod[i]=-1 ;
43
51
52
+ renderTiles.resize (dxy);
53
+
44
54
update_stat=NULL ;
45
55
// update_stat=new char[dxy*TILEMAP_LOD];
46
56
update_in_frame=false ;
@@ -64,9 +74,8 @@ void cTileMapRender::ClearTilemapPool()
64
74
{
65
75
for (int y=0 ; y < tilemap->GetTileNumber ().y ; y++) {
66
76
for (int x = 0 ; x < tilemap->GetTileNumber ().x ; x++) {
67
- sTile & Tile = tilemap->GetTile (x, y);
68
- int & bumpTileID = Tile.bumpTileID ;
69
- bumpTileID = -1 ;
77
+ auto & Tile = GetRenderTile (x, y);
78
+ Tile.bumpTileID = -1 ;
70
79
}
71
80
}
72
81
@@ -153,7 +162,7 @@ void cTileMapRender::PreDraw(cCamera* DrawNode)
153
162
for (int y=0 ; y < tilemap->GetTileNumber ().y ; y++)
154
163
for (int x=0 ; x < tilemap->GetTileNumber ().x ; x++)
155
164
{
156
- sTile &Tile = tilemap-> GetTile (x, y);
165
+ sRenderTile &Tile = GetRenderTile (x, y);
157
166
int &bumpTileID = Tile.bumpTileID ;
158
167
if (!Tile.GetAttribute (ATTRTILE_DRAWLOD))
159
168
{
@@ -162,6 +171,10 @@ void cTileMapRender::PreDraw(cCamera* DrawNode)
162
171
}
163
172
164
173
Tile.ClearAttribute (ATTRTILE_DRAWLOD);
174
+
175
+ if (tilemap->GetTile (x, y).GetAttribute (ATTRTILE_UPDATELOD)) {
176
+ Tile.SetAttribute (ATTRTILE_UPDATELOD);
177
+ }
165
178
}
166
179
167
180
if (update_stat)
@@ -218,7 +231,7 @@ int cTileMapRender::bumpTileAlloc(int lod,int xpos,int ypos)
218
231
int w = tilemap->GetTileSize ().x >> bumpTexScale[lod];
219
232
int h = tilemap->GetTileSize ().y >> bumpTexScale[lod];
220
233
cTilemapTexturePool* pool = FindFreeTexturePool (w, h);
221
- sBumpTile * tile = new sBumpTile (tilemap, pool, lod, xpos, ypos);
234
+ sBumpTile * tile = new sBumpTile (tilemap, this , pool, lod, xpos, ypos);
222
235
int i;
223
236
for (i = 0 ; i < bumpTiles.size (); i++) {
224
237
if (!bumpTiles[i]) {
@@ -310,7 +323,6 @@ void cTileMapRender::DrawBump(cCamera* DrawNode,eBlendMode MatMode,TILEMAP_DRAW
310
323
cCamera* pShadowMapCamera=DrawNode->FindCildCamera (ATTRCAMERA_SHADOWMAP);
311
324
int reflection = DrawNode->GetAttribute (ATTRCAMERA_REFLECTION);
312
325
cCamera* pNormalCamera=DrawNode->GetRoot ();
313
- cTileMapRender* render=tilemap->GetTilemapRender ();
314
326
bool use_shadow_map=false ;
315
327
316
328
// TODO remove this once D3D9 specifics are removed
@@ -464,7 +476,7 @@ void cTileMapRender::DrawBump(cCamera* DrawNode,eBlendMode MatMode,TILEMAP_DRAW
464
476
/**/
465
477
{
466
478
// process visible tile
467
- sTile &Tile = tilemap-> GetTile (k, n);
479
+ sRenderTile &Tile = GetRenderTile (k, n);
468
480
int &bumpTileID = Tile.bumpTileID ;
469
481
470
482
// calc LOD считается всегда по отгошению к прямой камере для
@@ -477,8 +489,7 @@ void cTileMapRender::DrawBump(cCamera* DrawNode,eBlendMode MatMode,TILEMAP_DRAW
477
489
vis_lod[k+n*dk]=iLod;
478
490
479
491
// create/update render tile
480
- if (render->bumpTileValid (bumpTileID)
481
- && render->bumpTiles [bumpTileID]->LOD != iLod && !shadow )
492
+ if (bumpTileValid (bumpTileID) && bumpTiles[bumpTileID]->LOD != iLod && !shadow )
482
493
{
483
494
// LOD changed, free old tile and allocate new
484
495
bumpTileFree (bumpTileID);
@@ -520,7 +531,7 @@ void cTileMapRender::DrawBump(cCamera* DrawNode,eBlendMode MatMode,TILEMAP_DRAW
520
531
for (n = 0 ; n < dn; n++)
521
532
for (k = 0 ; k < dk; k++)
522
533
{
523
- sTile &Tile = tilemap-> GetTile (k, n);
534
+ sRenderTile &Tile = GetRenderTile (k, n);
524
535
int bumpTileID = Tile.bumpTileID ;
525
536
if (bumpTileID<0 )continue ;
526
537
sBumpTile *bumpTile = bumpTiles[bumpTileID];
@@ -607,8 +618,8 @@ void cTileMapRender::DrawBump(cCamera* DrawNode,eBlendMode MatMode,TILEMAP_DRAW
607
618
int nTiles = 0 ;
608
619
VertexBuffer* lastVB = nullptr ;
609
620
#endif
610
- VertexPoolManager* vtxPoolMan = render-> GetVertexPool ();
611
- IndexPoolManager* idxPoolMan = render-> GetIndexPool ();
621
+ VertexPoolManager* vtxPoolMan = GetVertexPool ();
622
+ IndexPoolManager* idxPoolMan = GetIndexPool ();
612
623
for (cTilemapTexturePool* curpool : bumpTexPools) {
613
624
if (curpool->tileRenderList .empty ()) {
614
625
continue ;
0 commit comments