@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
using namespace gui;
|
using namespace gui;
|
||||||
|
|
||||||
|
std::shared_ptr<gui::Button> generatorTypeButton;
|
||||||
|
|
||||||
namespace menus {
|
namespace menus {
|
||||||
std::string generatorID;
|
std::string generatorID;
|
||||||
}
|
}
|
||||||
@@ -32,7 +34,6 @@ inline uint64_t randU64() {
|
|||||||
((uint64_t)rand() << 56);
|
((uint64_t)rand() << 56);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline uint64_t str2seed(std::wstring seedstr) {
|
inline uint64_t str2seed(std::wstring seedstr) {
|
||||||
if (util::is_integer(seedstr)) {
|
if (util::is_integer(seedstr)) {
|
||||||
try {
|
try {
|
||||||
@@ -80,6 +81,7 @@ void menus::create_world_generators_panel(Engine* engine) {
|
|||||||
button->listenAction(
|
button->listenAction(
|
||||||
[=](GUI*) {
|
[=](GUI*) {
|
||||||
menus::generatorID = id;
|
menus::generatorID = id;
|
||||||
|
generatorTypeButton->setText(langs::get(L"World generator", L"world") + (L": ") + util::str2wstr_utf8(translate_generator_id(menus::generatorID)));
|
||||||
menu->back();
|
menu->back();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -106,7 +108,8 @@ void menus::create_new_world_panel(Engine* engine) {
|
|||||||
auto seedInput = std::make_shared<TextBox>(seedstr, glm::vec4(6.0f));
|
auto seedInput = std::make_shared<TextBox>(seedstr, glm::vec4(6.0f));
|
||||||
panel->add(seedInput);
|
panel->add(seedInput);
|
||||||
|
|
||||||
panel->add(guiutil::gotoButton(langs::get(L"World generator", L"world"), "world_generators", engine->getGUI()->getMenu()));
|
generatorTypeButton = guiutil::gotoButton(langs::get(L"World generator", L"world") + (L": ") + util::str2wstr_utf8(translate_generator_id(menus::generatorID)), "world_generators", engine->getGUI()->getMenu());
|
||||||
|
panel->add(generatorTypeButton);
|
||||||
|
|
||||||
panel->add(menus::create_button(L"Create World", glm::vec4(10), glm::vec4(1, 20, 1, 1),
|
panel->add(menus::create_button(L"Create World", glm::vec4(10), glm::vec4(1, 20, 1, 1),
|
||||||
[=](GUI*) {
|
[=](GUI*) {
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ void PlayerController::updateInteraction(){
|
|||||||
vox = chunks->get(x, y, z);
|
vox = chunks->get(x, y, z);
|
||||||
blockid_t chosenBlock = def->rt.id;
|
blockid_t chosenBlock = def->rt.id;
|
||||||
if (vox && (target = indices->getBlockDef(vox->id))->replaceable) {
|
if (vox && (target = indices->getBlockDef(vox->id))->replaceable) {
|
||||||
if (!level->physics->isBlockInside(x,y,z, player->hitbox.get())
|
if (!level->physics->isBlockInside(x,y,z,def,states, player->hitbox.get())
|
||||||
|| !def->obstacle){
|
|| !def->obstacle){
|
||||||
if (def->grounded && !chunks->isSolidBlock(x, y-1, z)) {
|
if (def->grounded && !chunks->isSolidBlock(x, y-1, z)) {
|
||||||
chosenBlock = 0;
|
chosenBlock = 0;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "../maths/aabb.h"
|
#include "../maths/aabb.h"
|
||||||
#include "../voxels/Block.h"
|
#include "../voxels/Block.h"
|
||||||
#include "../voxels/Chunks.h"
|
#include "../voxels/Chunks.h"
|
||||||
|
#include "../voxels/voxel.h"
|
||||||
|
|
||||||
const double E = 0.03;
|
const double E = 0.03;
|
||||||
const double MAX_FIX = 0.1;
|
const double MAX_FIX = 0.1;
|
||||||
@@ -218,3 +219,22 @@ bool PhysicsSolver::isBlockInside(int x, int y, int z, Hitbox* hitbox) {
|
|||||||
y >= floor(pos.y-half.y) && y <= floor(pos.y+half.y);
|
y >= floor(pos.y-half.y) && y <= floor(pos.y+half.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PhysicsSolver::isBlockInside(int x, int y, int z, Block* def, blockstate_t states, Hitbox* hitbox) {
|
||||||
|
vec3& pos = hitbox->position;
|
||||||
|
vec3& half = hitbox->halfsize;
|
||||||
|
voxel v;
|
||||||
|
v.states = states;
|
||||||
|
const auto& boxes = def->rotatable
|
||||||
|
? def->rt.hitboxes[v.rotation()]
|
||||||
|
: def->hitboxes;
|
||||||
|
for (const auto& block_hitbox : boxes) {
|
||||||
|
vec3 min = block_hitbox.min();
|
||||||
|
vec3 max = block_hitbox.max();
|
||||||
|
// 0.00001 - inaccuracy
|
||||||
|
if (min.x < pos.x+half.x-x-0.00001 && max.x > pos.x-half.x-x+0.00001 &&
|
||||||
|
min.z < pos.z+half.z-z-0.00001 && max.z > pos.z-half.z-z+0.00001 &&
|
||||||
|
min.y < pos.y+half.y-y-0.00001 && max.y > pos.y-half.y-y+0.00001)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
|
#include "../voxels/Block.h"
|
||||||
|
|
||||||
class Hitbox;
|
class Hitbox;
|
||||||
class Chunks;
|
class Chunks;
|
||||||
@@ -26,6 +27,7 @@ public:
|
|||||||
const glm::vec3 half,
|
const glm::vec3 half,
|
||||||
float stepHeight);
|
float stepHeight);
|
||||||
bool isBlockInside(int x, int y, int z, Hitbox* hitbox);
|
bool isBlockInside(int x, int y, int z, Hitbox* hitbox);
|
||||||
|
bool isBlockInside(int x, int y, int z, Block* def, blockstate_t states, Hitbox* hitbox);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PHYSICS_PHYSICSSOLVER_H_ */
|
#endif /* PHYSICS_PHYSICSSOLVER_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user