mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-24 00:00:13 +00:00
Increase wall collision sweep steps to prevent clipping
This commit is contained in:
parent
f3f97cf9de
commit
8bd60c3320
1 changed files with 6 additions and 5 deletions
|
|
@ -356,10 +356,10 @@ void CameraController::update(float deltaTime) {
|
|||
glm::vec3 startPos = *followTarget;
|
||||
glm::vec3 desiredPos = targetPos;
|
||||
float moveDist = glm::length(desiredPos - startPos);
|
||||
// Adaptive CCD: keep per-step movement short, especially on low FPS spikes.
|
||||
int sweepSteps = std::max(1, std::min(4, static_cast<int>(std::ceil(moveDist / 0.5f))));
|
||||
// Adaptive CCD: keep per-step movement short to avoid clipping through walls.
|
||||
int sweepSteps = std::max(1, std::min(8, static_cast<int>(std::ceil(moveDist / 0.3f))));
|
||||
if (deltaTime > 0.04f) {
|
||||
sweepSteps = std::min(6, std::max(sweepSteps, static_cast<int>(std::ceil(deltaTime / 0.016f))));
|
||||
sweepSteps = std::min(12, std::max(sweepSteps, static_cast<int>(std::ceil(deltaTime / 0.016f))));
|
||||
}
|
||||
glm::vec3 stepPos = startPos;
|
||||
glm::vec3 stepDelta = (desiredPos - startPos) / static_cast<float>(sweepSteps);
|
||||
|
|
@ -782,9 +782,10 @@ void CameraController::update(float deltaTime) {
|
|||
glm::vec3 startFeet = camera->getPosition() - glm::vec3(0, 0, eyeHeight);
|
||||
glm::vec3 desiredFeet = newPos - glm::vec3(0, 0, eyeHeight);
|
||||
float moveDist = glm::length(desiredFeet - startFeet);
|
||||
int sweepSteps = std::max(1, std::min(4, static_cast<int>(std::ceil(moveDist / 0.5f))));
|
||||
// Adaptive CCD: keep per-step movement short to avoid clipping through walls.
|
||||
int sweepSteps = std::max(1, std::min(8, static_cast<int>(std::ceil(moveDist / 0.3f))));
|
||||
if (deltaTime > 0.04f) {
|
||||
sweepSteps = std::min(6, std::max(sweepSteps, static_cast<int>(std::ceil(deltaTime / 0.016f))));
|
||||
sweepSteps = std::min(12, std::max(sweepSteps, static_cast<int>(std::ceil(deltaTime / 0.016f))));
|
||||
}
|
||||
glm::vec3 stepPos = startFeet;
|
||||
glm::vec3 stepDelta = (desiredFeet - startFeet) / static_cast<float>(sweepSteps);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue