fix pipe rotation + test blocks

This commit is contained in:
A-lex-Ra 2023-12-13 21:33:55 +06:00
parent cb13b42960
commit ae10ca248d
12 changed files with 43 additions and 9 deletions

View File

@ -9,7 +9,7 @@ file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES}) add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES})
if(MSVC) if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4) target_compile_options(${PROJECT_NAME} PRIVATE /W4 /O2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /source-charset:UTF-8") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /source-charset:UTF-8")
else() else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -lstdc++fs target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -lstdc++fs

View File

@ -0,0 +1,16 @@
{
"texture-faces": [
"torch_side",
"torch_side",
"torch_bottom",
"torch_top",
"torch_side",
"torch_side"
],
"emission": [13, 13, 12],
"model": "aabb",
"hitbox": [0.3, 0.0, 0.7, 0.125, 0.5, 0.125],
"light-passing": true,
"obstacle": false,
"rotation": "pipe"
}

View File

@ -0,0 +1,16 @@
{
"texture-faces": [
"white",
"white",
"wallpaper_s",
"wallpaper_s",
"white",
"white"
],
"emission": [0, 0, 0],
"model": "aabb",
"hitbox": [0.0, 0.0, 0.0, 1.0, 0.01, 1.0],
"light-passing": true,
"obstacle": false,
"rotation": "pipe"
}

View File

@ -24,6 +24,8 @@
"blue_lamp", "blue_lamp",
"pane", "pane",
"pipe", "pipe",
"lightbulb" "lightbulb",
"torch",
"wallpaper"
] ]
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

View File

@ -117,12 +117,12 @@ void CameraControl::update(PlayerInput& input, float delta, Chunks* chunks) {
player->currentViewCamera = camera; player->currentViewCamera = camera;
} }
if (player->currentViewCamera == player->SPCamera) { if (player->currentViewCamera == player->SPCamera) {
player->SPCamera->position = chunks->rayCastToObstacle(camera->position, camera->front, 3.0f); player->SPCamera->position = chunks->rayCastToObstacle(camera->position, camera->front, 3.0f) - 0.2f*(camera->front);
player->SPCamera->dir = -camera->dir; player->SPCamera->dir = -camera->dir;
player->SPCamera->front = -camera->front; player->SPCamera->front = -camera->front;
} }
else if (player->currentViewCamera == player->TPCamera) { else if (player->currentViewCamera == player->TPCamera) {
player->TPCamera->position = chunks->rayCastToObstacle(camera->position, -camera->front, 3.0f); player->TPCamera->position = chunks->rayCastToObstacle(camera->position, -camera->front, 3.0f) + 0.2f * (camera->front);
player->TPCamera->dir = camera->dir; player->TPCamera->dir = camera->dir;
player->TPCamera->front = camera->front; player->TPCamera->front = camera->front;
} }

View File

@ -14,11 +14,11 @@ void CoordSystem::transform(AABB& aabb) {
aabb.b += fix2; aabb.b += fix2;
} }
const BlockRotProfile BlockRotProfile::PIPE {"pipe", { const BlockRotProfile BlockRotProfile::PIPE {"pipe", {//TODO consexpr or init-time fix and fix2 calculations
{ { 1, 0, 0 }, { 0, 0, 1 }, { 0,-1, 0 }, { 0, 0,-1 }, { 0, 1, 0 } }, // North { { 1, 0, 0 }, { 0, 0, 1 }, { 0, -1, 0 }, { 0, 0, -1 }, { 0, 1, 0 } }, // North
{ { 0, 1, 0 }, {-1, 0, 0 }, { 0, 0, 1 }, { 1, 0, 0 }, { 1, 0, 0 } }, // East { { 0, 0, 1 }, {-1, 0, 0 }, { 0, -1, 0 }, { 1, 0, -1 }, { 1, 1, 0 } }, // East
{ { 1, 0, 0 }, { 0, 0,-1 }, { 0, 1, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }, // South { { -1, 0, 0 }, { 0, 0,-1 }, { 0, -1, 0 }, { 1, 0, 0 }, { 1, 1, 1 } }, // South
{ { 0,-1, 0 }, { 1, 0, 0 }, { 0, 0, 1 }, { 0, 1, 0 }, { 0, 1, 0 } }, // West { { 0, 0, -1 }, { 1, 0, 0 }, { 0, -1, 0 }, { 0, 0, 0 }, { 0, 1, 1 } }, // West
{ { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }, // Up { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }, // Up
{ { 1, 0, 0 }, { 0,-1, 0 }, { 0, 0,-1 }, { 0, 1,-1 }, { 0, 1, 1 } }, // Down { { 1, 0, 0 }, { 0,-1, 0 }, { 0, 0,-1 }, { 0, 1,-1 }, { 0, 1, 1 } }, // Down
}}; }};