History

more correct hitFraction adjustments

Andrew Meadows committed 10 years ago

Commit ecc6cb41 parent 6f5f6d21 file · +3 −3Browse files

Showing the changes to interface/src/avatar/MyCharacterController.cpp (1 of 1 file). Show all

Unified · Split

interface/src/avatar/MyCharacterController.cpp+3−3
@@ -149,11 +149,11 @@ bool MyCharacterController::testRayShotgun(const glm::vec3& position, const glm: · 148 unmodified lines
149 if (!result.walkable) {149 if (!result.walkable) {
150 // the top scan wasn't walkable so don't bother scanning the bottom150 // the top scan wasn't walkable so don't bother scanning the bottom
151 // remove both forwardSlop and backSlop151 // remove both forwardSlop and backSlop
152 result.hitFraction = (closestRayResult.m_closestHitFraction * (backSlop + stepLength + forwardSlop) - forwardSlop) / (backSlop + stepLength);152 result.hitFraction = glm::min(1.0f, (closestRayResult.m_closestHitFraction * (backSlop + stepLength + forwardSlop) - backSlop) / stepLength);
153 } else {153 } else {
154 if (needToRemoveForwardSlop && result.hitFraction < 1.0f) {154 if (needToRemoveForwardSlop && result.hitFraction < 1.0f) {
155 // remove forwardSlop155 // remove forwardSlop
156 result.hitFraction = (closestRayResult.m_closestHitFraction * (stepLength + forwardSlop) - forwardSlop) / stepLength;156 result.hitFraction = (closestRayResult.m_closestHitFraction * (backSlop + stepLength + forwardSlop)) / (backSlop + stepLength);
157 }157 }
158 // scan the bottom158 // scan the bottom
159 for (int32_t i = 0; i < _bottomPoints.size(); ++i) {159 for (int32_t i = 0; i < _bottomPoints.size(); ++i) {
@@ -168,7 +168,7 @@ bool MyCharacterController::testRayShotgun(const glm::vec3& position, const glm: · 8 unmodified lines
168 // remove backSlop168 // remove backSlop
169 // NOTE: backSlop removal can produce a NEGATIVE hitFraction!169 // NOTE: backSlop removal can produce a NEGATIVE hitFraction!
170 // which means the shape is actually in interpenetration170 // which means the shape is actually in interpenetration
171 result.hitFraction = (closestRayResult.m_closestHitFraction * (backSlop + stepLength) - backSlop) / stepLength;171 result.hitFraction = ((closestRayResult.m_closestHitFraction * (backSlop + stepLength)) - backSlop) / stepLength;
172 }172 }
173 return result.hitFraction < 1.0f;173 return result.hitFraction < 1.0f;
174}174}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t