Chunk render distance, simulation stuff and other
This commit is contained in:
parent
0cc61ec358
commit
01b2dd8bd3
@ -2,6 +2,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/gtx/norm.hpp>
|
||||
|
||||
#include "cache.hpp"
|
||||
#include "cmdfile.hpp"
|
||||
#include "utils/files.hpp"
|
||||
@ -168,10 +171,19 @@ void assets::Map::Draw(const game::view::DrawArgs& args) const
|
||||
|
||||
const auto& mesh = *basemodel_->GetMesh();
|
||||
|
||||
const float max_dist = args.render_distance + 200.0f;
|
||||
const float max_dist2 = max_dist * max_dist;
|
||||
|
||||
for (auto& chunk : chunks_)
|
||||
{
|
||||
if (args.frustum.IsAABBVisible(chunk.aabb))
|
||||
DrawChunk(args, mesh, chunk);
|
||||
glm::vec3 center = (chunk.aabb.min + chunk.aabb.max) * 0.5f;
|
||||
if (glm::distance2(args.eye, center) > max_dist2)
|
||||
continue;
|
||||
|
||||
if (!args.frustum.IsAABBVisible(chunk.aabb))
|
||||
continue;
|
||||
|
||||
DrawChunk(args, mesh, chunk);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ void App::Frame()
|
||||
params.view_proj = proj * view;
|
||||
params.cam_pos = eye;
|
||||
|
||||
game::view::DrawArgs draw_args(dlist_, params.view_proj, viewport_size_);
|
||||
game::view::DrawArgs draw_args(dlist_, params.view_proj, eye, viewport_size_, 500.0f);
|
||||
world->Draw(draw_args);
|
||||
|
||||
glm::mat4 camera_world = glm::inverse(view);
|
||||
|
||||
@ -58,6 +58,9 @@ static void InitSDL()
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
|
||||
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
||||
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8);
|
||||
|
||||
std::cout << "Creating SDL window..." << std::endl;
|
||||
s_window =
|
||||
SDL_CreateWindow("PortalGame", 100, 100, 640, 480,
|
||||
|
||||
@ -94,7 +94,7 @@ game::OpenWorld::OpenWorld() : World("openworld")
|
||||
// }
|
||||
|
||||
// spawn bots
|
||||
for (size_t i = 0; i < 70; ++i)
|
||||
for (size_t i = 0; i < 300; ++i)
|
||||
{
|
||||
SpawnBot();
|
||||
}
|
||||
|
||||
@ -35,7 +35,9 @@ void game::World::RegisterEntity(std::unique_ptr<Entity> ent)
|
||||
void game::World::Update(int64_t delta_time)
|
||||
{
|
||||
time_ms_ += delta_time;
|
||||
GetBtWorld().stepSimulation(static_cast<float>(delta_time) * 0.001f, 5);
|
||||
float delta_s = static_cast<float>(delta_time) * 0.001f;
|
||||
// GetBtWorld().stepSimulation(delta_s, 1, delta_s);
|
||||
GetBtWorld().stepSimulation(delta_s, 2, delta_s * 0.5f);
|
||||
|
||||
// update entities
|
||||
for (auto it = ents_.begin(); it != ents_.end();)
|
||||
|
||||
@ -5,15 +5,19 @@
|
||||
|
||||
namespace game::view
|
||||
{
|
||||
|
||||
struct DrawArgs
|
||||
{
|
||||
gfx::DrawList& dlist;
|
||||
const glm::mat4& view_proj;
|
||||
gfx::Frustum frustum;
|
||||
glm::ivec2 screen_size;
|
||||
|
||||
const glm::mat4 view_proj;
|
||||
const glm::vec3 eye;
|
||||
const gfx::Frustum frustum;
|
||||
const glm::ivec2 screen_size;
|
||||
const float render_distance;
|
||||
|
||||
DrawArgs(gfx::DrawList& dlist, const glm::mat4& view_proj, glm::ivec2 screen_size)
|
||||
: dlist(dlist), view_proj(view_proj), frustum(view_proj), screen_size(screen_size)
|
||||
DrawArgs(gfx::DrawList& dlist, const glm::mat4& view_proj, const glm::vec3& eye, const glm::ivec2& screen_size, float render_distance)
|
||||
: dlist(dlist), view_proj(view_proj), eye(eye), frustum(view_proj), screen_size(screen_size), render_distance(render_distance)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@ -27,6 +27,8 @@ void gfx::Renderer::Begin(size_t width, size_t height)
|
||||
{
|
||||
current_shader_ = nullptr;
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
//glEnable(GL_MULTISAMPLE);
|
||||
}
|
||||
|
||||
void gfx::Renderer::ClearColor(const glm::vec3& color)
|
||||
|
||||
@ -25,6 +25,10 @@ void sv::Server::Run()
|
||||
timeBeginPeriod(1);
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
std::cout << "Running DEBUG build!" << std::endl;
|
||||
#endif
|
||||
|
||||
bool exit = false;
|
||||
while (!exit)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user