![]() |
Botcraft 1.21.5
|
#include <WorldRenderer.hpp>
Public Member Functions | |
WorldRenderer (const unsigned int section_height_) | |
~WorldRenderer () | |
std::shared_ptr< Camera > | GetCamera () |
void | InitGL () |
void | UpdateViewMatrix () |
void | SetCameraProjection (const glm::mat4 &proj) |
void | UpdateFaces () |
void | UpdateChunk (const int x_, const int z_, const std::optional< Botcraft::Chunk > &chunk) |
void | UpdateEntity (const int id, const std::vector< Face > &faces) |
void | UseAtlasTextureGL () |
void | ClearFaces () |
void | SetPosOrientation (const double x_, const double y_, const double z_, const float yaw_, const float pitch_) |
void | RenderFaces (int *num_chunks_=nullptr, int *num_rendered_chunks_=nullptr, int *num_entities_=nullptr, int *num_rendered_entities_=nullptr, int *num_faces_=nullptr, int *num_rendered_faces_=nullptr) |
Private Member Functions | |
void | AddFace (const Position &block_pos, const Vector3< double > &offset, const Face &face_, const std::vector< std::string > &texture_identifiers_, const std::vector< unsigned int > &texture_multipliers_) |
const std::vector< unsigned int > | GetColorModifier (const int y, const Biome *biome, const Blockstate *blockstate, const std::vector< bool > &use_tintindex) const |
const float | DistanceToCamera (const Position &chunk) const |
Private Attributes | |
unsigned int | view_uniform_buffer |
unsigned int | section_height |
std::unordered_map< Position, std::shared_ptr< Chunk > > | chunks |
std::mutex | chunks_mutex |
std::unordered_map< Position, std::shared_ptr< TransparentChunk > > | transparent_chunks |
std::mutex | transparent_chunks_mutex |
bool | blocks_faces_should_be_updated |
std::unordered_map< int, std::shared_ptr< Entity > > | entities |
std::mutex | entities_mutex |
bool | entities_faces_should_be_updated |
std::shared_ptr< Camera > | camera |
std::mutex | m_mutex_camera |
unsigned int | atlas_texture |
Definition at line 38 of file WorldRenderer.hpp.
Botcraft::Renderer::WorldRenderer::WorldRenderer | ( | const unsigned int | section_height_ | ) |
Definition at line 21 of file WorldRenderer.cpp.
References blocks_faces_should_be_updated, camera, chunks, entities, entities_faces_should_be_updated, section_height, and transparent_chunks.
Botcraft::Renderer::WorldRenderer::~WorldRenderer | ( | ) |
Definition at line 36 of file WorldRenderer.cpp.
References atlas_texture, and camera.
|
private |
Definition at line 520 of file WorldRenderer.cpp.
References Botcraft::CHUNK_WIDTH, chunks, chunks_mutex, Botcraft::Renderer::Face::GetTransparencyData(), Botcraft::Renderer::Partial, section_height, transparent_chunks, transparent_chunks_mutex, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
Referenced by UpdateChunk().
void Botcraft::Renderer::WorldRenderer::ClearFaces | ( | ) |
Definition at line 311 of file WorldRenderer.cpp.
References blocks_faces_should_be_updated, chunks, chunks_mutex, entities, entities_faces_should_be_updated, entities_mutex, transparent_chunks, and transparent_chunks_mutex.
|
private |
Definition at line 606 of file WorldRenderer.cpp.
References camera, Botcraft::CHUNK_WIDTH, section_height, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
std::shared_ptr< Camera > Botcraft::Renderer::WorldRenderer::GetCamera | ( | ) |
Definition at line 42 of file WorldRenderer.cpp.
References camera.
|
private |
Definition at line 558 of file WorldRenderer.cpp.
References Botcraft::Biome::GetColorMultiplier(), Botcraft::Blockstate::GetId(), Botcraft::Blockstate::GetTintType(), Botcraft::Blockstate::GetVariableValue(), Botcraft::Biome::GetWaterColorMultiplier(), Botcraft::Grass, Botcraft::Leaves, Botcraft::None, Botcraft::Redstone, and Botcraft::Water.
Referenced by UpdateChunk().
void Botcraft::Renderer::WorldRenderer::InitGL | ( | ) |
Definition at line 47 of file WorldRenderer.cpp.
References atlas_texture, Botcraft::Renderer::Atlas::Get(), Botcraft::AssetsManager::GetAtlas(), Botcraft::Renderer::Atlas::GetHeight(), Botcraft::AssetsManager::getInstance(), Botcraft::Renderer::Atlas::GetWidth(), and view_uniform_buffer.
void Botcraft::Renderer::WorldRenderer::RenderFaces | ( | int * | num_chunks_ = nullptr , |
int * | num_rendered_chunks_ = nullptr , |
||
int * | num_entities_ = nullptr , |
||
int * | num_rendered_entities_ = nullptr , |
||
int * | num_faces_ = nullptr , |
||
int * | num_rendered_faces_ = nullptr |
||
) |
Definition at line 354 of file WorldRenderer.cpp.
References camera, Botcraft::CHUNK_WIDTH, chunks, chunks_mutex, entities, entities_mutex, Botcraft::Renderer::Inside, Botcraft::Renderer::Intersect, m_mutex_camera, Botcraft::Renderer::Outside, section_height, transparent_chunks, transparent_chunks_mutex, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
void Botcraft::Renderer::WorldRenderer::SetCameraProjection | ( | const glm::mat4 & | proj | ) |
Definition at line 100 of file WorldRenderer.cpp.
References camera, and m_mutex_camera.
void Botcraft::Renderer::WorldRenderer::SetPosOrientation | ( | const double | x_, |
const double | y_, | ||
const double | z_, | ||
const float | yaw_, | ||
const float | pitch_ | ||
) |
Definition at line 340 of file WorldRenderer.cpp.
References camera, and m_mutex_camera.
void Botcraft::Renderer::WorldRenderer::UpdateChunk | ( | const int | x_, |
const int | z_, | ||
const std::optional< Botcraft::Chunk > & | chunk | ||
) |
Definition at line 161 of file WorldRenderer.cpp.
References AddFace(), blocks_faces_should_be_updated, Botcraft::CHUNK_WIDTH, chunks, chunks_mutex, GetColorModifier(), Botcraft::Model::GetFaces(), Botcraft::Blockstate::GetHorizontalOffsetAtPos(), Botcraft::Blockstate::GetModel(), Botcraft::Blockstate::GetModelId(), Botcraft::Blockstate::GetName(), Botcraft::Blockstate::IsAir(), Botcraft::None, transparent_chunks, transparent_chunks_mutex, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
void Botcraft::Renderer::WorldRenderer::UpdateEntity | ( | const int | id, |
const std::vector< Face > & | faces | ||
) |
Definition at line 283 of file WorldRenderer.cpp.
References entities, entities_faces_should_be_updated, and entities_mutex.
void Botcraft::Renderer::WorldRenderer::UpdateFaces | ( | ) |
Definition at line 106 of file WorldRenderer.cpp.
References blocks_faces_should_be_updated, chunks, chunks_mutex, entities, entities_faces_should_be_updated, entities_mutex, transparent_chunks, and transparent_chunks_mutex.
void Botcraft::Renderer::WorldRenderer::UpdateViewMatrix | ( | ) |
Definition at line 76 of file WorldRenderer.cpp.
References camera, m_mutex_camera, transparent_chunks, transparent_chunks_mutex, Botcraft::Renderer::Updated, and view_uniform_buffer.
void Botcraft::Renderer::WorldRenderer::UseAtlasTextureGL | ( | ) |
Definition at line 306 of file WorldRenderer.cpp.
References atlas_texture.
|
private |
Definition at line 101 of file WorldRenderer.hpp.
Referenced by InitGL(), UseAtlasTextureGL(), and ~WorldRenderer().
|
private |
Definition at line 92 of file WorldRenderer.hpp.
Referenced by ClearFaces(), UpdateChunk(), UpdateFaces(), and WorldRenderer().
|
private |
Definition at line 98 of file WorldRenderer.hpp.
Referenced by DistanceToCamera(), GetCamera(), RenderFaces(), SetCameraProjection(), SetPosOrientation(), UpdateViewMatrix(), WorldRenderer(), and ~WorldRenderer().
|
private |
Definition at line 88 of file WorldRenderer.hpp.
Referenced by AddFace(), ClearFaces(), RenderFaces(), UpdateChunk(), UpdateFaces(), and WorldRenderer().
|
private |
Definition at line 89 of file WorldRenderer.hpp.
Referenced by AddFace(), ClearFaces(), RenderFaces(), UpdateChunk(), and UpdateFaces().
|
private |
Definition at line 94 of file WorldRenderer.hpp.
Referenced by ClearFaces(), RenderFaces(), UpdateEntity(), UpdateFaces(), and WorldRenderer().
|
private |
Definition at line 96 of file WorldRenderer.hpp.
Referenced by ClearFaces(), UpdateEntity(), UpdateFaces(), and WorldRenderer().
|
private |
Definition at line 95 of file WorldRenderer.hpp.
Referenced by ClearFaces(), RenderFaces(), UpdateEntity(), and UpdateFaces().
|
private |
Definition at line 99 of file WorldRenderer.hpp.
Referenced by RenderFaces(), SetCameraProjection(), SetPosOrientation(), and UpdateViewMatrix().
|
private |
Definition at line 86 of file WorldRenderer.hpp.
Referenced by AddFace(), DistanceToCamera(), RenderFaces(), and WorldRenderer().
|
private |
Definition at line 90 of file WorldRenderer.hpp.
Referenced by AddFace(), ClearFaces(), RenderFaces(), UpdateChunk(), UpdateFaces(), UpdateViewMatrix(), and WorldRenderer().
|
private |
Definition at line 91 of file WorldRenderer.hpp.
Referenced by AddFace(), ClearFaces(), RenderFaces(), UpdateChunk(), UpdateFaces(), and UpdateViewMatrix().
|
private |
Definition at line 81 of file WorldRenderer.hpp.
Referenced by InitGL(), and UpdateViewMatrix().