Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions browedit/HotkeyActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <browedit/util/Util.h>
#include <GLFW/glfw3.h>

extern bool previewWall; //move this
extern bool dropperEnabled; //move this


Expand Down Expand Up @@ -144,7 +143,7 @@ void BrowEdit::registerActions()
HotkeyRegistry::registerAction(HotkeyAction::WallEdit_AddWall, [this]() { activeMapView->map->wallAddSelected(this); }, hasActiveMapViewWallMode);
HotkeyRegistry::registerAction(HotkeyAction::WallEdit_RemoveWall, [this]() { activeMapView->map->wallRemoveSelected(this); }, hasActiveMapViewWallMode);
HotkeyRegistry::registerAction(HotkeyAction::WallEdit_ReApply, [this]() { activeMapView->map->wallReApplySelected(this); }, hasActiveMapViewWallMode);
HotkeyRegistry::registerAction(HotkeyAction::WallEdit_Preview, [this]() { previewWall = !previewWall; }, hasActiveMapViewWallMode);
HotkeyRegistry::registerAction(HotkeyAction::WallEdit_Preview, [this]() { activeMapView->wallPreview = !activeMapView->wallPreview; }, hasActiveMapViewWallMode);
HotkeyRegistry::registerAction(HotkeyAction::WallEdit_OffsetLower, [this]() { activeMapView->wallOffset = glm::max(1, activeMapView->wallOffset - 1); }, hasActiveMapViewWallMode);
HotkeyRegistry::registerAction(HotkeyAction::WallEdit_OffsetRaise, [this]() { activeMapView->wallOffset++; }, hasActiveMapViewWallMode);
HotkeyRegistry::registerAction(HotkeyAction::WallEdit_SizeLower, [this]() { activeMapView->wallWidth = glm::max(1, activeMapView->wallWidth - 1); }, hasActiveMapViewWallMode);
Expand Down
11 changes: 5 additions & 6 deletions browedit/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,6 @@ void WallCalculation::prepare(BrowEdit* browEdit)
uvStart = uv1 + browEdit->activeMapView->textureEditUv1.x * (uv2 - uv1) + browEdit->activeMapView->textureEditUv1.y * (uv3 - uv1);
}

