Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
5d791b3cec
@ -12,6 +12,18 @@ player.set_pos(playerid: int, x: number, y: number, z: number)
|
|||||||
|
|
||||||
Set player position
|
Set player position
|
||||||
|
|
||||||
|
``` python
|
||||||
|
player.get_vel(playerid: int) -> number, number, number
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns the x, y, z linear velocity of the player
|
||||||
|
|
||||||
|
``` python
|
||||||
|
player.set_vel(playerid: int, x: number, y: number, z: number)
|
||||||
|
```
|
||||||
|
|
||||||
|
Sets x, y, z player linear velocity
|
||||||
|
|
||||||
```python
|
```python
|
||||||
player.get_rot(playerid: int) -> number, number, number
|
player.get_rot(playerid: int) -> number, number, number
|
||||||
```
|
```
|
||||||
|
|||||||
@ -51,7 +51,7 @@ tsf:set_size(size: vec3)
|
|||||||
-- Returns the entity rotation
|
-- Returns the entity rotation
|
||||||
tsf:get_rot() -> mat4
|
tsf:get_rot() -> mat4
|
||||||
-- Sets entity rotation
|
-- Sets entity rotation
|
||||||
tsf:set_rot(size: mat4)
|
tsf:set_rot(rotation: mat4)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Rigidbody
|
### Rigidbody
|
||||||
|
|||||||
@ -12,6 +12,18 @@ player.set_pos(playerid: int, x: number, y: number, z: number)
|
|||||||
|
|
||||||
Устанавливает x, y, z координаты игрока
|
Устанавливает x, y, z координаты игрока
|
||||||
|
|
||||||
|
```python
|
||||||
|
player.get_vel(playerid: int) -> number, number, number
|
||||||
|
```
|
||||||
|
|
||||||
|
Возвращает x, y, z линейной скорости игрока
|
||||||
|
|
||||||
|
```python
|
||||||
|
player.set_vel(playerid: int, x: number, y: number, z: number)
|
||||||
|
```
|
||||||
|
|
||||||
|
Устанавливает x, y, z линейной скорости игрока
|
||||||
|
|
||||||
```python
|
```python
|
||||||
player.get_rot(playerid: int) -> number, number, number
|
player.get_rot(playerid: int) -> number, number, number
|
||||||
```
|
```
|
||||||
|
|||||||
@ -51,7 +51,7 @@ tsf:set_size(size: vec3)
|
|||||||
-- Возвращает вращение сущности
|
-- Возвращает вращение сущности
|
||||||
tsf:get_rot() -> mat4
|
tsf:get_rot() -> mat4
|
||||||
-- Устанавливает вращение сущности
|
-- Устанавливает вращение сущности
|
||||||
tsf:set_rot(size: mat4)
|
tsf:set_rot(rotation: mat4)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Rigidbody
|
### Rigidbody
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"id": "base",
|
"id": "base",
|
||||||
"title": "Base",
|
"title": "Base",
|
||||||
"version": "0.22",
|
"version": "0.23",
|
||||||
"description": "basic content package"
|
"description": "basic content package"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
inline constexpr int ENGINE_VERSION_MAJOR = 0;
|
inline constexpr int ENGINE_VERSION_MAJOR = 0;
|
||||||
inline constexpr int ENGINE_VERSION_MINOR = 22;
|
inline constexpr int ENGINE_VERSION_MINOR = 23;
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
inline constexpr bool ENGINE_DEBUG_BUILD = false;
|
inline constexpr bool ENGINE_DEBUG_BUILD = false;
|
||||||
@ -15,7 +15,7 @@ inline constexpr bool ENGINE_DEBUG_BUILD = false;
|
|||||||
inline constexpr bool ENGINE_DEBUG_BUILD = true;
|
inline constexpr bool ENGINE_DEBUG_BUILD = true;
|
||||||
#endif // NDEBUG
|
#endif // NDEBUG
|
||||||
|
|
||||||
inline const std::string ENGINE_VERSION_STRING = "0.22";
|
inline const std::string ENGINE_VERSION_STRING = "0.23";
|
||||||
|
|
||||||
inline constexpr blockid_t BLOCK_AIR = 0;
|
inline constexpr blockid_t BLOCK_AIR = 0;
|
||||||
inline constexpr itemid_t ITEM_EMPTY = 0;
|
inline constexpr itemid_t ITEM_EMPTY = 0;
|
||||||
|
|||||||
@ -113,6 +113,10 @@ bool WorldRenderer::drawChunk(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WorldRenderer::drawChunks(Chunks* chunks, Camera* camera, Shader* shader) {
|
void WorldRenderer::drawChunks(Chunks* chunks, Camera* camera, Shader* shader) {
|
||||||
|
auto assets = engine->getAssets();
|
||||||
|
auto atlas = assets->get<Atlas>("blocks");
|
||||||
|
|
||||||
|
atlas->getTexture()->bind();
|
||||||
renderer->update();
|
renderer->update();
|
||||||
|
|
||||||
// [warning] this whole method is not thread-safe for chunks
|
// [warning] this whole method is not thread-safe for chunks
|
||||||
@ -122,8 +126,8 @@ void WorldRenderer::drawChunks(Chunks* chunks, Camera* camera, Shader* shader) {
|
|||||||
if (chunks->chunks[i] == nullptr) continue;
|
if (chunks->chunks[i] == nullptr) continue;
|
||||||
indices.emplace_back(i);
|
indices.emplace_back(i);
|
||||||
}
|
}
|
||||||
float px = camera->position.x / (float)CHUNK_W - 0.5f;
|
float px = camera->position.x / static_cast<float>(CHUNK_W) - 0.5f;
|
||||||
float pz = camera->position.z / (float)CHUNK_D - 0.5f;
|
float pz = camera->position.z / static_cast<float>(CHUNK_D) - 0.5f;
|
||||||
std::sort(indices.begin(), indices.end(), [chunks, px, pz](auto i, auto j) {
|
std::sort(indices.begin(), indices.end(), [chunks, px, pz](auto i, auto j) {
|
||||||
const auto a = chunks->chunks[i].get();
|
const auto a = chunks->chunks[i].get();
|
||||||
const auto b = chunks->chunks[j].get();
|
const auto b = chunks->chunks[j].get();
|
||||||
@ -186,21 +190,13 @@ void WorldRenderer::renderLevel(
|
|||||||
bool pause
|
bool pause
|
||||||
) {
|
) {
|
||||||
auto assets = engine->getAssets();
|
auto assets = engine->getAssets();
|
||||||
auto atlas = assets->get<Atlas>("blocks");
|
|
||||||
|
|
||||||
bool culling = engine->getSettings().graphics.frustumCulling.get();
|
bool culling = engine->getSettings().graphics.frustumCulling.get();
|
||||||
float fogFactor = 15.0f / ((float)settings.chunks.loadDistance.get() - 2);
|
float fogFactor = 15.0f / ((float)settings.chunks.loadDistance.get() - 2);
|
||||||
|
|
||||||
auto shader = assets->get<Shader>("main");
|
|
||||||
setupWorldShader(shader, camera, settings, fogFactor);
|
|
||||||
|
|
||||||
skybox->bind();
|
|
||||||
atlas->getTexture()->bind();
|
|
||||||
|
|
||||||
drawChunks(level->chunks.get(), camera, shader);
|
|
||||||
|
|
||||||
auto entityShader = assets->get<Shader>("entity");
|
auto entityShader = assets->get<Shader>("entity");
|
||||||
setupWorldShader(entityShader, camera, settings, fogFactor);
|
setupWorldShader(entityShader, camera, settings, fogFactor);
|
||||||
|
skybox->bind();
|
||||||
|
|
||||||
level->entities->render(
|
level->entities->render(
|
||||||
assets,
|
assets,
|
||||||
@ -209,11 +205,16 @@ void WorldRenderer::renderLevel(
|
|||||||
delta,
|
delta,
|
||||||
pause
|
pause
|
||||||
);
|
);
|
||||||
|
modelBatch->render();
|
||||||
|
|
||||||
|
auto shader = assets->get<Shader>("main");
|
||||||
|
setupWorldShader(shader, camera, settings, fogFactor);
|
||||||
|
|
||||||
|
drawChunks(level->chunks.get(), camera, shader);
|
||||||
|
|
||||||
if (!pause) {
|
if (!pause) {
|
||||||
scripting::on_frontend_render();
|
scripting::on_frontend_render();
|
||||||
}
|
}
|
||||||
modelBatch->render();
|
|
||||||
|
|
||||||
skybox->unbind();
|
skybox->unbind();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include <voxels/voxel.hpp>
|
#include <voxels/voxel.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
#define GLM_ENABLE_EXPERIMENTAL
|
#define GLM_ENABLE_EXPERIMENTAL
|
||||||
#include <glm/gtx/norm.hpp>
|
#include <glm/gtx/norm.hpp>
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,7 @@ struct CameraSettings {
|
|||||||
struct GraphicsSettings {
|
struct GraphicsSettings {
|
||||||
/// @brief Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance.
|
/// @brief Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance.
|
||||||
/// 1.0 is linear, 2.0 is quadratic
|
/// 1.0 is linear, 2.0 is quadratic
|
||||||
NumberSetting fogCurve {1.6f, 1.0f, 6.0f};
|
NumberSetting fogCurve {1.0f, 1.0f, 6.0f};
|
||||||
/// @brief Lighting gamma
|
/// @brief Lighting gamma
|
||||||
NumberSetting gamma {1.0f, 0.4f, 1.0f};
|
NumberSetting gamma {1.0f, 0.4f, 1.0f};
|
||||||
/// @brief Enable blocks backlight to prevent complete darkness
|
/// @brief Enable blocks backlight to prevent complete darkness
|
||||||
|
|||||||
@ -130,9 +130,12 @@ int Window::initialize(DisplaySettings* settings) {
|
|||||||
Window::width = settings->width.get();
|
Window::width = settings->width.get();
|
||||||
Window::height = settings->height.get();
|
Window::height = settings->height.get();
|
||||||
|
|
||||||
std::string title = "VoxelEngine-Cpp v" +
|
std::string title = "VoxelCore v" +
|
||||||
std::to_string(ENGINE_VERSION_MAJOR) + "." +
|
std::to_string(ENGINE_VERSION_MAJOR) + "." +
|
||||||
std::to_string(ENGINE_VERSION_MINOR);
|
std::to_string(ENGINE_VERSION_MINOR);
|
||||||
|
if (ENGINE_DEBUG_BUILD) {
|
||||||
|
title += " [debug]";
|
||||||
|
}
|
||||||
|
|
||||||
glfwSetErrorCallback(error_callback);
|
glfwSetErrorCallback(error_callback);
|
||||||
if (glfwInit() == GLFW_FALSE) {
|
if (glfwInit() == GLFW_FALSE) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user