Fix geometry collision traps and implement authentic sector morphing
This commit is contained in:
1 parent
cd63921ea4
commit
b9353f552c
16 files changed
+1470
-131
No files matched your search
+38
-3
@@ -474,9 +474,15 @@ void GameApp::handle_sim_events() {
|
||||
}
|
||||
race_sim_.clear_events();
|
||||
|
||||
int x0 = 0, z0 = 0, x1 = 0, z1 = 0;
|
||||
if (race_sim_.consume_terrain_dirty(x0, z0, x1, z1)) {
|
||||
world_ren_.update_terrain_region(race_sim_.level(), x0, z0, x1, z1);
|
||||
std::vector<sim::DirtyRect> dirty_rects;
|
||||
bool columns_dirty = false;
|
||||
if (race_sim_.consume_world_dirty(dirty_rects, columns_dirty)) {
|
||||
for (const auto& r : dirty_rects) {
|
||||
world_ren_.update_terrain_region(race_sim_.level(), r.x0, r.z0, r.x1, r.z1);
|
||||
}
|
||||
if (columns_dirty) {
|
||||
world_ren_.rebuild_columns(race_sim_.level());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1140,6 +1146,35 @@ void GameApp::render_frame(float alpha) {
|
||||
cams[vp].eye = pose.pos + fwd * 0.45f + Vec3(0.0f, 0.42f, 0.0f);
|
||||
cams[vp].target = pose.pos + fwd * 6.0f + Vec3(0.0f, 0.2f, 0.0f);
|
||||
}
|
||||
if (cam_mode_ == 0 || cam_mode_ == 1) {
|
||||
float cam_floor_y = 0.0f;
|
||||
float cam_ceil_y = 1e6f;
|
||||
race_sim_.level().sample_surface_and_ceiling(cams[vp].eye.x, cams[vp].eye.z,
|
||||
pose.pos.y, cam_floor_y, cam_ceil_y);
|
||||
if (cams[vp].eye.y < cam_floor_y + 0.35f) {
|
||||
cams[vp].eye.y = cam_floor_y + 0.35f;
|
||||
}
|
||||
if (cam_ceil_y < 1e5f) {
|
||||
float max_cam_y = std::max(pose.pos.y + 0.15f, cam_ceil_y - 0.18f);
|
||||
if (cams[vp].eye.y > max_cam_y) {
|
||||
cams[vp].eye.y = max_cam_y;
|
||||
}
|
||||
}
|
||||
Vec3 anchor = pose.pos + Vec3(0.0f, 0.35f, 0.0f);
|
||||
Vec3 prev_clear = anchor;
|
||||
constexpr int kCamSteps = 10;
|
||||
for (int k = 1; k <= kCamSteps; ++k) {
|
||||
float t = static_cast<float>(k) / static_cast<float>(kCamSteps);
|
||||
Vec3 p = lerp(anchor, cams[vp].eye, t);
|
||||
int ix = static_cast<int>(std::floor(p.x));
|
||||
int iz = static_cast<int>(std::floor(p.z));
|
||||
if (race_sim_.level().is_cell_solid_at_point(ix, iz, p.x, p.z, p.y, 0.15f)) {
|
||||
cams[vp].eye = prev_clear;
|
||||
break;
|
||||
}
|
||||
prev_clear = p;
|
||||
}
|
||||
}
|
||||
float min_cam_y = race_sim_.level().sample_height_world(cams[vp].eye.x, cams[vp].eye.z) + 0.4f;
|
||||
if (cams[vp].eye.y < min_cam_y) cams[vp].eye.y = min_cam_y;
|
||||
world_ren_.render_world_view(cams[vp], models, parts, vp, split_count, cfg_);
|
||||
|
||||
Reference in new issue
Block a user