extern std::vector<glm::ivec3> selectedWalls; //ewwww
void Map::wallAddSelected(BrowEdit* browEdit)
{
auto gnd = rootNode->getComponent<Gnd>();
Expand All @@ -984,7 +983,7 @@ void Map::wallAddSelected(BrowEdit* browEdit)
auto ga = new GroupAction();
int id = (int)gnd->tiles.size();

for (const auto& w : selectedWalls)
for (const auto& w : wallSelection)
{
auto cube = gnd->cubes[w.x][w.y];

Expand Down Expand Up @@ -1023,7 +1022,7 @@ void Map::wallReApplySelected(BrowEdit* browEdit)
auto ga = new GroupAction();
int id = (int)gnd->tiles.size();

for (const auto& w : selectedWalls)
for (const auto& w : wallSelection)
{
auto cube = gnd->cubes[w.x][w.y];

Expand Down Expand Up @@ -1057,7 +1056,7 @@ void Map::wallRemoveSelected(BrowEdit* browEdit)
auto gnd = rootNode->getComponent<Gnd>();
auto gndRenderer = rootNode->getComponent<GndRenderer>();
auto ga = new GroupAction();
for (const auto& w : selectedWalls)
for (const auto& w : wallSelection)
{
auto cube = gnd->cubes[w.x][w.y];
if (w.z == 1 && cube->tileSide != -1)
Expand All @@ -1076,7 +1075,7 @@ void Map::wallFlipSelectedTextureHorizontal(BrowEdit* browEdit)
auto gndRenderer = rootNode->getComponent<GndRenderer>();
auto ga = new GroupAction();

for (const auto& w : selectedWalls)
for (const auto& w : wallSelection)
{
auto cube = gnd->cubes[w.x][w.y];
Gnd::Tile* tile = nullptr;
Expand All @@ -1101,7 +1100,7 @@ void Map::wallFlipSelectedTextureVertical(BrowEdit* browEdit)
auto gndRenderer = rootNode->getComponent<GndRenderer>();
auto ga = new GroupAction();

for (const auto& w : selectedWalls)
for (const auto& w : wallSelection)
{
auto cube = gnd->cubes[w.x][w.y];
Gnd::Tile* tile = nullptr;
Expand Down
9 changes: 8 additions & 1 deletion browedit/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ class Map
std::vector<glm::ivec2> tileSelection;
std::vector<glm::ivec2> gatSelection;
std::vector<glm::ivec2> waterSelection;
std::vector<glm::ivec3> wallSelection;

struct {
glm::ivec2 selectionStart;
int selectionSide;
bool selecting = false;
bool panning = false;
} wallSelect;

bool changed = false;
bool mapHasNoGnd = false; // This variable is meant to prevent the console from being filled with the "map has no gnd" error

std::vector<glm::ivec2> getSelectionAroundTiles();


Node* findAndBuildNode(const std::string &path, Node* root = nullptr);

Map(const std::string& name, BrowEdit* browEdit);
Expand Down
49 changes: 43 additions & 6 deletions browedit/MapView.Heightmode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <browedit/math/Polygon.h>
#include <browedit/actions/GroupAction.h>
#include <browedit/actions/TileSelectAction.h>
#include <browedit/actions/TileNewAction.h>
#include <browedit/actions/CubeHeightChangeAction.h>
#include <browedit/actions/CubeTileChangeAction.h>
#include <browedit/actions/NewObjectAction.h>
Expand Down Expand Up @@ -712,36 +713,72 @@ void MapView::postRenderHeightMode(BrowEdit* browEdit)

if (browEdit->windowData.heightEdit.edgeMode == 3 && gnd->tiles.size() > 0) // add walls
{
auto ga = new GroupAction();
int id = (int)gnd->tiles.size();

auto addTile = [&](const glm::ivec2& w, int index)
{
auto cube = gnd->cubes[w.x][w.y];
auto t = new Gnd::Tile();

t->color = glm::ivec4(255, 255, 255, 255);
t->textureIndex = 0;
t->lightmapIndex = 0;

t->v1 = glm::vec2(0.00, 1);
t->v2 = glm::vec2(0.25, 1);
t->v3 = glm::vec2(0.00, 0);
t->v4 = glm::vec2(0.25, 0);

switch (index) {
case 0:
ga->addAction(new CubeTileChangeAction(w, cube, id, cube->tileFront, cube->tileSide));
break;
case 1:
ga->addAction(new CubeTileChangeAction(w, cube, cube->tileUp, id, cube->tileSide));
break;
case 2:
ga->addAction(new CubeTileChangeAction(w, cube, cube->tileUp, cube->tileFront, id));
break;
}

cube->tileIds[index] = id++;
ga->addAction(new TileNewAction(t));
};

for (auto t : map->tileSelection)
{
//h1 bottomleft
//h2 bottomright
//h3 topleft
//h4 topright
if (t.x > 0 && !isTileSelected(t.x - 1, t.y) && (
gnd->cubes[t.x][t.y]->h1 != gnd->cubes[t.x - 1][t.y]->h2 ||
gnd->cubes[t.x][t.y]->h1 != gnd->cubes[t.x - 1][t.y]->h2 ||
gnd->cubes[t.x][t.y]->h3 != gnd->cubes[t.x - 1][t.y]->h4) &&
gnd->cubes[t.x - 1][t.y]->tileSide == -1)
gnd->cubes[t.x - 1][t.y]->tileSide = 0;

addTile(glm::ivec2(t.x - 1, t.y), 2);
if (t.x < gnd->width-1 && !isTileSelected(t.x + 1, t.y) && (
gnd->cubes[t.x][t.y]->h2 != gnd->cubes[t.x + 1][t.y]->h1 ||
gnd->cubes[t.x][t.y]->h4 != gnd->cubes[t.x + 1][t.y]->h3) &&
gnd->cubes[t.x][t.y]->tileSide == -1)
gnd->cubes[t.x][t.y]->tileSide = 0;
addTile(t, 2);

if (t.y > 0 && !isTileSelected(t.x, t.y - 1) && (
gnd->cubes[t.x][t.y]->h1 != gnd->cubes[t.x][t.y - 1]->h3 ||
gnd->cubes[t.x][t.y]->h2 != gnd->cubes[t.x][t.y - 1]->h4) &&
gnd->cubes[t.x][t.y - 1]->tileFront == -1)
gnd->cubes[t.x][t.y - 1]->tileFront = 0;
addTile(glm::ivec2(t.x, t.y - 1), 1);

if (t.y < gnd->height-1 && !isTileSelected(t.x, t.y + 1) && (
gnd->cubes[t.x][t.y]->h3 != gnd->cubes[t.x][t.y + 1]->h1 ||
gnd->cubes[t.x][t.y]->h4 != gnd->cubes[t.x][t.y + 1]->h2) &&
gnd->cubes[t.x][t.y]->tileFront == -1)
gnd->cubes[t.x][t.y]->tileFront = 0;
addTile(t, 1);
}

if (!ga->isEmpty()) {
map->doAction(ga, browEdit);
}
}

Expand Down
5 changes: 5 additions & 0 deletions browedit/MapView.Texturemode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ void MapView::postRenderTextureMode(BrowEdit* browEdit)
{
auto cube = gnd->cubes[tile.x][tile.y];

if (textureBrushWidth == 0)
textureBrushWidth = 1;
if (textureBrushHeight == 0)
textureBrushHeight = 1;

glm::vec2 v1 = uvStart + xInc * (float)((tile.x + browEdit->textureFillOffset.x)%textureBrushWidth) + yInc * (float)((tile.y + browEdit->textureFillOffset.y)%textureBrushHeight);
glm::vec2 v2 = v1 + xInc;
glm::vec2 v3 = v1 + yInc;
Expand Down
Loading
Loading