1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-12-01 15:35:47 +00:00

Merge branch 'tile-optimization' of github.com:AquariaOSE/Aquaria into tile-optimization

This commit is contained in:
fgenesis 2023-09-10 20:34:09 +02:00
commit db8912cb16
7 changed files with 34 additions and 5 deletions

View file

@ -40,6 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "GLLoad.h"
#include "RenderBase.h"
#include "Image.h"
#include "TileRender.h"
#include <sys/stat.h>

View file

@ -458,6 +458,8 @@ public:
void fixupJoysticks();
void initActionButtons();
void importActionButtons();
TileRender *tileRenders[MAX_TILE_LAYERS];
};
extern DSQ *dsq;

View file

@ -2491,6 +2491,7 @@ void Game::applyState()
{
TileRender *tr = new TileRender(dsq->tilemgr.tilestore[i]);
addRenderObject(tr, LR_ELEMENTS1 + i);
dsq->tileRenders[i] = tr;
}
for (int i = LR_ELEMENTS1; i <= LR_ELEMENTS12; i++) // LR_ELEMENTS13 is darkness, stop before that

View file

@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "GridRender.h"
#include "Shot.h"
#include "Tile.h"
#include "TileRender.h"
#ifdef BBGE_BUILD_WINDOWS
#define WIN32_LEAN_AND_MEAN
@ -1678,6 +1678,11 @@ void SceneEditor::setActiveLayer(unsigned bglayer)
if(this->bgLayer == bglayer)
return;
for(size_t i = 0; i < MAX_TILE_LAYERS; ++i)
dsq->tileRenders[i]->renderBorders = false;
dsq->tileRenders[bglayer]->renderBorders = true;
destroyMultiTileHelper();
clearSelection();
this->bgLayer = bglayer;
@ -1697,12 +1702,14 @@ void SceneEditor::action(int id, int state, int source, InputDevice device)
if(editType == ET_ELEMENTS)
{
bool change = true;
if(size_t N = selectedTiles.size())
{
TileStorage& ts = getCurrentLayerTiles();
if (core->getCtrlState())
{
change = false;
if (id == ACTION_BGLAYEREND)
{
ts.setEffect(dsq->tilemgr.tileEffects, -1, &selectedTiles[0], N);
@ -1728,13 +1735,13 @@ void SceneEditor::action(int id, int state, int source, InputDevice device)
for(size_t i = 0; i < N; ++i)
selectedTiles.push_back(idx + i);
//ts.changeFlags(TILEFLAG_SELECTED, 0, &selectedTiles[0], N); // they still have that flag
change = false;
}
}
}
}
if(change)
setActiveLayer(newLayer);
}
}
}
}
@ -2257,6 +2264,7 @@ void SceneEditor::toggle(bool on)
{
btnMenu->alpha = 1;
dsq->getRenderObjectLayer(LR_BLACKGROUND)->update = true;
dsq->tileRenders[bgLayer]->renderBorders = true;
game->togglePause(on);
if (game->avatar)
@ -2294,6 +2302,7 @@ void SceneEditor::toggle(bool on)
movingEntity = 0;
dsq->getRenderObjectLayer(LR_BLACKGROUND)->update = false;
dsq->tileRenders[bgLayer]->renderBorders = false;
game->togglePause(on);
if (game->avatar)
@ -2408,10 +2417,18 @@ void SceneEditor::update(float dt)
int sel = -1;
if (state == ES_SELECTING && !ismulti)
{
selectedTiles.clear();
sel = this->getTileAtCursor();
//if(sel < 0 || (selectedTiles.size() == 1 && selectedTiles[0] != (size_t)sel))
{
selectedTiles.clear();
getCurrentLayerTiles().clearSelection();
}
if(sel >= 0)
{
selectedTiles.push_back(sel);
const size_t idx = sel;
getCurrentLayerTiles().select(&idx, 1);
}
}
if (sel >= 0 || ismulti)

View file

@ -217,6 +217,11 @@ void TileStorage::changeFlags(unsigned flagsToSet, unsigned flagsToUnset, const
}
}
void TileStorage::select(const size_t *indices, size_t n)
{
changeFlags(TILEFLAG_SELECTED, 0, indices, n);
}
size_t TileStorage::cloneSome(const TileEffectStorage& effstore, const size_t* indices, size_t n)
{
const size_t ret = tiles.size(); // new starting index of clone tiles

View file

@ -239,6 +239,7 @@ public:
void refreshAll(); // call this after changing properties or moving to front/back
void destroyAll();
void select(const size_t *indices, size_t n);
void clearSelection();
struct Sizes

View file

@ -172,6 +172,8 @@ void TileRender::onRender(const RenderState& rs) const
lastTexId = 0;
prevEff = ((TileEffectData*)NULL)+1;
rs.gpu.setBlend(BLEND_DEFAULT);
if(grid && RenderObject::renderCollisionShape)
{
grid->renderDebugPoints(rs);