merge "main" into AlexRa:main
This commit is contained in:
commit
18cc2bf867
@ -1,27 +1,30 @@
|
|||||||
{
|
{
|
||||||
"blocks": [
|
"items": [
|
||||||
"dirt",
|
"bazalt_breaker"
|
||||||
"grass_block",
|
],
|
||||||
"lamp",
|
"blocks": [
|
||||||
"glass",
|
"dirt",
|
||||||
"planks",
|
"grass_block",
|
||||||
"wood",
|
"lamp",
|
||||||
"leaves",
|
"glass",
|
||||||
"stone",
|
"planks",
|
||||||
"water",
|
"wood",
|
||||||
"sand",
|
"leaves",
|
||||||
"bazalt",
|
"stone",
|
||||||
"grass",
|
"water",
|
||||||
"flower",
|
"sand",
|
||||||
"brick",
|
"bazalt",
|
||||||
"metal",
|
"grass",
|
||||||
"rust",
|
"flower",
|
||||||
"red_lamp",
|
"brick",
|
||||||
"green_lamp",
|
"metal",
|
||||||
"blue_lamp",
|
"rust",
|
||||||
"pane",
|
"red_lamp",
|
||||||
"pipe",
|
"green_lamp",
|
||||||
"lightbulb",
|
"blue_lamp",
|
||||||
"torch"
|
"pane",
|
||||||
]
|
"pipe",
|
||||||
|
"lightbulb",
|
||||||
|
"torch"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
4
res/content/base/items/bazalt_breaker.json
Normal file
4
res/content/base/items/bazalt_breaker.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"icon-type": "sprite",
|
||||||
|
"icon": "items:bazalt_breaker"
|
||||||
|
}
|
||||||
3
res/content/base/scripts/bazalt_breaker.lua
Normal file
3
res/content/base/scripts/bazalt_breaker.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function on_block_break_by(x, y, z, p)
|
||||||
|
set_block(x, y, z, 0, 0)
|
||||||
|
end
|
||||||
BIN
res/content/base/textures/items/bazalt_breaker.png
Normal file
BIN
res/content/base/textures/items/bazalt_breaker.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 672 B |
@ -14,6 +14,7 @@ menu.Quit=Выхад
|
|||||||
menu.Continue=Працягнуть
|
menu.Continue=Працягнуть
|
||||||
menu.Save and Quit to Menu=Захаваць і Выйсці ў Меню
|
menu.Save and Quit to Menu=Захаваць і Выйсці ў Меню
|
||||||
menu.missing-content=Адсутнічае Кантэнт!
|
menu.missing-content=Адсутнічае Кантэнт!
|
||||||
|
menu.Content Error=Памылка Кантэнту
|
||||||
menu.Controls=Кіраванне
|
menu.Controls=Кіраванне
|
||||||
menu.Back to Main Menu=Вярнуцца ў Меню
|
menu.Back to Main Menu=Вярнуцца ў Меню
|
||||||
menu.Settings=Налады
|
menu.Settings=Налады
|
||||||
|
|||||||
@ -260,7 +260,7 @@ void PlayerController::updateInteraction(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lclick) {
|
if (lclick) {
|
||||||
if (!input.shift && item->rt.funcsset.on_use_on_block) {
|
if (!input.shift && item->rt.funcsset.on_block_break_by) {
|
||||||
if (scripting::on_item_break_block(player, item, x, y, z))
|
if (scripting::on_item_break_block(player, item, x, y, z))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,10 +14,10 @@
|
|||||||
#include "../../lighting/Lighting.h"
|
#include "../../lighting/Lighting.h"
|
||||||
#include "../../logic/BlocksController.h"
|
#include "../../logic/BlocksController.h"
|
||||||
|
|
||||||
#if (LUA_VERSION_NUM < 503 && !defined(LUAJIT_VERSION))
|
#if (LUA_VERSION_NUM < 502)
|
||||||
static void luaL_openlib(lua_State* L, const char* name, const luaL_Reg* libfuncs) {
|
inline void luaL_openlib(lua_State* L, const char* name, const luaL_Reg* libfuncs, int nup) {
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
luaL_setfuncs(L, libfuncs, 0);
|
luaL_setfuncs(L, libfuncs, nup);
|
||||||
lua_setglobal(L, name);
|
lua_setglobal(L, name);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -36,7 +36,8 @@ void PhysicsSolver::step(
|
|||||||
|
|
||||||
vel += gravity * dt * gravityScale;
|
vel += gravity * dt * gravityScale;
|
||||||
if (collisions) {
|
if (collisions) {
|
||||||
colisionCalc(chunks, hitbox, vel, pos, half);
|
colisionCalc(chunks, hitbox, vel, pos, half,
|
||||||
|
(gravityScale > 0.0f) ? 0.5f : 0.0f);
|
||||||
}
|
}
|
||||||
vel.x *= glm::max(0.0f, 1.0f - dt * linear_damping);
|
vel.x *= glm::max(0.0f, 1.0f - dt * linear_damping);
|
||||||
vel.z *= glm::max(0.0f, 1.0f - dt * linear_damping);
|
vel.z *= glm::max(0.0f, 1.0f - dt * linear_damping);
|
||||||
@ -78,7 +79,8 @@ void PhysicsSolver::colisionCalc(
|
|||||||
Hitbox* hitbox,
|
Hitbox* hitbox,
|
||||||
vec3& vel,
|
vec3& vel,
|
||||||
vec3& pos,
|
vec3& pos,
|
||||||
const vec3 half)
|
const vec3 half,
|
||||||
|
float stepHeight)
|
||||||
{
|
{
|
||||||
// step size (smaller - more accurate, but slower)
|
// step size (smaller - more accurate, but slower)
|
||||||
float s = 2.0f/BLOCK_AABB_GRID;
|
float s = 2.0f/BLOCK_AABB_GRID;
|
||||||
@ -86,7 +88,7 @@ void PhysicsSolver::colisionCalc(
|
|||||||
const AABB* aabb;
|
const AABB* aabb;
|
||||||
|
|
||||||
if (vel.x < 0.0f){
|
if (vel.x < 0.0f){
|
||||||
for (float y = (pos.y-half.y+E); y <= (pos.y+half.y-E); y+=s){
|
for (float y = (pos.y-half.y+E+stepHeight); y <= (pos.y+half.y-E); y+=s){
|
||||||
for (float z = (pos.z-half.z+E); z <= (pos.z+half.z-E); z+=s){
|
for (float z = (pos.z-half.z+E); z <= (pos.z+half.z-E); z+=s){
|
||||||
float x = (pos.x-half.x-E);
|
float x = (pos.x-half.x-E);
|
||||||
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
||||||
@ -101,7 +103,7 @@ void PhysicsSolver::colisionCalc(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vel.x > 0.0f){
|
if (vel.x > 0.0f){
|
||||||
for (float y = (pos.y-half.y+E); y <= (pos.y+half.y-E); y+=s){
|
for (float y = (pos.y-half.y+E+stepHeight); y <= (pos.y+half.y-E); y+=s){
|
||||||
for (float z = (pos.z-half.z+E); z <= (pos.z+half.z-E); z+=s){
|
for (float z = (pos.z-half.z+E); z <= (pos.z+half.z-E); z+=s){
|
||||||
float x = (pos.x+half.x+E);
|
float x = (pos.x+half.x+E);
|
||||||
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
||||||
@ -117,7 +119,7 @@ void PhysicsSolver::colisionCalc(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vel.z < 0.0f){
|
if (vel.z < 0.0f){
|
||||||
for (float y = (pos.y-half.y+E); y <= (pos.y+half.y-E); y+=s){
|
for (float y = (pos.y-half.y+E+stepHeight); y <= (pos.y+half.y-E); y+=s){
|
||||||
for (float x = (pos.x-half.x+E); x <= (pos.x+half.x-E); x+=s){
|
for (float x = (pos.x-half.x+E); x <= (pos.x+half.x-E); x+=s){
|
||||||
float z = (pos.z-half.z-E);
|
float z = (pos.z-half.z-E);
|
||||||
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
||||||
@ -133,7 +135,7 @@ void PhysicsSolver::colisionCalc(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vel.z > 0.0f){
|
if (vel.z > 0.0f){
|
||||||
for (float y = (pos.y-half.y+E); y <= (pos.y+half.y-E); y+=s){
|
for (float y = (pos.y-half.y+E+stepHeight); y <= (pos.y+half.y-E); y+=s){
|
||||||
for (float x = (pos.x-half.x+E); x <= (pos.x+half.x-E); x+=s){
|
for (float x = (pos.x-half.x+E); x <= (pos.x+half.x-E); x+=s){
|
||||||
float z = (pos.z+half.z+E);
|
float z = (pos.z+half.z+E);
|
||||||
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
||||||
@ -164,6 +166,21 @@ void PhysicsSolver::colisionCalc(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (stepHeight > 0.0 && vel.y <= 0.0f){
|
||||||
|
for (float x = (pos.x-half.x+E); x <= (pos.x+half.x-E); x+=s){
|
||||||
|
for (float z = (pos.z-half.z+E); z <= (pos.z+half.z-E); z+=s){
|
||||||
|
float y = (pos.y-half.y+E);
|
||||||
|
if ((aabb = chunks->isObstacleAt(x,y,z))){
|
||||||
|
vel.y *= 0.0f;
|
||||||
|
float newy = floor(y) + aabb->max().y + half.y;
|
||||||
|
if (glm::abs(newy-pos.y) <= MAX_FIX+stepHeight) {
|
||||||
|
pos.y = newy;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (vel.y > 0.0f){
|
if (vel.y > 0.0f){
|
||||||
for (float x = (pos.x-half.x+E); x <= (pos.x+half.x-E); x+=s){
|
for (float x = (pos.x-half.x+E); x <= (pos.x+half.x-E); x+=s){
|
||||||
for (float z = (pos.z-half.z+E); z <= (pos.z+half.z-E); z+=s){
|
for (float z = (pos.z-half.z+E); z <= (pos.z+half.z-E); z+=s){
|
||||||
|
|||||||
@ -8,18 +8,24 @@ class Hitbox;
|
|||||||
class Chunks;
|
class Chunks;
|
||||||
|
|
||||||
class PhysicsSolver {
|
class PhysicsSolver {
|
||||||
glm::vec3 gravity;
|
glm::vec3 gravity;
|
||||||
public:
|
public:
|
||||||
PhysicsSolver(glm::vec3 gravity);
|
PhysicsSolver(glm::vec3 gravity);
|
||||||
void step(Chunks* chunks,
|
void step(Chunks* chunks,
|
||||||
Hitbox* hitbox,
|
Hitbox* hitbox,
|
||||||
float delta,
|
float delta,
|
||||||
uint substeps,
|
uint substeps,
|
||||||
bool shifting,
|
bool shifting,
|
||||||
float gravityScale,
|
float gravityScale,
|
||||||
bool collisions);
|
bool collisions);
|
||||||
void colisionCalc(Chunks* chunks, Hitbox* hitbox, glm::vec3& vel, glm::vec3& pos, const glm::vec3 half);
|
void colisionCalc(
|
||||||
bool isBlockInside(int x, int y, int z, Hitbox* hitbox);
|
Chunks* chunks,
|
||||||
|
Hitbox* hitbox,
|
||||||
|
glm::vec3& vel,
|
||||||
|
glm::vec3& pos,
|
||||||
|
const glm::vec3 half,
|
||||||
|
float stepHeight);
|
||||||
|
bool isBlockInside(int x, int y, int z, Hitbox* hitbox);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PHYSICS_PHYSICSSOLVER_H_ */
|
#endif /* PHYSICS_PHYSICSSOLVER_H_ */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user