Merge branch 'dev' into pathfinding

This commit is contained in:
MihailRis
2025-08-19 19:47:10 +03:00
57 changed files with 818 additions and 207 deletions
+9 -1
View File
@@ -126,7 +126,15 @@ void Batch3D::sprite(
float scale = 1.0f / static_cast<float>(atlasRes);
float u = (index % atlasRes) * scale;
float v = 1.0f - ((index / atlasRes) * scale) - scale;
sprite(pos, up, right, w, h, UVRegion(u, v, u+scale, v+scale), tint);
sprite(
pos + right * w + up * h, // revert centering
up,
right,
w,
h,
UVRegion(u, v, u + scale, v + scale),
tint
);
}
void Batch3D::sprite(
+3
View File
@@ -171,6 +171,9 @@ const Mesh<ChunkVertex>* ChunksRenderer::retrieveChunk(
if (mesh == nullptr) {
return nullptr;
}
if (chunk->flags.dirtyHeights) {
chunk->updateHeights();
}
if (culling) {
glm::vec3 min(chunk->x * CHUNK_W, chunk->bottom, chunk->z * CHUNK_D);
glm::vec3 max(
+6 -2
View File
@@ -51,6 +51,7 @@ void TextsRenderer::renderNote(
glm::vec3 yvec = note.getAxisY();
int width = font.calcWidth(text, text.length());
int height = font.getLineHeight();
if (preset.displayMode == NoteDisplayMode::Y_FREE_BILLBOARD ||
preset.displayMode == NoteDisplayMode::XY_FREE_BILLBOARD) {
xvec = camera.position - pos;
@@ -96,8 +97,11 @@ void TextsRenderer::renderNote(
pos = screenPos / screenPos.w;
}
} else if (!frustum.isBoxVisible(pos - xvec * (width * 0.5f * preset.scale),
pos + xvec * (width * 0.5f * preset.scale))) {
} else if (!frustum.isBoxVisible(
pos - xvec * (width * 0.5f) * preset.scale,
pos + xvec * (width * 0.5f) * preset.scale +
yvec * static_cast<float>(height) * preset.scale
)) {
return;
}
auto color = preset.color;
+10 -9
View File
@@ -56,6 +56,13 @@ GUI::GUI(Engine& engine)
store("tooltip", tooltip);
store("tooltip.label", UINode::find(tooltip, "tooltip.label"));
container->add(tooltip);
rootDocument = std::make_unique<UiDocument>(
"core:root",
uidocscript {},
std::dynamic_pointer_cast<gui::UINode>(container),
nullptr
);
}
GUI::~GUI() = default;
@@ -74,15 +81,8 @@ std::shared_ptr<Menu> GUI::getMenu() {
}
void GUI::onAssetsLoad(Assets* assets) {
assets->store(
std::make_unique<UiDocument>(
"core:root",
uidocscript {},
std::dynamic_pointer_cast<gui::UINode>(container),
nullptr
),
"core:root"
);
rootDocument->rebuildIndices();
assets->store(rootDocument, "core:root");
}
void GUI::resetTooltip() {
@@ -302,6 +302,7 @@ bool GUI::isFocusCaught() const {
}
void GUI::add(std::shared_ptr<UINode> node) {
UINode::getIndices(node, rootDocument->getMapWriteable());
container->add(std::move(node));
}
+3
View File
@@ -22,6 +22,8 @@ namespace devtools {
class Editor;
}
class UiDocument;
/*
Some info about padding and margin.
Padding is element inner space, margin is outer
@@ -70,6 +72,7 @@ namespace gui {
std::shared_ptr<UINode> pressed;
std::shared_ptr<UINode> focus;
std::shared_ptr<UINode> tooltip;
std::shared_ptr<UiDocument> rootDocument;
std::unordered_map<std::string, std::shared_ptr<UINode>> storage;
std::unique_ptr<Camera> uicamera;
+80 -1
View File
@@ -810,6 +810,85 @@ void TextBox::stepDefaultUp(bool shiftPressed, bool breakSelection) {
}
}
static int calc_indent(int linestart, std::wstring_view input) {
int indent = 0;
while (linestart + indent < input.length() &&
input[linestart + indent] == L' ')
indent++;
return indent;
}
void TextBox::onTab(bool shiftPressed) {
std::wstring indentStr = L" ";
if (!shiftPressed && getSelectionLength() == 0) {
paste(indentStr);
return;
}
if (getSelectionLength() == 0) {
selectionStart = caret;
selectionEnd = caret;
selectionOrigin = caret;
}
int lineA = getLineAt(selectionStart);
int lineB = getLineAt(selectionEnd);
int caretLine = getLineAt(caret);
size_t lineAStart = getLinePos(lineA);
size_t lineBStart = getLinePos(lineB);
size_t caretLineStart = getLinePos(caretLine);
size_t caretIndent = calc_indent(caretLineStart, input);
size_t aIndent = calc_indent(lineAStart, input);
size_t bIndent = calc_indent(lineBStart, input);
int lastSelectionStart = selectionStart;
int lastSelectionEnd = selectionEnd;
size_t lastCaret = caret;
auto combination = history->beginCombination();
resetSelection();
for (int line = lineA; line <= lineB; line++) {
size_t linestart = getLinePos(line);
int indent = calc_indent(linestart, input);
if (shiftPressed) {
if (indent >= indentStr.length()) {
setCaret(linestart);
select(linestart, linestart + indentStr.length());
eraseSelected();
}
} else {
setCaret(linestart);
paste(indentStr);
}
refreshLabel(); // todo: replace with textbox cache
}
int linestart = getLinePos(caretLine);
int linestartA = getLinePos(lineA);
int linestartB = getLinePos(lineB);
int la = lastSelectionStart - lineAStart;
int lb = lastSelectionEnd - lineBStart;
if (shiftPressed) {
setCaret(lastCaret - caretLineStart + linestart - std::min<int>(caretIndent, indentStr.length()));
selectionStart = la + linestartA - std::min<int>(std::min<int>(la, aIndent), indentStr.length());
selectionEnd = lb + linestartB - std::min<int>(std::min<int>(lb, bIndent), indentStr.length());
} else {
setCaret(lastCaret - caretLineStart + linestart + indentStr.length());
selectionStart = la + linestartA + indentStr.length();
selectionEnd = lb + linestartB + indentStr.length();
}
if (selectionOrigin == lastSelectionStart) {
selectionOrigin = selectionStart;
} else {
selectionOrigin = selectionEnd;
}
historian->sync();
}
void TextBox::refreshSyntax() {
if (!syntax.empty()) {
const auto& processor = gui.getEditor().getSyntaxProcessor();
@@ -868,7 +947,7 @@ void TextBox::performEditingKeyboardEvents(Keycode key) {
}
}
} else if (key == Keycode::TAB) {
paste(L" ");
onTab(shiftPressed);
} else if (key == Keycode::LEFT) {
stepLeft(shiftPressed, breakSelection);
} else if (key == Keycode::RIGHT) {
+2
View File
@@ -71,6 +71,8 @@ namespace gui {
void stepDefaultDown(bool shiftPressed, bool breakSelection);
void stepDefaultUp(bool shiftPressed, bool breakSelection);
void onTab(bool shiftPressed);
size_t normalizeIndex(int index);
int calcIndexAt(int x, int y) const;