mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 20:11:50 +00:00
Merge branch 'main' into environments
This commit is contained in:
commit
a557068b90
54 changed files with 780 additions and 539 deletions
|
|
@ -136,18 +136,18 @@ void Mesh::addBox(
|
|||
const bool enabledSides[6],
|
||||
const glm::mat4& transform
|
||||
) {
|
||||
if (enabledSides[0]) // north
|
||||
addPlane(pos+Z*size, X*size, Y*size, Z, uvs[0], transform);
|
||||
if (enabledSides[1]) // south
|
||||
addPlane(pos-Z*size, -X*size, Y*size, -Z, uvs[1], transform);
|
||||
if (enabledSides[2]) // top
|
||||
addPlane(pos+Y*size, X*size, -Z*size, Y, uvs[2] * glm::vec2(-1), transform);
|
||||
if (enabledSides[3]) // bottom
|
||||
addPlane(pos-Y*size, X*size, Z*size, -Y, uvs[3] * glm::vec2(-1, 1), transform);
|
||||
if (enabledSides[4]) // west
|
||||
addPlane(pos+X*size, -Z*size, Y*size, X, uvs[4], transform);
|
||||
if (enabledSides[5]) // east
|
||||
addPlane(pos-X*size, Z*size, Y*size, -X, uvs[5] * glm::vec2(-1, 1), transform);
|
||||
if (enabledSides[0]) // east
|
||||
addPlane(pos-X*size, Z*size, Y*size, -X, uvs[0], transform);
|
||||
if (enabledSides[1]) // west
|
||||
addPlane(pos+X*size, -Z*size, Y*size, X, uvs[1] * glm::vec2(-1, 1), transform);
|
||||
if (enabledSides[2]) // bottom
|
||||
addPlane(pos-Y*size, X*size, Z*size, -Y, uvs[2], transform);
|
||||
if (enabledSides[3]) // top
|
||||
addPlane(pos+Y*size, X*size, -Z*size, Y, uvs[3] * glm::vec2(-1, 1), transform);
|
||||
if (enabledSides[4]) // south
|
||||
addPlane(pos-Z*size, -X*size, Y*size, -Z, uvs[4], transform);
|
||||
if (enabledSides[5]) // north
|
||||
addPlane(pos+Z*size, X*size, Y*size, Z, uvs[5] * glm::vec2(-1, 1), transform);
|
||||
}
|
||||
|
||||
void Mesh::scale(const glm::vec3& size) {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ Mesh<VertexStructure>::~Mesh() {
|
|||
MeshStats::meshesCount--;
|
||||
glDeleteVertexArrays(1, &vao);
|
||||
glDeleteBuffers(1, &vbo);
|
||||
for (int i = ibos.size() - 1; i >= 0; i--) {
|
||||
for (int i = 0; i < ibos.size(); i++) {
|
||||
glDeleteBuffers(1, &ibos[i].ibo);
|
||||
}
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ void Mesh<VertexStructure>::reload(
|
|||
glBufferData(GL_ARRAY_BUFFER, 0, {}, GL_STREAM_DRAW);
|
||||
}
|
||||
|
||||
for (int i = indices.size(); i < ibos.size(); i++) {
|
||||
for (int i = 0; i < ibos.size(); i++) {
|
||||
glDeleteBuffers(1, &ibos[i].ibo);
|
||||
}
|
||||
ibos.clear();
|
||||
|
|
|
|||
|
|
@ -271,8 +271,7 @@ void Decorator::updateBlockEmitters(const Camera& camera) {
|
|||
remove = true;
|
||||
}
|
||||
} else {
|
||||
iter = blockEmitters.erase(iter);
|
||||
continue;
|
||||
remove = true;
|
||||
}
|
||||
if (util::distance2(iter->first, glm::ivec3(camera.position)) >
|
||||
UPDATE_AREA_DIAMETER * UPDATE_AREA_DIAMETER) {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ static inline void update_particle(
|
|||
|
||||
void ParticlesRenderer::updateParticles(float delta) {
|
||||
std::vector<const Texture*> unusedTextures;
|
||||
visibleParticles = 0;
|
||||
|
||||
for (auto& [texture, vec] : particles) {
|
||||
if (vec.empty()) {
|
||||
|
|
@ -186,7 +187,6 @@ void ParticlesRenderer::update(const Camera& camera, float delta) {
|
|||
|
||||
void ParticlesRenderer::render(const Camera& camera) {
|
||||
aliveEmitters = emitters.size();
|
||||
visibleParticles = 0;
|
||||
|
||||
bool backlight = settings.backlight.get();
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ FullCheckBox::FullCheckBox(
|
|||
|
||||
add(checkbox);
|
||||
|
||||
auto& checkboxActions = actions;
|
||||
label->setMargin(glm::vec4(5.f, 5.f, 0.f, 0.f));
|
||||
label->listenAction(UIAction::CLICK, [&checkboxActions](auto& gui) {
|
||||
checkboxActions.notify(UIAction::CLICK, gui);
|
||||
});
|
||||
add(label);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,12 +83,12 @@ static util::TextureRegion determine_texture_region(
|
|||
const Assets& assets, const std::string& texture
|
||||
) {
|
||||
static std::array<std::string, 6> faces {
|
||||
"blocks:dbg_north",
|
||||
"blocks:dbg_south",
|
||||
"blocks:dbg_top",
|
||||
"blocks:dbg_bottom",
|
||||
"blocks:dbg_west",
|
||||
"blocks:dbg_east",
|
||||
"blocks:dbg_west",
|
||||
"blocks:dbg_bottom",
|
||||
"blocks:dbg_top",
|
||||
"blocks:dbg_south",
|
||||
"blocks:dbg_north",
|
||||
};
|
||||
|
||||
if (texture.length() < 2 || texture.at(0) != '$') {
|
||||
|
|
|
|||
|
|
@ -889,8 +889,8 @@ static std::shared_ptr<UINode> read_iframe(
|
|||
return iframe;
|
||||
}
|
||||
|
||||
UiXmlReader::UiXmlReader(gui::GUI& gui, scriptenv&& env)
|
||||
: gui(gui), env(std::move(env)) {
|
||||
UiXmlReader::UiXmlReader(gui::GUI& gui, const scriptenv& env)
|
||||
: gui(gui), env(env) {
|
||||
contextStack.emplace("");
|
||||
add("image", read_image);
|
||||
add("canvas", read_canvas);
|
||||
|
|
@ -922,8 +922,7 @@ void UiXmlReader::addIgnore(const std::string& tag) {
|
|||
ignored.insert(tag);
|
||||
}
|
||||
|
||||
std::shared_ptr<UINode> UiXmlReader::readUINode(const xml::xmlelement& element
|
||||
) {
|
||||
std::shared_ptr<UINode> UiXmlReader::readUINode(const xml::xmlelement& element) {
|
||||
if (element.has("if")) {
|
||||
const auto& cond = element.attr("if").getText();
|
||||
if (cond.empty() || cond == "false" || cond == "nil") return nullptr;
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ namespace gui {
|
|||
std::unordered_set<std::string> ignored;
|
||||
std::stack<std::string> contextStack;
|
||||
std::string filename;
|
||||
scriptenv env;
|
||||
const scriptenv& env;
|
||||
public:
|
||||
UiXmlReader(gui::GUI& gui, scriptenv&& env);
|
||||
UiXmlReader(gui::GUI& gui, const scriptenv& env);
|
||||
|
||||
void add(const std::string& tag, uinode_reader reader);
|
||||
bool hasReader(const std::string& tag) const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue